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.
We implemented folds for various operators and would like to contribute them successively. Those folds are for:
- tosa.add
- tosa.cast
- tosa.clamp
- tosa.mul
- tosa.pow
- tosa.rsqrt
clang-format not found in user’s local PATH; not linting file.