提交 f0a8c9ba authored 作者: Alexander Matyasko's avatar Alexander Matyasko

Fix gpu cholesky test

Small eigenvalues can lead to failure when computing cholesky decompsotion on gpu. To prevent that, explicitly ensure that eigenvalues are not too small.
上级 e0a6e3f9
...@@ -314,7 +314,13 @@ class TestMagma(unittest.TestCase): ...@@ -314,7 +314,13 @@ class TestMagma(unittest.TestCase):
def check_cholesky(self, N, lower=True, rtol=None, atol=None): def check_cholesky(self, N, lower=True, rtol=None, atol=None):
A = rand(N, N).astype('float32') A = rand(N, N).astype('float32')
A = np.dot(A.T, A) # ensure that eigenvalues are not too small which sometimes results in
# magma failure due to gpu limited numerical precision
D, W = np.linalg.eigh(A)
D[D < 1] = 1
V_m = np.zeros_like(A)
np.fill_diagonal(V_m, D)
A = np.dot(np.dot(W.T, V_m), W)
L = self.run_gpu_cholesky(A, lower=lower) L = self.run_gpu_cholesky(A, lower=lower)
if not lower: if not lower:
L = L.T L = L.T
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论