fix bug -- failing on non float tensor output types (#58)

* fixed the missing implementation of output tensor construction based on type checking

* cleanup

* cleanup
This commit is contained in:
shahasad 2018-11-29 08:15:18 -08:00 committed by Pranav Sharma
parent 8980cbbfad
commit 7780fd6cd9
4 changed files with 300 additions and 4 deletions

View file

@ -8,6 +8,7 @@ using System.Numerics.Tensors;
using System.Buffers;
using System.Collections;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Microsoft.ML.OnnxRuntime
{
@ -185,16 +186,68 @@ namespace Microsoft.ML.OnnxRuntime
{
NamedOnnxValue result = null;
if (true /* TODO: check native data type when API available. assuming Tensor<float> for now */)
/* Get Tensor element type */ //TODO: Assumed value is Tensor, need to support non-tensor types in future
IntPtr typeAndShape = IntPtr.Zero;
TensorElementType elemType = TensorElementType.DataTypeMax;
try
{
NativeOnnxTensorMemory<float> nativeTensorWrapper = new NativeOnnxTensorMemory<float>(nativeOnnxValue);
DenseTensor<float> dt = new DenseTensor<float>(nativeTensorWrapper.Memory, nativeTensorWrapper.Dimensions);
result = new NamedOnnxValue(name, dt);
NativeApiStatus.VerifySuccess(NativeMethods.ONNXRuntimeGetTensorShapeAndType(nativeOnnxValue, out typeAndShape));
elemType = NativeMethods.ONNXRuntimeGetTensorElementType(typeAndShape);
}
finally
{
if (typeAndShape != IntPtr.Zero)
{
NativeMethods.ONNXRuntimeReleaseObject(typeAndShape);
}
}
switch (elemType)
{
case TensorElementType.Float:
result = NameOnnxValueFromNativeTensor<float>(name, nativeOnnxValue);
break;
case TensorElementType.Double:
result = NameOnnxValueFromNativeTensor<double>(name, nativeOnnxValue);
break;
case TensorElementType.Int16:
result = NameOnnxValueFromNativeTensor<short>(name, nativeOnnxValue);
break;
case TensorElementType.UInt16:
result = NameOnnxValueFromNativeTensor<ushort>(name, nativeOnnxValue);
break;
case TensorElementType.Int32:
result = NameOnnxValueFromNativeTensor<int>(name, nativeOnnxValue);
break;
case TensorElementType.UInt32:
result = NameOnnxValueFromNativeTensor<uint>(name, nativeOnnxValue);
break;
case TensorElementType.Int64:
result = NameOnnxValueFromNativeTensor<long>(name, nativeOnnxValue);
break;
case TensorElementType.UInt64:
result = NameOnnxValueFromNativeTensor<ulong>(name, nativeOnnxValue);
break;
case TensorElementType.UInt8:
result = NameOnnxValueFromNativeTensor<byte>(name, nativeOnnxValue);
break;
default:
throw new NotSupportedException("Tensor of element type: "+elemType+" is not supported");
}
return result;
}
private static NamedOnnxValue NameOnnxValueFromNativeTensor<T>(string name, IntPtr nativeOnnxValue)
{
NativeOnnxTensorMemory<T> nativeTensorWrapper = new NativeOnnxTensorMemory<T>(nativeOnnxValue);
DenseTensor<T> dt = new DenseTensor<T>(nativeTensorWrapper.Memory, nativeTensorWrapper.Dimensions);
return NamedOnnxValue.CreateFromTensor<T>(name, dt);
}
private bool TryPinAsTensor<T>(
out MemoryHandle pinnedMemoryHandle,
out IntPtr dataBufferPointer,

View file

@ -79,6 +79,12 @@ namespace Microsoft.ML.OnnxRuntime
Dispose(false);
}
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
public bool IsDisposed => _disposed;
protected bool IsRetained => _referenceCount > 0;
@ -99,6 +105,22 @@ namespace Microsoft.ML.OnnxRuntime
}
}
public int Count
{
get
{
return _elementCount;
}
}
public int ElementWidth
{
get
{
return _elementWidth;
}
}
public override Span<T> GetSpan()
{
if (IsDisposed)

View file

@ -183,6 +183,227 @@ namespace Microsoft.ML.OnnxRuntime.Tests
session.Dispose();
}
[Fact]
private void Yunsong()
{
var session = new InferenceSession(@"model_181031_12.onnx");
float[] zerof = new float[] { 0 };
long[] zerol = new long[] { 1 };
var data = new List<NamedOnnxValue>() {
NamedOnnxValue.CreateFromTensor<float>("input_0_0", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_0_1", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_1_0", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_1_1", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_1_2", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_1_3", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_1_4", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_2_0", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_2_1", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_2_2", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_2_3", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_2_4", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_2_5", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_3_0", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_3_1", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_0", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_1", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_2", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_3", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_4", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_5", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_6", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_7", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_8", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_9", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_10", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_11", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_12", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_13", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_14", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_15", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_16", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_17", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_18", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_19", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_20", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_21", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_22", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_23", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_24", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_25", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_26", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_27", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_28", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_29", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_30", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_31", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_32", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_33", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_34", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_35", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_36", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_37", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_38", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_39", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_40", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_41", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_42", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_43", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_44", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_45", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_46", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_47", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_48", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_49", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_50", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_51", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_52", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_53", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_54", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_55", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_56", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_57", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_58", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_59", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_60", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_61", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_62", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_63", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_64", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_65", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_66", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_67", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_68", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_69", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_70", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_71", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_72", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_73", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_74", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_75", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_76", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_77", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_78", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_79", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_80", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_81", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_82", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_83", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_84", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_85", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_86", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_87", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_88", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_89", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_90", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_91", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_92", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_93", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_94", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_95", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_96", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_97", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_98", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_99", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_100", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_101", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_102", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_103", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_104", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_105", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_106", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_107", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_108", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_109", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_110", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_111", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_112", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_113", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_114", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_115", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_116", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_117", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_118", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_119", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_120", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_121", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_122", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_123", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_124", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_125", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_126", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_127", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_128", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_129", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_130", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_131", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_132", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_133", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_134", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_135", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_136", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_137", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_138", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_139", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_140", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_141", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_142", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_143", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_144", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_145", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_146", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<float>("input_4_147", new DenseTensor<float>(zerof, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_0", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_1", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_2", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_3", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_4", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_5", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_6", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_7", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_8", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_9", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_10", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_11", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_12", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_13", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_14", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_15", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_16", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_17", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_18", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_19", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_20", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_21", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_22", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_23", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_24", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_25", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_26", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_27", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_28", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_29", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_30", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_31", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_32", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_33", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_34", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_35", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_36", new DenseTensor<long>(zerol, new int[] { 1 })),
NamedOnnxValue.CreateFromTensor<long>("input_5_37", new DenseTensor<long>(zerol, new int[] { 1 })),
};
var result = session.Run(data);
Assert.NotNull(result);
Assert.Equal(1, result.Count);
var value = result.First<NamedOnnxValue>();
Assert.Equal("label", value.Name);
Assert.NotNull(value.AsTensor<long>());
Assert.Equal(1, value.AsTensor<long>().Length);
}
static float[] LoadTensorFromFile(string filename)
{

BIN
csharp/testdata/model_181031_12.onnx vendored Normal file

Binary file not shown.