Pytorch torch.nn.functional.avg_pool stride defalut None cause error in _infer_type

The default value of stride in nn.functional.avg_pool is set as None,

It will cause TVMError: Check failed: ObjectTypeChecker<TObjectRef>: :Check(ptr): Expect relay.Expr but get Array since inputs[2] is empty. We have to define stride explicitly in torch avg_pool function or deal with the default None type of stride in tvm frontend pytorch.

Thanks, optional arguments should be handeled something like this

Can you send a PR to fix this?

I am not sure if I should post it here, sorry if it is the wrong place.

torch.nn.functional.max_pool2d suffers from the same problem. At least, when I execute relay.frontend.from_pytorch with a simple model containing only: x = torch.nn.functional.max_pool2d(x, 2) I get the following error:

TVMError: Error(s) have occurred. The program has been annotated with them:

In main: #[version = “0.0.5”] fn (%input0: Tensor[(1, 1, 28, 28), float32]) { nn.max_pool2d(%input0, pool_size=[2, 2], strides=[], padding=[0, 0, 0, 0]) an internal invariant was violated while typechecking your program [15:36:17] /home/david/tvm/include/tvm/runtime/container.h:681: Check failed: 0 <= i && i < p->size_: IndexError: indexing 0 on an array of size 0 ; }

It is solved by giving a specific value (different from None) to the “stride” optional argument of the torch.nn.functional.max_pool2d function: x = torch.nn.functional.max_pool2d(x, 2, stride=2)

It seems to be already solved for the avg_pool function. I found the following error fix conversation in GitHub:

I think the same fix is needed for the max_pool2d function.

Thanks, should be fixed by