Replace uses of `_is_tracing` with `torch.onnx.is_in_onnx_export()`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
Through the codebase we have special implementations for ONNX guarded by torchvision._is_tracing(). We should see if it would be possible to replace it with torch.onnx.is_in_onnx_export() so that the meaning of those code-blocks is simpler, and so that we don't depend on internal PyTorch APIs.
I would start by checking if replacing https://github.com/pytorch/vision/blob/5b663c8eb691d540d064197a681a3a0fa924599c/torchvision/__init__.py#L92 with the aforementioned function passes ONNX tests, and then replace all remaining uses of it in the codebase.
cc @neginraoof
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the replacement at torchvision/init.py line 92 and run the ONNX tests to check whether the behavior remains correct. Then search the codebase for the remaining uses of torchvision._is_tracing and evaluate each ONNX-specific guard. Done means all applicable uses rely on torch.onnx.is_in_onnx_export() without breaking the ONNX tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100