[Mlir-commits] [mlir] 8e9808c - [mlir][linalg] Tune hasTensorSemantics/hasBufferSemantics methods.
Tobias Gysi
llvmlistbot at llvm.org
Wed Aug 25 12:45:31 PDT 2021
Author: Tobias Gysi
Date: 2021-08-25T19:28:37Z
New Revision: 8e9808ca3a2760f46655852b34d7c8ccc19edd8a
URL: https://github.com/llvm/llvm-project/commit/8e9808ca3a2760f46655852b34d7c8ccc19edd8a
DIFF: https://github.com/llvm/llvm-project/commit/8e9808ca3a2760f46655852b34d7c8ccc19edd8a.diff
LOG: [mlir][linalg] Tune hasTensorSemantics/hasBufferSemantics methods.
Optimize performance by iterating all operands at once.
Reviewed By: benvanik
Differential Revision: https://reviews.llvm.org/D108716
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index a276e7b32129..36146c341f68 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -691,13 +691,11 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
/*methodBody=*/"",
/*defaultImplementation=*/[{
return this->getOperation()->getNumResults() == 0 &&
- llvm::all_of(getInputOperands(), [&](OpOperand *opOperand) {
- return isScalar(opOperand) ||
- opOperand->get().getType().template isa<MemRefType>();
- }) &&
- llvm::all_of(getOutputOperands(), [](OpOperand *opOperand) {
- return opOperand->get().getType().template isa<MemRefType>();
- });
+ llvm::all_of(this->getOperation()->getOpOperands(),
+ [&](OpOperand &opOperand) {
+ return isScalar(&opOperand) ||
+ opOperand.get().getType().template isa<MemRefType>();
+ });
}]
>,
InterfaceMethod<
@@ -709,13 +707,10 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
- return
- llvm::all_of(getInputOperands(), [&](OpOperand *opOperand) {
- return isScalar(opOperand) ||
- opOperand->get().getType().template isa<RankedTensorType>();
- }) &&
- llvm::all_of(getOutputOperands(), [](OpOperand *opOperand) {
- return opOperand->get().getType().template isa<RankedTensorType>();
+ return llvm::all_of(this->getOperation()->getOpOperands(),
+ [&](OpOperand &opOperand) {
+ return isScalar(&opOperand) ||
+ opOperand.get().getType().template isa<RankedTensorType>();
});
}]
>,
More information about the Mlir-commits
mailing list