Skip to content

Commit 1934901

Browse files
authored
Add test for dynamic padding (#2541)
This is a follow up of #2540 to add a test described in #2539. Fix #2539 Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent d98e3dd commit 1934901

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/function_libs/torch_lib/e2e_ops_tests.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,21 @@ def forward(self, query, key, value, attn_mask):
159159
)
160160
_testing.assert_onnx_program(onnx_program)
161161

162+
def test_dynamic_paddings(self):
163+
class Model(torch.nn.Module):
164+
def forward(self, x):
165+
height = x.size(2) # height is SymInt
166+
x = torch.nn.functional.pad(x, (0, 0, 0, height), mode="replicate")
167+
return x
168+
169+
onnx_program = torch.onnx.export(
170+
Model(),
171+
(torch.rand(1, 1, 1, 1),),
172+
dynamo=True,
173+
dynamic_shapes=({2: torch.export.Dim("H")},),
174+
)
175+
_testing.assert_onnx_program(onnx_program)
176+
162177

163178
if __name__ == "__main__":
164179
unittest.main()

0 commit comments

Comments
 (0)