Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][Vector] Introduce 'vector.mask' operation and MaskableOpInterface
This patch introduces the `vector.mask` operation and the MaskableOpInterface as described in https://discourse.llvm.org/t/rfc-vector-masking-representation-in-mlir/64964. The `vector.mask` operation is used to predicate the execution of operations implementing the MaskableOpInterface. This interface will be implemented by maskable operations and provides information about its masking constraints and semantics. For now, only vector transfer and reduction ops implement the MaskableOpInterface for illustration and testing purposes. Reviewed By: nicolasvasilache, rriddle Differential Revision: https://reviews.llvm.org/D134939
- Loading branch information
Showing
15 changed files
with
497 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
add_subdirectory(IR) | ||
add_subdirectory(Interfaces) | ||
add_subdirectory(Transforms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_mlir_interface(MaskingInterfaces) |
22 changes: 22 additions & 0 deletions
22
mlir/include/mlir/Dialect/Vector/Interfaces/MaskingInterfaces.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===- MaskingInterfaces.h - Masking interfaces ---------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements the interfaces for masking operations. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES_H_ | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES_H_ | ||
|
||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
/// Include the generated interface declarations. | ||
#include "mlir/Dialect/Vector/Interfaces/MaskingInterfaces.h.inc" | ||
|
||
#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES_H_ |
52 changes: 52 additions & 0 deletions
52
mlir/include/mlir/Dialect/Vector/Interfaces/MaskingInterfaces.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===- MaskingInterfaces.td - Masking Interfaces Decls === -*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This is the definition file for vector masking related interfaces. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def MaskableOpInterface : OpInterface<"MaskableOpInterface"> { | ||
let description = [{ | ||
The 'MaskableOpInterface' define an operation that can be masked using the | ||
`vector.mask` operation and provides information about its masking | ||
constraints and semantics. | ||
}]; | ||
let cppNamespace = "::mlir::vector"; | ||
let methods = [ | ||
InterfaceMethod< | ||
/*desc=*/"Returns true if the operation may have a passthru argument when" | ||
" masked.", | ||
/*retTy=*/"bool", | ||
/*methodName=*/"supportsPassthru", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
return false; | ||
}]>, | ||
InterfaceMethod< | ||
/*desc=*/"Returns the mask type expected by this operation. It requires the" | ||
" operation to be vectorized.", | ||
/*retTy=*/"mlir::VectorType", | ||
/*methodName=*/"getExpectedMaskType", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
// Default implementation is only aimed for operations that implement the | ||
// `getVectorType()` method. | ||
return $_op.getVectorType().cloneWith( | ||
/*shape=*/llvm::None, IntegerType::get($_op.getContext(), /*width=*/1)); | ||
}]>, | ||
]; | ||
} | ||
|
||
#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
add_subdirectory(IR) | ||
add_subdirectory(Interfaces) | ||
add_subdirectory(Transforms) | ||
add_subdirectory(Utils) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.