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(ONNX): avoids resizing unsupported dimensions #3945

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

bjacobgordon
Copy link
Contributor

@bjacobgordon bjacobgordon commented Jan 7, 2025

Based on #3975

@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch 3 times, most recently from 6baa8d5 to ab7e021 Compare January 8, 2025 23:02
@bjacobgordon bjacobgordon changed the title fix(ONNX): protects against mismatched dynamic meta dimensions fix(ONNX): avoids resizing fixed dimensions Jan 9, 2025
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch from ab7e021 to 7aec80b Compare January 9, 2025 17:17
Copy link
Collaborator

@zjgarvey zjgarvey left a comment

Choose a reason for hiding this comment

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

I think the main structural question is about the need for adding the BaseTensorType method. If it were useful elsewhere (I have some doubts, since we would need to know too much about the two tensor shapes prior to using it- namely that they are present, and they have the same rank), I would consider keeping it; however, the code is simplified here by not using it, and I suspect that the same would be true in other circumstances where it might be used.

lib/Dialect/Torch/IR/TorchTypes.cpp Outdated Show resolved Hide resolved
include/torch-mlir/Dialect/Torch/IR/TorchTypes.h Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch from 7aec80b to a20ee29 Compare January 10, 2025 23:03
@bjacobgordon bjacobgordon changed the title fix(ONNX): avoids resizing fixed dimensions fix(ONNX): avoids non-scalable dimensions in onnx.resize Jan 13, 2025
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch from a20ee29 to 574f4fe Compare January 13, 2025 15:22
@bjacobgordon bjacobgordon marked this pull request as ready for review January 13, 2025 17:06
@bjacobgordon bjacobgordon requested a review from zjgarvey January 13, 2025 17:06
Copy link
Collaborator

@zjgarvey zjgarvey left a comment

Choose a reason for hiding this comment

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

Sorry for the misdirect earlier, we need to perform the runtime asserts on the scales or sizes values instead of sizes, since we will not have access to the correct output sizes ahead of time.

lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp Outdated Show resolved Hide resolved
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch from 574f4fe to cb371ea Compare January 14, 2025 15:04
@IanWood1
Copy link
Contributor

IanWood1 commented Jan 14, 2025

I think the renaming of loc -> opLocation should probably be split into a different PR so it can be reviewed separately, it adds ~600 lines of changes that aren't directly related to the functional changes. It would help to keep this PR focused and easier to review.

@bjacobgordon bjacobgordon marked this pull request as draft January 15, 2025 14:49
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch 3 times, most recently from 05ea165 to cb20894 Compare January 15, 2025 23:19
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch 4 times, most recently from 8a78147 to 54cf76e Compare January 17, 2025 21:50
@bjacobgordon
Copy link
Contributor Author

bjacobgordon commented Jan 17, 2025

Okay, @zjgarvey, I think we're in business! Got green on the CI a few hours ago. Just wrapped up self-review.

I'm guessing now we'll:

  • discuss how the diffs might need to change
  • finalize those changes
  • discuss which chunks of commits need to be in the PR stack
    Something like that?

I kept the commits atomic and ordered such that it's easier to propagate changes to the head of the branch in case an earlier commit needs to be inserted/tweaked/excised.

Let me know what you think!

@bjacobgordon bjacobgordon requested a review from zjgarvey January 17, 2025 21:59
@bjacobgordon bjacobgordon marked this pull request as ready for review January 17, 2025 21:59
@bjacobgordon bjacobgordon changed the title fix(ONNX): avoids non-scalable dimensions in onnx.resize fix(ONNX): avoids resizing unsupported dimensions Jan 17, 2025
@zjgarvey
Copy link
Collaborator

Okay, @zjgarvey, I think we're in business! Got green on the CI a few hours ago. Just wrapped up self-review.

I'm guessing now we'll:

* discuss how the diffs might need to change

* finalize those changes

* discuss which chunks of commits need to be in the PR stack
  Something like that?

I kept the commits atomic and ordered such that it's easier to propagate changes to the head of the branch in case an earlier commit needs to be inserted/tweaked/excised.

Let me know what you think!

Nice!

At least for now, please exclude any commits which involve style changes not directly related to the fix content. E.g. widespread enforcement of naming preferences like the loc -> opLocation should be factored out into a separate PR as @IanWood1 suggested.

@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch from 54cf76e to 052404a Compare January 20, 2025 14:51
- Before:
  - "get": implies retrieval of some private property
  - "Value": restatement of the return type `Value`
  - "List": assumed result of casting the returned instance
- After:
  - "create": contextualizes the need to pass in `rewriter`
  - "Scalar": contextualizes the opaque return type
  - "Sublist": the relationship between the first parameter and the returned result
- helper isn't concerned with the role of the tensor at the call site, only its shape
- easier to read
- allows for cleaner diffs if they ever change
@bjacobgordon bjacobgordon force-pushed the fix-onnx-adds-exceptions-enforcing-convention-in-resize-op branch from a3daf2a to 73fa3b2 Compare January 24, 2025 18:17
@bjacobgordon bjacobgordon marked this pull request as draft January 24, 2025 18:17
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.

3 participants