(t *testing.T)
| 122 | } |
| 123 | |
| 124 | func TestSessionWithStringTensors(t *testing.T) { |
| 125 | // Construct the graph: |
| 126 | // AsString(StringToHashBucketFast("PleaseHashMe")) Will be much |
| 127 | // prettier if using the ops package, but in this package graphs are |
| 128 | // constructed from first principles. |
| 129 | var ( |
| 130 | g = NewGraph() |
| 131 | feed, _ = Const(g, "input", "PleaseHashMe") |
| 132 | hash, _ = g.AddOperation(OpSpec{ |
| 133 | Type: "StringToHashBucketFast", |
| 134 | Input: []Input{feed}, |
| 135 | Attrs: map[string]interface{}{ |
| 136 | "num_buckets": int64(1 << 32), |
| 137 | }, |
| 138 | }) |
| 139 | str, _ = g.AddOperation(OpSpec{ |
| 140 | Type: "AsString", |
| 141 | Input: []Input{hash.Output(0)}, |
| 142 | }) |
| 143 | ) |
| 144 | s, err := NewSession(g, nil) |
| 145 | if err != nil { |
| 146 | t.Fatal(err) |
| 147 | } |
| 148 | output, err := s.Run(nil, []Output{str.Output(0)}, nil) |
| 149 | if err != nil { |
| 150 | t.Fatal(err) |
| 151 | } |
| 152 | if len(output) != 1 { |
| 153 | t.Fatal(len(output)) |
| 154 | } |
| 155 | got, ok := output[0].Value().(string) |
| 156 | if !ok { |
| 157 | t.Fatalf("Got %T, wanted string", output[0].Value()) |
| 158 | } |
| 159 | if want := "1027741475"; got != want { |
| 160 | t.Fatalf("Got %q, want %q", got, want) |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | func TestConcurrency(t *testing.T) { |
| 165 | tensor, err := NewTensor(int64(1)) |
nothing calls this directly
no test coverage detected