Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Close onnx optimizer for ncnn #961

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions mmdeploy/apis/pytorch2onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import torch

from mmdeploy.apis.core.pipeline_manager import no_mp
from mmdeploy.utils import (get_backend, get_dynamic_axes, get_input_shape,
get_onnx_config, load_config)
from mmdeploy.utils import (Backend, get_backend, get_dynamic_axes,
get_input_shape, get_onnx_config, load_config)
from .core import PIPELINE_MANAGER
from .onnx import export

Expand Down Expand Up @@ -88,6 +88,11 @@ def torch2onnx(img: Any,
keep_initializers_as_inputs = onnx_cfg.get('keep_initializers_as_inputs',
True)
optimize = onnx_cfg.get('optimize', False)
if backend == Backend.NCNN.value:
"""NCNN backend needs a precise blob counts, while using onnx
optimizer will merge duplicate initilizers without reference count.
"""
optimize = False
with no_mp():
export(
torch_model,
Expand Down