Skip to content

Commit 1afdc31

Browse files
authored
Test feeding dense output as intermediate for the new sparse ops (#877)
1 parent fde64bd commit 1afdc31

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

test/00_sparse/Convert.cu

+12
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,17 @@ TYPED_TEST(ConvertSparseTestsAll, ConvertCSC) {
196196
}
197197
}
198198

199+
// Allow dense computations (post-convert).
200+
TestType C3 = static_cast<TestType>(3);
201+
(O = sparse2dense(S) + C3).run(exec);
202+
203+
// Verify result.
204+
exec.sync();
205+
for (index_t i = 0; i < m; i++) {
206+
for (index_t j = 0; j < n; j++) {
207+
ASSERT_EQ(O(i, j) - C3, D(i, j));
208+
}
209+
}
210+
199211
MATX_EXIT_HANDLER();
200212
}

test/00_sparse/Solve.cu

+20-1
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,31 @@ TYPED_TEST(SolveSparseTestsAll, SolveCSR) {
101101
for (index_t j = 0; j < 2; j++) {
102102
if constexpr (is_complex_v<TestType>) {
103103
ASSERT_NEAR(X(i, j).real(), E(i, j).real(), this->thresh);
104-
ASSERT_NEAR(X(i, j).imag(), E(i,j ).imag(), this->thresh);
104+
ASSERT_NEAR(X(i, j).imag(), E(i, j).imag(), this->thresh);
105105
}
106106
else {
107107
ASSERT_NEAR(X(i, j), E(i, j), this->thresh);
108108
}
109+
}
110+
}
111+
112+
// Allow dense computations (pre-/post-solve).
113+
TestType C3 = static_cast<TestType>(3);
114+
TestType C5 = static_cast<TestType>(5);
115+
(Y = (Y - C3)).run(exec);
116+
(X = solve(S, Y + C3) + C5).run(exec);
109117

118+
// Verify result.
119+
exec.sync();
120+
for (index_t i = 0; i < 4; i++) {
121+
for (index_t j = 0; j < 2; j++) {
122+
if constexpr (is_complex_v<TestType>) {
123+
ASSERT_NEAR((X(i, j) - C5).real(), E(i, j).real(), this->thresh);
124+
ASSERT_NEAR((X(i, j) - C5).imag(), E(i, j).imag(), this->thresh);
125+
}
126+
else {
127+
ASSERT_NEAR(X(i, j) - C5, E(i, j), this->thresh);
128+
}
110129
}
111130
}
112131

0 commit comments

Comments
 (0)