Skip to content

Commit ac1f2de

Browse files
[MLIR][docs] Mention declarePromisedInterface in Interfaces doc (#88689)
Co-authored-by: Frederik Harwath <[email protected]> Co-authored-by: Mehdi Amini <[email protected]>
1 parent 91dd844 commit ac1f2de

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

mlir/docs/Interfaces.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,30 @@ owner of the dialect containing the object nor the owner of the interface are
299299
aware of an interface implementation, which can lead to duplicate or
300300
diverging implementations.
301301
302+
Forgetting to register an external model can lead to bugs which are hard to
303+
track down. The `declarePromisedInterface` function can be used to declare that
304+
an external model implementation for an operation must eventually be provided.
305+
306+
```
307+
void MyDialect::initialize() {
308+
declarePromisedInterface<SomeInterface, SomeOp>();
309+
...
310+
}
311+
```
312+
313+
Now attempting to use the interface, e.g in a cast, without a prior registration
314+
of the external model will lead to a runtime error that will look similar to
315+
this:
316+
317+
```
318+
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.
319+
```
320+
321+
If you encounter this error for a dialect and an interface provided by MLIR, you
322+
may look for a method that will be named like
323+
`register<Dialect><Interface>ExternalModels(DialectRegistry &registry);` ; try
324+
to find it with `git grep 'register.*SomeInterface.*Model' mlir`.
325+
302326
#### Dialect Fallback for OpInterface
303327
304328
Some dialects have an open ecosystem and don't register all of the possible

0 commit comments

Comments
 (0)