def test_gpu_matrix_inverse_inplace(self): N = 1000 A_val_gpu = gpuarray_shared_constructor(rand(N, N).astype('float32')) A_val_copy = A_val_gpu.get_value() fn = theano.function([], GpuMagmaMatrixInverse(inplace=True)(A_val_gpu), mode=mode_with_gpu, accept_inplace=True) fn() utt.assert_allclose(np.dot(A_val_gpu.get_value(), A_val_copy), np.eye(N), atol=1e-3)
def test_gpu_matrix_inverse_inplace(self): N = 1000 test_rng = np.random.RandomState(seed=1) A_val_gpu = gpuarray_shared_constructor( test_rng.rand(N, N).astype("float32") * 2 - 1) A_val_copy = A_val_gpu.get_value() A_val_gpu_inv = GpuMagmaMatrixInverse()(A_val_gpu) fn = theano.function([], A_val_gpu_inv, mode=mode_with_gpu, updates=[(A_val_gpu, A_val_gpu_inv)]) assert any([ node.op.inplace for node in fn.maker.fgraph.toposort() if isinstance(node.op, GpuMagmaMatrixInverse) ]) fn() utt.assert_allclose(np.eye(N), np.dot(A_val_gpu.get_value(), A_val_copy), atol=5e-3)