Skip to content

Conversation

@mfrancio
Copy link
Contributor

@mfrancio mfrancio commented Sep 11, 2024

The inliner interface does not implement any restrictions for inlining.

@llvmbot llvmbot added the mlir label Sep 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2024

@llvm/pr-subscribers-mlir

Author: Matteo Franciolini (mfrancio)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/108297.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Mesh/IR/MeshOps.cpp (+22)
diff --git a/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp b/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
index c35020b4c20ccc..20dd271636a937 100644
--- a/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
+++ b/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
@@ -24,6 +24,7 @@
 #include "mlir/IR/Value.h"
 #include "mlir/Interfaces/ViewLikeInterface.h"
 #include "mlir/Support/LLVM.h"
+#include "mlir/Transforms/InliningUtils.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
@@ -74,6 +75,26 @@ static DimensionSize operator*(DimensionSize lhs, DimensionSize rhs) {
   return lhs.value() * rhs.value();
 }
 
+//===----------------------------------------------------------------------===//
+// Inliner 
+//===----------------------------------------------------------------------===//
+
+namespace {
+struct MeshInlinerInterface : public DialectInlinerInterface {
+  using DialectInlinerInterface::DialectInlinerInterface;
+  // Currently no restrictions are encoded for inlining.
+  bool isLegalToInline(Operation *, Operation *, bool) const final {
+    return true;
+  }
+  bool isLegalToInline(Region *, Region *, bool, IRMapping &) const final {
+    return true;
+  }
+  bool isLegalToInline(Operation *, Region *, bool, IRMapping &) const final {
+    return true;
+  }
+};
+} // namespace
+
 //===----------------------------------------------------------------------===//
 // Mesh dialect
 //===----------------------------------------------------------------------===//
@@ -91,6 +112,7 @@ void MeshDialect::initialize() {
 #define GET_TYPEDEF_LIST
 #include "mlir/Dialect/Mesh/IR/MeshTypes.cpp.inc"
       >();
+  addInterface<MeshInlinerInterface>();
 }
 
 Operation *MeshDialect::materializeConstant(OpBuilder &builder, Attribute value,

@mfrancio mfrancio changed the title [mlir][mesh] Introduce DialectInlinerInterface for the Mesh dialect [mlir][mesh] Introduce DialectInlinerInterface for Mesh dialect Sep 11, 2024
@github-actions
Copy link

github-actions bot commented Sep 11, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@mfrancio mfrancio force-pushed the user/mfranciolini/meshInlinerInterface branch from df76ef9 to 99bc7c1 Compare September 11, 2024 21:45
@joker-eph
Copy link
Collaborator

Can you provide a test please?

The inliner interface does not implement any restrictions for inlining.
@mfrancio mfrancio force-pushed the user/mfranciolini/meshInlinerInterface branch from 99bc7c1 to e812edc Compare September 13, 2024 18:35
@mfrancio
Copy link
Contributor Author

Can you provide a test please?

Sure! added.

@mfrancio mfrancio merged commit ca49739 into llvm:main Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants