Skip to content

Create ops with static shapes in PadTensorOpConversion if they're static - #5516

Merged
hanhanW merged 3 commits into
iree-org:mainfrom
hanhanW:pad-static
Apr 19, 2021
Merged

hanhanW merged 3 commits into
iree-org:mainfrom
hanhanW:pad-static

Conversation

@hanhanW

@hanhanW hanhanW commented Apr 19, 2021

Copy link
Copy Markdown
Contributor

Currently, the mhlo.pad will be lowered to linalg.pad_tensor and then
lowered to linalg.init_tensor + linalg.fill + subtensor_insert. The
init_tensor op will produce a dynamic shape even if the shape is static.
This leads a tensor.cast op added and relies on further patterns to
fix them. This is not needed to static shape and will hit some issues
related to #5385.

hanhanW added 2 commits April 19, 2021 08:21
Currently, the mhlo.pad will be lowered to linalg.pad_tensor and then
lowered to `linalg.init_tensor + linalg.fill + subtensor_insert`. The
init_tensor op will produce a dynamic shape even if the shape is static.
This leads a `tensor.cast` op added and relies on further patterns to
fix them. This is not needed to static shape and will hit some issues
related to iree-org#5385.
@hanhanW

hanhanW commented Apr 19, 2021

Copy link
Copy Markdown
Contributor Author

I think we do not need the cast ops anymore. If the types are static, they will still be static. If the types are dynamic, they should leave with dynamic types.

Verified with all the tests internally and externally. It doesn't break anything.

It is not easy to write tests for the change. You can look into d07189f and will find that they were added in the pass and got folded in canonicalization pass.

@hanhanW
hanhanW merged commit 131f2e2 into iree-org:main Apr 19, 2021
@hanhanW
hanhanW deleted the pad-static branch April 19, 2021 17:03
@hanhanW hanhanW mentioned this pull request Apr 19, 2021
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