[all-commits] [llvm/llvm-project] d84d41: [mlir][tosa] Constant folding for reciprocal

Tina Jung via All-commits all-commits at lists.llvm.org
Wed Jul 5 02:39:17 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d84d418e2adc421c98e484ab3b09e2f4f3e5c1ef
  Author: Tina Jung <tina.maria.jung at xilinx.com>
  Date:   2023-07-05 (Wed, 05 Jul 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/Tosa/Transforms/Passes.h
    M mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt
    R mlir/lib/Dialect/Tosa/Transforms/TosaFoldConstantTranspose.cpp
    A mlir/lib/Dialect/Tosa/Transforms/TosaFolders.cpp
    M mlir/lib/Dialect/Tosa/Transforms/TosaLayerwiseConstantFoldPass.cpp
    A mlir/test/Dialect/Tosa/constant-reciprocal-fold.mlir

  Log Message:
  [mlir][tosa] Constant folding for reciprocal

Add constant fold for tosa.reciprocal, which can be applied if the input is a dense constant tensor. The reciprocal is computed for every element and the result is a tensor with the same dimensions as the input tensor.

As the input tensor might require a lot of memory and the folding might double the required memory, a heuristic decides when to actually apply the folding. Currently, the operation will be replaced only if the input constant is a splat (i.e. requires little memory) or has in single user (similar to the already existing fold for constant transposes). This keeps the additionally required space low.

Differential Revision: https://reviews.llvm.org/D150578

More information about the All-commits mailing list