Future Support for 'Acceleration','mex' When Running ONNX Networks - RF-DETR

24 ビュー (過去 30 日間)
Ilan
Ilan 2025 年 12 月 18 日 13:39
コメント済み: Ram Kokku 2025 年 12 月 18 日 15:37
I am working with an ONNX model imported into MATLAB using importNetworkFromONNX.
The model is a RF-DETR object detection network exported from Python.
I would like to use MEX acceleration for inference, but it currently does not seem to be supported for this workflow.
oNet = importNetworkFromONNX("rfdetr.onnx");
sizeImg = 384;
% Load an image
tImg = imread("img.png");
tImgSmall = imresize(tImg,[sizeImg sizeImg]);
mImg = single(tImgSmall);
dlImg = dlarray(mImg,"SSC");
mGPUImg = gpuArray(dlImg);
[dlBoxes, dlLabels] = oNet.predict(mGPUImg, 'Acceleration', 'mex');
I get this error message:
error using dlnetwork/predict (line 700)
Option 'Acceleration', 'mex' is not supported for this network. Use option 'Acceleration', 'auto' instead.
Caused by:
Error using nnet.internal.cnn.coder.MexNetworkConfig/mustBeSupportedNetwork
Layer hyper-parameters for custom layer 'ConstantOfShape_To_ReshapeLayer1102' must be numeric scalar, scalar logical, character or string array, or a matrix of type double or single.
in the future it will be possible that you will support this network?
thanks
  1 件のコメント
Ram Kokku
Ram Kokku 約1時間 前
Hi Ilan,
MEX acceleration uses code generation internally. It appears that the layer 'ConstantOfShape_To_ReshapeLayer1102' contains unsupported constructs. Use analyzeNetworkForCodegen(dlnet, TargetLibrary = 'cudnn') to find more details about this error and other blocking issues. While replacing these constructs with supported ones could be a workaround, it may not be straightforward. Since your goal is to improve model inference in MATLAB ( based on : https://www.mathworks.com/matlabcentral/answers/2181894-onnx-model-import-and-inference-performance-in-matlab-is-significantly-slower-than-python-cpu-gpu?s_tid=prof_contriblnk), I recommend waiting for a response to that thread before modifying the model.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by