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

Function TestSessionConfig

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

Source from the content-addressed store, hash-verified

250}
251
252func TestSessionConfig(t *testing.T) {
253 // Exercise SessionOptions.
254 // Arguably, a better API would be for SessionOptions.Config to be the
255 // type generated by the protocol buffer compiler. But for now, the
256 // tensorflow package continues to be independent of protocol buffers
257 // and this test exercises the option since the implementation has a
258 // nuanced conversion to C types.
259 //
260 // Till then, the []byte form of Config here was generated using a toy
261 // tensorflow Python program:
262 /*
263 import tensorflow
264 c = tensorflow.ConfigProto()
265 c.intra_op_parallelism_threads = 1
266 print c.SerializeToString()
267 */
268 graph := NewGraph()
269 c, err := Const(graph, "Const", int32(14))
270 if err != nil {
271 t.Fatal(err)
272 }
273 opts := SessionOptions{Config: []byte("(\x01")}
274 s, err := NewSession(graph, &opts)
275 if err != nil {
276 t.Fatal(err)
277 }
278 output, err := s.Run(nil, []Output{c}, nil)
279 if err != nil {
280 t.Fatal(err)
281 }
282 if output[0].Value().(int32) != 14 {
283 t.Fatalf("Got %v, want -1", output[0].Value())
284 }
285}
286
287func TestListDevices(t *testing.T) {
288 s, err := NewSession(NewGraph(), nil)

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
NewGraphFunction · 0.85
NewSessionFunction · 0.70
ConstFunction · 0.50
ValueMethod · 0.45

Tested by

no test coverage detected