[Mlir-commits] [mlir] [MLIR][docs] Mention declarePromisedInterface in Interfaces doc (PR #88689)
Frederik Harwath
llvmlistbot at llvm.org
Mon Apr 15 10:48:32 PDT 2024
https://github.com/frederik-h updated https://github.com/llvm/llvm-project/pull/88689
>From 6994d7c96b2e345e83e300d2259679ac690f3043 Mon Sep 17 00:00:00 2001
From: Frederik Harwath <fharwath at amd.com>
Date: Mon, 15 Apr 2024 09:19:33 +0200
Subject: [PATCH 1/3] [MLIR][docs] Mention declarePromisedInterface in
Interfaces doc
---
mlir/docs/Interfaces.md | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md
index 536e7613e50936..4fb6f8a88bfa8d 100644
--- a/mlir/docs/Interfaces.md
+++ b/mlir/docs/Interfaces.md
@@ -299,6 +299,19 @@ owner of the dialect containing the object nor the owner of the interface are
aware of an interface implementation, which can lead to duplicate or
diverging implementations.
+Forgetting to register an external model can lead to bugs which are hard
+to track down. The `declarePromisedInterface` function can be used
+to declare that an external model implementation for an operation
+must eventually be provided.
+```
+ void MyDialect::initialize() {
+ declarePromisedInterface<SomeInterface, SomeOp>();
+ ...
+ }
+```
+Now attempting to use the interface, e.g in a cast, without a prior
+registration of the external model will lead to a runtime error.
+
#### Dialect Fallback for OpInterface
Some dialects have an open ecosystem and don't register all of the possible
>From dad1abfa1507c6d8b8243535d88e0b76f581ee6b Mon Sep 17 00:00:00 2001
From: Frederik Harwath <fharwath at amd.com>
Date: Mon, 15 Apr 2024 14:29:41 +0200
Subject: [PATCH 2/3] [MLIR][docs] Add example of error message for declared
but unregistered interface
---
mlir/docs/Interfaces.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md
index 4fb6f8a88bfa8d..ec1ccc84685284 100644
--- a/mlir/docs/Interfaces.md
+++ b/mlir/docs/Interfaces.md
@@ -310,7 +310,11 @@ must eventually be provided.
}
```
Now attempting to use the interface, e.g in a cast, without a prior
-registration of the external model will lead to a runtime error.
+registration of the external model will lead to a runtime error that will
+look similar to this:
+```
+LLVM ERROR: checking for an interface (`SomeInterface`) that was promised by dialect 'mydialect' but never implemented. This is generally an indication that the dialect extension implementing the interface was never registered.
+```
#### Dialect Fallback for OpInterface
>From 96ffac3e3c82b354a3c3af175734944a8fb493d0 Mon Sep 17 00:00:00 2001
From: Frederik Harwath <fharwath at amd.com>
Date: Mon, 15 Apr 2024 19:48:06 +0200
Subject: [PATCH 3/3] Trigger CI
More information about the Mlir-commits
mailing list