Skip to content

Commit c632c40

Browse files
quanap5krEsther2013
authored andcommitted
scan unit test
1 parent 6d66092 commit c632c40

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/TensorFlowNET.UnitTest/ManagedAPI/ControlFlowApiTest.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using NumSharp;
23
using System;
34
using Tensorflow;
45
using static Tensorflow.Binding;
@@ -45,5 +46,21 @@ public void WhileLoopGraphMode()
4546
var r = tf.while_loop(c, b, i);
4647
Assert.AreEqual(10, (int)r);
4748
}
49+
50+
[TestMethod, Ignore]
51+
public void ScanFunctionGraphMode()
52+
{
53+
tf.compat.v1.disable_eager_execution();
54+
Func<Tensor, Tensor, Tensor> fn = (prev, current) => tf.add(prev, current);
55+
var input = tf.placeholder(TF_DataType.TF_FLOAT, new TensorShape(6));
56+
var scan = tf.scan(fn, input);
57+
58+
using (var sess = tf.Session())
59+
{
60+
sess.run(tf.global_variables_initializer());
61+
var result = sess.run(scan, new FeedItem(input, np.array(1, 2, 3, 4, 5, 6)));
62+
Assert.AreEqual(new float[] { 1, 3, 6, 10, 15, 21 }, result.ToArray<float>());
63+
}
64+
}
4865
}
4966
}

0 commit comments

Comments
 (0)