Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
1055a2e1
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看板
提交
1055a2e1
编写于
12月 09, 2020
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the conflic
上级
9194d510
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
7 addition
and
60 deletion
+7
-60
x2paddle/convert.py
x2paddle/convert.py
+2
-41
x2paddle/core/program.py
x2paddle/core/program.py
+1
-1
x2paddle/decoder/onnx_decoder.py
x2paddle/decoder/onnx_decoder.py
+1
-5
x2paddle/decoder/onnx_shape_inference.py
x2paddle/decoder/onnx_shape_inference.py
+2
-6
x2paddle/optimizer/tensorflow/prelu.py
x2paddle/optimizer/tensorflow/prelu.py
+1
-7
未找到文件。
x2paddle/convert.py
浏览文件 @
1055a2e1
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
#
Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
...
...
@@ -117,27 +117,6 @@ def tf2paddle(model_path,
return
from
x2paddle.decoder.tf_decoder
import
TFDecoder
<<<<<<<
HEAD
from
x2paddle.op_mapper.tf_op_mapper
import
TFOpMapper
from
x2paddle.optimizer.tensorflow.bias
import
BiasOpt
from
x2paddle.optimizer.tensorflow.transpose
import
TransposeOpt
from
x2paddle.optimizer.tensorflow.batch_norm
import
BatchNormOpt
from
x2paddle.optimizer.tensorflow.prelu
import
PReLUOpt
print
(
"Now translating model from tensorflow to paddle."
)
model
=
TFDecoder
(
model_path
,
define_input_shape
=
define_input_shape
)
mapper
=
TFOpMapper
(
model
)
program
.
build
()
bias_opt
=
BiasOpt
()
transpose_opt
=
TransposeOpt
()
batch_norm_opt
=
BatchNormOpt
()
prelu_opt
=
PReLUOpt
()
bias_opt
.
run
(
program
)
batch_norm_opt
.
run
(
program
)
prelu_opt
.
run
(
program
)
transpose_opt
.
run
(
program
)
program
.
gen_model
(
save_dir
)
=======
if
paddle_type
==
"dygraph"
:
from
x2paddle.op_mapper.dygraph.tf2paddle.tf_op_mapper
import
TFOpMapper
else
:
...
...
@@ -167,7 +146,6 @@ def tf2paddle(model_path,
transpose_opt
.
run
(
mapper
.
paddle_graph
)
mapper
.
paddle_graph
.
gen_model
(
save_dir
)
>>>>>>>
paddle
-
2.0
def
caffe2paddle
(
proto
,
weight
,
save_dir
,
caffe_proto
,
...
...
@@ -259,20 +237,7 @@ def pytorch2paddle(module, save_dir, jit_type="trace", input_examples=None):
graph_opt
=
GraphOptimizer
(
source_frame
=
"pytorch"
,
paddle_type
=
"dygraph"
,
jit_type
=
jit_type
)
graph_opt
.
optimize
(
mapper
.
paddle_graph
)
print
(
"Model optimized."
)
<<<<<<<
HEAD
if
input_shapes
is
not
None
:
real_input_shapes
=
list
()
for
shape
in
input_shapes
:
sp
=
shape
[
1
:
-
1
].
split
(
","
)
for
i
,
s
in
enumerate
(
sp
):
sp
[
i
]
=
int
(
s
)
real_input_shapes
.
append
(
sp
)
else
:
real_input_shapes
=
None
mapper
.
graph
.
gen_model
(
save_dir
,
real_input_shapes
)
=======
mapper
.
paddle_graph
.
gen_model
(
save_dir
,
jit_type
=
jit_type
)
>>>>>>>
paddle
-
2.0
def
main
():
...
...
@@ -343,11 +308,7 @@ def main():
else
:
raise
Exception
(
<<<<<<<
HEAD
"--framework only support tensorflow/caffe/onnx/ now"
)
=======
"--framework only support tensorflow/caffe/onnx now"
)
>>>>>>>
paddle
-
2.0
if
__name__
==
"__main__"
:
...
...
x2paddle/core/program.py
浏览文件 @
1055a2e1
...
...
@@ -293,7 +293,7 @@ class PaddleGraph(object):
try
:
self
.
dygraph2static
(
save_dir
,
input_shapes
,
input_types
)
except
Exception
as
e
:
print
(
"Fail to generate inference model! Problem happend while export inference model from python code '{}';
\n
"
.
format
(
cod
a
_path
))
print
(
"Fail to generate inference model! Problem happend while export inference model from python code '{}';
\n
"
.
format
(
cod
e
_path
))
print
(
"===================Error Information==============="
)
raise
e
...
...
x2paddle/decoder/onnx_decoder.py
浏览文件 @
1055a2e1
...
...
@@ -154,11 +154,7 @@ class ONNXGraph(Graph):
if
self
.
graph
is
None
:
print
(
'[WARNING] Shape inference by ONNX offical interface.'
)
onnx_model
=
shape_inference
.
infer_shapes
(
onnx_model
)
<<<<<<<
HEAD
self
.
graph
=
onnx_model
.
graph
=======
self
.
graph
=
onnx_model
.
graph
>>>>>>>
paddle
-
2.0
print
(
"shape inferenced."
)
self
.
build
()
self
.
collect_value_infos
()
...
...
x2paddle/decoder/onnx_shape_inference.py
浏览文件 @
1055a2e1
...
...
@@ -1601,15 +1601,11 @@ class SymbolicShapeInference:
in_mp
)
symbolic_shape_inference
.
_update_output_from_vi
()
if
not
all_shapes_inferred
:
print
(
'!'
*
10
)
symbolic_shape_inference
.
out_mp_
=
shape_inference
.
infer_shapes
(
symbolic_shape_inference
.
out_mp_
)
print
(
'[INFO] Complete symbolic shape inference.'
)
except
:
<<<<<<<
HEAD
print
(
'[WARNING] Incomplete symbolic shape inference.'
)
=======
print
(
'[WARNING] Incomplete symbolic shape inference'
)
>>>>>>>
paddle
-
2.0
symbolic_shape_inference
.
out_mp_
=
shape_inference
.
infer_shapes
(
symbolic_shape_inference
.
out_mp_
)
return
symbolic_shape_inference
.
out_mp_
.
graph
\ No newline at end of file
x2paddle/optimizer/tensorflow/prelu.py
浏览文件 @
1055a2e1
...
...
@@ -118,12 +118,6 @@ class PReLUOpt:
graph
.
layers
[
transpose0
.
id
]
=
transpose0
graph
.
layers
[
prelu
.
id
]
=
prelu
graph
.
layers
[
transpose1
.
id
]
=
transpose1
<<<<<<<
HEAD
graph
.
parameters
[
alpha
.
outputs
[
0
]]
=
np
.
expand_dims
(
graph
.
parameters
[
alpha
.
outputs
[
0
]],
0
)
graph
.
build
()
=======
first_axis
=
graph
.
parameters
[
alpha
.
outputs
[
0
]].
shape
[
0
]
graph
.
parameters
[
alpha
.
outputs
[
0
]]
=
np
.
reshape
(
graph
.
parameters
[
alpha
.
outputs
[
0
]],
(
1
,
first_axis
,
1
,
1
))
graph
.
build
()
\ No newline at end of file
>>>>>>>
paddle
-
2.0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录