Hi everyone,
I am implementing a verifier for the tosa pool operations (tosa.max_pool2d or tosa.avg_pool2d). I was implementing this check ERROR_IF(OW != idiv_check(IW + pad_left + pad_right - kernel_x, stride_x) + 1);
from the spec in Maxpool Spec, and realized idiv_check
triggers an error for some pool operations that have been legalized from Onnx or Torch. Then, I realized the current implementation of idiv_check
demands IW + pad_left + pad_right - kernel_x
to be a multiple of stride_x
. The question is how tosa handles the situations in which the upper dialect has a maxpool operation that the summation of input size, kernel, pad sizes are not divisible by the stride. The onnx and torch dialects use floor or ceil operation for these cases.
int32_t idiv_check(int32_t input1, int32_t input2) {
ERROR_IF(input1 % input2 != 0); // input1 must be a multiple of input2
return input1 / input2; // exact quotient without rounding
}
Onnx:
%1 = "onnx.MaxPoolSingleOut"(%0) {ceil_mode = 0 : si64, kernel_shape = [3, 3], pads = [1, 1, 1, 1], strides = [2, 2]} : (tensor<1x64x112x112xf32>) -> tensor<1x64x56x56xf32>
Tosa:
%1= "tosa.max_pool2d"(%0) {kernel = [3, 3], pad = [1, 1, 1, 1], stride = [2, 2]} : (tensor<1x112x112x64xf32>) -> tensor<1x56x56x64xf32>
Then:
idiv_check(112 + 1 + 1 - 3, 2) = idiv_check(111, 2) ---------> Error
Should the idiv_check be a floor/ceil operation instead?
Thanks,
Ehsan