Skip to content

Commit 206a071

Browse files
alexpantyukhinmigueldeicaza
authored andcommitted
add test for ListDevices. (migueldeicaza#244)
* add test for ListDevices. * free device list.
1 parent a457072 commit 206a071

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

TensorFlowSharp/Tensorflow.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,8 +2512,7 @@ public IEnumerable<DeviceAttributes> ListDevices(TFStatus status = null)
25122512
list.Add (new DeviceAttributes (name, deviceType, memory));
25132513
}
25142514

2515-
// TODO: Fix deleting.
2516-
// TF_DeleteDeviceList (rawDeviceList);
2515+
TF_DeleteDeviceList (rawDeviceList);
25172516

25182517
return list;
25192518
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Linq;
2+
using TensorFlow;
3+
using Xunit;
4+
5+
namespace TensorFlowSharp.Tests.CSharp
6+
{
7+
public class SessionTests
8+
{
9+
[Fact]
10+
public void Should_ListDeviceReturnDevices ()
11+
{
12+
using (var graph = new TFGraph ())
13+
using (var session = new TFSession (graph)) {
14+
var devices = session.ListDevices ();
15+
16+
Assert.True(devices.Any());
17+
}
18+
}
19+
}
20+
}

tests/TensorFlowSharp.Tests.CSharp/TensorFlowSharp.Tests.CSharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<Compile Include="CondTests.cs" />
6868
<Compile Include="GradientTests.cs" />
6969
<Compile Include="ArrayTests.cs" />
70+
<Compile Include="SessionTests.cs" />
7071
<Compile Include="ShapeTests.cs" />
7172
<Compile Include="TensorTests.cs" />
7273
<Compile Include="ClipTests.cs" />

0 commit comments

Comments
 (0)