there are several dialects in my project
I’d like to define global trait among different dialects.
MLIR defines lots of traits Traits - MLIR
is there method to create such trait which can be used in any dialect/op?
there are several dialects in my project
I’d like to define global trait among different dialects.
MLIR defines lots of traits Traits - MLIR
is there method to create such trait which can be used in any dialect/op?
A Trait is just a C++ class, you can copy any of the traits defined in MLIR in your own project as a model.
To use them in ODS, take example on AffineScope for example (or all the others around there).
yes, trait can be reused everywhere
how about interface?
take a convolution as an example, let’s say there are FooDialect and BarDialect has convolution op
if the number of dialects increases, have to do similar things again and again
that’s why I ask if there is solution which define a global interface and implement once
Interfaces don’t need to be associated with a dialect. There’s some examples here: llvm-project/mlir/include/mlir/Interfaces at main · llvm/llvm-project · GitHub
In general it is the transforms / the analysis that drives the development / design of an interface: you create an interface for the need of the pass and the dialects implement it.