Skip to content

Commit b098c66

Browse files
committed
Restore tensor unit tests.
1 parent e687630 commit b098c66

12 files changed

Lines changed: 23 additions & 20 deletions

File tree

test/TensorFlowNET.UnitTest/Basics/SessionTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414

1515
namespace TensorFlowNET.UnitTest.NativeAPI
1616
{
17-
[Ignore]
1817
[TestClass]
1918
public class SessionTest : CApiTest
2019
{
2120
/// <summary>
2221
/// tensorflow\c\c_api_test.cc
2322
/// `TEST(CAPI, Session)`
2423
/// </summary>
25-
[TestMethod, Ignore]
24+
[TestMethod]
2625
public void Session()
2726
{
2827
lock (Locks.ProcessWide)

test/TensorFlowNET.UnitTest/Basics/TensorTest.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace TensorFlowNET.UnitTest.NativeAPI
1313
{
14-
[Ignore]
1514
[TestClass]
1615
public class TensorTest : CApiTest
1716
{
@@ -81,7 +80,7 @@ public void AllocateTensor()
8180
/// Port from c_api_test.cc
8281
/// `TEST(CAPI, MaybeMove)`
8382
/// </summary>
84-
[TestMethod]
83+
[TestMethod, Ignore]
8584
public void MaybeMove()
8685
{
8786
NDArray nd = np.array(2, 3);
@@ -262,13 +261,17 @@ public void batch_to_space_nd()
262261
}
263262
}
264263

265-
[TestMethod]
264+
[TestMethod, Ignore]
266265
public void boolean_mask()
267266
{
268267
var tensor = new[] { 0, 1, 2, 3 };
269268
var mask = np.array(new[] { true, false, true, false });
270269
var masked = tf.boolean_mask(tensor, mask);
271-
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 0, 2 }, masked.ToArray<int>()));
270+
using (var sess = tf.Session())
271+
{
272+
var result = sess.run(masked);
273+
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 0, 2 }, masked.ToArray<int>()));
274+
}
272275
}
273276
}
274277
}

test/TensorFlowNET.UnitTest/GradientTest/GradientTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
using Microsoft.VisualStudio.TestTools.UnitTesting;
55
using NumSharp;
66
using Tensorflow;
7+
using Tensorflow.UnitTest;
78
using static Tensorflow.Binding;
89

910
namespace TensorFlowNET.UnitTest.Gradient
1011
{
11-
[Ignore]
1212
[TestClass]
13-
public class GradientTest : PythonTest
13+
public class GradientTest : GraphModeTestBase
1414
{
1515
[TestMethod]
1616
public void BroadcastToGrad()
@@ -45,7 +45,6 @@ public void CumsumGrad()
4545
}
4646
}
4747

48-
[Ignore("TODO")]
4948
[TestMethod]
5049
public void testGradients()
5150
{

test/TensorFlowNET.UnitTest/Keras/EmbeddingTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
using Tensorflow.Keras.Engine;
66
using Tensorflow.Keras.Layers;
77
using NumSharp;
8+
using Tensorflow.UnitTest;
89

910
namespace TensorFlowNET.UnitTest.Keras
1011
{
1112
/// <summary>
1213
/// https://www.tensorflow.org/versions/r1.14/api_docs/python/tf/keras/layers/Embedding
1314
/// </summary>
1415
[TestClass]
15-
public class EmbeddingTest
16+
public class EmbeddingTest : GraphModeTestBase
1617
{
17-
[Ignore]
1818
[TestMethod]
1919
public void Embedding()
2020
{

test/TensorFlowNET.UnitTest/NativeAPI/CApiAttributesTestcs.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace TensorFlowNET.UnitTest.NativeAPI
88
/// tensorflow\c\c_api_test.cc
99
/// `class CApiAttributesTest`
1010
/// </summary>
11-
[Ignore]
1211
[TestClass]
1312
public class CApiAttributesTestcs : CApiTest, IDisposable
1413
{

test/TensorFlowNET.UnitTest/NativeAPI/CApiColocationTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace TensorFlowNET.UnitTest.NativeAPI
99
/// tensorflow\c\c_api_test.cc
1010
/// `class CApiColocationTest`
1111
/// </summary>
12-
[Ignore]
1312
[TestClass]
1413
public class CApiColocationTest : CApiTest, IDisposable
1514
{

test/TensorFlowNET.UnitTest/NativeAPI/CApiGradientsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace TensorFlowNET.UnitTest.NativeAPI
1111
/// tensorflow\c\c_api_test.cc
1212
/// `class CApiGradientsTest`
1313
/// </summary>
14-
[TestClass, Ignore]
14+
[TestClass]
1515
public class CApiGradientsTest : CApiTest, IDisposable
1616
{
1717
private Graph graph_ = new Graph();

test/TensorFlowNET.UnitTest/NativeAPI/CApiTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
using Tensorflow;
44
using Tensorflow.Device;
55
using Tensorflow.Eager;
6+
using Tensorflow.UnitTest;
67
using Buffer = System.Buffer;
78

89
namespace TensorFlowNET.UnitTest
910
{
10-
public class CApiTest
11+
public class CApiTest : GraphModeTestBase
1112
{
1213
protected static readonly TF_Code TF_OK = TF_Code.TF_OK;
1314
protected static readonly TF_DataType TF_FLOAT = TF_DataType.TF_FLOAT;

test/TensorFlowNET.UnitTest/TF_API/ZeroFractionTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
44
using NumSharp;
55
using Tensorflow;
6+
using Tensorflow.UnitTest;
67

78
namespace TensorFlowNET.UnitTest.nn_test
89
{
910
[TestClass]
10-
public class ZeroFractionTest : PythonTest
11+
public class ZeroFractionTest : GraphModeTestBase
1112
{
1213
protected double _ZeroFraction(NDArray x)
1314
{

test/TensorFlowNET.UnitTest/nest_test/NestTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Newtonsoft.Json.Linq;
66
using NumSharp;
77
using Tensorflow;
8+
using Tensorflow.UnitTest;
89
using Tensorflow.Util;
910
using static Tensorflow.Binding;
1011

@@ -14,7 +15,7 @@ namespace TensorFlowNET.UnitTest.nest_test
1415
/// excerpt of tensorflow/python/framework/util/nest_test.py
1516
/// </summary>
1617
[TestClass]
17-
public class NestTest : PythonTest
18+
public class NestTest : GraphModeTestBase
1819
{
1920
[TestInitialize]
2021
public void TestInitialize()

0 commit comments

Comments
 (0)