Is there method to differentiate attribute? (original) (raw)
November 21, 2025, 9:36am 1
take linalg.reduce op as an example,
linalg.reduce {test_attribute = “Test Attribute” } dimension = [3]
there are two attributes for above op.
i’m curious if there is method which can differentiate its two attributes.
Operation* op;
for (auto attr : op.getAttrs()) {
// all attr will be here
}
I'd like to get op specific attribute (dimension)
auto reduceOp = cast<linalg::ReduceOp>(op);
reduceOp.getDimension...
However, i wonder if it is possible not to cast op.
Operation* op;
for (auto attr : op.magicMethodToGetOpSpecificAttrs()) {
// only dimension is here
}
thank you for your help.
In general a generic access to operation properties is very likely to call for an operation interface to expose it.