Skip to content
Permalink
Browse files

Make ineffassign happier (#332)

* Make ineffassign happier

* Update examples/tiny-yolo-v2-coco/detection_layer.go with suggestions

* Handle errors idiomatically
  • Loading branch information...
volmedo authored and owulveryck committed Oct 14, 2019
1 parent a6f8db2 commit a64fa4921f35a02f8aa3524d39d4d0195ec9320c
Showing with 22 additions and 6 deletions.
  1. +4 −3 broadcast_test.go
  2. +0 −1 dual_test.go
  3. +1 −1 examples/charRNN/model.go
  4. +4 −0 examples/tiny-yolo-v2-coco/detection_layer.go
  5. +13 −1 known_issues_test.go
@@ -65,7 +65,7 @@ func TestBroadcast(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if a, b, err = Broadcast(x, y, NewBroadcastPattern(nil, []byte{1})); err != nil {
if _, _, err = Broadcast(x, y, NewBroadcastPattern(nil, []byte{1})); err != nil {
ioutil.WriteFile("Broadcast.dot", []byte(g.ToDot()), 0644)
t.Fatal(err)
}
@@ -84,8 +84,9 @@ func TestBroadcast(t *testing.T) {
ioutil.WriteFile("Broadcast.dot", []byte(g.ToDot()), 0644)
t.Fatalf("%+v", err)
}
z, err = Add(a, b)
if a, b, err = Broadcast(x, y, NewBroadcastPattern(nil, []byte{1})); err != nil {
// TODO: Check the error returned by Add?
z, _ = Add(a, b)
if _, _, err = Broadcast(x, y, NewBroadcastPattern(nil, []byte{1})); err != nil {
ioutil.WriteFile("Broadcast.dot", []byte(g.ToDot()), 0644)
t.Fatal(err)
}
@@ -40,7 +40,6 @@ func TestDVBindVar(t *testing.T) {
}
assert.Equal(t, 1.0, retVal.d.Data())

x = tensor.New(tensor.WithBacking([]float64{1, 2, 3, 4}))
x = tensor.New(tensor.WithBacking([]float64{4, 3, 2, 1}))
op = newEBOByType(addOpType, TypeOf(x), TypeOf(y))
xdv = constantDV(x)
@@ -262,7 +262,7 @@ func (r *charRNN) fwd(srcIndex int, prev *lstmOut) (retVal *lstmOut, err error)
prevCells = prev.cells
}

inputVector := r.inputVector
var inputVector *Node
var hiddens, cells Nodes
for i, l := range r.ls {
if i == 0 {
@@ -57,7 +57,11 @@ func (tiny *TinyYOLOv2Net) ProcessOutput() (Detections, error) {

bb := make(Detections, 0)
outDense := outTensor.(*tensor.Dense)
// TODO: Check the error returned by Reshape?
err := outDense.Reshape((tiny.classesNum+5)*tiny.boxesPerCell, 13, 13)
if err != nil {
return nil, err
}
data, err := native.Tensor3F32(outDense)
if err != nil {
return nil, err
@@ -26,15 +26,24 @@ func TestIssue182(t *testing.T) {

xT := tensor.New(tensor.WithBacking([]float64{1, 1, 1}), tensor.WithShape(3))
y, err := Mul(x, a)
if err != nil {
t.Fatal(err)
}
z, err := Mul(y, b)
if err != nil {
t.Fatal(err)
}
dz, err := Grad(z, x)
if err != nil {
t.Fatal(err)
}
machine := NewTapeMachine(g)
defer machine.Close()

machine.Let(x, xT)
machine.Let(b, -0.5)
for turns := 0; turns < 4; turns++ {
if err = machine.RunAll(); err != nil {
if err := machine.RunAll(); err != nil {
t.Fatalf("Machine failed to run at turn %v", turns)
}
machine.Reset()
@@ -107,6 +116,9 @@ func TestIssue268_im2col(t *testing.T) {
49, 0, 0, 0, 18, 19, 0, 23, 24, 0, 0, 0, 0, 43, 44, 0, 48, 49, 0, 0, 0, 0,
}))
y, err := Im2Col(x, []int{3, 3}, []int{1, 1}, []int{1, 1}, []int{1, 1})
if err != nil {
t.Fatal(err)
}

machine := NewTapeMachine(g)
if err = machine.RunAll(); err != nil {

0 comments on commit a64fa49

Please sign in to comment.
You can’t perform that action at this time.