未验证 提交 5e645693 编写于 作者: W WJJ1995 提交者: GitHub

Fixed torch pad (#863)

* add logical ops

* add run_dynamic switch

* add Or and Xor

* add Compare ops

* fixed compare bug

* fixed pad bug

* fixed pad bug
上级 f3861400
...@@ -1221,18 +1221,18 @@ def aten_constant_pad_nd(mapper, graph, node): ...@@ -1221,18 +1221,18 @@ def aten_constant_pad_nd(mapper, graph, node):
layer_attrs["value"] = mapper.attrs[inputs_name[2]] layer_attrs["value"] = mapper.attrs[inputs_name[2]]
if padding_attr is not None: if padding_attr is not None:
## convert torch pad attr to paddle pad attr, eg:(x1,x2,x3,x4)->(x3,x4,x1,x2)
padding_attr = np.array(padding_attr).reshape((-1, 2))
padding_attr = np.flip(padding_attr, axis=0).flatten().tolist()
layer_inputs["x"] = inputs_name[0] layer_inputs["x"] = inputs_name[0]
kernel_name = "paddle.nn.functional.pad" kernel_name = "paddle.nn.functional.pad"
if len(padding_attr) == 2: if len(padding_attr) == 2:
layer_attrs["pad"] = [0, 0, 0, 0, 0, 0] + padding_attr layer_attrs["pad"] = [0, 0, 0, 0, 0, 0] + padding_attr
elif len(padding_attr) == 4: elif len(padding_attr) == 4:
layer_inputs["x"] = inputs_name[0]
layer_attrs["pad"] = [0, 0, 0, 0] + padding_attr layer_attrs["pad"] = [0, 0, 0, 0] + padding_attr
elif len(padding_attr) == 6: elif len(padding_attr) == 6:
layer_inputs["x"] = inputs_name[0]
layer_attrs["pad"] = [0, 0] + padding_attr layer_attrs["pad"] = [0, 0] + padding_attr
else: else:
layer_inputs["x"] = inputs_name[0]
layer_attrs["pad"] = padding_attr layer_attrs["pad"] = padding_attr
graph.add_layer( graph.add_layer(
kernel_name, kernel_name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册