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

Method _testBinary

tensorflow/compiler/tests/binary_ops_test.py:41–61  ·  view source on GitHub ↗
(self,
                  op,
                  a,
                  b,
                  expected,
                  equality_test=None,
                  rtol=None,
                  atol=None)

Source from the content-addressed store, hash-verified

39 """Test cases for binary operators."""
40
41 def _testBinary(self,
42 op,
43 a,
44 b,
45 expected,
46 equality_test=None,
47 rtol=None,
48 atol=None):
49 with self.session() as session:
50 with self.test_scope():
51 pa = array_ops.placeholder(dtypes.as_dtype(a.dtype), a.shape, name="a")
52 pb = array_ops.placeholder(dtypes.as_dtype(b.dtype), b.shape, name="b")
53 output = op(pa, pb)
54 result = session.run(output, {pa: a, pb: b})
55 if equality_test is None:
56 equality_test = self.assertAllCloseAccordingToType
57 if rtol is None:
58 rtol = 1e-15 if a.dtype == np.float64 else 1e-3
59 if atol is None:
60 atol = 1e-15 if a.dtype == np.float64 else 1e-6
61 equality_test(result, expected, rtol=rtol, atol=atol)
62
63 def _testSymmetricBinary(self, op, a, b, expected, equality_test=None):
64 self._testBinary(op, a, b, expected, equality_test)

Callers 15

_testSymmetricBinaryMethod · 0.95
testFloatOpsMethod · 0.95
testIntOpsMethod · 0.95
testAddMethod · 0.95
testMultiplyMethod · 0.95
testPowMethod · 0.95
testNumericOpsMethod · 0.95
testNextAfterMethod · 0.95
testComplexOpsMethod · 0.95
testComplexMathMethod · 0.95
_testDivisionMethod · 0.95
_testRemainderMethod · 0.95

Calls 5

opFunction · 0.50
sessionMethod · 0.45
test_scopeMethod · 0.45
placeholderMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected