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

Suppress ONNX export trace warning #5437

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

deepsworld
Copy link
Contributor

@deepsworld deepsworld commented Nov 1, 2021

Checking for onnx_dynamic first should suppress the warning:

TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved condition check ordering in YOLO model inference logic.

📊 Key Changes

  • Swapped the order of condition checks during the inference pathway when determining if the grid needs to be recalculated.

🎯 Purpose & Impact

  • Purpose: To optimize the condition check for consistency and potentially improve the execution speed by prioritizing the onnx_dynamic check.
  • Impact: This may lead to minor performance improvements during model inference, especially beneficial for ONNX runtime environments. It helps streamline the model's forward pass by efficiently determining when to recalculate the anchor grids. Users may experience more responsive inference with specific deployment scenarios, though overall impact might be minimal for most users.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hello @deepsworld, thank you for submitting a 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with upstream/master. If your PR is behind upstream/master an automatic GitHub actions rebase may be attempted by including the /rebase command in a comment body, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
git checkout feature  # <----- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
  • ✅ Verify all Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." -Bruce Lee

@deepsworld deepsworld changed the title Update yolo.py Suppress onnx export trace warning. Nov 1, 2021
@glenn-jocher
Copy link
Member

/rebase

Checking for `onnx_dynamic` first should suppress the warning:

```log
TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic
```
@glenn-jocher glenn-jocher changed the title Suppress onnx export trace warning. Suppress ONNX export trace warning Nov 5, 2021
@glenn-jocher glenn-jocher merged commit 3364379 into ultralytics:master Nov 5, 2021
@glenn-jocher
Copy link
Member

@deepsworld PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
Checking for `onnx_dynamic` first should suppress the warning:

```log
TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants