MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TestSessionRunNeg

Function TestSessionRunNeg

tensorflow/go/session_test.go:38–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestSessionRunNeg(t *testing.T) {
39 var tests = []struct {
40 input interface{}
41 expected interface{}
42 }{
43 {int64(1), int64(-1)},
44 {[]float64{-1, -2, 3}, []float64{1, 2, -3}},
45 {[][]float32{{1, -2}, {-3, 4}}, [][]float32{{-1, 2}, {3, -4}}},
46 }
47
48 for _, test := range tests {
49 t.Run(fmt.Sprint(test.input), func(t *testing.T) {
50 t1, err := NewTensor(test.input)
51 if err != nil {
52 t.Fatal(err)
53 }
54 graph, inp, out := createTestGraph(t, t1.DataType())
55 s, err := NewSession(graph, &SessionOptions{})
56 if err != nil {
57 t.Fatal(err)
58 }
59 output, err := s.Run(map[Output]*Tensor{inp: t1}, []Output{out}, []*Operation{out.Op})
60 if err != nil {
61 t.Fatal(err)
62 }
63 if len(output) != 1 {
64 t.Fatalf("got %d outputs, want 1", len(output))
65 }
66 val := output[0].Value()
67 if !reflect.DeepEqual(test.expected, val) {
68 t.Errorf("got %v, want %v", val, test.expected)
69 }
70 if err := s.Close(); err != nil {
71 t.Error(err)
72 }
73 })
74 }
75}
76
77func TestSessionRunConcat(t *testing.T) {
78 // Runs the Concat operation on two matrices: m1 and m2, along the

Callers

nothing calls this directly

Calls 9

RunMethod · 0.95
DataTypeMethod · 0.95
CloseMethod · 0.95
int64Function · 0.85
NewTensorFunction · 0.85
createTestGraphFunction · 0.85
NewSessionFunction · 0.70
ValueMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected