Browse Source

MultithreadingTests.cs: Added unit-test for case #380

tags/v0.12
Eli Belash 6 years ago
parent
commit
83b9eb82af
1 changed files with 45 additions and 1 deletions
  1. +45
    -1
      test/TensorFlowNET.UnitTest/MultithreadingTests.cs

+ 45
- 1
test/TensorFlowNET.UnitTest/MultithreadingTests.cs View File

@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NumSharp;
using Tensorflow;
using Tensorflow.Util;
using static Tensorflow.Binding;
@@ -260,7 +263,7 @@ namespace TensorFlowNET.UnitTest
}
}

[TestMethod]
public void TF_GraphOperationByName()
{
@@ -280,5 +283,46 @@ namespace TensorFlowNET.UnitTest
}
}
}

private static string modelPath = "./model/";

[TestMethod]
public void TF_GraphOperationByName_FromModel()
{
MultiThreadedUnitTestExecuter.Run(8, Core);

//the core method
void Core(int tid)
{
Console.WriteLine();
for (int j = 0; j < 100; j++)
{
var sess = Session.LoadFromSavedModel(modelPath).as_default();
var inputs = new[] {"sp", "fuel"};

var inp = inputs.Select(name => sess.graph.OperationByName(name).output).ToArray();
var outp = sess.graph.OperationByName("softmax_tensor").output;

for (var i = 0; i < 100; i++)
{
{
var data = new float[96];
FeedItem[] feeds = new FeedItem[2];

for (int f = 0; f < 2; f++)
feeds[f] = new FeedItem(inp[f], new NDArray(data));

try
{
sess.run(outp, feeds);
} catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
}
}
}
}

Loading…
Cancel
Save