| 9 | using namespace test; |
| 10 | |
| 11 | TEST_F(CUDA, SINGULAR_VALUE_DECOMPOSITION) { |
| 12 | auto opr_naive = handle_naive()->create_operator<SVDForward>(); |
| 13 | auto opr_cuda = handle_cuda()->create_operator<SVDForward>(); |
| 14 | auto testcases = SVDTestcase::make(); |
| 15 | for (auto& t : testcases) { |
| 16 | auto cuda_result = t.run(opr_cuda.get()); |
| 17 | |
| 18 | bool old_compute_nv = t.m_param.compute_uv; |
| 19 | t.m_param.compute_uv = false; |
| 20 | auto naive_result = t.run(opr_naive.get()); |
| 21 | t.m_param.compute_uv = old_compute_nv; |
| 22 | |
| 23 | MEGDNN_ASSERT_TENSOR_EQ(*naive_result.s, *cuda_result.s); |
| 24 | if (t.m_param.compute_uv) { |
| 25 | MEGDNN_ASSERT_TENSOR_EQ(*cuda_result.recovered_mat, t.m_mat); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // vim: syntax=cpp.doxygen |