Skip to content

Simplifications around narrow dimensions in encodings. - #18607

Merged
bjacob merged 1 commit into
iree-org:mainfrom
bjacob:drop-kNarrowThreshold
Sep 28, 2024
Merged

bjacob merged 1 commit into
iree-org:mainfrom
bjacob:drop-kNarrowThreshold

Conversation

@bjacob

@bjacob bjacob commented Sep 26, 2024 •

Copy link
Copy Markdown
Collaborator
  • Drop the kNarrowThreshold constant, relying instead on the default padding value.
    • When reading an encoding attribute to tell if a round_dims_to entry should be considered narrow, rely on the fact that we only ever need one narrowest dimension in a given matmul to be considered narrow, so the smallest round_dims_to entry is the narrow one; if all round_dims_to entries are equal, the matmul is not narrow.
  • Introduce a MatmulNarrowDim struct to unify helpers and group them in EncodingOps.{h,cpp}.
    • This enforces in the type system that at most one of the M or N dimensions may be narrow, not both. Previously, we had different structs/tuples, none of which enforced that, so we felt compiled to write comments about the unenforced contract, and the concerned code was scattered across different files.
  • Remove the getMatmulNarrow{M,N} getters on EncodingAttr.
    • Generally we are over-relying on TableGen class methods, which only obfuscates things compared to functions declared manually in C++ files, and the new MatmulNarrowDim struct allows replacing both these methods by a single getMatmulNarrowDim, which also simplifies callers.

@bjacob
bjacob force-pushed the drop-kNarrowThreshold branch from 4e9d414 to f193bee Compare September 27, 2024 02:33
@bjacob bjacob changed the title Drop the kNarrowThreshold constant. Simplifications around narrow dimensions in encodings. Sep 27, 2024
@bjacob bjacob added the benchmarks:x86_64 Run default x86_64 benchmarks label Sep 27, 2024
@bjacob
bjacob force-pushed the drop-kNarrowThreshold branch from f193bee to 1b80195 Compare September 27, 2024 13:38
Signed-off-by: Benoit Jacob <[email protected]>

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

Nice cleanup!

@bjacob
bjacob merged commit 9e09115 into iree-org:main Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmarks:x86_64 Run default x86_64 benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants