Skip to content

[MLIR][docs] Mention declarePromisedInterface in Interfaces doc #88689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions mlir/docs/Interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,30 @@ 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 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.
```

If you encounter this error for a dialect and an interface provided by MLIR, you
may look for a method that will be named like
`register<Dialect><Interface>ExternalModels(DialectRegistry &registry);` ; try
to find it with `git grep 'register.*SomeInterface.*Model' mlir`.

#### Dialect Fallback for OpInterface

Some dialects have an open ecosystem and don't register all of the possible
Expand Down