Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
2ca65904
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
未验证
提交
2ca65904
编写于
9月 14, 2022
作者:
J
JingZhuangzhuang
提交者:
GitHub
9月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cherry pick delay tensorrt log (#45958)
* cherry pick delay tensorrt log * Update trt_plugin.h
上级
2fac8abb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
33 deletion
+51
-33
paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc
...id/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc
+6
-0
paddle/fluid/inference/tensorrt/plugin/trt_plugin.h
paddle/fluid/inference/tensorrt/plugin/trt_plugin.h
+35
-3
paddle/fluid/inference/tensorrt/test_dynamic_engine.cc
paddle/fluid/inference/tensorrt/test_dynamic_engine.cc
+1
-0
paddle/fluid/platform/dynload/tensorrt.cc
paddle/fluid/platform/dynload/tensorrt.cc
+5
-15
paddle/phi/backends/dynload/tensorrt.cc
paddle/phi/backends/dynload/tensorrt.cc
+4
-15
未找到文件。
paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc
浏览文件 @
2ca65904
...
...
@@ -32,6 +32,7 @@
#include "paddle/fluid/inference/tensorrt/engine.h"
#include "paddle/fluid/inference/tensorrt/helper.h"
#include "paddle/fluid/inference/tensorrt/op_teller.h"
#include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h"
#include "paddle/fluid/inference/utils/io_utils.h"
#include "paddle/phi/common/backend.h"
#include "paddle/phi/common/data_type.h"
...
...
@@ -117,6 +118,11 @@ void analysis::TensorRtSubgraphPass::ApplyImpl(
framework
::
ir
::
Graph
*
graph
)
const
{
framework
::
ir
::
FusePassBase
::
Init
(
"tensorrt_subgraph_pass"
,
graph
);
static
std
::
once_flag
trt_plugin_registered
;
std
::
call_once
(
trt_plugin_registered
,
[]()
{
tensorrt
::
plugin
::
TrtPluginRegistry
::
Global
()
->
RegistToTrt
();
});
auto
model_precision
=
static_cast
<
phi
::
DataType
>
(
Get
<
int
>
(
"model_precision"
));
if
(
model_precision
==
phi
::
DataType
::
BFLOAT16
)
{
...
...
paddle/fluid/inference/tensorrt/plugin/trt_plugin.h
浏览文件 @
2ca65904
...
...
@@ -38,6 +38,13 @@ namespace inference {
namespace
tensorrt
{
namespace
plugin
{
#if defined(_WIN32)
#define UNUSED
#define __builtin_expect(EXP, C) (EXP)
#else
#define UNUSED __attribute__((unused))
#endif
class
PluginTensorRT
;
typedef
std
::
function
<
PluginTensorRT
*
(
const
void
*
,
size_t
)
>
...
...
@@ -372,6 +379,26 @@ class TensorRTPluginCreator : public nvinfer1::IPluginCreator {
std
::
vector
<
nvinfer1
::
PluginField
>
plugin_attributes_
;
};
class
TrtPluginRegistry
{
public:
static
TrtPluginRegistry
*
Global
()
{
static
TrtPluginRegistry
registry
;
return
&
registry
;
}
bool
Regist
(
const
std
::
string
&
name
,
const
std
::
function
<
void
()
>&
func
)
{
map
.
emplace
(
name
,
func
);
return
true
;
}
void
RegistToTrt
()
{
for
(
auto
&
it
:
map
)
{
it
.
second
();
}
}
private:
std
::
unordered_map
<
std
::
string
,
std
::
function
<
void
()
>>
map
;
};
template
<
typename
T
>
class
TrtPluginRegistrarV2
{
public:
...
...
@@ -386,9 +413,14 @@ class TrtPluginRegistrarV2 {
T
creator
;
};
#define REGISTER_TRT_PLUGIN_V2(name) \
static paddle::inference::tensorrt::plugin::TrtPluginRegistrarV2<name> \
plugin_registrar_##name {}
#define REGISTER_TRT_PLUGIN_V2(name) REGISTER_TRT_PLUGIN_V2_HELPER(name)
#define REGISTER_TRT_PLUGIN_V2_HELPER(name) \
UNUSED static bool REGISTER_TRT_PLUGIN_V2_HELPER##name = \
TrtPluginRegistry::Global()->Regist(#name, []() -> void { \
static paddle::inference::tensorrt::plugin::TrtPluginRegistrarV2<name> \
plugin_registrar_##name{}; \
});
}
// namespace plugin
}
// namespace tensorrt
...
...
paddle/fluid/inference/tensorrt/test_dynamic_engine.cc
浏览文件 @
2ca65904
...
...
@@ -284,6 +284,7 @@ class TensorRTDynamicTestFusedTokenPrune : public ::testing::Test {
TEST_F
(
TensorRTDynamicTestFusedTokenPrune
,
test_fused_token_prune
)
{
#if IS_TRT_VERSION_GE(8000)
tensorrt
::
plugin
::
TrtPluginRegistry
::
Global
()
->
RegistToTrt
();
auto
*
attn
=
engine_
->
DeclareInput
(
"attn"
,
nvinfer1
::
DataType
::
kHALF
,
nvinfer1
::
Dims4
{
-
1
,
1
,
4
,
4
});
auto
*
x
=
engine_
->
DeclareInput
(
...
...
paddle/fluid/platform/dynload/tensorrt.cc
浏览文件 @
2ca65904
...
...
@@ -41,21 +41,11 @@ void* GetDsoHandle(const std::string& dso_name) {
void
*
dso_handle
=
dlopen
(
dso_name
.
c_str
(),
dynload_flags
);
if
(
nullptr
==
dso_handle
)
{
auto
error_msg
=
"You are using Paddle compiled with TensorRT, but TensorRT dynamic "
"library is not found. Ignore this if TensorRT is not needed.
\n
"
"The TensorRT that Paddle depends on is not configured correctly.
\n
"
" Suggestions:
\n
"
" 1. Check if the TensorRT is installed correctly and its version"
" is matched with paddlepaddle you installed.
\n
"
" 2. Configure environment variables as "
"follows:
\n
"
" - Linux: set LD_LIBRARY_PATH by `export LD_LIBRARY_PATH=...`
\n
"
" - Windows: set PATH by `set PATH=XXX;%PATH%`
\n
"
" - Mac: set DYLD_LIBRARY_PATH by `export DYLD_LIBRARY_PATH=...`
\n
"
;
LOG
(
WARNING
)
<<
error_msg
;
}
PADDLE_ENFORCE_NOT_NULL
(
dso_handle
,
paddle
::
platform
::
errors
::
NotFound
(
"TensorRT is needed, "
"but TensorRT dynamic library is not found."
));
return
dso_handle
;
}
...
...
paddle/phi/backends/dynload/tensorrt.cc
浏览文件 @
2ca65904
...
...
@@ -40,21 +40,10 @@ void* GetDsoHandle(const std::string& dso_name) {
void
*
dso_handle
=
dlopen
(
dso_name
.
c_str
(),
dynload_flags
);
if
(
nullptr
==
dso_handle
)
{
auto
error_msg
=
"You are using Paddle compiled with TensorRT, but TensorRT dynamic "
"library is not found. Ignore this if TensorRT is not needed.
\n
"
"The TensorRT that Paddle depends on is not configured correctly.
\n
"
" Suggestions:
\n
"
" 1. Check if the TensorRT is installed correctly and its version"
" is matched with paddlepaddle you installed.
\n
"
" 2. Configure environment variables as "
"follows:
\n
"
" - Linux: set LD_LIBRARY_PATH by `export LD_LIBRARY_PATH=...`
\n
"
" - Windows: set PATH by `set PATH=XXX;%PATH%`
\n
"
" - Mac: set DYLD_LIBRARY_PATH by `export DYLD_LIBRARY_PATH=...`
\n
"
;
LOG
(
WARNING
)
<<
error_msg
;
}
PADDLE_ENFORCE_NOT_NULL
(
dso_handle
,
paddle
::
platform
::
errors
::
NotFound
(
"TensorRT is needed, "
"but TensorRT dynamic library is not found."
));
return
dso_handle
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录