locnd182644 opened a new pull request, #18641:
URL: https://github.com/apache/tvm/pull/18641
### Summary
Fixed incorrect output shape of Pool op when ceil_mode = true
### Steps to Reproduce
Example: Create Pool Operator from PyTorch
```
class PoolModule(nn.Module):
def forward(self, x):
return torch.nn.AvgPool2d(2, 2, 1, True)(x)
```
```
class Module:
def main(x: R.Tensor((1, 3, 17, 17), dtype="float32")) ->
R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")):
with R.dataflow():
lv: R.Tensor((1, 3, 10, 10), dtype="float32") =
R.nn.avg_pool2d(x, pool_size=[2, 2], strides=[2, 2], dilation=[1, 1],
padding=[1, 1, 1, 1], ceil_mode=True, count_include_pad=True, layout="NCHW",
out_layout="NCHW")
gv: R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")) = (lv,)
R.output(gv)
return gv
```
### Expected
```
class Module:
def main(x: R.Tensor((1, 3, 17, 17), dtype="float32")) ->
R.Tuple(R.Tensor((1, 3, 9, 9), dtype="float32")):
with R.dataflow():
lv: R.Tensor((1, 3, 9, 9), dtype="float32") = R.nn.avg_pool2d(x,
pool_size=[2, 2], strides=[2, 2], dilation=[1, 1], padding=[1, 1, 1, 1],
ceil_mode=True, count_include_pad=True, layout="NCHW", out_layout="NCHW")
gv: R.Tuple(R.Tensor((1, 3, 9, 9), dtype="float32")) = (lv,)
R.output(gv)
return gv
```
### Resolve
- Citation:
https://docs.pytorch.org/docs/stable/generated/torch.nn.AvgPool2d.html
<img width="500" height="200" alt="PR1"
src="https://github.com/user-attachments/assets/52a27448-006f-409e-b8b4-65f49e908d5f"
/>
- Fixed: #18594
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]