You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to convert Mask R-CNN model into RyzenAI model and run on Ryzen NPU.
When I convert torchvision Mask R-CNN model into ONNX, it contains IF operator.
RyzenAI doesn't support IF operator with NPU inference, so I tried to remove it, but I couldn't found the solution to fix.
Issue
Could anyone please check and answer?
Is this behavior expected?
To convert Mask R-CNN into ONNX model without using IF operator, what should I do?
However, commented out this code doesn't work, using _batched_nms_vanilla() instead of _batched_nms_coordinate_trick() also doesn't work, too.
Versions
(ryzen-ai) PS C:\work\mask_vision> python .\collect_env.py
Collecting environment information...
PyTorch version: 2.3.1+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Microsoft Windows 11 Enterprise Evaluation (10.0.2263164 bit)
GCC version: Could not collect
Clang version: Could not collect
CMake version: version 3.31.2
Libc version: N/A
Python version: 3.10.16| packaged by conda-forge | (main, Dec 52024,14:07:43) [MSCv.194264bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.22631-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Name: AMD Ryzen 7 8845HS
[DetailinformationisREDACTEDbecauseofNDA]
Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] onnx==1.16.1
[pip3] onnxruntime==1.17.0
[pip3] onnxruntime_extensions==0.13.0
[pip3] onnxruntime-vitisai==1.19.0
[pip3] onnxscript==0.1.0.dev20250123
[pip3] onnxsim==0.4.36
[pip3] torch==2.3.1+cpu
[pip3] torch-geometric==2.6.1
[pip3] torchvision==0.18.1+cpu
[pip3] vai-q-onnx==1.19.0
[conda] mkl 2021.4.0 pypi_0 pypi
[conda] numpy 1.26.4 pypi_0 pypi
[conda] torch 2.3.1+cpu pypi_0 pypi
[conda] torch-geometric 2.6.1 pypi_0 pypi
[conda] torchvision 0.18.1+cpu pypi_0 pypi
(ryzen-ai) PS C:\work\mask_vision>
NOTE: It is difficult to update into newest version because of compatibility. It seems that batched_nms is not changed, so anyone may be able to reproduce it in newest version.
The text was updated successfully, but these errors were encountered:
🐛 Describe the bug
Background
I'd like to convert Mask R-CNN model into RyzenAI model and run on Ryzen NPU.
When I convert torchvision Mask R-CNN model into ONNX, it contains
IF
operator.RyzenAI doesn't support
IF
operator with NPU inference, so I tried to remove it, but I couldn't found the solution to fix.Issue
Could anyone please check and answer?
IF
operator, what should I do?Sample code
Results
mask_rcnn_torchvision.onnx
containsIF
operator. While this operator is inrpn
block, the name is not/rpn/foobar
butonnx::If_xxxx
.sub_graph1 (ELSE subgraph):
sub_graph (THEN subgraph):
Expected behavior
mask_rcnn_torchvision.onnx
doesn't containIF
operator.My investigation
I traced inside torchvision Mask R-CNN structure and found that it may be caused by
torch.ops.batched_nms()
vision/torchvision/ops/boxes.py
Lines 44 to 113 in 0d68c7d
I think
IF
operator is generated by this code:vision/torchvision/ops/boxes.py
Lines 89 to 90 in 0d68c7d
However, commented out this code doesn't work, using
_batched_nms_vanilla()
instead of_batched_nms_coordinate_trick()
also doesn't work, too.Versions
NOTE: It is difficult to update into newest version because of compatibility. It seems that
batched_nms
is not changed, so anyone may be able to reproduce it in newest version.The text was updated successfully, but these errors were encountered: