Browse Source

added a benchmark suite

tags/v0.10
Meinrad Recheis 6 years ago
parent
commit
43d7833b8d
5 changed files with 125 additions and 2 deletions
  1. +8
    -2
      TensorFlow.NET.sln
  2. +40
    -0
      src/TensorFlowNet.Benchmarks/Program.cs
  3. +55
    -0
      src/TensorFlowNet.Benchmarks/TensorCreation.cs
  4. +22
    -0
      src/TensorFlowNet.Benchmarks/TensorFlowNet.Benchmark.csproj
  5. BIN
      src/TensorFlowNet.Benchmarks/tensorflow.dll

+ 8
- 2
TensorFlow.NET.sln View File

@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29025.244
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.UnitTest", "test\TensorFlowNET.UnitTest\TensorFlowNET.UnitTest.csproj", "{029A8CF1-CF95-4DCB-98AA-9D3D96A83B3E}"
EndProject
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Keras.UnitTest", "test\Kera
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TensorFlowNET.Examples.FSharp", "test\TensorFlowNET.Examples.FSharp\TensorFlowNET.Examples.FSharp.fsproj", "{62BC3801-F0D3-44A9-A0AC-712F40C8F961}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowNet.Benchmark", "src\TensorFlowNet.Benchmarks\TensorFlowNet.Benchmark.csproj", "{68861442-971A-4196-876E-C9330F0B3C54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
{62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Release|Any CPU.Build.0 = Release|Any CPU
{68861442-971A-4196-876E-C9330F0B3C54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68861442-971A-4196-876E-C9330F0B3C54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68861442-971A-4196-876E-C9330F0B3C54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68861442-971A-4196-876E-C9330F0B3C54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 40
- 0
src/TensorFlowNet.Benchmarks/Program.cs View File

@@ -0,0 +1,40 @@
using System;
using System.Reflection;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;
namespace TensorFlowNet.Benchmark
{
class Program
{
/// <summary>
/// dotnet NumSharp.Benchmark.dll (Benchmark Class Name)
/// dotnet NumSharp.Benchmark.dll nparange
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
#if DEBUG
IConfig config = new DebugInProcessConfig();
#else
IConfig config = null;
#endif
if (args?.Length > 0)
{
for (int i = 0; i < args.Length; i++)
{
string name = $"TensorFlowNet.Benchmark.{args[i]}";
var type = Type.GetType(name);
BenchmarkRunner.Run(type, config);
}
}
else
{
BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args, config);
}
Console.ReadLine();
}
}
}

+ 55
- 0
src/TensorFlowNet.Benchmarks/TensorCreation.cs View File

@@ -0,0 +1,55 @@
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NumSharp;
using Tensorflow;
namespace TensorFlowNet.Benchmark
{
[SimpleJob(launchCount: 1, warmupCount: 10, targetCount: 30)]
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
public class TensorCreation
{
private double[] data;
[GlobalSetup]
public void Setup()
{
data = new double[1000];
}
[Benchmark]
public void TensorFromArray()
{
var g=new Graph();
for (int i = 0; i < 100; i++)
{
var tensor = new Tensor(data);
}
}
[Benchmark]
public void TensorFromNDArray()
{
var g = new Graph();
for (int i = 0; i < 100; i++)
{
var tensor = new Tensor(new NDArray(data));
}
}
//[Benchmark]
//public void Constant()
//{
// for (int i = 0; i < 100; i++)
// {
// //var tensor = new Tensor(new NDArray(data));
// var c = tf.constant(42.0);
// }
//}
}
}

+ 22
- 0
src/TensorFlowNet.Benchmarks/TensorFlowNet.Benchmark.csproj View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TensorFlowNET.Core\TensorFlowNET.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="tensorflow.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

BIN
src/TensorFlowNet.Benchmarks/tensorflow.dll View File


Loading…
Cancel
Save