Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
6ce10dc4
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6ce10dc4
编写于
12月 17, 2020
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the tensorflow
上级
f64b23a7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
15 deletion
+38
-15
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
+19
-7
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
+19
-8
未找到文件。
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
浏览文件 @
6ce10dc4
...
...
@@ -73,15 +73,17 @@ class TFOpMapper(OpMapper):
'Sub'
:
'fluid.layers.elementwise_sub'
,
'Maximum'
:
'paddle.maximum'
,
'Minimum'
:
'paddle.minimum'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
bool_ops
=
{
'LessEqual'
:
'paddle.less_equal'
,
'GreaterEqual'
:
'paddle.greater_equal'
,
'Greater'
:
'paddle.greater_than'
,
'NotEqual'
:
'paddle.not_equal'
,
'Equal'
:
'paddle.equal'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
def
__init__
(
self
,
decoder
):
...
...
@@ -123,6 +125,8 @@ class TFOpMapper(OpMapper):
self
.
directly_map
(
node
)
elif
op
in
self
.
elementwise_ops
:
self
.
elementwise_map
(
node
)
elif
op
in
self
.
bool_ops
:
self
.
bool_map
(
node
)
elif
hasattr
(
self
,
op
):
func
=
getattr
(
self
,
op
)
func
(
node
)
...
...
@@ -138,7 +142,8 @@ class TFOpMapper(OpMapper):
op
=
node
.
layer_type
if
not
hasattr
(
self
,
op
)
and
\
op
not
in
self
.
directly_map_ops
and
\
op
not
in
self
.
elementwise_ops
:
op
not
in
self
.
elementwise_ops
and
\
op
not
in
self
.
bool_ops
:
unsupported_ops
.
add
(
op
)
if
len
(
unsupported_ops
)
==
0
:
return
True
...
...
@@ -178,7 +183,9 @@ class TFOpMapper(OpMapper):
outputs
=
[
node
.
name
],
**
layer_attrs
)
def
elementwise_map
(
self
,
node
):
def
elementwise_map
(
self
,
node
,
op_type
=
None
):
if
op_type
is
None
:
assert
node
.
layer_type
in
self
.
elementwise_ops
op_type
=
self
.
elementwise_ops
[
node
.
layer_type
]
x
=
self
.
graph
.
get_input_node
(
node
,
0
)
y
=
self
.
graph
.
get_input_node
(
node
,
1
)
...
...
@@ -191,6 +198,11 @@ class TFOpMapper(OpMapper):
outputs
=
[
node
.
name
])
self
.
paddle_graph
.
layers
[
layer_id
].
input_shapes
=
{
"x"
:
x_shape
,
"y"
:
y_shape
}
def
bool_map
(
self
,
node
):
op_type
=
self
.
bool_ops
[
node
.
layer_type
]
self
.
elementwise_map
(
node
,
op_type
)
node
.
set_dtype
(
"bool"
)
def
Placeholder
(
self
,
node
):
shape
=
node
.
out_shapes
[
0
]
assert
len
(
shape
)
!=
0
,
"Unknown shape of input nodes[{}]."
.
format
(
...
...
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
浏览文件 @
6ce10dc4
...
...
@@ -75,15 +75,17 @@ class TFOpMapper(OpMapper):
'Sub'
:
'fluid.layers.elementwise_sub'
,
'Maximum'
:
'paddle.maximum'
,
'Minimum'
:
'paddle.minimum'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
bool_ops
=
{
'LessEqual'
:
'paddle.less_equal'
,
'GreaterEqual'
:
'paddle.greater_equal'
,
'Greater'
:
'paddle.greater_than'
,
'NotEqual'
:
'paddle.not_equal'
,
'Equal'
:
'paddle.equal'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
def
__init__
(
self
,
decoder
):
...
...
@@ -124,6 +126,8 @@ class TFOpMapper(OpMapper):
self
.
directly_map
(
node
)
elif
op
in
self
.
elementwise_ops
:
self
.
elementwise_map
(
node
)
elif
op
in
self
.
bool_ops
:
self
.
bool_map
(
node
)
elif
hasattr
(
self
,
op
):
func
=
getattr
(
self
,
op
)
func
(
node
)
...
...
@@ -138,7 +142,8 @@ class TFOpMapper(OpMapper):
op
=
node
.
layer_type
if
not
hasattr
(
self
,
op
)
and
\
op
not
in
self
.
directly_map_ops
and
\
op
not
in
self
.
elementwise_ops
:
op
not
in
self
.
elementwise_ops
and
\
op
not
in
self
.
bool_ops
:
unsupported_ops
.
add
(
op
)
if
len
(
unsupported_ops
)
==
0
:
return
True
...
...
@@ -167,7 +172,8 @@ class TFOpMapper(OpMapper):
outputs
=
[
node
.
name
],
**
attr
)
def
elementwise_map
(
self
,
node
):
def
elementwise_map
(
self
,
node
,
op_type
=
None
):
if
op_type
is
None
:
assert
node
.
layer_type
in
self
.
elementwise_ops
op_type
=
self
.
elementwise_ops
[
node
.
layer_type
]
x
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
])
...
...
@@ -181,6 +187,11 @@ class TFOpMapper(OpMapper):
outputs
=
[
node
.
name
])
self
.
paddle_graph
.
layers
[
layer_id
].
input_shapes
=
{
"x"
:
x_shape
,
"y"
:
y_shape
}
def
bool_map
(
self
,
node
):
op_type
=
self
.
bool_ops
[
node
.
layer_type
]
self
.
elementwise_map
(
node
,
op_type
)
node
.
set_dtype
(
"bool"
)
def
Placeholder
(
self
,
node
):
shape
=
node
.
out_shapes
[
0
]
assert
len
(
shape
)
!=
0
,
"Unknown shape of input nodes[{}]."
.
format
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录