提交 b3db7f40 authored 作者: notoraptor's avatar notoraptor

Set atol to 5e-3 for Magma matrix inverse testings.

上级 4ccf9932
......@@ -212,23 +212,21 @@ class TestMagma(unittest.TestCase):
fn = theano.function([A], gpu_matrix_inverse(A), mode=mode_with_gpu)
N = 1000
# We reload RNG here to get a specific failing case with seed = 17.
# NB: It seems we don't even need unittests.rseed nor utt.seed_rng().
seed = int(theano.config.unittests.rseed)
test_rng = np.random.RandomState(seed=seed)
test_rng = np.random.RandomState(seed=int(theano.config.unittests.rseed))
# Copied from theano.tensor.tests.test_basic.rand.
A_val = test_rng.rand(N, N).astype('float32') * 2 - 1
A_val_inv = fn(A_val)
utt.assert_allclose(np.eye(N), np.dot(A_val_inv, A_val))
utt.assert_allclose(np.eye(N), np.dot(A_val_inv, A_val), atol=5e-3)
def test_gpu_matrix_inverse_inplace(self):
N = 1000
A_val_gpu = gpuarray_shared_constructor(rand(N, N).astype('float32'))
test_rng = np.random.RandomState(seed=int(theano.config.unittests.rseed))
A_val_gpu = gpuarray_shared_constructor(test_rng.rand(N, N).astype('float32') * 2 - 1)
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.eye(N), np.dot(A_val_gpu.get_value(), A_val_copy), atol=1e-2)
utt.assert_allclose(np.eye(N), np.dot(A_val_gpu.get_value(), A_val_copy), atol=5e-3)
def test_gpu_matrix_inverse_inplace_opt(self):
A = theano.tensor.fmatrix("A")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论