Skip to content

[NFC][Encoding] Move materializeEncodingValueFn to type converter - #20720

Merged
hanhanW merged 1 commit into
mainfrom
users/jtuyls/refactor-materialize-encoding-value-fn
May 5, 2025
Merged

hanhanW merged 1 commit into
mainfrom
users/jtuyls/refactor-materialize-encoding-value-fn

Conversation

@jtuyls

@jtuyls jtuyls commented May 5, 2025

Copy link
Copy Markdown
Contributor

This PR performs some refactoring as part of collapsing MaterializeEncodingIntoPadding into MaterializeEncoding (#20160) and moves the materializeEncodingValueFn parameter from OpMaterializeEncodingPattern to the MaterializeEncodingTypeConverter, together with the getInnerTileSizesOfr implementation, for following reasons:

  • The typeConverter and materializeEncodingValueFn objects are typically passed around together, so now only typeConverter needs to be passed around and this simplifies the code.
  • As part of Collapse MaterializeEncodingIntoPadding into the generic pass #20160, I am creating a getOffsetsSizesStrides method in the MaterializeEncodingTypeConverter and SerializableEncodingAttrInterface and all encoding specific logic should be moved there. I would specifically like to avoid the need for passing a MaterializeEncodingValueFn to getOffsetsSizesStrides. This PR moves us in that direction.

@jtuyls
jtuyls requested a review from hanhanW as a code owner May 5, 2025 14:38

@hanhanW hanhanW left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change makes sense to me. Just one optional nit when I reviewed the refactoring code. I made a corresponding change for IREE in #20731

Comment on lines +147 to +148
if (llvm::all_of(staticTileSizes,
[](int64_t i) { return !ShapedType::isDynamic(i); })) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can avoid the lambda if we use ShapedType::isDynamicShape(staticTileSizes). It also looks cleaner to me.

I understand that it is refactoring the code. I'd appreciate it if you update the old code during the refactoring. We can either fix it in my PR (#20731) or in your PR.

(My PR exclude this case to avoid conflict. I can make the change after you land this. Either works for me. I'll let you make the call.)

@hanhanW

hanhanW commented May 5, 2025 •

Copy link
Copy Markdown
Contributor

Actually, let's go ahead and merge the PR because my comment is very trivial. Any post comments from other reviewers can be addressed in a follow-up (, if someone chimes in). This is a reasonable change to me. Merging the PR now.

@hanhanW
hanhanW merged commit 55d86cd into main May 5, 2025
@hanhanW
hanhanW deleted the users/jtuyls/refactor-materialize-encoding-value-fn branch May 5, 2025 22:53
KyleHerndon pushed a commit to KyleHerndon/iree that referenced this pull request May 7, 2025
…ee-org#20720)

This PR performs some refactoring as part of collapsing
MaterializeEncodingIntoPadding into MaterializeEncoding
(iree-org#20160) and moves the
`materializeEncodingValueFn` parameter from OpMaterializeEncodingPattern
to the MaterializeEncodingTypeConverter, together with the
`getInnerTileSizesOfr` implementation, for following reasons:
- The `typeConverter` and `materializeEncodingValueFn` objects are
typically passed around together, so now only `typeConverter` needs to
be passed around and this simplifies the code.
- As part of iree-org#20160, I am
creating a `getOffsetsSizesStrides` method in the
MaterializeEncodingTypeConverter and SerializableEncodingAttrInterface
and all encoding specific logic should be moved there. I would
specifically like to avoid the need for passing a
`MaterializeEncodingValueFn` to `getOffsetsSizesStrides`. This PR moves
us in that direction.

Signed-off-by: Jorn Tuyls <[email protected]>
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
…0720)

This PR performs some refactoring as part of collapsing
MaterializeEncodingIntoPadding into MaterializeEncoding
(#20160) and moves the
`materializeEncodingValueFn` parameter from OpMaterializeEncodingPattern
to the MaterializeEncodingTypeConverter, together with the
`getInnerTileSizesOfr` implementation, for following reasons:
- The `typeConverter` and `materializeEncodingValueFn` objects are
typically passed around together, so now only `typeConverter` needs to
be passed around and this simplifies the code.
- As part of #20160, I am
creating a `getOffsetsSizesStrides` method in the
MaterializeEncodingTypeConverter and SerializableEncodingAttrInterface
and all encoding specific logic should be moved there. I would
specifically like to avoid the need for passing a
`MaterializeEncodingValueFn` to `getOffsetsSizesStrides`. This PR moves
us in that direction.

Signed-off-by: Jorn Tuyls <[email protected]>
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.

2 participants