Unity-Technologies / barracuda-release

Other
561 stars 76 forks source link

Model import failure when moving from 1.2.1 -> 1.3.0: NotImplementedException #142

Closed Eric-Lee closed 3 years ago

Eric-Lee commented 3 years ago

Hello,

When upgrading from Barracuda 1.2.1-preview to Barracuda 1.3.0-preview, an ONNX model that previously imported successfully is now throwing the following error during import:

Asset import failed, "Assets/MLModels/testnet.onnx" > NotImplementedException: InferOutputShapeNCHW: Unhandled layer: name:output__axis1, inputs:[312], axis:1, 
Unity.Barracuda.Compiler.IRShapeInferenceHelper.ShapeInference.InferOutputShapeNCHW (Unity.Barracuda.Layer layer, System.Int32[] inputRanks, Unity.Barracuda.TensorShape[] inputShapes) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/Core/Compiler/ShapeInference/IRShapeInferenceHelper.cs:707)
Unity.Barracuda.Compiler.IRShapeInferenceHelper.ShapeInference.UpdateKnownTensorShapesNCHW (Unity.Barracuda.Model model, System.Collections.Generic.IDictionary`2[TKey,TValue] ranksByName, System.Collections.Generic.IDictionary`2[System.String,System.Nullable`1[Unity.Barracuda.TensorShape]]& shapesByName) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/Core/Compiler/ShapeInference/IRShapeInferenceHelper.cs:736)
Unity.Barracuda.Compiler.Passes.IRShapeInferenceAndConstantFusing.FuseShapesIntoConstants (Unity.Barracuda.Model& model, System.Collections.Generic.IDictionary`2[TKey,TValue] shapesByName, System.Collections.Generic.IDictionary`2[TKey,TValue] ranksByName) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/Core/Compiler/Passes/IRShapeInferenceAndConstantFusing.cs:66)
Unity.Barracuda.Compiler.Passes.IRShapeInferenceAndConstantFusing.Run (Unity.Barracuda.Model& model) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/Core/Compiler/Passes/IRShapeInferenceAndConstantFusing.cs:23)
Unity.Barracuda.Compiler.Passes.IntermediateToRunnableNHWCPass.Run (Unity.Barracuda.Model& model) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/Core/Compiler/Passes/IntermediateToRunnableNHWCPass.cs:12)
Unity.Barracuda.ONNX.ONNXModelConverter.Convert (Google.Protobuf.CodedInputStream inputStream) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:119)
Unity.Barracuda.ONNX.ONNXModelConverter.Convert (System.String filePath) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:83)
Unity.Barracuda.ONNXModelImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Editor/ONNXModelImporter.cs:58)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at <bd45cfd5e8c2437da9b5cc29b19f336f>:0)
UnityEditor.Experimental.AssetImporters.AssetImporterEditor:ApplyRevertGUI()
Unity.Barracuda.Editor.ONNXModelImporterEditor:OnInspectorGUI() (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Editor/ONNXModelImporterEditor.cs:67)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

UnityEditor.Experimental.AssetImporters.AssetImporterEditor:ApplyRevertGUI()
Unity.Barracuda.Editor.ONNXModelImporterEditor:OnInspectorGUI() (at Library/PackageCache/com.unity.barracuda@1.3.0-preview/Barracuda/Editor/ONNXModelImporterEditor.cs:67)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

The layer in question is an ArgMax layer. Upon import in 1.2.1-preview, the layer has name: output__axis7 and axis: 7

Here is the model: testnet.onnx

Any help is appreciated!

AlexRibard commented 3 years ago

Indeed, looks like this op got lost during the bump to 1.3.0. Thanks for spotting that :) Fixing it, will probably make it for 1.3.1

Aurimasp commented 3 years ago

Hello Eric-Lee. I have verified this fix in Barracuda 1.3.1 and will close the case.