Skip to content

[MLIR][AArch64] Lower vector.contract to Neon FEAT_BF16 operations #148198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mlir/include/mlir/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,10 @@ def ConvertVectorToLLVMPass : Pass<"convert-vector-to-llvm"> {
"bool", /*default=*/"false",
"Enables the use of Arm FEAT_I8MM instructions while lowering "
"the vector dialect.">,
Option<"armBF16", "enable-arm-bf16",
"bool", /*default=*/"false",
"Enables the use of Arm FEAT_BF16 instructions while lowering "
"the vector dialect.">,
Option<"x86Vector", "enable-x86vector",
"bool", /*default=*/"false",
"Enables the use of X86Vector dialect while lowering the vector "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ def ApplyArmNeonContractionToI8MMPatternsOp
"apply_patterns.arm_neon.vector_contract_to_i8mm",
[DeclareOpInterfaceMethods<PatternDescriptorOpInterface>]> {
let description = [{
Indicates that vector.contract operations should be lowered to
finer-grained vector primitives from the ArmNeon dialect.
Indicates that vector contract operations should be lowered to
to ArmNeon dialect operations mapping to instructions from FEAT_I8MM.
}];

let assemblyFormat = "attr-dict";
}

def ApplyArmNeonContractionToBFMMLAPatternsOp
: Op<Transform_Dialect, "apply_patterns.arm_neon.vector_contract_to_bfmmla",
[DeclareOpInterfaceMethods<PatternDescriptorOpInterface>]> {
let description = [{
Indicates that vector contract operations should be lowered to
to ArmNeon dialect operations mapping to instructions from FEAT_BF16.
}];

let assemblyFormat = "attr-dict";
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/ArmNeon/Transforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace mlir {
class RewritePatternSet;

namespace arm_neon {
void populateLowerContractionToNeonI8MMPatternPatterns(
RewritePatternSet &patterns);
void populateLowerContractionToNeonI8MMPatterns(RewritePatternSet &patterns);
void populateLowerContractionToNeonBFMMLAPatterns(RewritePatternSet &patterns);
} // namespace arm_neon

} // namespace mlir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ void ConvertVectorToLLVMPass::runOnOperation() {
populateVectorGatherLoweringPatterns(patterns);
if (armI8MM) {
if (armNeon)
arm_neon::populateLowerContractionToNeonI8MMPatternPatterns(patterns);
arm_neon::populateLowerContractionToNeonI8MMPatterns(patterns);
if (armSVE)
populateLowerContractionToSVEI8MMPatternPatterns(patterns);
}
if (armBF16 && armNeon)
arm_neon::populateLowerContractionToNeonBFMMLAPatterns(patterns);
(void)applyPatternsGreedily(getOperation(), std::move(patterns));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ using namespace mlir;

void transform::ApplyArmNeonContractionToI8MMPatternsOp::populatePatterns(
RewritePatternSet &patterns) {
arm_neon::populateLowerContractionToNeonI8MMPatternPatterns(patterns);
arm_neon::populateLowerContractionToNeonI8MMPatterns(patterns);
}

void transform::ApplyArmNeonContractionToBFMMLAPatternsOp::populatePatterns(
RewritePatternSet &patterns) {
arm_neon::populateLowerContractionToNeonBFMMLAPatterns(patterns);
}

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/ArmNeon/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_mlir_dialect_library(MLIRArmNeonTransforms
LowerContractionToNeonI8MMPattern.cpp
LowerContractToNeonPatterns.cpp

DEPENDS
MLIRArmNeonIncGen
Expand Down
Loading
Loading