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

[Feature] Workarounds for ONNX Export Force CPU #2543

Closed
ozen opened this issue Nov 11, 2023 · 3 comments
Closed

[Feature] Workarounds for ONNX Export Force CPU #2543

ozen opened this issue Nov 11, 2023 · 3 comments

Comments

@ozen
Copy link

ozen commented Nov 11, 2023

Motivation

In the onnx export pipeline, the device argument is disregarded, and the export operation is performed on the CPU.

# force to export on cpu
patched_model = patched_model.cpu()
if isinstance(args, torch.Tensor):
args = args.cpu()
elif isinstance(args, (tuple, list)):
args = tuple([_.cpu() for _ in args])
else:
raise RuntimeError(f'Not supported args: {args}')

I can see this was introduce by #2347

In the PR discussion @grimoire raised the issue with the ops without cpu support, and @RunningLeon suggested adding dummy ops as workaround.

I stumbled upon this when trying to export FasterRCNN with GARPNHead, which utilize MaskedConv2d layer that doesn't have CPU support.

So my questions are:

  1. How does adding dummy ops not break the model?
  2. If adding dummy ops is possible, how can I do it?
  3. Why is forcing cpu export required to support panoptic segmentation model?

Thanks.

Related resources

No response

Additional context

No response

@RunningLeon
Copy link
Collaborator

@ozen hi

  1. mmdeploy does not have op masked_conv from mmcv for any backend, you have to implement it by yourself.
  2. you can simply return a dummy results in the beginning of the forward function: https://github.com/open-mmlab/mmcv/blob/b366e923e46321f8e4eb26e79b622029e0eb2683/mmcv/ops/masked_conv.py#L38C21-L38C21

Copy link

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.

@github-actions github-actions bot added the Stale label Nov 20, 2023
Copy link

This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants