Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8c1c72af
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8c1c72af
编写于
10月 27, 2021
作者:
W
Wilber
提交者:
GitHub
10月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable trt test check and fix trt ut error(3/3) (#36581)
上级
9f9ed3ae
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
87 addition
and
21 deletion
+87
-21
paddle/fluid/framework/ir/graph_viz_pass.cc
paddle/fluid/framework/ir/graph_viz_pass.cc
+4
-0
paddle/fluid/inference/analysis/ir_pass_manager.cc
paddle/fluid/inference/analysis/ir_pass_manager.cc
+11
-3
paddle/fluid/inference/api/analysis_config.cc
paddle/fluid/inference/api/analysis_config.cc
+34
-11
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+23
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py
...d/tests/unittests/ir/inference/test_trt_convert_conv2d.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_fusion.py
.../unittests/ir/inference/test_trt_convert_conv2d_fusion.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py
...ittests/ir/inference/test_trt_convert_conv2d_transpose.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d.py
...ittests/ir/inference/test_trt_convert_depthwise_conv2d.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py
.../inference/test_trt_convert_depthwise_conv2d_transpose.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_nearest_interp_v2.py
...ttests/ir/inference/test_trt_convert_nearest_interp_v2.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reduce_mean.py
...ts/unittests/ir/inference/test_trt_convert_reduce_mean.py
+2
-2
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reduce_sum.py
...sts/unittests/ir/inference/test_trt_convert_reduce_sum.py
+2
-2
python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py
.../tests/unittests/ir/inference/trt_layer_auto_scan_test.py
+5
-3
未找到文件。
paddle/fluid/framework/ir/graph_viz_pass.cc
浏览文件 @
8c1c72af
...
...
@@ -62,10 +62,14 @@ void GraphVizPass::ApplyImpl(ir::Graph* graph) const {
}
}
}
const
std
::
string
&
optim_cache_dir
=
Get
<
std
::
string
>
(
"optim_cache_dir"
);
std
::
string
program_bytes
=
program_desc
.
Proto
()
->
SerializeAsString
();
// rename from "17_ir_fc_fuse_pass.dot" to "fc_fuse_pass.pdmodel"
program_path
=
graph_viz_path
.
substr
(
found1
+
4
,
found2
-
found1
-
4
)
+
".pdmodel"
;
if
(
!
optim_cache_dir
.
empty
())
{
program_path
=
optim_cache_dir
+
"/"
+
program_path
;
}
std
::
ofstream
file
(
program_path
.
c_str
(),
std
::
ios
::
binary
);
file
.
write
(
program_bytes
.
c_str
(),
program_bytes
.
size
());
file
.
close
();
...
...
paddle/fluid/inference/analysis/ir_pass_manager.cc
浏览文件 @
8c1c72af
...
...
@@ -56,10 +56,18 @@ void IRPassManager::CreatePasses(Argument *argument,
auto
pass
=
framework
::
ir
::
PassRegistry
::
Instance
().
Get
(
pass_name
);
if
(
pass_name
==
"graph_viz_pass"
)
{
std
::
string
dot_file_path
=
std
::
to_string
(
pass_num
)
+
"_ir_"
+
(
pre_pass
.
empty
()
?
"origin"
:
pre_pass
)
+
std
::
string
optim_cache_dir
=
argument
->
optim_cache_dir
();
std
::
string
dot_file_path
;
if
(
optim_cache_dir
.
empty
())
{
dot_file_path
=
std
::
to_string
(
pass_num
)
+
"_ir_"
+
(
pre_pass
.
empty
()
?
"origin"
:
pre_pass
)
+
".dot"
;
}
else
{
dot_file_path
=
optim_cache_dir
+
"/"
+
std
::
to_string
(
pass_num
)
+
"_ir_"
+
(
pre_pass
.
empty
()
?
"origin"
:
pre_pass
)
+
".dot"
;
}
pass
->
Set
(
"graph_viz_path"
,
new
std
::
string
(
std
::
move
(
dot_file_path
)));
pass
->
Set
(
"optim_cache_dir"
,
new
std
::
string
(
std
::
move
(
optim_cache_dir
)));
pass_num
++
;
}
else
if
(
pass_name
==
"mkldnn_placement_pass"
)
{
pass
->
Set
(
"mkldnn_enabled_op_types"
,
...
...
paddle/fluid/inference/api/analysis_config.cc
浏览文件 @
8c1c72af
...
...
@@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <sstream>
#include <string>
#include <tuple>
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/api/paddle_pass_builder.h"
#include "paddle/fluid/inference/utils/table_printer.h"
...
...
@@ -20,6 +22,10 @@
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/gpu_info.h"
#ifdef PADDLE_WITH_TENSORRT
#include "paddle/fluid/inference/tensorrt/helper.h"
#endif
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
DECLARE_uint64
(
initial_gpu_memory_in_mb
);
#endif
...
...
@@ -758,6 +764,18 @@ std::string AnalysisConfig::Summary() {
{
"mkldnn_cache_capacity"
,
std
::
to_string
(
mkldnn_cache_capacity_
)});
os
.
InsetDivider
();
// gpu info
os
.
InsertRow
({
"use_gpu"
,
use_gpu_
?
"true"
:
"false"
});
if
(
use_gpu_
)
{
os
.
InsertRow
({
"gpu_device_id"
,
std
::
to_string
(
gpu_device_id_
)});
os
.
InsertRow
({
"memory_pool_init_size"
,
std
::
to_string
(
memory_pool_init_size_mb_
)
+
"MB"
});
os
.
InsertRow
(
{
"thread_local_stream"
,
thread_local_stream_
?
"true"
:
"false"
});
os
.
InsertRow
({
"use_tensorrt"
,
use_tensorrt_
?
"true"
:
"false"
});
if
(
use_tensorrt_
)
{
#ifdef PADDLE_WITH_TENSORRT
auto
Precision2String
=
[](
paddle
::
AnalysisConfig
::
Precision
prec
)
->
std
::
string
{
if
(
prec
==
Precision
::
kFloat32
)
...
...
@@ -769,17 +787,21 @@ std::string AnalysisConfig::Summary() {
else
return
"None"
;
};
// gpu info
os
.
InsertRow
({
"use_gpu"
,
use_gpu_
?
"true"
:
"false"
});
if
(
use_gpu_
)
{
os
.
InsertRow
({
"gpu_device_id"
,
std
::
to_string
(
gpu_device_id_
)});
os
.
InsertRow
({
"memory_pool_init_size"
,
std
::
to_string
(
memory_pool_init_size_mb_
)
+
"MB"
});
auto
version2string
=
[](
const
std
::
tuple
<
int
,
int
,
int
>
&
ver
)
->
std
::
string
{
std
::
ostringstream
os
;
int
major
=
std
::
get
<
0
>
(
ver
);
int
minor
=
std
::
get
<
1
>
(
ver
);
int
patch
=
std
::
get
<
2
>
(
ver
);
os
<<
major
<<
"."
<<
minor
<<
"."
<<
patch
;
return
os
.
str
();
};
os
.
InsertRow
(
{
"thread_local_stream"
,
thread_local_stream_
?
"true"
:
"false"
});
os
.
InsertRow
({
"use_tensorrt"
,
use_tensorrt_
?
"true"
:
"false"
});
if
(
use_tensorrt_
)
{
{
"trt_compile_version"
,
version2string
(
inference
::
tensorrt
::
GetTrtCompileVersion
())});
os
.
InsertRow
(
{
"trt_runtime_version"
,
version2string
(
inference
::
tensorrt
::
GetTrtRuntimeVersion
())});
os
.
InsertRow
({
"tensorrt_precision_mode"
,
Precision2String
(
tensorrt_precision_mode_
)});
os
.
InsertRow
({
"tensorrt_workspace_size"
,
...
...
@@ -805,6 +827,7 @@ std::string AnalysisConfig::Summary() {
if
(
trt_use_dla_
)
{
os
.
InsertRow
({
"tensorrt_dla_core"
,
std
::
to_string
(
trt_dla_core_
)});
}
#endif
}
}
os
.
InsetDivider
();
...
...
paddle/scripts/paddle_build.sh
浏览文件 @
8c1c72af
...
...
@@ -2388,6 +2388,25 @@ function find_temporary_files() {
fi
}
function
trt_convert_test
()
{
set
+e
cd
${
PADDLE_ROOT
}
result_num
=
0
export
PYTHONPATH
=
$PYTHONPATH
:
${
PADDLE_ROOT
}
/build/python
for
file_name
in
`
find python/
-name
'test_trt_convert*'
`
;
do
echo
"----- test trt ut:
$file_name
-----"
python
$file_name
res
=
$?
if
[
"
$res
"
!=
"0"
]
;
then
echo
"
$file_name
convert test failed "
>
&2
result_num
=
11
fi
done
if
[
"
$result_num
"
!=
"0"
]
;
then
exit
11
fi
}
function
build_pr_and_develop
()
{
cmake_gen_and_build
${
PYTHON_ABI
:-
""
}
${
parallel_number
}
mkdir
${
PADDLE_ROOT
}
/build/pr_whl
&&
cp
${
PADDLE_ROOT
}
/build/python/dist/
*
.whl
${
PADDLE_ROOT
}
/build/pr_whl
...
...
@@ -2656,6 +2675,10 @@ function main() {
test_model_benchmark
)
test_model_benchmark
;;
trt_convert_test
)
# only test trt convert.
trt_convert_test
;;
*
)
print_usage
exit
1
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py
浏览文件 @
8c1c72af
...
...
@@ -15,6 +15,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
import
numpy
as
np
import
unittest
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_fusion.py
浏览文件 @
8c1c72af
...
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertConv2dFusionTest
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py
浏览文件 @
8c1c72af
...
...
@@ -15,6 +15,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
import
numpy
as
np
import
unittest
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d.py
浏览文件 @
8c1c72af
...
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertDepthwiseConv2dTest
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py
浏览文件 @
8c1c72af
...
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertDepthwiseConv2dTransposeTest
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_nearest_interp_v2.py
浏览文件 @
8c1c72af
...
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertNearestInterpV2Test
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reduce_mean.py
浏览文件 @
8c1c72af
...
...
@@ -120,7 +120,7 @@ class TrtConvertReduceMeanTest(TrtLayerAutoScanTest):
attrs
,
False
),
1e-5
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
(
1e-
5
,
1e-5
)
attrs
,
False
),
(
1e-
4
,
1e-4
)
# for dynamic_shape
generate_dynamic_shape
(
attrs
)
...
...
@@ -129,7 +129,7 @@ class TrtConvertReduceMeanTest(TrtLayerAutoScanTest):
True
),
1e-5
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
(
1e-
5
,
1e-5
)
attrs
,
True
),
(
1e-
4
,
1e-4
)
pass
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reduce_sum.py
浏览文件 @
8c1c72af
...
...
@@ -120,7 +120,7 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
attrs
,
False
),
(
1e-5
,
1e-5
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
(
1e-
5
,
1e-5
)
attrs
,
False
),
(
1e-
4
,
1e-4
)
# for dynamic_shape
generate_dynamic_shape
(
attrs
)
...
...
@@ -129,7 +129,7 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
attrs
,
True
),
(
1e-5
,
1e-5
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
(
1e-
5
,
1e-5
)
attrs
,
True
),
(
1e-
4
,
1e-4
)
pass
...
...
python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py
浏览文件 @
8c1c72af
...
...
@@ -122,7 +122,8 @@ class TrtLayerAutoScanTest(AutoScanTest):
"Output has diff between GPU and TensorRT. "
)
def
assert_op_size
(
self
,
trt_engine_num
,
paddle_op_num
):
last_passed_program
=
'transpose_flatten_concat_fuse_pass.pdmodel'
last_passed_program
=
os
.
path
.
join
(
self
.
trt_cache_dir
,
'transpose_flatten_concat_fuse_pass.pdmodel'
)
model_bytes
=
paddle
.
static
.
load_from_file
(
last_passed_program
)
pg
=
paddle
.
static
.
deserialize_program
(
model_bytes
)
main_block
=
pg
.
desc
.
block
(
0
)
...
...
@@ -179,7 +180,8 @@ class TrtLayerAutoScanTest(AutoScanTest):
def
run_test
(
self
,
quant
=
False
):
status
=
True
np
.
random
.
seed
(
int
(
1000
*
time
.
time
())
%
2
**
32
)
# Choose different tests by week
np
.
random
.
seed
(
int
(
time
.
strftime
(
"%W"
)))
run_flags
=
[]
for
prog_config
in
self
.
sample_program_configs
():
# In CI, only run 30% cases
...
...
@@ -283,4 +285,4 @@ class TrtLayerAutoScanTest(AutoScanTest):
self
.
success_log
(
'RUN '
+
str
(
prog_config
)
+
' vs '
+
self
.
inference_config_str
(
pred_config
))
#
self.assertTrue(status)
self
.
assertTrue
(
status
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录