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

Function TestOperationConsumers

tensorflow/go/operation_test.go:190–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestOperationConsumers(t *testing.T) {
191 g := NewGraph()
192 x, err := Placeholder(g, "x", Float)
193 if err != nil {
194 t.Fatal(err)
195 }
196 a, err := Neg(g, "a", x)
197 if err != nil {
198 t.Fatal(err)
199 }
200 b, err := Neg(g, "b", x)
201 if err != nil {
202 t.Fatal(err)
203 }
204
205 consumers := []*Operation{a.Op, b.Op}
206
207 xConsumers := x.Consumers()
208 if out := len(xConsumers); out != 2 {
209 t.Fatalf("Got %d consumers, wanted 2", out)
210 }
211
212 for i, consumer := range xConsumers {
213 got := consumer.Op.Name()
214 want := consumers[i].Name()
215 if got != want {
216 t.Fatalf("%d. Got op name %q, wanted %q", i, got, want)
217 }
218
219 got = consumer.Producer().Op.Name()
220 want = x.Op.Name()
221 if got != want {
222 t.Fatalf("%d. Got op name %q, wanted %q", i, got, want)
223 }
224 }
225
226 if len(b.Consumers()) != 0 {
227 t.Fatalf("expected %+v to have no consumers", b)
228 }
229}
230
231func TestOperationDevice(t *testing.T) {
232 graph := NewGraph()

Callers

nothing calls this directly

Calls 6

NewGraphFunction · 0.85
ConsumersMethod · 0.80
ProducerMethod · 0.80
PlaceholderFunction · 0.70
NegFunction · 0.70
NameMethod · 0.45

Tested by

no test coverage detected