This is an archive of the discontinued LLVM Phabricator instance.

Add a lowering of quantized_matmul to matmul.
AbandonedPublic

Authored by Benoit on Feb 22 2022, 2:18 PM.

Details

Reviewers
nicolasvasilache
Summary

This adds a pattern that lowers linalg.quantized_matmul to linalg.matmul.

quantized_matmul is useful as a higher-level op, as it matches higher-level dialects such as TOSA.
Most practical codegen paths will want to distribute out the zero-point
subtractions and thereby reduce quantized_matmul to matmul. This commit
adds a pass and pattern doing that literally, generating a linalg.matmul
named op. While that's not necessary (generic linalg transforms
could [be taught to] do the same), at this point a few different groups have found (*) that
they currently depend on matmuls being named matmul ops for various
reasons, so this pattern will be useful for the time being.

(*): Tracking issue:
https://github.com/google/iree/issues/8330

Two different sets of people having run into this:
https://github.com/google/iree/issues/8149
https://github.com/google/iree/pull/8281

Independently, I also need this for other matmul-to-mmt4d.

Diff Detail

Event Timeline

Benoit created this revision.Feb 22 2022, 2:18 PM
Benoit requested review of this revision.Feb 22 2022, 2:18 PM
Benoit retitled this revision from quantized-matmul-to-matmul to [WIP][DRAFT]quantized-matmul-to-matmul.Feb 22 2022, 2:20 PM
Benoit edited the summary of this revision. (Show Details)
ormris removed a subscriber: ormris.Feb 24 2022, 10:08 AM
Benoit updated this revision to Diff 411193.Feb 24 2022, 11:09 AM

Ready for review!

Benoit retitled this revision from [WIP][DRAFT]quantized-matmul-to-matmul to Add a lowering of quantized_matmul to matmul..Feb 24 2022, 11:12 AM
Benoit edited the summary of this revision. (Show Details)
Benoit added a reviewer: mravishankar.
Benoit updated this revision to Diff 411197.Feb 24 2022, 11:22 AM
Benoit edited the summary of this revision. (Show Details)

remove unneeded using namespace

Benoit edited the summary of this revision. (Show Details)Feb 24 2022, 11:23 AM
Benoit abandoned this revision.Feb 24 2022, 1:36 PM

Abandoning: per discussion with @mravishankar , quantized_matmul may be an oddity not worthy of a new MLIR core pattern. Going to take this to IREE for now. Feel free to reopen / take over this if there is interest in this on the MLIR core side.

For what it's worth: the new home of this is https://github.com/google/iree/pull/8409