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

Function TestGraphWriteToAndImport

tensorflow/go/graph_test.go:55–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestGraphWriteToAndImport(t *testing.T) {
56 // Construct a graph
57 g := NewGraph()
58 v, err := NewTensor(int64(1))
59 if err != nil {
60 t.Fatal(err)
61 }
62 input, err := Placeholder(g, "input", v.DataType())
63 if err != nil {
64 t.Fatal(err)
65 }
66 if _, err := Neg(g, "neg", input); err != nil {
67 t.Fatal(err)
68 }
69
70 // Serialize the graph
71 buf := new(bytes.Buffer)
72 if _, err := g.WriteTo(buf); err != nil {
73 t.Fatal(err)
74 }
75
76 // Import it into the same graph, with a prefix
77 if err := g.Import(buf.Bytes(), "imported"); err != nil {
78 t.Error(err)
79 }
80 if err := hasOperations(g, "input", "neg", "imported/input", "imported/neg"); err != nil {
81 t.Error(err)
82 }
83}
84
85func TestGraphAddGradients(t *testing.T) {
86 g := NewGraph()

Callers

nothing calls this directly

Calls 10

DataTypeMethod · 0.95
WriteToMethod · 0.95
ImportMethod · 0.95
NewGraphFunction · 0.85
NewTensorFunction · 0.85
int64Function · 0.85
hasOperationsFunction · 0.85
PlaceholderFunction · 0.70
NegFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected