Start LLVM integrate integrate-llvm-20231103 (#15403)
Co-authored-by: Kunwar Grover <groverkss@gmail.com>
Co-authored-by: Stella Laurenzo <stellaraccident@gmail.com>
diff --git a/compiler/src/iree/compiler/Codegen/Common/BUILD.bazel b/compiler/src/iree/compiler/Codegen/Common/BUILD.bazel
index d96edd9..601b98c 100644
--- a/compiler/src/iree/compiler/Codegen/Common/BUILD.bazel
+++ b/compiler/src/iree/compiler/Codegen/Common/BUILD.bazel
@@ -59,7 +59,7 @@
"@llvm-project//mlir:BufferizationOpsTdFiles",
"@llvm-project//mlir:MemRefOpsTdFiles",
"@llvm-project//mlir:OpBaseTdFiles",
- "@llvm-project//mlir:SubsetInsertionOpInterfaceTdFiles",
+ "@llvm-project//mlir:SubsetOpInterfaceTdFiles",
"@llvm-project//mlir:TensorOpsTdFiles",
],
)
diff --git a/compiler/src/iree/compiler/Codegen/Interfaces/BUILD.bazel b/compiler/src/iree/compiler/Codegen/Interfaces/BUILD.bazel
index 05803a9..25d0dc2 100644
--- a/compiler/src/iree/compiler/Codegen/Interfaces/BUILD.bazel
+++ b/compiler/src/iree/compiler/Codegen/Interfaces/BUILD.bazel
@@ -94,7 +94,7 @@
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:SCFTransforms",
- "@llvm-project//mlir:SubsetInsertionOpInterface",
+ "@llvm-project//mlir:SubsetOpInterface",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TensorTransforms",
diff --git a/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp b/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp
index 858a40f..e136ec7 100644
--- a/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp
+++ b/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp
@@ -25,7 +25,7 @@
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h"
#include "mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h"
-#include "mlir/Interfaces/SubsetInsertionOpInterface.h"
+#include "mlir/Interfaces/SubsetOpInterface.h"
#include "mlir/Support/LLVM.h"
using mlir::SubsetInsertionOpInterface;
@@ -502,25 +502,60 @@
}
};
-/// Returns true if the value of a `storeOp` bufferizes to an equivalent
-/// DispatchTensorLoadOp result that bufferizes inplace.
-static bool isValueEquivalentToAnInplaceTensorLoadOp(
- IREE::Flow::DispatchTensorStoreOp storeOp, Value candidate,
- function_ref<bool(Value, Value)> equivalenceFn) {
- auto loadOp = candidate.getDefiningOp<IREE::Flow::DispatchTensorLoadOp>();
- if (!loadOp)
+struct DispatchTensorLoadOpSubsetInterface
+ : public SubsetOpInterface::ExternalModel<
+ DispatchTensorLoadOpSubsetInterface,
+ IREE::Flow::DispatchTensorLoadOp> {
+ bool operatesOnEquivalentSubset(
+ Operation *op, SubsetOpInterface candidate,
+ function_ref<bool(Value, Value)> equivalenceFn) const {
+ // Returns true if the value of a `loadOp` bufferizes to an equivalent
+ // DispatchTensorStoreOp result that bufferizes inplace.
+ auto loadOp = cast<IREE::Flow::DispatchTensorLoadOp>(op);
+ auto storeOp = dyn_cast<IREE::Flow::DispatchTensorStoreOp>(op);
+ if (!storeOp)
+ return false;
+ return equivalenceFn(loadOp.getSource(), storeOp.getTarget());
+ }
+
+ bool operatesOnDisjointSubset(
+ Operation *op, SubsetOpInterface candidate,
+ function_ref<bool(Value, Value)> equivalenceFn) const {
+ // TODO: This is a new entry point and not clear it is correct.
return false;
- if (!equivalenceFn(loadOp.getSource(), storeOp.getTarget()))
- return false;
- // TODO: Assert that offsets, sizes and strides are the same.
- return true;
-}
+ }
+};
struct DispatchTensorStoreOpSubsetInterface
- : public SubsetInsertionOpInterface::ExternalModel<
+ : public SubsetOpInterface::ExternalModel<
DispatchTensorStoreOpSubsetInterface,
IREE::Flow::DispatchTensorStoreOp> {
+ bool operatesOnEquivalentSubset(
+ Operation *op, SubsetOpInterface candidate,
+ function_ref<bool(Value, Value)> equivalenceFn) const {
+ // Returns true if the value of a `storeOp` bufferizes to an equivalent
+ // DispatchTensorLoadOp result that bufferizes inplace.
+ auto storeOp = cast<IREE::Flow::DispatchTensorStoreOp>(op);
+ auto loadOp = dyn_cast<IREE::Flow::DispatchTensorLoadOp>(op);
+ if (!loadOp)
+ return false;
+ return equivalenceFn(loadOp.getSource(), storeOp.getTarget());
+ }
+
+ bool operatesOnDisjointSubset(
+ Operation *op, SubsetOpInterface candidate,
+ function_ref<bool(Value, Value)> equivalenceFn) const {
+ // TODO: This is a new entry point and not clear it is correct.
+ return false;
+ }
+};
+
+struct DispatchTensorStoreOpSubsetInsertionInterface
+ : public SubsetInsertionOpInterface::ExternalModel<
+ DispatchTensorStoreOpSubsetInsertionInterface,
+ IREE::Flow::DispatchTensorStoreOp> {
+
OpOperand &getSourceOperand(Operation *op) const {
return op->getOpOperand(0);
}
@@ -529,14 +564,6 @@
return op->getOpOperand(1);
}
- bool
- isEquivalentSubset(Operation *op, Value candidate,
- function_ref<bool(Value, Value)> equivalenceFn) const {
- auto storeOp = cast<IREE::Flow::DispatchTensorStoreOp>(op);
- return isValueEquivalentToAnInplaceTensorLoadOp(storeOp, candidate,
- equivalenceFn);
- }
-
Value buildSubsetExtraction(Operation *op, OpBuilder &builder,
Location loc) const {
auto storeOp = cast<IREE::Flow::DispatchTensorStoreOp>(op);
@@ -580,12 +607,19 @@
// Register IREE operations.
registry.addExtension(
+[](MLIRContext *ctx, IREE::Flow::FlowDialect *dialect) {
+ // DispatchTensorLoadOp
IREE::Flow::DispatchTensorLoadOp::attachInterface<
DispatchTensorLoadOpInterface>(*ctx);
+ IREE::Flow::DispatchTensorLoadOp::attachInterface<
+ DispatchTensorLoadOpSubsetInterface>(*ctx);
+
+ // DispatchTensorStoreOp
IREE::Flow::DispatchTensorStoreOp::attachInterface<
DispatchTensorStoreOpInterface>(*ctx);
IREE::Flow::DispatchTensorStoreOp::attachInterface<
DispatchTensorStoreOpSubsetInterface>(*ctx);
+ IREE::Flow::DispatchTensorStoreOp::attachInterface<
+ DispatchTensorStoreOpSubsetInsertionInterface>(*ctx);
});
registry.addExtension(+[](MLIRContext *ctx,
IREE::LinalgExt::IREELinalgExtDialect *dialect) {
diff --git a/compiler/src/iree/compiler/Codegen/Interfaces/CMakeLists.txt b/compiler/src/iree/compiler/Codegen/Interfaces/CMakeLists.txt
index 6d34889..c166bb4 100644
--- a/compiler/src/iree/compiler/Codegen/Interfaces/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Codegen/Interfaces/CMakeLists.txt
@@ -64,7 +64,7 @@
MLIRLinalgTransforms
MLIRMemRefDialect
MLIRSCFTransforms
- MLIRSubsetInsertionOpInterface
+ MLIRSubsetOpInterface
MLIRSupport
MLIRTensorDialect
MLIRTensorTransforms
diff --git a/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp b/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp
index e3560a2..dc43d21 100644
--- a/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp
+++ b/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp
@@ -663,8 +663,10 @@
funcH, mlir::vector::ContractionOp::getOperationName());
}
// TODO: Better builder.
- Value forOpH = b.create<transform::GetParentForOp>(
- transform::AnyOpType::get(b.getContext()), computeOpH);
+ Value forOpH = b.create<transform::GetParentOp>(
+ transform::AnyOpType::get(b.getContext()), computeOpH,
+ /*isolated_from_above=*/false, /*allow_empty_results=*/false,
+ /*op_name=*/b.getStringAttr("scf.for"), /*deduplicate=*/true);
// TODO: Better builder instead of setting post-hoc.
auto pipelineOp = b.create<
iree_compiler::IREE::transform_dialect::PipelineSharedMemoryCopiesOp>(
diff --git a/third_party/llvm-project b/third_party/llvm-project
index 28ac9cb..2556bee 160000
--- a/third_party/llvm-project
+++ b/third_party/llvm-project
@@ -1 +1 @@
-Subproject commit 28ac9cbae0eeb0eb026695148e9ba6460ae6c7d2
+Subproject commit 2556bee5cb108e85c24d50d141cb405106fc4e4d
diff --git a/third_party/torch-mlir b/third_party/torch-mlir
index 536e45c..6f81ad7 160000
--- a/third_party/torch-mlir
+++ b/third_party/torch-mlir
@@ -1 +1 @@
-Subproject commit 536e45cb3bc6951ae90de5c8e969d7fd03cfd955
+Subproject commit 6f81ad72938deb56c6d43bbc01388c1f8f1253c1