Skip to content

Commit 5b3e7bc

Browse files
committed
Added backprop test.
1 parent 6a0fa6d commit 5b3e7bc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pytorch_block_sparse/tests/test_replace.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ def test_block_replace(self):
119119
#print((c-c_0).abs().max())
120120
self.assertTrue(False)
121121

122+
# Check matmul with sparse support
123+
b = torch.randn((1,size[0]), device = bsm.data.device).abs()
124+
125+
bsm.matmul_with_output_sparse_support(b,a, overwrite_data=True)
126+
dbsm_back = bsm.to_dense()
127+
dbsm0_back = b.t().mm(a)
128+
dbsm0_back = dbsm0_back * bsm.to_dense(data_replace=torch.ones_like(bsm.data))
129+
130+
self.assertTrue(dbsm0_back.isclose(dbsm_back).all())
131+
132+
133+
134+
135+
122136

123137

124138

0 commit comments

Comments
 (0)