We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac4c68d commit c5a78fcCopy full SHA for c5a78fc
tests/test_backend.py
@@ -438,6 +438,16 @@ def test_conv2d_6(self):
438
kernel_val = np.arange(1, 1 + np.prod(kernel_shape)).astype("float32").reshape(kernel_shape)
439
self._conv_test(x_val, kernel_val, strides=strides, padding="VALID", rtol=1e-05)
440
441
+ @check_tf_min_version("1.14", "tf 1.14 needed for explicit padding")
442
+ def test_conv2d_explicit_padding(self):
443
+ x_shape = [1, 35, 35, 288]
444
+ kernel_shape = [3, 3, 288, 384]
445
+ pads = [[0, 0], [1, 2], [3, 4], [0, 0]]
446
+ strides = [1, 1, 1, 1]
447
+ x_val = np.arange(1, 1 + np.prod(x_shape)).astype("float32").reshape(x_shape)
448
+ kernel_val = np.arange(1, 1 + np.prod(kernel_shape)).astype("float32").reshape(kernel_shape)
449
+ self._conv_test(x_val, kernel_val, strides=strides, padding=pads, rtol=1e-05)
450
+
451
def test_conv2d_dilation_same(self):
452
x_shape = [1, 35, 35, 288] # NHWC
453
kernel_shape = [3, 3, 288, 384] # [filter_height, filter_width, in_channels, out_channels]
tf2onnx/onnx_opset/nn.py
@@ -249,6 +249,15 @@ def add_padding(ctx, node, kernel_shape, strides, dilations=None, spatial=2):
249
node.set_attr("pads", pads)
250
elif padding == "VALID":
251
pass
252
+ elif padding == "EXPLICIT":
253
+ pads = node.get_attr_value("explicit_paddings")
254
+ start_pads = []
255
+ end_pads = []
256
+ d = 1 if is_channels_last(node) else 2
257
+ for i in range(spatial):
258
+ start_pads.append(pads[(d + i) * 2])
259
+ end_pads.append(pads[(d + i) * 2 + 1])
260
+ node.set_attr("pads", start_pads + end_pads)
261
else:
262
raise ValueError("invalid padding value: {}".format(padding))
263
0 commit comments