(self, s, *input_shapes, **kwargs)
| 36 | class EinsumOpTest(test.TestCase): |
| 37 | |
| 38 | def _check(self, s, *input_shapes, **kwargs): |
| 39 | dtype = kwargs.pop('dtype', np.float32) |
| 40 | r = np.random.RandomState(0) |
| 41 | inputs = [] |
| 42 | for shape in input_shapes: |
| 43 | arr = np.array(r.randn(*shape)).astype(dtype) |
| 44 | if dtype == np.complex64 or dtype == np.complex128: |
| 45 | arr += 1j * np.array(r.randn(*shape)).astype(dtype) |
| 46 | inputs.append(arr) |
| 47 | input_tensors = [constant_op.constant(x, shape=x.shape) for x in inputs] |
| 48 | a = np.einsum(s, *inputs) |
| 49 | with ops.device("/cpu:0"): |
| 50 | b = self.evaluate(gen_linalg_ops.einsum(input_tensors, s)) |
| 51 | self.assertAllClose(a, b, atol=1e-4, rtol=1e-4) |
| 52 | |
| 53 | def testUnary(self): |
| 54 | self._check('->', ()) |
no test coverage detected