Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def check(self, context, x: ir.Value, pad: ir.Value, conv: ir.Value) -> orp.Matc
if np.any(self._pads_list[:2] + self._pads_list[x_rank : x_rank + 2]):
self._pads_list = None
return check_result.fail(f"{pads.name} must be zero in non-spatial dimensions.")
if any(p < 0 for p in self._pads_list):
self._pads_list = None
return check_result.fail(f"{pads.name} must not contain negative values.")

return check_result

Expand Down
8 changes: 8 additions & 0 deletions onnxscript/rewriter/rules/common/_fuse_pad_into_conv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ def test_fuse_pad_into_conv(self, pad_pads, const_value, axes, conv_pads, conv_a
"VALID",
"auto_pad must be 'NOTSET'.",
),
(
"constant",
ir.tensor([0, 0, -1, -1, -1, 0, 0, 0, 0, 0], name="pads"),
None,
None,
"NOTSET",
"must not contain negative values",
),
]
)
def test_unsupported_fuse_pad_into_conv(
Expand Down