Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove np matrix_rank and multi_dot trick #2147

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions framework/api/linalg/test_matrix_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_matrix_rank_base():
x = np.array(
[[-2.0, 2.0, 1.0, 2.0, 2.0], [-2.0, 2.0, 1.0, 2.0, 2.0], [1.0, 3.0, 4.0, 1.0, 7.0], [-4.0, 4.0, 2.0, 4.0, 4.0]]
)
res = [np.linalg.matrix_rank(x, tol=tol, hermitian=hermitian)]
res = np.linalg.matrix_rank(x, tol=tol, hermitian=hermitian)
obj.base(res=res, x=x, tol=tol, hermitian=hermitian)


Expand All @@ -54,7 +54,7 @@ def test_matrix_rank_1():
x = np.array(
[[-2.0, 2.0, 1.0, 2.0, 2.0], [-2.0, 2.0, 1.0, 2.0, 2.0], [1.0, 3.0, 4.0, 1.0, 7.0], [-4.0, 4.0, 2.0, 4.0, 4.0]]
)
res = [np.linalg.matrix_rank(x, tol=tol, hermitian=hermitian)]
res = np.linalg.matrix_rank(x, tol=tol, hermitian=hermitian)
obj.run(res=res, x=x, tol=tol, hermitian=hermitian)


Expand All @@ -68,7 +68,7 @@ def test_matrix_rank_2():
tol = 4.4
hermitian = True
x = np.array([[-2.0, 2.0, 1.0, 2.0], [-2.0, 2.0, 1.0, 2.0], [1.0, 3.0, 4.0, 1.0], [-4.0, 4.0, 2.0, 4.0]])
res = [np.linalg.matrix_rank(x, tol=tol, hermitian=hermitian)]
res = np.linalg.matrix_rank(x, tol=tol, hermitian=hermitian)
obj.run(res=res, x=x, tol=tol, hermitian=hermitian)


Expand Down
4 changes: 2 additions & 2 deletions framework/api/linalg/test_multi_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_multi_dot2():
types = ["float32", "float64"]
x1 = np.random.rand(4)
x2 = np.random.rand(4)
res = np.dot(x1, x2).reshape([1])
res = np.dot(x1, x2)
for d in types:
api_res, api_grad = cal_multi_dot(d, x1=x1, x2=x2)
assert api_res.shape == res.shape
Expand All @@ -189,7 +189,7 @@ def test_multi_dot3():
x2 = np.random.rand(4, 5)
x3 = np.random.rand(5, 2)
x4 = np.random.rand(2)
res = np.dot(np.dot(x1, x2), np.dot(x3, x4)).reshape([1])
res = np.dot(np.dot(x1, x2), np.dot(x3, x4))
for d in types:
api_res, api_grad = cal_multi_dot(d, x1=x1, x2=x2, x3=x3, x4=x4)
assert api_res.shape == res.shape
Expand Down