This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Added folders for tosa.add
ClosedPublic

Authored by rsuderman on Aug 19 2022, 6:09 PM.

Details

Summary

Added folders for tosa.add that handles bypassing add-zero,
fold additions of two splat tensors, and additions between
two tensors with small values.

Diff Detail

Event Timeline

rsuderman created this revision.Aug 19 2022, 6:09 PM
Herald added a project: Restricted Project. · View Herald Transcript
rsuderman requested review of this revision.Aug 19 2022, 6:09 PM
rsuderman updated this revision to Diff 454147.Aug 19 2022, 6:10 PM

Added missing newline at the end of the file

rsuderman added a reviewer: jpienaar.
jpienaar added inline comments.Aug 19 2022, 9:12 PM
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?

jpienaar added inline comments.Aug 20 2022, 10:36 AM
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.

rsuderman updated this revision to Diff 454613.Aug 22 2022, 2:34 PM

Removed non-splat constant folder.

rsuderman marked 2 inline comments as done.Aug 22 2022, 2:36 PM
rsuderman added inline comments.
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.

rsuderman marked an inline comment as done.Aug 22 2022, 2:37 PM
rriddle retitled this revision from BEGIN_PUBLIC [mlir][tosa] Added folders for tosa.add to [mlir][tosa] Added folders for tosa.add.Aug 22 2022, 2:37 PM
rsuderman edited the summary of this revision. (Show Details)Aug 22 2022, 6:16 PM
jpienaar accepted this revision.Aug 24 2022, 12:26 PM
This revision is now accepted and ready to land.Aug 24 2022, 12:26 PM
This revision was automatically updated to reflect the committed changes.