[mlir][linalg] Fix FoldConstantTranspose execution inefficiency
authorLei Zhang <antiagainst@google.com>
Thu, 28 Oct 2021 13:45:07 +0000 (09:45 -0400)
committerLei Zhang <antiagainst@google.com>
Thu, 28 Oct 2021 13:45:14 +0000 (09:45 -0400)
commitc788cad83b6b5c24f8160f9fc11a69dd7beafb8b
tree9d5d915a33c3a24550dae4607b5239fcfffedcc7
parentd29ccbecd093c881c599fd41db5d68dae744f91f
[mlir][linalg] Fix FoldConstantTranspose execution inefficiency

* Move SmallVectors outside of inner loops to avoid frequent
  allocations and deallocations
* Calculate linearized index and call flat range getters to
  avoid internal shape querying behind `getValue`.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D112099
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp