I compiled it successfully.
but when i use %4 = math.atan %3: f64, the error with
LLVM ERROR: can't create Attribute 'mlir::arith::FastMathFlagsAttr' because storage uniquer isn't initialized: the dialect was likely not loaded, or the attribute wasn't added with addAttributes<...>() in the Dialect::initialize() method.
Aborted (core dumped)
What does your main function look like? Maybe the Math dialect is not loaded correctly? I get a different error when I don’t load the Math dialect but when I do, it gets parsed without problem.
It appears that the arith dialect is not loaded, and that math should be declaring a dependency on it because it uses attributes from it. Try loading arith when you create the context.
Nope. Pattern rewriter configuration doesn’t load dialects, and neither does registration, see FAQ - MLIR. That being said, it should be loaded when math is loaded by the parser, but math is missing a dependency declaration. That’s what my patch fixes.
Thanks.
But how can I fix this problem in my custom project. Because when I look math.td in latest main repo, but I do not find your patch in main repo. So if I want to fix this porblem, should I add
let dependentDialects = [
"::mlir::arith::ArithDialect"
];
this contect to my local mlir/include/mlir/Dialect/Math/IR/MathBase.td and rebuild llvm project ?
You can apply the patch directly to your copy of the source tree or as git cherry-pick after it lands (I’d recommend creating a branch so you see what changes you added compared to the mainline project).