importONNXFunction can't import 'Conv' Operator which is not supported with its current settings or in this context?
14 次查看(过去 30 天)
显示 更早的评论
When I tried to use the built-in function importONNXFunction to import my ONNX model into the MATLAB environment, I encountered a 'Conv' operator not supported error. The warning was:
Warning: Unable to import some ONNX operators or attributes. They may have been replaced by 'PLACEHOLDER' functions in the imported model function.
60 operator(s) : Operator 'Conv' is not supported with its current settings or in this context.
This 'Conv' operator should be supported, as it has been specified in the documentation as a supported operator. my ONNX model link here. The code used in MATLAB is:
modelfile = "xfeat.onnx";
params = importONNXFunction(modelfile,"xfeatFcn")
img1 = imresize(imread("viprectification_deskLeft.png"),2);
img2 = imresize(imread("viprectification_deskRight.png"),2);
%% model inference
[mkpts1,mkpts2] = xfeatFcn(img1,img2,params);
Warning: Attribute(s) [training_mode] in layer 'x_fine_matcher_fine_matcher_1_BatchNorma' with operator type 'BatchNormalization' are unknown. It is possible that the imported model will not output the same
predictions as the source model.
In
In
In
In
In
In
In
In
Warning: Attribute(s) [training_mode] in layer 'x_fine_matcher_fine_matcher_4_BatchNorma' with operator type 'BatchNormalization' are unknown. It is possible that the imported model will not output the same
predictions as the source model.
In
In
In
In
In
In
In
In
Warning: Attribute(s) [training_mode] in layer 'x_fine_matcher_fine_matcher_7_BatchNorma' with operator type 'BatchNormalization' are unknown. It is possible that the imported model will not output the same
predictions as the source model.
In
In
In
In
In
In
In
In
Warning: Attribute(s) [training_mode] in layer 'x_fine_matcher_fine_matcher_10_BatchNorm' with operator type 'BatchNormalization' are unknown. It is possible that the imported model will not output the same
predictions as the source model.
In
In
In
In
In
In
In
In
Function containing the imported ONNX network architecture was saved to the file xfeatFcn.m.
To learn how to use this function, type: help xfeatFcn.
Warning: Unable to import some ONNX operators or attributes. They may have been replaced by 'PLACEHOLDER' functions in the imported model function.
60 operator(s) : Operator 'Conv' is not supported with its current settings or in this context.
Unrecognized function or variable 'PLACEHOLDER'.
[Vars.x_net_block1_block1_0_layer_layer_0_1__1, NumDims.x_net_block1_block1_0_layer_layer_0_1__1] = PLACEHOLDER(Vars.x_net_norm_1_InstanceNormalization_outpu, Vars.onnx__Conv_1586, Vars.onnx__Conv_1587, NumDims.x_net_norm_1_InstanceNormalization_outpu, NumDims.onnx__Conv_1586, NumDims.onnx__Conv_1587, Vars.Convdilations1085, Vars.Convgroup1086, Vars.Convkernel_shape1087, Vars.Convpads1088, Vars.Convstrides1089, NumDims.Convdilations1085, NumDims.Convgroup1086, NumDims.Convkernel_shape1087, NumDims.Convpads1088, NumDims.Convstrides1089);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
[matched_points1, matched_points2, matched_points1NumDims, matched_points2NumDims, state] = main_graphGraph1000(input1, input2, NumDims.input1, NumDims.input2, Vars, NumDims, Training, params.State);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
[mkpts1,mkpts2] = xfeatFcn(img1,img2,params);
------------------------------------------------------
my env:
- '25.1.0.2897550 (R2025a) Prerelease Update 5'
- "Deep Learning Toolbox Converter for ONNX Model Format" "25.1.0" true "ONNXCONVERTER"
2 个评论
Megh Singh
2025-4-14
@cui,xingxing I tried loading the ONNX model in Python ONNXRuntime and sent 2 dummy inputs of size:
1 x 3 x 400 x 300 (N x C x H x W) since the model does not specify the expected height and width of its inputs, and these are the sizes of "viprectification_deskLeft.png" and "viprectification_deskRight.png". Following is my python scirpt:
import onnxruntime as ort
import numpy as np
model_path = 'xfeat.onnx'
session = ort.InferenceSession(model_path)
input1_name = session.get_inputs()[0].name
input2_name = session.get_inputs()[1].name
# Create a dummy input tensor with the same shape as the model's input
# Replace this with your actual input data
dummy_input1 = np.random.rand(1,3,400,300).astype(np.float32)
dummy_input2 = np.random.rand(1,3,400,300).astype(np.float32)
# Run inference
outputs = session.run(None, {input1_name: dummy_input1, input2_name: dummy_input2})
Unfortunately, I run into the following error in ONNX Runtime, upon running the above script:
---------------------------------------------------------------------------Fail Traceback (most recent call last) Cell In[7], line 14 11 dummy_input2 = np.random.rand(1,3,400,300).astype(np.float32) 13 # Run inference---> 14 outputs = session.run(None, {input1_name: dummy_input1, input2_name: dummy_input2}) 16 # Print the output 17 print("Model output:", outputs[0]) File ~\AppData\Roaming\Python\Python311\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py:220, in Session.run(self, output_names, input_feed, run_options) 218 output_names = [output.name for output in self._outputs_meta] 219 try: --> 220 return self._sess.run(output_names, input_feed, run_options) 221 except C.EPFail as err: 222 if self._enable_fallback: Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running TopK node. Name:'/TopK_3' Status Message: k argument [6400] should not be greater than specified axis dim value [3072]
Please let me know the correct input sizes that work for this model, in ONNX Runtime?
Since you already reached out to us through MathWorks Technical Support, please directly reply to them with the requested information.
采纳的回答
更多回答(1 个)
Matt J
2025-4-12
编辑:Matt J
2025-4-12
This 'Conv' operator should be supported, as it has been specified in the documentation as a supported operator.
I haven't looked at your ONNX model, but the appearance of Conv in the table is not reason enough to think it will be supported in all possible configurations. As the documentation you linked to says,
"importONNXFunction supports the following ONNX operators for conversion into built-in MATLAB layers or custom layers, with some limitations."
As for what specific limitations you might have encountered, CHAT-GPT suggests the following possibilities:


另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!