dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
8.93k stars 1.86k forks source link

Unable to update OnnxRuntime #6916

Open ericstj opened 6 months ago

ericstj commented 6 months ago

System Information (please complete the following information):

Describe the bug When updating OnnxRuntime to 1.15.0 or later 4 tests fail with

  Error Message:
   System.InvalidOperationException : Error initializing model :Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:Fail] OnnxValueType must either be a tensor or sparse tensor
   at Microsoft.ML.OnnxRuntime.NodeMetadata.CheckTensor()
   at Microsoft.ML.OnnxRuntime.NodeMetadata.get_Dimensions()
   at Microsoft.ML.Transforms.Onnx.OnnxModel.GetOnnxVariablesFromMetadata(IReadOnlyDictionary`2 nodeMetadata, IDictionary`2 shapeDictionary, Dictionary`2 typePool, Dictionary`2 casterPool) in C:\src\dotnet\machinelearning\src\Microsoft.ML.OnnxTransformer\OnnxUtils.cs:line 302
   at Microsoft.ML.Transforms.Onnx.OnnxModel..ctor(String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu, Boolean ownModelFile, IDictionary`2 shapeDictionary, Int32 recursionLimit, Nullable`1 interOpNumThreads, Nullable`1 intraOpNumThreads) in C:\src\dotnet\machinelearning\src\Microsoft.ML.OnnxTransformer\OnnxUtils.cs:line 257
   at Microsoft.ML.Transforms.Onnx.OnnxTransformer..ctor(IHostEnvironment env, Options options, Byte[] modelBytes) in C:\src\dotnet\machinelearning\src\Microsoft.ML.OnnxTransformer\OnnxTransform.cs:line 260

Failing tests are: Microsoft.ML.Tests.OnnxTransformTests.TestOnnxModelNotDisposal Microsoft.ML.Tests.OnnxTransformTests.TestOnnxModelDisposal Microsoft.ML.Tests.OnnxTransformTests.TestOnnxZipMapWithStringKeys Microsoft.ML.Tests.OnnxTransformTests.TestOnnxZipMapWithInt64Keys

To Reproduce Steps to reproduce the behavior:

  1. Update MicrosoftMLOnnxRuntimeVersion to 1.16.1.
  2. build and run test on Microsoft.ML.OnnxTransformerTest

Expected behavior All tests pass

Screenshots, Code, Sample Projects 4 tests above fail

abagh0703 commented 4 months ago

I also experienced this. Maybe this issue is better suited for the Onnxruntime repo https://github.com/microsoft/onnxruntime