It's not guaranteed that padding is symmetric. It's important to keep offset for algorithms need all paddings.
| 30 | // It's not guaranteed that padding is symmetric. It's important to keep |
| 31 | // offset for algorithms need all paddings. |
| 32 | inline int ComputePaddingWithOffset(int stride, int dilation_rate, int in_size, |
| 33 | int filter_size, int out_size, |
| 34 | int* offset) { |
| 35 | int effective_filter_size = (filter_size - 1) * dilation_rate + 1; |
| 36 | int total_padding = |
| 37 | ((out_size - 1) * stride + effective_filter_size - in_size); |
| 38 | total_padding = total_padding > 0 ? total_padding : 0; |
| 39 | *offset = total_padding % 2; |
| 40 | return total_padding / 2; |
| 41 | } |
| 42 | |
| 43 | // Matching GetWindowedOutputSize in TensorFlow. |
| 44 | inline int ComputeOutSize(TfLitePadding padding, int image_size, |
no outgoing calls
no test coverage detected