[Mlir-commits] [mlir] [mlir] Enhance dimOp fold (PR #187286)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Mar 27 15:47:55 PDT 2026


MaheshRavishankar wrote:

> Seems like that does not apply to all the patterns though, only some specific cases as far as I can tell. A lot of the constant foldings don't fall into this, do they?

I dont think you can really say which pattern it applies to and which it doesnt. In general its upto the implementation of the interface to specify which dimensions of the output depend on dimensions of the input. To summarize basically this does not handle case where dim resolution result in a "DAG" of operations, and always materializes a "Tree" of operations. so every time you reach the same node through different paths, it will materialize the node redundantly, and that can exponentially increase the compilation time. 

Looking at the other change you sent out, I think maybe the best solution here is that the `dim` resolution should just be a stand-alone pass that just tracks all dim operations created and whenever the same tensor dimension is needed just reuses an already created operation instead of rematerializing it. 

https://github.com/llvm/llvm-project/pull/187286


More information about the Mlir-commits mailing list