[mlir][tosa] Improve performance of tosa.transpose constant folding
authorSpenser Bauman <sbauman@mathworks.com>
Fri, 24 Mar 2023 19:42:12 +0000 (19:42 +0000)
committerRobert Suderman <suderman@google.com>
Fri, 24 Mar 2023 19:50:13 +0000 (19:50 +0000)
commit110c1b64a7b9984a604aa2809e0fb8c01278609d
tree4441733ccfe84374b1472796c546f92fe00a45c8
parent1fce1d341b17762bb45bdc89520b00820fd63337
[mlir][tosa] Improve performance of tosa.transpose constant folding

Folding of the tosa.transpose operation is both time and memory
intensive as the underlying ElementsAttr is processed as a sequence of
Attributes. This change attempts operate on the underlying raw data of
the ElementsAttr.

In an example resnet50 network, this change reduces the time spent in
folding transpose ops from 35s to 1.5s.

Reviewed By: GeorgeARM, rsuderman, stellaraccident

Differential Revision: https://reviews.llvm.org/D146526
mlir/lib/Dialect/Tosa/Transforms/TosaFoldConstantTranspose.cpp
mlir/test/Dialect/Tosa/constant-op-fold.mlir