Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AvgPool with non symmetrical padding is not implemented #172

Open
jamesWalker55 opened this issue Aug 18, 2023 · 1 comment
Open

AvgPool with non symmetrical padding is not implemented #172

jamesWalker55 opened this issue Aug 18, 2023 · 1 comment
Labels
feat new feature for the user

Comments

@jamesWalker55
Copy link

I'm trying to convert a model from onnx to pytorch, however I'm get the following error:

     43 padding, padding_module = onnx_auto_pad_to_torch_padding(
     44     onnx_padding=node_attributes.get('pads', [0] * spatial_rank * 2),
     45     auto_pad=node_attributes.get('auto_pad', 'NOTSET'),
     46 )
     47 if padding_module is not None:
---> 48     raise NotImplementedError('AvgPool with non symmetrical padding is not implemented.')
     50 torch_module = avgpool_class(
     51     kernel_size=kernel_shape,
     52     stride=strides,
   (...)
     55     ceil_mode=ceil_mode == 1,
     56 )
     58 return OperationConverterResult(
     59     torch_module=torch_module,
     60     onnx_mapping=onnx_mapping_from_node(node=node),
     61 )

NotImplementedError: AvgPool with non symmetrical padding is not implemented.
@senysenyseny16 senysenyseny16 added the feat new feature for the user label Aug 21, 2023
@github-actions github-actions bot added the Stale label Sep 21, 2023
@github-actions github-actions bot added the Stale label Oct 22, 2023
@ENOT-AutoDL ENOT-AutoDL deleted a comment from github-actions bot Oct 23, 2023
@ENOT-AutoDL ENOT-AutoDL deleted a comment from github-actions bot Oct 23, 2023
@palant
Copy link

palant commented Jan 20, 2024

I’m not sure whether this change is correct but it appears to work:

     padding, padding_module = onnx_auto_pad_to_torch_padding(
         onnx_padding=node_attributes.get('pads', [0] * spatial_rank * 2),
         auto_pad=node_attributes.get('auto_pad', 'NOTSET'),
     )   
-    if padding_module is not None:
-        raise NotImplementedError('AvgPool with non symmetrical padding is not implemented.')
 
     torch_module = avgpool_class(
         kernel_size=kernel_shape,
         stride=strides,
         padding=padding,
         count_include_pad=count_include_pad == 1,
         ceil_mode=ceil_mode == 1,
     )   
 +   
 +   if padding_module is not None:
 +       torch_module = nn.Sequential(padding_module, torch_module)
 
     return OperationConverterResult(
         torch_module=torch_module,
         onnx_mapping=onnx_mapping_from_node(node=node),
     )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature for the user
Projects
None yet
Development

No branches or pull requests

3 participants