(t *testing.T)
| 75 | } |
| 76 | |
| 77 | func TestSessionRunConcat(t *testing.T) { |
| 78 | // Runs the Concat operation on two matrices: m1 and m2, along the |
| 79 | // first dimension (dim1). |
| 80 | // This tests the use of both Output and OutputList as inputs to the |
| 81 | // Concat operation. |
| 82 | var ( |
| 83 | g = NewGraph() |
| 84 | dim1, _ = Const(g, "dim1", int32(1)) |
| 85 | m1, _ = Const(g, "m1", [][]int64{ |
| 86 | {1, 2, 3}, |
| 87 | {4, 5, 6}, |
| 88 | }) |
| 89 | m2, _ = Const(g, "m2", [][]int64{ |
| 90 | {7, 8, 9}, |
| 91 | {10, 11, 12}, |
| 92 | }) |
| 93 | want = [][]int64{ |
| 94 | {1, 2, 3, 7, 8, 9}, |
| 95 | {4, 5, 6, 10, 11, 12}, |
| 96 | } |
| 97 | ) |
| 98 | concat, err := g.AddOperation(OpSpec{ |
| 99 | Type: "Concat", |
| 100 | Input: []Input{ |
| 101 | dim1, |
| 102 | OutputList{m1, m2}, |
| 103 | }, |
| 104 | }) |
| 105 | if err != nil { |
| 106 | t.Fatal(err) |
| 107 | } |
| 108 | s, err := NewSession(g, &SessionOptions{}) |
| 109 | if err != nil { |
| 110 | t.Fatal(err) |
| 111 | } |
| 112 | output, err := s.Run(nil, []Output{concat.Output(0)}, nil) |
| 113 | if err != nil { |
| 114 | t.Fatal(err) |
| 115 | } |
| 116 | if len(output) != 1 { |
| 117 | t.Fatal(len(output)) |
| 118 | } |
| 119 | if got := output[0].Value(); !reflect.DeepEqual(got, want) { |
| 120 | t.Fatalf("Got %v, want %v", got, want) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func TestSessionWithStringTensors(t *testing.T) { |
| 125 | // Construct the graph: |
nothing calls this directly
no test coverage detected