diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index 3f974441288b6..0bf59ddc37e90 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -71,9 +71,9 @@ private void CanRunInferenceOnAModel() var results = session.Run(container); // results is an IReadOnlyList container Assert.Equal(1, results.Count); - + float[] expectedOutput = LoadTensorFromFile(@"bench.expected_out"); - float errorMargin = 1e-6F; + float errorMargin = 1e-6F; // validate the results foreach (var r in results) { @@ -82,7 +82,7 @@ private void CanRunInferenceOnAModel() var resultTensor = r.AsTensor(); int[] expectedDimensions = { 1, 1000, 1, 1 }; // hardcoded for now for the test data Assert.Equal(expectedDimensions.Length, resultTensor.Rank); - + var resultDimensions = resultTensor.Dimensions; for (int i = 0; i < expectedDimensions.Length; i++) { @@ -113,8 +113,8 @@ private void ThrowWrongInputName() var container = new List(); container.Add(NamedOnnxValue.CreateFromTensor("wrong_name", tensor)); var ex = Assert.Throws(() => session.Run(container)); - Assert.Equal("[ErrorCode:InvalidArgument] Missing required inputs: data_0", ex.Message); - session.Dispose(); + Assert.Equal("[ErrorCode:InvalidArgument] Invalid Feed Input Names: wrong_name Valid input names are: data_0 ", ex.Message); + session.Dispose(); } [Fact] @@ -179,231 +179,204 @@ private void ThrowExtraInputs() container.Add(nov1); container.Add(nov2); var ex = Assert.Throws(() => session.Run(container)); - Assert.StartsWith("[ErrorCode:InvalidArgument] Invalid Feed Input Names: extra. Valid input names are: ", ex.Message); + Assert.Equal("[ErrorCode:InvalidArgument] The number of feeds is not same as the number of the model input, expect 1 got 2", ex.Message); session.Dispose(); } + [Fact] + private void TestModelInputFloat() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_FLOAT.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var nov = NamedOnnxValue.CreateFromTensor("input", + new DenseTensor(new float[] {1.0f, 2.0f, -3.0f, float.MinValue, float.MaxValue }, + new int[] { 1, 5 }) ); + container.Add(nov); + var res = session.Run(container); + } + + [Fact(Skip = "Boolean tensor not supported yet")] + private void TestModelInputBOOL() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_BOOL.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new bool[] { true, false, true, false, true }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + [Fact] + + private void TestModelInputINT32() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_INT32.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new int[] { 1, -2, -3, int.MinValue, int.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + [Fact] - private void Yunsong() + private void TestModelInputDOUBLE() { - 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); + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_DOUBLE.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new double[] { 1.0, 2.0, -3.0, 5, 5},new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + //new DenseTensor(new double[] { 1.0, 2.0, -3.0, double.MinValue, double.MaxValue}, + //new int[] { 1, 5 })); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); } + [Fact(Skip = "String tensor not supported yet")] + private void TestModelInputSTRING() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_STRING.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new string[] { "a", "c", "d", "z", "f" }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + [Fact(Skip = "Int8 not supported yet")] + private void TestModelInputINT8() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_INT8.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new sbyte[] { 1, 2, -3, sbyte.MinValue, sbyte.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + + [Fact] + private void TestModelInputUINT8() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_UINT8.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new byte[] { 1, 2, 3, byte.MinValue, byte.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + + [Fact] + private void TestModelInputUINT16() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_UINT16.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new UInt16[] { 1, 2, 3, UInt16.MinValue, UInt16.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + + [Fact] + private void TestModelInputINT16() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_INT16.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new Int16[] { 1, 2, 3, Int16.MinValue, Int16.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + + [Fact] + private void TestModelInputINT64() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_INT64.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new Int64[] { 1, 2, -3, Int64.MinValue, Int64.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + + [Fact] + private void TestModelInputUINT32() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_UINT32.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new UInt32[] { 1, 2, 3, UInt32.MinValue, UInt32.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + [Fact] + private void TestModelInputUINT64() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_UINT64.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new UInt64[] { 1, 2, 3, UInt64.MinValue, UInt64.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } + + [Fact(Skip = "Boolean FLOAT16 not available in C#")] + private void TestModelInputFLOAT16() + { + // model takes 1x5 input of fixed type, echoes back + string modelPath = Directory.GetCurrentDirectory() + @"\test_types_FLOAT16.onnx"; + var session = new InferenceSession(modelPath); + var container = new List(); + var tensorIn = new DenseTensor(new float[] { 1.0f, 2.0f, -3.0f, float.MinValue, float.MaxValue }, new int[] { 1, 5 }); + var nov = NamedOnnxValue.CreateFromTensor("input", tensorIn); + container.Add(nov); + var res = session.Run(container); + var tensorOut = res.First().AsTensor(); + Assert.True(tensorOut.SequenceEqual(tensorIn)); + } static float[] LoadTensorFromFile(string filename) { @@ -432,6 +405,5 @@ static Tuple> OpenSessionSqueezeNe var tensor = new DenseTensor(inputData, inputMeta["data_0"].Dimensions); return new Tuple>(session, inputData, tensor); } - } } \ No newline at end of file diff --git a/csharp/testdata/model_181031_12.onnx b/csharp/testdata/model_181031_12.onnx deleted file mode 100644 index fda80bcc07e1c..0000000000000 Binary files a/csharp/testdata/model_181031_12.onnx and /dev/null differ diff --git a/csharp/testdata/test_types_BOOL.onnx b/csharp/testdata/test_types_BOOL.onnx new file mode 100644 index 0000000000000..005aa79303179 Binary files /dev/null and b/csharp/testdata/test_types_BOOL.onnx differ diff --git a/csharp/testdata/test_types_DOUBLE.onnx b/csharp/testdata/test_types_DOUBLE.onnx new file mode 100644 index 0000000000000..8a98310868091 Binary files /dev/null and b/csharp/testdata/test_types_DOUBLE.onnx differ diff --git a/csharp/testdata/test_types_FLOAT.onnx b/csharp/testdata/test_types_FLOAT.onnx new file mode 100644 index 0000000000000..ce213fb7ec818 Binary files /dev/null and b/csharp/testdata/test_types_FLOAT.onnx differ diff --git a/csharp/testdata/test_types_FLOAT16.onnx b/csharp/testdata/test_types_FLOAT16.onnx new file mode 100644 index 0000000000000..f671bb7ce3253 Binary files /dev/null and b/csharp/testdata/test_types_FLOAT16.onnx differ diff --git a/csharp/testdata/test_types_INT16.onnx b/csharp/testdata/test_types_INT16.onnx new file mode 100644 index 0000000000000..911edf549863d Binary files /dev/null and b/csharp/testdata/test_types_INT16.onnx differ diff --git a/csharp/testdata/test_types_INT32.onnx b/csharp/testdata/test_types_INT32.onnx new file mode 100644 index 0000000000000..5f59b553379ea Binary files /dev/null and b/csharp/testdata/test_types_INT32.onnx differ diff --git a/csharp/testdata/test_types_INT64.onnx b/csharp/testdata/test_types_INT64.onnx new file mode 100644 index 0000000000000..984cc51001445 Binary files /dev/null and b/csharp/testdata/test_types_INT64.onnx differ diff --git a/csharp/testdata/test_types_INT8.onnx b/csharp/testdata/test_types_INT8.onnx new file mode 100644 index 0000000000000..b6947e990a46a Binary files /dev/null and b/csharp/testdata/test_types_INT8.onnx differ diff --git a/csharp/testdata/test_types_STRING.onnx b/csharp/testdata/test_types_STRING.onnx new file mode 100644 index 0000000000000..16927acbcc5e3 Binary files /dev/null and b/csharp/testdata/test_types_STRING.onnx differ diff --git a/csharp/testdata/test_types_UINT16.onnx b/csharp/testdata/test_types_UINT16.onnx new file mode 100644 index 0000000000000..f6fcc00abb362 Binary files /dev/null and b/csharp/testdata/test_types_UINT16.onnx differ diff --git a/csharp/testdata/test_types_UINT32.onnx b/csharp/testdata/test_types_UINT32.onnx new file mode 100644 index 0000000000000..ca0acc80aab0b Binary files /dev/null and b/csharp/testdata/test_types_UINT32.onnx differ diff --git a/csharp/testdata/test_types_UINT64.onnx b/csharp/testdata/test_types_UINT64.onnx new file mode 100644 index 0000000000000..a08e3fd689a26 Binary files /dev/null and b/csharp/testdata/test_types_UINT64.onnx differ diff --git a/csharp/testdata/test_types_UINT8.onnx b/csharp/testdata/test_types_UINT8.onnx new file mode 100644 index 0000000000000..78c7746e58479 Binary files /dev/null and b/csharp/testdata/test_types_UINT8.onnx differ