提交 5282bad4 编写于 作者: S SunAhong1993

fix the pad

上级 8085ee04
...@@ -445,6 +445,8 @@ class OpSet9(): ...@@ -445,6 +445,8 @@ class OpSet9():
layer_outputs = [nn_op_name, output_name] layer_outputs = [nn_op_name, output_name]
if is_pads_attr: if is_pads_attr:
paddings = [] paddings = []
if len(pads) == 10 and sum(pads) == 0:
pads = pads[0: 6]
if len(pads) in [2, 4, 6]: if len(pads) in [2, 4, 6]:
if data_shape: if data_shape:
assume_pad |= data_shape and 2 * (len(data_shape) - 2) == len(pads) # NCHW assume_pad |= data_shape and 2 * (len(data_shape) - 2) == len(pads) # NCHW
......
...@@ -407,6 +407,8 @@ class OpSet9(): ...@@ -407,6 +407,8 @@ class OpSet9():
if is_pads_attr: if is_pads_attr:
paddings = [] paddings = []
paddle_op = 'paddle.nn.functional.pad' paddle_op = 'paddle.nn.functional.pad'
if len(pads) == 10 and sum(pads) == 0:
pads = pads[0: 6]
if len(pads) in [2, 4, 6]: if len(pads) in [2, 4, 6]:
if data_shape: if data_shape:
assume_pad |= data_shape and 2 * (len(data_shape) - 2) == len(pads) # NCHW assume_pad |= data_shape and 2 * (len(data_shape) - 2) == len(pads) # NCHW
...@@ -424,7 +426,7 @@ class OpSet9(): ...@@ -424,7 +426,7 @@ class OpSet9():
(2, -1)).transpose().astype("int32") (2, -1)).transpose().astype("int32")
paddings = np.flip(paddings, axis=0).flatten().tolist() paddings = np.flip(paddings, axis=0).flatten().tolist()
layer_attrs['pad'] = paddings layer_attrs['pad'] = paddings
layer_attrs['data_format'] = data_format layer_attrs['data_format'] = string(data_format)
else: else:
if data_shape: if data_shape:
assume_pad |= data_shape and 2 * len(data_shape) == len(pads) # NCHW assume_pad |= data_shape and 2 * len(data_shape) == len(pads) # NCHW
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册