diff --git a/testdata/dnn/onnx/data/input_calc_pads.npy b/testdata/dnn/onnx/data/input_calc_pads.npy new file mode 100644 index 000000000..726e2c8ee Binary files /dev/null and b/testdata/dnn/onnx/data/input_calc_pads.npy differ diff --git a/testdata/dnn/onnx/data/output_calc_pads.npy b/testdata/dnn/onnx/data/output_calc_pads.npy new file mode 100644 index 000000000..960f41072 Binary files /dev/null and b/testdata/dnn/onnx/data/output_calc_pads.npy differ diff --git a/testdata/dnn/onnx/generate_onnx_models.py b/testdata/dnn/onnx/generate_onnx_models.py index bc7732d2f..8d5cc52c3 100644 --- a/testdata/dnn/onnx/generate_onnx_models.py +++ b/testdata/dnn/onnx/generate_onnx_models.py @@ -1233,3 +1233,15 @@ def forward(self, x): x = Variable(torch.randn([1, 2, 2, 2])) model = Mish() save_data_and_model("mish", x, model) + +class PadCalculation(nn.Module): + def forward(self, x): + y = F.max_pool2d(x, kernel_size=2) + diff_h = x.shape[2] - y.shape[2] + diff_w = x.shape[3] - y.shape[3] + y = F.pad(y, [diff_w // 2, diff_w - diff_w // 2, diff_h // 2, diff_h - diff_h // 2]) + return y + +x = Variable(torch.randn([1, 1, 3, 4])) +model = PadCalculation() +save_data_and_model("calc_pads", x, model, version=11) diff --git a/testdata/dnn/onnx/models/calc_pads.onnx b/testdata/dnn/onnx/models/calc_pads.onnx new file mode 100644 index 000000000..8019a84a5 Binary files /dev/null and b/testdata/dnn/onnx/models/calc_pads.onnx differ