Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
urhero
Paddle
提交
eb116336
P
Paddle
项目概览
urhero
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
eb116336
编写于
4月 08, 2020
作者:
P
Pei Yang
提交者:
GitHub
4月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
batch_norm trt converter error message, test=develop (#23620)
上级
c1187cd6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
13 deletion
+48
-13
paddle/fluid/inference/tensorrt/convert/activation_op.cc
paddle/fluid/inference/tensorrt/convert/activation_op.cc
+1
-2
paddle/fluid/inference/tensorrt/convert/batch_norm_op.cc
paddle/fluid/inference/tensorrt/convert/batch_norm_op.cc
+47
-11
未找到文件。
paddle/fluid/inference/tensorrt/convert/activation_op.cc
浏览文件 @
eb116336
...
...
@@ -49,10 +49,9 @@ class ActivationOpConverter : public OpConverter {
layer
->
setAlpha
(
0.
);
layer
->
setBeta
(
6.
);
}
g
#endif
auto
output_name
=
op_desc
.
Output
(
"Out"
)[
0
];
auto
output_name
=
op_desc
.
Output
(
"Out"
)[
0
];
RreplenishLayerAndOutput
(
layer
,
op_type_
,
{
output_name
},
test_mode
);
if
(
op_desc
.
HasAttr
(
"out_scale"
))
{
...
...
paddle/fluid/inference/tensorrt/convert/batch_norm_op.cc
浏览文件 @
eb116336
...
...
@@ -26,13 +26,37 @@ class BatchNormOpConverter : public OpConverter {
VLOG
(
3
)
<<
"convert a fluid batch norm op to tensorrt batch_norm"
;
framework
::
OpDesc
op_desc
(
op
,
nullptr
);
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"X"
).
size
(),
1
);
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Bias"
).
size
(),
1
);
// Bias is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Mean"
).
size
(),
1
);
// Mean is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Scale"
).
size
(),
1
);
// Scale is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Variance"
).
size
(),
1
);
// Variance is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Output
(
"Y"
).
size
(),
1
);
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"X"
).
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Invalid input X's size of batch_norm TRT converter. "
"Expected 1, received %d."
,
op_desc
.
Input
(
"X"
).
size
()));
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Bias"
).
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Invalid input Bias's size of batch_norm TRT "
"converter. Expected 1, received %d."
,
op_desc
.
Input
(
"Bias"
).
size
()));
// Bias is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Mean"
).
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Invalid input Mean's size of batch_norm TRT "
"converter. Expected 1, received %d."
,
op_desc
.
Input
(
"Mean"
).
size
()));
// Mean is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Scale"
).
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Invalid input Scale's size of batch_norm TRT "
"converter. Expected 1, received %d."
,
op_desc
.
Input
(
"Scale"
).
size
()));
// Scale is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Input
(
"Variance"
).
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Invalid input Variance's size of batch_norm TRT converter. "
"Expected 1, received %d."
,
op_desc
.
Input
(
"Variance"
).
size
()));
// Variance is a weight
PADDLE_ENFORCE_EQ
(
op_desc
.
Output
(
"Y"
).
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Invalid output Y's size of batch_norm TRT "
"converter. Expected 1, received %d."
,
op_desc
.
Output
(
"Y"
).
size
()));
auto
*
X
=
engine_
->
GetITensor
(
op_desc
.
Input
(
"X"
).
front
());
// Declare weights
...
...
@@ -42,10 +66,22 @@ class BatchNormOpConverter : public OpConverter {
auto
*
Variance_v
=
scope
.
FindVar
(
op_desc
.
Input
(
"Variance"
).
front
());
const
float
eps
=
boost
::
get
<
float
>
(
op_desc
.
GetAttr
(
"epsilon"
));
PADDLE_ENFORCE_NOT_NULL
(
Bias_v
);
PADDLE_ENFORCE_NOT_NULL
(
Mean_v
);
PADDLE_ENFORCE_NOT_NULL
(
Scale_v
);
PADDLE_ENFORCE_NOT_NULL
(
Variance_v
);
PADDLE_ENFORCE_NOT_NULL
(
Bias_v
,
platform
::
errors
::
NotFound
(
"Variable of Bias of batch_norm TRT converter is not found."
));
PADDLE_ENFORCE_NOT_NULL
(
Mean_v
,
platform
::
errors
::
NotFound
(
"Variable of Mean of batch_norm TRT converter is not found."
));
PADDLE_ENFORCE_NOT_NULL
(
Scale_v
,
platform
::
errors
::
NotFound
(
"Variable of Scale of batch_norm TRT converter is not found."
));
PADDLE_ENFORCE_NOT_NULL
(
Variance_v
,
platform
::
errors
::
NotFound
(
"Variable of Variance of batch_norm TRT converter is not found."
));
// get tensor
auto
*
Bias_t
=
Bias_v
->
GetMutable
<
framework
::
LoDTensor
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录