This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Define `spirv.*Dot` integer dot product ops
ClosedPublic

Authored by kuhar on Dec 2 2022, 7:03 PM.

Details

Summary

This covers SDot, SUDot, and UDot. The *AccSat version will be
added in a follow-up revision.

Diff Detail

Event Timeline

kuhar created this revision.Dec 2 2022, 7:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2022, 7:03 PM
kuhar requested review of this revision.Dec 2 2022, 7:03 PM
kuhar added inline comments.Dec 2 2022, 7:06 PM
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
580

FYI, this got reordered when I ran the script to generate new instructions. I can undo this if it makes this revision confusing.

antiagainst requested changes to this revision.Dec 3 2022, 9:39 AM

Awesome! Thanks for working this through!

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
580

SG, thanks for the explanation!

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVIntegerDotProductOps.td
47

Missing optional packed_vector_format?

57

Missing optional packed_vector_format?

mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp
57 ↗(On Diff #479793)

While we are here can we add everything that gotten promoted to v1.6 so we won't need to come to this place again? List here https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_changes_from_version_1_5

Some of the extensions might not be defined yet in SPIRVBase.td; feel free to add them. (Also might be good to extract changes to this place to a separate prior patch.)

mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
4807

.. for both operands. (Calling them as vector operands is a bit confusing here given operands can be of integer type too..)

4822

Missing validation rules for "When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors."?

mlir/test/Dialect/SPIRV/IR/target-env.mlir
128

These tests are not implied capabilities? They are suitable extensions and capabilities. Can we also add tests for

  • Full list of necessary of capabilities, but missing extensions
  • Full list of necessary of extensions, but missing some capabilities
  • Using v1.6 to imply extensions
This revision now requires changes to proceed.Dec 3 2022, 9:39 AM
kuhar updated this revision to Diff 480554.Dec 6 2022, 11:20 AM
kuhar marked 5 inline comments as done.

Address comments and rebase

kuhar added inline comments.Dec 6 2022, 11:23 AM
mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp
57 ↗(On Diff #479793)

Done

mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
49

FYI, I only sorted these lexicographically and added one more name

4807

There can be 2 or 3 operands, so 'both operands' is not precise.
This is how the spec calls them. Initially, I had them as 'factors', but decided to follow the spec language instead, which calls the first two 'vectors' and the last one 'accumulator'. WDYT about changing this to 'factors' or keeping as 'vectors'?

kuhar updated this revision to Diff 480556.Dec 6 2022, 11:25 AM

Update examples

kuhar updated this revision to Diff 480559.Dec 6 2022, 11:27 AM

Fix a typo

antiagainst accepted this revision.Dec 6 2022, 2:43 PM
antiagainst added inline comments.
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
4807

ah okay. fine to keep as-is to be consistent with the spec then.

mlir/test/Dialect/SPIRV/IR/integer-dot-product-ops.mlir
14

I think we can improve the assembly to print something like spirv.SDot <PackedVectorFormat4x8Bit> %a %b to make this nicer by let assemblyFormat = "$format $vector1 , $vector2 : type(operands) -> type(results) or something. Fine to me to land this revision; but please feel free to play with it a bit.

This revision is now accepted and ready to land.Dec 6 2022, 2:43 PM
kuhar added inline comments.Dec 6 2022, 5:16 PM
mlir/test/Dialect/SPIRV/IR/integer-dot-product-ops.mlir
14

Ack. I'll commit this as-is so that we don't keep the size of this patch under control.

This revision was landed with ongoing or failed builds.Dec 6 2022, 5:21 PM
This revision was automatically updated to reflect the committed changes.