Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
c3f3643b
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c3f3643b
编写于
3月 03, 2022
作者:
W
wenbin
提交者:
GitHub
3月 03, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EmbEltwiseLayernorm fix (#40015)
* emb fix * fix trt6 compile * fix half * absolute error fix
上级
5d9e11a4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
19 deletion
+35
-19
paddle/fluid/inference/tensorrt/engine.h
paddle/fluid/inference/tensorrt/engine.h
+2
-0
paddle/fluid/operators/tensorrt/tensorrt_engine_op.h
paddle/fluid/operators/tensorrt/tensorrt_engine_op.h
+31
-5
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_emb_eltwise_layernorm.py
...ts/ir/inference/test_trt_convert_emb_eltwise_layernorm.py
+2
-14
未找到文件。
paddle/fluid/inference/tensorrt/engine.h
浏览文件 @
c3f3643b
...
...
@@ -54,6 +54,8 @@ TRT_DT FluidDataType2TRT(FluidDT type) {
return
TRT_DT
::
kFLOAT
;
case
FluidDT
::
VarType_Type_INT32
:
return
TRT_DT
::
kINT32
;
case
FluidDT
::
VarType_Type_FP16
:
return
TRT_DT
::
kHALF
;
default:
return
TRT_DT
::
kINT32
;
}
...
...
paddle/fluid/operators/tensorrt/tensorrt_engine_op.h
浏览文件 @
c3f3643b
...
...
@@ -79,6 +79,28 @@ static void RuntimeStaticShapeCheck(std::vector<int64_t> runtime_input_shape,
model_input_shape_str
,
runtime_input_shape_str
));
}
static
paddle
::
experimental
::
DataType
TRT2FluidDataType
(
nvinfer1
::
DataType
type
)
{
switch
(
type
)
{
case
nvinfer1
::
DataType
::
kFLOAT
:
return
paddle
::
experimental
::
DataType
::
FLOAT32
;
case
nvinfer1
::
DataType
::
kINT32
:
return
paddle
::
experimental
::
DataType
::
INT32
;
case
nvinfer1
::
DataType
::
kHALF
:
return
paddle
::
experimental
::
DataType
::
FLOAT16
;
case
nvinfer1
::
DataType
::
kINT8
:
return
paddle
::
experimental
::
DataType
::
INT8
;
#if IS_TRT_VERSION_GE(7000)
case
nvinfer1
::
DataType
::
kBOOL
:
return
paddle
::
experimental
::
DataType
::
BOOL
;
#endif
default:
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
"unknown fluid datatype in Fluid op converter"
));
return
paddle
::
experimental
::
DataType
::
FLOAT32
;
}
}
static
void
RuntimeDynamicShapeCheck
(
const
std
::
string
&
x
,
const
std
::
vector
<
int32_t
>
&
runtime_input_shape
,
const
std
::
vector
<
int32_t
>
&
min_input_shape
,
...
...
@@ -520,9 +542,12 @@ class TensorRTEngineOp : public framework::OperatorBase {
buffers
[
bind_index
]
=
static_cast
<
void
*>
(
t
.
data
<
int64_t
>
());
}
else
if
(
type
==
framework
::
proto
::
VarType
::
INT32
)
{
buffers
[
bind_index
]
=
static_cast
<
void
*>
(
t
.
data
<
int32_t
>
());
}
else
if
(
type
==
framework
::
proto
::
VarType
::
FP16
)
{
buffers
[
bind_index
]
=
static_cast
<
void
*>
(
t
.
data
<
float16
>
());
}
else
{
PADDLE_THROW
(
platform
::
errors
::
Fatal
(
"The TRT Engine OP only support float/int32_t/int64_t input."
));
PADDLE_THROW
(
platform
::
errors
::
Fatal
(
"The TRT Engine OP only support "
"float/int32_t/int64_t/float16 input."
));
}
}
...
...
@@ -570,9 +595,10 @@ class TensorRTEngineOp : public framework::OperatorBase {
"than the number of bindings, but got binding "
"index = %d, number of bindings = %d."
,
bind_index
,
num_bindings
));
buffers
[
bind_index
]
=
static_cast
<
void
*>
(
fluid_t
->
mutable_data
<
float
>
(
dev_place
));
auto
trt_type
=
engine
->
engine
()
->
getBindingDataType
(
bind_index
);
// get adr and set type
buffers
[
bind_index
]
=
static_cast
<
void
*>
(
fluid_t
->
mutable_data
(
dev_place
,
TRT2FluidDataType
(
trt_type
)));
output_index
+=
1
;
}
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_emb_eltwise_layernorm.py
浏览文件 @
c3f3643b
...
...
@@ -244,28 +244,16 @@ class TrtConvertEmbEltwiseLayernormTest1(TrtLayerAutoScanTest):
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
(
0
,
5
),
1e-5
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
(
0
,
5
),
1e-5
yield
self
.
create_inference_config
(),
(
0
,
5
),
2e-2
# for dynamic_shape
generate_dynamic_shape
(
attrs
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
(
1
,
4
),
1e-5
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
(
1
,
4
),
1e-5
def
add_skip_trt_case
(
self
):
def
teller1
(
program_config
,
predictor_config
):
if
self
.
trt_param
.
precision
==
paddle_infer
.
PrecisionType
.
Half
and
len
(
self
.
dynamic_shape
.
min_input_shape
)
!=
0
:
return
True
return
False
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"The output has diff between gpu and trt when dynamic fp16 mode."
)
yield
self
.
create_inference_config
(),
(
1
,
4
),
2e-2
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
run_test
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录