From 5ba0ae8bba9981573bcfb3e033221db43ea2d3e2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:39:18 +0000 Subject: [PATCH 1/2] Initial plan From a4c955e9e34fd2ee67a0809bd90b380442af386a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:45:10 +0000 Subject: [PATCH 2/2] fix: reject negative pad values in fuse_pad_into_conv optimization Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com> --- onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py | 3 +++ .../rewriter/rules/common/_fuse_pad_into_conv_test.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py b/onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py index 39aab00eda..f4daf5d2f2 100644 --- a/onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py +++ b/onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py @@ -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 diff --git a/onnxscript/rewriter/rules/common/_fuse_pad_into_conv_test.py b/onnxscript/rewriter/rules/common/_fuse_pad_into_conv_test.py index ded57fe023..529198fda4 100644 --- a/onnxscript/rewriter/rules/common/_fuse_pad_into_conv_test.py +++ b/onnxscript/rewriter/rules/common/_fuse_pad_into_conv_test.py @@ -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(