diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/NamedOnnxValue.cs b/csharp/src/Microsoft.ML.OnnxRuntime/NamedOnnxValue.cs index db71783366..1df2bceccc 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/NamedOnnxValue.cs +++ b/csharp/src/Microsoft.ML.OnnxRuntime/NamedOnnxValue.cs @@ -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 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 nativeTensorWrapper = new NativeOnnxTensorMemory(nativeOnnxValue); - DenseTensor dt = new DenseTensor(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(name, nativeOnnxValue); + break; + case TensorElementType.Double: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.Int16: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.UInt16: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.Int32: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.UInt32: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.Int64: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.UInt64: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + case TensorElementType.UInt8: + result = NameOnnxValueFromNativeTensor(name, nativeOnnxValue); + break; + default: + throw new NotSupportedException("Tensor of element type: "+elemType+" is not supported"); + } return result; } + + private static NamedOnnxValue NameOnnxValueFromNativeTensor(string name, IntPtr nativeOnnxValue) + { + NativeOnnxTensorMemory nativeTensorWrapper = new NativeOnnxTensorMemory(nativeOnnxValue); + DenseTensor dt = new DenseTensor(nativeTensorWrapper.Memory, nativeTensorWrapper.Dimensions); + return NamedOnnxValue.CreateFromTensor(name, dt); + } + + private bool TryPinAsTensor( out MemoryHandle pinnedMemoryHandle, out IntPtr dataBufferPointer, diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/NativeOnnxTensorMemory.cs b/csharp/src/Microsoft.ML.OnnxRuntime/NativeOnnxTensorMemory.cs index f70aa8083e..0339ac8871 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/NativeOnnxTensorMemory.cs +++ b/csharp/src/Microsoft.ML.OnnxRuntime/NativeOnnxTensorMemory.cs @@ -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 GetSpan() { if (IsDisposed) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index e185cb6796..3f97444128 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -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.CreateFromTensor("input_0_0", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_0_1", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_1_0", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_1_1", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_1_2", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_1_3", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_1_4", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_2_0", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_2_1", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_2_2", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_2_3", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_2_4", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_2_5", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_3_0", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_3_1", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_0", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_1", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_2", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_3", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_4", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_5", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_6", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_7", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_8", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_9", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_10", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_11", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_12", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_13", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_14", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_15", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_16", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_17", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_18", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_19", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_20", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_21", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_22", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_23", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_24", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_25", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_26", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_27", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_28", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_29", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_30", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_31", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_32", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_33", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_34", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_35", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_36", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_37", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_38", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_39", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_40", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_41", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_42", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_43", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_44", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_45", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_46", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_47", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_48", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_49", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_50", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_51", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_52", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_53", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_54", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_55", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_56", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_57", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_58", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_59", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_60", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_61", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_62", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_63", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_64", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_65", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_66", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_67", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_68", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_69", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_70", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_71", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_72", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_73", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_74", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_75", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_76", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_77", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_78", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_79", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_80", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_81", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_82", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_83", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_84", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_85", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_86", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_87", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_88", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_89", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_90", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_91", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_92", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_93", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_94", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_95", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_96", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_97", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_98", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_99", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_100", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_101", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_102", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_103", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_104", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_105", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_106", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_107", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_108", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_109", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_110", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_111", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_112", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_113", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_114", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_115", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_116", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_117", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_118", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_119", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_120", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_121", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_122", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_123", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_124", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_125", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_126", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_127", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_128", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_129", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_130", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_131", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_132", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_133", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_134", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_135", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_136", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_137", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_138", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_139", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_140", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_141", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_142", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_143", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_144", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_145", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_146", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_4_147", new DenseTensor(zerof, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_0", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_1", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_2", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_3", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_4", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_5", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_6", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_7", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_8", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_9", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_10", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_11", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_12", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_13", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_14", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_15", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_16", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_17", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_18", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_19", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_20", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_21", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_22", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_23", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_24", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_25", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_26", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_27", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_28", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_29", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_30", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_31", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_32", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_33", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_34", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_35", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_36", new DenseTensor(zerol, new int[] { 1 })), + NamedOnnxValue.CreateFromTensor("input_5_37", new DenseTensor(zerol, new int[] { 1 })), + }; + + var result = session.Run(data); + Assert.NotNull(result); + Assert.Equal(1, result.Count); + var value = result.First(); + Assert.Equal("label", value.Name); + Assert.NotNull(value.AsTensor()); + Assert.Equal(1, value.AsTensor().Length); + } + + static float[] LoadTensorFromFile(string filename) { diff --git a/csharp/testdata/model_181031_12.onnx b/csharp/testdata/model_181031_12.onnx new file mode 100644 index 0000000000..fda80bcc07 Binary files /dev/null and b/csharp/testdata/model_181031_12.onnx differ