Skip to content

[Codegen] inner_tiled op: finish CPU support including scalable tiles. - #24218

Merged
bjacob merged 1 commit into
iree-org:mainfrom
bjacob:inner-tiled-verification
Apr 28, 2026
Merged

bjacob merged 1 commit into
iree-org:mainfrom
bjacob:inner-tiled-verification

Conversation

@bjacob

@bjacob bjacob commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

This finishes generalizing the inner_tiled op to support CPU usage, including scalable dimensions.

AI: Claude Opus 4.7 in Cursor.

@bjacob
bjacob marked this pull request as ready for review April 22, 2026 19:41
@bjacob
bjacob marked this pull request as draft April 22, 2026 20:20
Comment on lines +325 to +332
StringRef kindNs = cast<Attribute>(getKind()).getDialect().getNamespace();
StringRef semNs = cast<Attribute>(getSemantics()).getDialect().getNamespace();
if (kindNs != semNs) {
return emitOpError(
llvm::formatv("kind attribute (dialect '{0}') and semantics attribute "
"(dialect '{1}') must use the same dialect namespace",
kindNs, semNs));
}

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.

I feel that we should update the doc because of the verification changes.

This operation can represent an intrinsic both in undistributed
(workgroup/subgroup/warp) and distributed (thread) level. This is indicated
by the `distributed` boolean attribute. The same `kind` attribute may be
used in both cases.
The inner-tile shapes of tensor operands (defined as above as the trailing
dimensions not present in the indexing maps) must agree with the shapes of
the vector tiles implied by the intrinsic specified in `kind`. The exact
criterion depends on the `opaque` boolean attribute:
* When `opaque = true`, the only requirement is that they have the same
number of elements.
* When `opaque = false`, the shapes must match exactly after omitting any
unit-dimensions.
Note that different `kind` attributes may adopt different conventions as to
the intrinsic vector tile formats. Some may use only flattened 1-D vectors,
and it may be necessary to use `opaque = true` to accommodate them. Others
may use higher-rank vectors with shapes reflecting semantics, allowing to
use `opaque = false`, which is preferable when possible at all thanks to the
stricter semantics. However, that is not only a function of the `kind`
attribute: using `opaque = false` also requires the tensor operands to have
appropriate shapes.
In some cases, variations on the inner tiled operations can be expressed
with the permutations attribute. This attribute represents the permutation
from that intrinsic's "canonical" layout (in the case of matrix multiplication,
this is row-major storage of the inner tile) to the format of the inner tile
in the arguments, with a permutation specified for each argument.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Completely rewritten and severely shrunk. The existing verbiage was vague, incomplete, imprecise, out of date.

Comment on lines +231 to +232
// - Otherwise, the shapes must match after dropping non-scalable unit extents
// from each side.

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.

I don't follow this part. Why do we drop unit extents?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is just documenting the exiting behavior.

Before #22369, the verifier only matched element counts (so in particular, unit dims didn't matter, but also the rest of the shape didn't matter besides element count).

#22369 introduced a mode (non-opaque) where we actually compare the shapes. but due to complications which I don't remember, I had to back away from trying to compare exact shapes with unit dims. So, the compromise was to drop unit dims, then compare.

@hanhanW

hanhanW commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Oh, it is draft now. I'll take another look when it is ready.

@bjacob

bjacob commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator Author

Oh, it is draft now. I'll take another look when it is ready.

Very sorry. What happened is that my OSSCI pod disappeared under my feet as I was trying to fix this issue (a minor git rebasing issue in itself).

@bjacob
bjacob force-pushed the inner-tiled-verification branch from d8687f0 to 74d7537 Compare April 22, 2026 21:10
@hanhanW

hanhanW commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Oh, it is draft now. I'll take another look when it is ready.

Very sorry. What happened is that my OSSCI pod disappeared under my feet as I was trying to fix this issue (a minor git rebasing issue in itself).

I saw the message, no worries. Take your time!

@bjacob
bjacob force-pushed the inner-tiled-verification branch from 74d7537 to 531f8b9 Compare April 24, 2026 16:50
@bjacob
bjacob marked this pull request as ready for review April 24, 2026 17:11
@bjacob

bjacob commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

I saw the message, no worries. Take your time!

@hanhanW , thanks for your patience and review comments already. This is ready for another round of review now.

@egebeysel

Copy link
Copy Markdown
Contributor

Thanks! I'll take a look on Monday as well 😄

@egebeysel egebeysel 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.

Thanks for the patch 😄 LGTM in general! The new documentation is also a bit clearer IMO :)

@bjacob
bjacob requested a review from hanhanW April 27, 2026 18:24

@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.

Thanks a lot for refreshing the doc! LGTM.

@bjacob
bjacob merged commit a064835 into iree-org:main Apr 28, 2026
43 of 45 checks passed
@bjacob bjacob mentioned this pull request Apr 30, 2026
25 of 28 tasks
jerryyin pushed a commit that referenced this pull request May 7, 2026
#24218)

This finishes generalizing the inner_tiled op to support CPU usage,
including scalable dimensions.

AI: Claude Opus 4.7 in Cursor.

Signed-off-by: Benoit Jacob <[email protected]>
RattataKing pushed a commit to RattataKing/iree that referenced this pull request May 27, 2026
iree-org#24218)

This finishes generalizing the inner_tiled op to support CPU usage,
including scalable dimensions.

AI: Claude Opus 4.7 in Cursor.

Signed-off-by: Benoit Jacob <[email protected]>
@devtbi devtbi mentioned this pull request Oct 5, 2026
9 tasks done
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