Added folders for tosa.add that handles bypassing add-zero,
fold additions of two splat tensors, and additions between
two tensors with small values.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
461 | I don't think we should have a hard coded constant here (per op fold hook feels also a bit weird too). The folding here should be pretty much always good/cheap - which all the others are except here. I know this is done in a few spots, but I also had couple of issues filed due to that. Given there is TosaFoldConstantTranspose, I'd rather have this there (with renaming) or something like that and then it can become a pass or pattern config option. WDYT? |
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
461 | I'd be OK if we did this locally with a big FIXME, as we'd really want an interpreter of this op guarded by cost model [still not ideal, but at least if we separate interpreting and folding it feels more like desired end state]. Interpretation here is valuable as a component. E.g., in TF shape inference we evaluate subgraphs required to determine the shape, but it's done lazily and it has different tradeoff than general folding. IREE's const -eval hoist pass also interesting here. Locally folding I feel is stopgap at best. It's fine if we treat it such tough, it is not too invasive but may just hide some other gaps. |
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
461 | Chatted offline - best to just remove until we have a better method for constant folding. The useful cases for constant folding can likely reduce to splats anyway. |
I don't think we should have a hard coded constant here (per op fold hook feels also a bit weird too). The folding here should be pretty much always good/cheap - which all the others are except here. I know this is done in a few spots, but I also had couple of issues filed due to that.
Given there is TosaFoldConstantTranspose, I'd rather have this there (with renaming) or something like that and then it can become a pass or pattern config option. WDYT?