Skip to content

Commit fcf8bc1

Browse files
committed
Added test for creating tensor from of an array.
1 parent 24b254c commit fcf8bc1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Test/TorchSharp.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ public void CreateFloatTensorFromData()
7575
}
7676
}
7777

78+
[TestMethod]
79+
public void CreateFloatTensorFromDataCheckDispose()
80+
{
81+
var data = new float[1000];
82+
data[100] = 1;
83+
84+
using (var tensor = FloatTensor.From(data, new long[] { 100, 10 }))
85+
{
86+
Assert.AreEqual(tensor.Data[100], 1);
87+
}
88+
89+
Assert.AreEqual(data[100], 1);
90+
}
91+
7892
[TestMethod]
7993
public void CreateFloatTensorFromData2()
8094
{

0 commit comments

Comments
 (0)