Skip to content

Commit 6e33484

Browse files
committed
Added test for sparse.
1 parent a4b5556 commit 6e33484

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Test/TorchSharp/TorchSharp.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,19 @@ public void InitUniform()
150150
}
151151
}
152152

153+
[TestMethod]
154+
public void TestSparse()
155+
{
156+
using (var i = LongTensor.From(new long[] { 0, 1, 1, 2, 0, 2 }, new long[] { 2, 3 }))
157+
using (var v = FloatTensor.From(new float[] { 3, 4, 5 }, new long[] { 3 }))
158+
{
159+
var sparse = FloatTensor.Sparse(i, v, new long[] { 2, 3 });
160+
161+
Assert.IsNotNull(sparse);
162+
Assert.IsTrue(sparse.IsSparse);
163+
}
164+
}
165+
153166
[TestMethod]
154167
public void CopyCpuToCuda()
155168
{

0 commit comments

Comments
 (0)