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

[ONNX] Support 'aten::randint' in torchscript onnx exporter #105089

Closed
wants to merge 2 commits into from

Conversation

BowenBao
Copy link
Collaborator

@BowenBao BowenBao commented Jul 12, 2023

Stack from ghstack (oldest at bottom):

Export as 'ONNX::RandomUniform' which produces floating point result,
then round it to integer with 'ONNX::Cast'.

Fixes https://github.com/microsoft/onnx-converters-private/issues/173

Export as 'ONNX::RandomUniform' which produces floating point result,
then round it to integer with 'ONNX::Cast'.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 12, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/105089

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit ffd7663:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: onnx torch.onnx related changes that should show up in the release notes label Jul 12, 2023
BowenBao added a commit that referenced this pull request Jul 12, 2023
Export as 'ONNX::RandomUniform' which produces floating point result,
then round it to integer with 'ONNX::Cast'.

ghstack-source-id: 5a869eece6cd036e851b7c108ee9b5efbabee1c1
Pull Request resolved: #105089
…t onnx exporter"

Export as 'ONNX::RandomUniform' which produces floating point result,
then round it to integer with 'ONNX::Cast'.

[ghstack-poisoned]
BowenBao added a commit that referenced this pull request Jul 12, 2023
Export as 'ONNX::RandomUniform' which produces floating point result,
then round it to integer with 'ONNX::Cast'.

ghstack-source-id: 07e0782d825f1fa0235ac108f063a46f391c5c31
Pull Request resolved: #105089
@BowenBao BowenBao added topic: improvements topic category ciflow/trunk Trigger trunk jobs on your pull request labels Jul 12, 2023
Copy link
Collaborator

@thiagocrepaldi thiagocrepaldi left a comment

Choose a reason for hiding this comment

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

LGTM. I am assuming we don't care testing torch.jit.script scenarios at this point. scalar_type handling usually crash for script as opposed to tracing

@BowenBao
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Comment on lines +5167 to +5169
randint = g.op("Cast", randn, to_i=int_dtype.onnx_type())
if int_dtype != scalar_type:
randint = g.op("Cast", randint, to_i=scalar_type.onnx_type())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trying to understand: why do we need to cast twice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

first time to "floor" floating random number to integer.
second time the dtype is part of op argument, could be floating number.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, thanks!

@facebook-github-bot facebook-github-bot deleted the gh/BowenBao/262/head branch July 16, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: improvements topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants