Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
12d04ab2
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看板
未验证
提交
12d04ab2
编写于
6月 07, 2023
作者:
Y
Yuanle Liu
提交者:
GitHub
6月 07, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance mixed precision check (#54413)
上级
77f62c48
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
17 deletion
+29
-17
paddle/fluid/inference/api/analysis_config.cc
paddle/fluid/inference/api/analysis_config.cc
+7
-11
paddle/fluid/inference/api/helper.h
paddle/fluid/inference/api/helper.h
+14
-0
paddle/ir/pass/ir_printing.cc
paddle/ir/pass/ir_printing.cc
+4
-4
paddle/ir/pass/pass_manager.h
paddle/ir/pass/pass_manager.h
+3
-2
paddle/ir/pass/pass_timing.cc
paddle/ir/pass/pass_timing.cc
+1
-0
未找到文件。
paddle/fluid/inference/api/analysis_config.cc
浏览文件 @
12d04ab2
...
...
@@ -109,6 +109,10 @@ void AnalysisConfig::EnableUseGpu(uint64_t memory_pool_init_size_mb,
mixed_precision_mode_
=
precision_mode
;
}
else
if
(
precision_mode
==
Precision
::
kHalf
||
precision_mode
==
Precision
::
kBf16
)
{
if
(
precision_mode
==
Precision
::
kBf16
)
{
LOG
(
WARNING
)
<<
"Some op (matmul, conv, etc.) run at bfloat16 precision "
"requires GPU compute capability >= 80."
;
}
enable_gpu_mixed_
=
true
;
mixed_precision_mode_
=
precision_mode
;
}
else
{
...
...
@@ -1244,6 +1248,8 @@ std::string AnalysisConfig::Summary() {
os
.
InsertRow
({
"use_cutlass"
,
use_cutlass_
?
"true"
:
"false"
});
os
.
InsertRow
({
"gpu_device_id"
,
std
::
to_string
(
gpu_device_id_
)});
os
.
InsertRow
({
"enable_gpu_mixed"
,
std
::
to_string
(
enable_gpu_mixed_
)});
os
.
InsertRow
({
"mixed_precision_mode"
,
inference
::
Precision2String
(
mixed_precision_mode_
)});
os
.
InsertRow
({
"memory_pool_init_size"
,
std
::
to_string
(
memory_pool_init_size_mb_
)
+
"MB"
});
os
.
InsertRow
(
...
...
@@ -1254,16 +1260,6 @@ std::string AnalysisConfig::Summary() {
os
.
InsertRow
({
"use_tensorrt"
,
use_tensorrt_
?
"true"
:
"false"
});
if
(
use_tensorrt_
)
{
#ifdef PADDLE_WITH_TENSORRT
auto
Precision2String
=
[](
Precision
prec
)
->
std
::
string
{
if
(
prec
==
Precision
::
kFloat32
)
return
"fp32"
;
else
if
(
prec
==
Precision
::
kHalf
)
return
"fp16"
;
else
if
(
prec
==
Precision
::
kInt8
)
return
"int8"
;
else
return
"None"
;
};
auto
version2string
=
[](
const
std
::
tuple
<
int
,
int
,
int
>
&
ver
)
->
std
::
string
{
std
::
ostringstream
os
;
...
...
@@ -1280,7 +1276,7 @@ std::string AnalysisConfig::Summary() {
{
"trt_runtime_version"
,
version2string
(
inference
::
tensorrt
::
GetTrtRuntimeVersion
())});
os
.
InsertRow
({
"tensorrt_precision_mode"
,
Precision2String
(
tensorrt_precision_mode_
)});
inference
::
Precision2String
(
tensorrt_precision_mode_
)});
os
.
InsertRow
({
"tensorrt_workspace_size"
,
std
::
to_string
(
tensorrt_workspace_size_
)});
os
.
InsertRow
(
...
...
paddle/fluid/inference/api/helper.h
浏览文件 @
12d04ab2
...
...
@@ -30,6 +30,7 @@
#include <vector>
#include "paddle/fluid/framework/data_type.h"
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#include "paddle/fluid/memory/stats.h"
#include "paddle/fluid/platform/enforce.h"
...
...
@@ -473,5 +474,18 @@ static inline void DisplayMemoryInfo(platform::Place place,
<<
"MB]"
;
}
static
std
::
string
Precision2String
(
AnalysisConfig
::
Precision
precison
)
{
if
(
precison
==
AnalysisConfig
::
Precision
::
kFloat32
)
return
"fp32"
;
else
if
(
precison
==
AnalysisConfig
::
Precision
::
kHalf
)
return
"fp16"
;
else
if
(
precison
==
AnalysisConfig
::
Precision
::
kInt8
)
return
"int8"
;
else
if
(
precison
==
AnalysisConfig
::
Precision
::
kBf16
)
return
"bf16"
;
else
return
"none"
;
}
}
// namespace inference
}
// namespace paddle
paddle/ir/pass/ir_printing.cc
浏览文件 @
12d04ab2
...
...
@@ -48,7 +48,7 @@ class IRPrinting : public PassInstrumentation {
~
IRPrinting
()
=
default
;
void
RunBeforePass
(
Pass
*
pass
,
Operation
*
op
)
override
{
if
(
option_
->
EnablePrintOnC
hange
())
{
if
(
option_
->
print_on_c
hange
())
{
// TODO(liuyuanle): support print on change
}
...
...
@@ -56,13 +56,13 @@ class IRPrinting : public PassInstrumentation {
std
::
string
header
=
"IRPrinting on "
+
op
->
name
()
+
" before "
+
pass
->
name
()
+
" pass"
;
detail
::
PrintHeader
(
header
,
os
);
PrintIR
(
op
,
option_
->
EnablePrintM
odule
(),
os
);
PrintIR
(
op
,
option_
->
print_m
odule
(),
os
);
os
<<
"
\n\n
"
;
});
}
void
RunAfterPass
(
Pass
*
pass
,
Operation
*
op
)
override
{
if
(
option_
->
EnablePrintOnC
hange
())
{
if
(
option_
->
print_on_c
hange
())
{
// TODO(liuyuanle): support print on change
}
...
...
@@ -70,7 +70,7 @@ class IRPrinting : public PassInstrumentation {
std
::
string
header
=
"IRPrinting on "
+
op
->
name
()
+
" after "
+
pass
->
name
()
+
" pass"
;
detail
::
PrintHeader
(
header
,
os
);
PrintIR
(
op
,
option_
->
EnablePrintM
odule
(),
os
);
PrintIR
(
op
,
option_
->
print_m
odule
(),
os
);
os
<<
"
\n\n
"
;
});
}
...
...
paddle/ir/pass/pass_manager.h
浏览文件 @
12d04ab2
...
...
@@ -91,9 +91,9 @@ class PassManager {
}
}
bool
EnablePrintM
odule
()
const
{
return
print_module_
;
}
bool
print_m
odule
()
const
{
return
print_module_
;
}
bool
EnablePrintOnC
hange
()
const
{
return
print_on_change_
;
}
bool
print_on_c
hange
()
const
{
return
print_on_change_
;
}
private:
// The enable_print_before_ and enable_print_after_ can be used to specify
...
...
@@ -102,6 +102,7 @@ class PassManager {
std
::
function
<
bool
(
Pass
*
,
Operation
*
)
>
enable_print_after_
;
bool
print_module_
;
bool
print_on_change_
;
std
::
ostream
&
os
;
...
...
paddle/ir/pass/pass_timing.cc
浏览文件 @
12d04ab2
...
...
@@ -23,6 +23,7 @@
#include "paddle/ir/pass/pass_instrumentation.h"
#include "paddle/ir/pass/pass_manager.h"
#include "paddle/ir/pass/utils.h"
namespace
ir
{
namespace
{
class
Timer
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录