mirror of https://github.com/llvm/torch-mlir
22cd4441e7
The static uneven divisible AdaptiveAvgPool2d means that although the input size is not an integer multiple of ouput size, but the kernel and stride size can also be fixed (not dynamic). The derivation logic of kernel and stride size is consistent with torch/_decomp/decomposations.py:adaptive_avg_pool2d as described in the following: 1. Stride Size Firstly , derive the start index in each reduce operation according to the output size (`n`), `start_index = ([0, 1, ..., n - 1] * input_size) // output_size`. For each index `k`, if `k * (input_size % output_size) < output_size`, then the current and previous stride keeps the same as `input_size // output_size`. So suppose `(n-1) * (input_size % output_size) < output_size`, the stride in the whole AdaptiveAvgPool2d process keeps static, as `input_size // output_size`. 2. Kernel Size torch/_decomp/decomposations.py:adaptive_avg_pool2d calculates a static kernel size when the input/output sizes satisfy either of the two conditions, `input_size % output_size == 0` or `output_size % (input_size % output_size) == 0`. Here if `input_size % output_size == 0`, then the kernel size equals `input_size // output_size`, otherwise `input_size // output_size + 1.` |
||
---|---|---|
.. | ||
torch-mlir | ||
torch-mlir-c | ||
torch-mlir-dialects | ||
CMakeLists.txt |