diff options
author | Frederik Harwath <frederik.harwath@amd.com> | 2024-04-16 14:09:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-16 14:09:25 +0200 |
commit | ac1f2de7b581c26a768c4d2a2aad36505cc63c31 (patch) | |
tree | 9dda9a8d1a31651c95ddb3b0305bbf2451dde90f | |
parent | 91dd844aa499d69c7ff75bf3156e2e3593a88057 (diff) |
[MLIR][docs] Mention declarePromisedInterface in Interfaces doc (#88689)
Co-authored-by: Frederik Harwath <fharwath@amd.com>
Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
-rw-r--r-- | mlir/docs/Interfaces.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md index 536e7613e509..51747db546bb 100644 --- a/mlir/docs/Interfaces.md +++ b/mlir/docs/Interfaces.md @@ -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 ®istry);` ; 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 |