def _checkGrad(self, x_in, y_in, adjoint_a, adjoint_b):
    x_t_shape = (x_in.shape[:(- 2)] + (x_in.shape[(- 1)], x_in.shape[(- 2)]))
    y_t_shape = (y_in.shape[:(- 2)] + (y_in.shape[(- 1)], y_in.shape[(- 2)]))
    x = (x_in if (not adjoint_a) else x_in.reshape(x_t_shape))
    y = (y_in if (not adjoint_b) else y_in.reshape(y_t_shape))
    epsilon = np.finfo(x.dtype).eps
    delta = (epsilon ** (1.0 / 3.0))
    with self.test_session(use_gpu=True):
        inx = constant_op.constant(x)
        iny = constant_op.constant(y)
        z = math_ops.matmul(inx, iny, adjoint_a, adjoint_b)
        loss = math_ops.reduce_sum(z)
        ((x_jacob_t, x_jacob_n), (y_jacob_t, y_jacob_n)) = gradient_checker.compute_gradient([inx, iny], [x.shape, y.shape], loss, [1], x_init_value=[x, y], delta=delta)
        tol = (20 * delta)
        self.assertAllClose(x_jacob_t, x_jacob_n, rtol=tol, atol=tol)
        self.assertAllClose(y_jacob_t, y_jacob_n, rtol=tol, atol=tol)
def _checkGrad(self, x_in, y_in, adjoint_a, adjoint_b):
    x_t_shape = (x_in.shape[:(- 2)] + (x_in.shape[(- 1)], x_in.shape[(- 2)]))
    y_t_shape = (y_in.shape[:(- 2)] + (y_in.shape[(- 1)], y_in.shape[(- 2)]))
    x = (x_in if (not adjoint_a) else x_in.reshape(x_t_shape))
    y = (y_in if (not adjoint_b) else y_in.reshape(y_t_shape))
    epsilon = np.finfo(x.dtype).eps
    delta = (epsilon ** (1.0 / 3.0))
    with self.test_session(use_gpu=True):
        inx = constant_op.constant(x)
        iny = constant_op.constant(y)
        z = math_ops.matmul(inx, iny, adjoint_a, adjoint_b)
        loss = math_ops.reduce_sum(z)
        ((x_jacob_t, x_jacob_n), (y_jacob_t, y_jacob_n)) = gradient_checker.compute_gradient([inx, iny], [x.shape, y.shape], loss, [1], x_init_value=[x, y], delta=delta)
        tol = (20 * delta)
        self.assertAllClose(x_jacob_t, x_jacob_n, rtol=tol, atol=tol)
        self.assertAllClose(y_jacob_t, y_jacob_n, rtol=tol, atol=tol)