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

Function TestAddOperationFailure

tensorflow/go/op/op_test.go:38–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestAddOperationFailure(t *testing.T) {
39 // Inspired from https://github.com/tensorflow/tensorflow/issues/9931
40 s := NewScope()
41
42 resize := ResizeArea(s, Placeholder(s, tf.Float), Const(s, []int64{80, 80}))
43 if err := s.Err(); err == nil {
44 t.Fatal("ResizeArea expects an int32 Tensor for size, should fail when an int64 is provided")
45 }
46 // And any use of resize should panic with an error message more informative than SIGSEGV
47 defer func() {
48 r := recover()
49 if r == nil {
50 return
51 }
52 s, ok := r.(string)
53 if ok && strings.Contains(s, "see Scope.Err() for details") {
54 return
55 }
56 t.Errorf("Expected panic string to Scope.Err(), found %T: %q", r, r)
57 }()
58 _ = resize.Shape()
59 t.Errorf("resize.Shape() should have paniced since the underlying Operation was not created")
60}
61
62func TestShapeAttribute(t *testing.T) {
63 s := NewScope()

Callers

nothing calls this directly

Calls 7

ErrMethod · 0.95
NewScopeFunction · 0.85
ResizeAreaFunction · 0.85
PlaceholderFunction · 0.70
ConstFunction · 0.70
ContainsMethod · 0.45
ShapeMethod · 0.45

Tested by

no test coverage detected