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 the MaskingOpInterface
This MaskingOpInterface provides masking cababilitites to those operations that implement it. For only is only implemented by the `vector.mask` operation and it's used to break the dependency between the Vector dialect (where the `vector.mask` op lives) and operations implementing the MaskableOpInterface. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D136734
- Loading branch information
Showing
14 changed files
with
265 additions
and
88 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
add_mlir_interface(MaskingInterfaces) | ||
add_mlir_interface(MaskableOpInterface) | ||
add_mlir_interface(MaskingOpInterface) |
23 changes: 23 additions & 0 deletions
23
mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.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,23 @@ | ||
//===- MaskableOpInterface.h ----------------------------------------------===// | ||
// | ||
// 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 MaskableOpInterface. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_H_ | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_H_ | ||
|
||
#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h" | ||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
// Include the generated interface declarations. | ||
#include "mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h.inc" | ||
|
||
#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_H_ |
72 changes: 72 additions & 0 deletions
72
mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.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,72 @@ | ||
//===- MaskableOpInterfaces.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 the MaskableOpInterface. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_TD | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def MaskableOpInterface : OpInterface<"MaskableOpInterface"> { | ||
let description = [{ | ||
The 'MaskableOpInterface' defines an operation that can be masked using a | ||
MaskingOpInterface (e.g., `vector.mask`) and provides information about its | ||
masking constraints and semantics. | ||
}]; | ||
let cppNamespace = "::mlir::vector"; | ||
let methods = [ | ||
InterfaceMethod< | ||
/*desc=*/"Returns true if the operation is masked by a " | ||
"MaskingOpInterface.", | ||
/*retTy=*/"bool", | ||
/*methodName=*/"isMasked", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
return mlir::isa<mlir::vector::MaskingOpInterface>($_op->getParentOp()); | ||
}]>, | ||
InterfaceMethod< | ||
/*desc=*/"Returns the MaskingOpInterface masking this operation.", | ||
/*retTy=*/"mlir::vector::MaskingOpInterface", | ||
/*methodName=*/"getMaskingOp", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
return mlir::cast<mlir::vector::MaskingOpInterface>( | ||
$_op->getParentOp()); | ||
}]>, | ||
InterfaceMethod< | ||
/*desc=*/"Returns true if the operation can 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_MASKABLEOPINTERFACE_TD |
52 changes: 0 additions & 52 deletions
52
mlir/include/mlir/Dialect/Vector/Interfaces/MaskingInterfaces.td
This file was deleted.
Oops, something went wrong.
14 changes: 7 additions & 7 deletions
14
...ect/Vector/Interfaces/MaskingInterfaces.h → ...ct/Vector/Interfaces/MaskingOpInterface.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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
//===- MaskingInterfaces.h - Masking interfaces ---------------------------===// | ||
//===- MaskingOpInterface.h -----------------------------------------------===// | ||
// | ||
// 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. | ||
// This file implements the MaskingOpInterface. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES_H_ | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES_H_ | ||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_H_ | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_H_ | ||
|
||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
/// Include the generated interface declarations. | ||
#include "mlir/Dialect/Vector/Interfaces/MaskingInterfaces.h.inc" | ||
// Include the generated interface declarations. | ||
#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h.inc" | ||
|
||
#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKINGINTERFACES_H_ | ||
#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_H_ |
58 changes: 58 additions & 0 deletions
58
mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.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,58 @@ | ||
//===- MaskingOpInterfaces.td - MaskingOpInterface 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 the MaskingOpInterface. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_TD | ||
#define MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def MaskingOpInterface : OpInterface<"MaskingOpInterface"> { | ||
let description = [{ | ||
The 'MaskingOpInterface' defines an vector operation that can apply masking | ||
to its own or other vector operations. | ||
}]; | ||
let cppNamespace = "::mlir::vector"; | ||
let methods = [ | ||
InterfaceMethod< | ||
/*desc=*/"Returns the mask value of this masking operation.", | ||
/*retTy=*/"mlir::Value", | ||
/*methodName=*/"getMask", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/"">, | ||
InterfaceMethod< | ||
/*desc=*/"Returns the operation masked by this masking operation.", | ||
// TODO: Return a MaskableOpInterface when interface infra can handle | ||
// dependences between interfaces. | ||
/*retTy=*/"Operation *", | ||
/*methodName=*/"getMaskableOp", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/"">, | ||
InterfaceMethod< | ||
/*desc=*/"Returns true if the masking operation has a passthru value.", | ||
/*retTy=*/"bool", | ||
/*methodName=*/"hasPassthru", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/"">, | ||
InterfaceMethod< | ||
/*desc=*/"Returns the passthru value of this masking operation.", | ||
/*retTy=*/"mlir::Value", | ||
/*methodName=*/"getPassthru", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/"">, | ||
]; | ||
} | ||
|
||
#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_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
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
12 changes: 7 additions & 5 deletions
12
...t/Vector/Interfaces/MaskingInterfaces.cpp → ...Vector/Interfaces/MaskableOpInterface.cpp
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,16 +1,18 @@ | ||
//===- MaskingInterfaces.cpp - Masking interfaces ----------====-*- C++ -*-===// | ||
//===- MaskableOpInterfaces.cpp - MaskableOpInterface Defs -====-*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/Vector/Interfaces/MaskingInterfaces.h" | ||
#include "mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h" | ||
|
||
using namespace mlir; | ||
using namespace mlir::vector; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Masking Interfaces | ||
// MaskableOpInterface Defs | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// Include the definitions of the masking interfaces. | ||
#include "mlir/Dialect/Vector/Interfaces/MaskingInterfaces.cpp.inc" | ||
#include "mlir/Dialect/Vector/Interfaces/MaskableOpInterface.cpp.inc" |
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,18 @@ | ||
//===- MaskingOpInterface.cpp - MaskingOpInterface Defs -----====-*- C++-*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h" | ||
|
||
using namespace mlir; | ||
using namespace mlir::vector; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// MaskingOpInterface Defs | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.cpp.inc" |
Oops, something went wrong.