Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
142f9bbf
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看板
提交
142f9bbf
编写于
7月 16, 2019
作者:
J
jiangjiajun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test code
上级
9b286963
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
11 deletion
+56
-11
x2paddle/core/fluid_code.py
x2paddle/core/fluid_code.py
+35
-7
x2paddle/core/graph.py
x2paddle/core/graph.py
+4
-2
x2paddle/emitter/tf_emitter.py
x2paddle/emitter/tf_emitter.py
+5
-2
x2paddle/optimizer/tf_optimizer.py
x2paddle/optimizer/tf_optimizer.py
+12
-0
未找到文件。
x2paddle/core/fluid_code.py
浏览文件 @
142f9bbf
...
@@ -17,18 +17,46 @@ class Layer(object):
...
@@ -17,18 +17,46 @@ class Layer(object):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
op
=
None
self
.
op
=
None
self
.
param_attr
=
dict
()
self
.
param_attr
=
dict
()
self
.
input
=
None
self
.
input
s
=
dict
()
self
.
output
=
None
self
.
output
=
None
self
.
str_code
=
None
def
get_code
(
self
):
def
get_code
(
self
):
if
self
.
str_code
is
not
None
:
layer_code
=
""
return
self
.
str_code
if
self
.
output
is
not
None
:
layer_code
=
self
.
output
+
" = "
layer_code
=
layer_code
+
"fluid.layers."
+
self
.
op
+
"("
for
key
,
tensor
in
self
.
inputs
.
items
():
layer_code
=
layer_code
+
key
+
"="
+
tensor
+
", "
for
key
,
value
in
self
.
param_attr
.
items
():
layer_code
=
layer_code
+
key
+
"="
+
value
+
", "
layer_code
=
layer_code
.
strip
(
", "
)
return
layer_code
+=
")"
class
FluidCode
(
object
):
class
FluidCode
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
code
s
=
list
()
self
.
layer
s
=
list
()
def
add_layer
(
self
,
op
,
input
,
output
,
param_attr
=
None
):
def
add_layer
(
self
,
op
,
inputs
,
output
,
param_attr
=
None
):
layer
=
Layer
()
layer
.
op
=
op
layer
.
inputs
=
inputs
layer
.
output
=
output
if
param_attr
is
not
None
:
layer
.
param_attr
=
param_attr
self
.
layers
.
append
(
layer
)
def
add_note
(
self
,
note
):
# note should be string
self
.
layers
.
append
(
note
)
def
gen_codes
(
self
):
codes
=
list
()
for
layer
in
self
.
layers
:
if
isinstance
(
layer
,
Layer
):
codes
.
append
(
layer
.
get_code
())
elif
isinstance
(
layer
,
str
):
codes
.
append
(
layer
)
x2paddle/core/graph.py
浏览文件 @
142f9bbf
...
@@ -62,14 +62,16 @@ class Graph(object):
...
@@ -62,14 +62,16 @@ class Graph(object):
num_inputs
[
name
]
=
len
(
node
.
inputs
)
num_inputs
[
name
]
=
len
(
node
.
inputs
)
self
.
topo_sort
=
self
.
input_nodes
[:]
self
.
topo_sort
=
self
.
input_nodes
[:]
for
idx
in
range
(
len
(
self
.
topo_sort
)
):
while
idx
<
len
(
self
.
topo_sort
):
current_node
=
self
.
node_map
[
self
.
topo_sort
[
idx
]]
current_node
=
self
.
node_map
[
self
.
topo_sort
[
idx
]]
for
node
in
current_node
.
outputs
:
for
node
in
current_node
.
outputs
:
num_inputs
[
node
.
layer_name
]
-=
1
num_inputs
[
node
.
layer_name
]
-=
1
if
num_inputs
[
node
.
layer_name
]
==
0
:
if
num_inputs
[
node
.
layer_name
]
==
0
:
self
.
topo_sort
.
append
(
node
.
layer_name
)
self
.
topo_sort
.
append
(
node
.
layer_name
)
idx
+=
1
for
i
,
tmp
in
enumerate
(
self
.
topo_sort
):
for
i
,
tmp
in
enumerate
(
self
.
topo_sort
):
print
(
tmp
)
print
(
tmp
,
self
.
node_map
[
tmp
].
layer_type
,
self
.
node_map
[
tmp
].
inputs
)
def
get_node
(
self
,
name
):
def
get_node
(
self
,
name
):
if
name
not
in
self
.
node_map
:
if
name
not
in
self
.
node_map
:
...
...
x2paddle/emitter/tf_emitter.py
浏览文件 @
142f9bbf
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
x2paddle.parser
import
TFGraph
from
x2paddle.parser
.tf_parser
import
TFGraph
from
x2paddle.core.emitter
import
Emitter
class
TFEmitter
(
Emitter
):
def
__init__
(
self
):
super
(
TFEmitter
,
self
x2paddle/optimizer/tf_optimizer.py
浏览文件 @
142f9bbf
...
@@ -13,6 +13,18 @@
...
@@ -13,6 +13,18 @@
# limitations under the License.
# limitations under the License.
# TODO useless node remove
# TODO useless node remove
from
x2paddle.parser.tf_parser
import
TFGraph
class
TFGraphOptimizer
(
object
):
def
__init__
(
self
):
print
(
"Not Implement"
)
self
.
useless_op
=
[
'NoOp'
]
def
remove_useless_node
(
self
,
graph
):
for
name
,
node
in
graph
.
node_map
.
items
():
if
node
.
layer_type
in
self
.
useless_op
:
# TODO identity node remove
# TODO identity node remove
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录