Skip to content

Commit

Permalink
Merge branch 'master' into feat/diagFlatOp
Browse files Browse the repository at this point in the history
  • Loading branch information
chewxy committed Oct 11, 2020
2 parents d065cc4 + 3d0a7eb commit 031ca33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 2 additions & 7 deletions operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,8 @@ func Reshape(n *Node, to tensor.Shape) (retVal *Node, err error) {
}

// Ravel flattens the given node and returns the new node
func Ravel(n *Node) (retVal *Node) {
retVal, err := Reshape(n, tensor.Shape{n.shape.TotalSize()})
if err != nil {
panic(err)
}

return retVal
func Ravel(n *Node) (retVal *Node, err error) {
return Reshape(n, tensor.Shape{n.shape.TotalSize()})
}

/* Contraction related operations */
Expand Down
3 changes: 2 additions & 1 deletion operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,9 @@ func TestRavel(t *testing.T) {
for i, rst := range ravelTests {
g := NewGraph()
t := NewTensor(g, Float64, len(rst.input), WithShape(rst.input...))
t2 := Ravel(t)
t2, err := Ravel(t)

c.NoError(err)
c.Equal(rst.output, t2.Shape(), "expected to be flatten in test case: %d", i)
}
}

0 comments on commit 031ca33

Please sign in to comment.