Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c79fa1c3
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
c79fa1c3
编写于
8月 04, 2021
作者:
L
Lijunhui
提交者:
GitHub
8月 04, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set Tensor Core MathType for bfloat16 in conv using cudnn (#34409)
上级
56b7ebbc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
68 deletion
+39
-68
paddle/fluid/operators/conv_cudnn_helper.h
paddle/fluid/operators/conv_cudnn_helper.h
+32
-67
paddle/fluid/platform/cudnn_desc.h
paddle/fluid/platform/cudnn_desc.h
+7
-1
未找到文件。
paddle/fluid/operators/conv_cudnn_helper.h
浏览文件 @
c79fa1c3
...
@@ -169,6 +169,35 @@ void ChooseAlgo(const std::vector<PerfType>& perf_results,
...
@@ -169,6 +169,35 @@ void ChooseAlgo(const std::vector<PerfType>& perf_results,
using
framework
::
ConvSearchCache
;
using
framework
::
ConvSearchCache
;
static
void
SetConvMathType
(
const
framework
::
ExecutionContext
&
ctx
,
cudnnDataType_t
dtype
,
const
platform
::
ConvolutionDescriptor
&
cdesc
)
{
#if CUDA_VERSION >= 9000 && CUDNN_VERSION_MIN(7, 0, 1)
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
if
(
dev_ctx
.
GetComputeCapability
()
>=
70
&&
dtype
==
CUDNN_DATA_HALF
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
cdesc
.
desc
(),
CUDNN_TENSOR_OP_MATH
));
VLOG
(
5
)
<<
"use cudnn_tensor_op_math"
;
#if CUDA_VERSION >= 11000
#if CUDNN_VERSION_MIN(8, 1, 0)
}
else
if
(
dev_ctx
.
GetComputeCapability
()
>=
80
&&
dtype
==
CUDNN_DATA_BFLOAT16
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
cdesc
.
desc
(),
CUDNN_TENSOR_OP_MATH
));
#endif // CUDNN_VERSION_MIN(8, 1, 0)
}
else
if
(
dtype
==
CUDNN_DATA_FLOAT
&&
!
cdesc
.
allow_tf32_
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
cdesc
.
desc
(),
CUDNN_FMA_MATH
));
#endif // CUDA_VERSION >= 11000
}
else
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
cdesc
.
desc
(),
CUDNN_DEFAULT_MATH
));
VLOG
(
5
)
<<
"NOT use cudnn_tensor_op_math"
;
}
#endif
return
;
}
struct
ConvArgs
{
struct
ConvArgs
{
cudnnHandle_t
handle
;
cudnnHandle_t
handle
;
platform
::
TensorDescriptor
idesc
,
odesc
;
platform
::
TensorDescriptor
idesc
,
odesc
;
...
@@ -208,36 +237,7 @@ struct SearchAlgorithm<cudnnConvolutionFwdAlgoPerf_t> {
...
@@ -208,36 +237,7 @@ struct SearchAlgorithm<cudnnConvolutionFwdAlgoPerf_t> {
size_t
workspace_size_limit
=
FLAGS_conv_workspace_size_limit
*
1024
*
1024
;
size_t
workspace_size_limit
=
FLAGS_conv_workspace_size_limit
*
1024
*
1024
;
size_t
workspace_size
=
0
;
size_t
workspace_size
=
0
;
algo_t
algo
;
algo_t
algo
;
SetConvMathType
(
ctx
,
dtype
,
args
.
cdesc
);
#if CUDA_VERSION >= 9000 && CUDNN_VERSION_MIN(7, 0, 1)
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
if
(
dev_ctx
.
GetComputeCapability
()
>=
70
&&
dtype
==
CUDNN_DATA_HALF
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_TENSOR_OP_MATH
));
VLOG
(
5
)
<<
"use cudnn_tensor_op_math"
;
#if CUDA_VERSION >= 11000
#if CUDNN_VERSION_MIN(8, 1, 0)
}
else
if
(
dev_ctx
.
GetComputeCapability
()
>=
80
&&
dtype
==
CUDNN_DATA_BFLOAT16
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_TENSOR_OP_MATH
));
VLOG
(
5
)
<<
"use cudnn_tensor_op_math"
;
#endif // CUDNN_VERSION >= 8100
}
else
if
(
dtype
==
CUDNN_DATA_FLOAT
&&
!
args
.
cdesc
.
allow_tf32_
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_FMA_MATH
));
VLOG
(
5
)
<<
"use cudnn_fma_math"
;
#endif // CUDA_VERSION >= 11000
}
else
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_DEFAULT_MATH
));
VLOG
(
5
)
<<
"use cudnn_default_math"
;
}
#endif
if
(
!
exhaustive_search
&&
!
deterministic
)
{
if
(
!
exhaustive_search
&&
!
deterministic
)
{
#if CUDNN_VERSION >= 7001
#if CUDNN_VERSION >= 7001
...
@@ -353,24 +353,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdDataAlgoPerf_t> {
...
@@ -353,24 +353,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdDataAlgoPerf_t> {
size_t
workspace_size
=
0
;
size_t
workspace_size
=
0
;
bool
has_got_workspace_size
=
true
;
bool
has_got_workspace_size
=
true
;
algo_t
algo
;
algo_t
algo
;
#if CUDA_VERSION >= 9000 && CUDNN_VERSION_MIN(7, 0, 1)
SetConvMathType
(
ctx
,
dtype
,
args
.
cdesc
);
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_DEFAULT_MATH
));
VLOG
(
5
)
<<
"NOT use cudnn_tensor_op_math"
;
if
(
dev_ctx
.
GetComputeCapability
()
>=
70
&&
dtype
==
CUDNN_DATA_HALF
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_TENSOR_OP_MATH
));
VLOG
(
5
)
<<
"use cudnn_tensor_op_math"
;
}
else
if
(
dtype
==
CUDNN_DATA_FLOAT
&&
!
args
.
cdesc
.
allow_tf32_
)
{
#if CUDA_VERSION >= 11000
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_FMA_MATH
));
#endif // CUDA_VERSION >= 11000
}
#endif
if
(
!
exhaustive_search
&&
!
deterministic
)
{
if
(
!
exhaustive_search
&&
!
deterministic
)
{
#if CUDNN_VERSION >= 7001
#if CUDNN_VERSION >= 7001
...
@@ -501,25 +484,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdFilterAlgoPerf_t> {
...
@@ -501,25 +484,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdFilterAlgoPerf_t> {
size_t
workspace_size_limit
=
FLAGS_conv_workspace_size_limit
*
1024
*
1024
;
size_t
workspace_size_limit
=
FLAGS_conv_workspace_size_limit
*
1024
*
1024
;
size_t
workspace_size
=
0
;
size_t
workspace_size
=
0
;
bool
has_got_workspace_size
=
true
;
bool
has_got_workspace_size
=
true
;
SetConvMathType
(
ctx
,
dtype
,
args
.
cdesc
);
#if CUDA_VERSION >= 9000 && CUDNN_VERSION_MIN(7, 0, 1)
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_DEFAULT_MATH
));
VLOG
(
5
)
<<
"NOT use cudnn_tensor_op_math"
;
if
(
dev_ctx
.
GetComputeCapability
()
>=
70
&&
dtype
==
CUDNN_DATA_HALF
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_TENSOR_OP_MATH
));
VLOG
(
5
)
<<
"use cudnn_tensor_op_math"
;
}
else
if
(
dtype
==
CUDNN_DATA_FLOAT
&&
!
args
.
cdesc
.
allow_tf32_
)
{
#if CUDA_VERSION >= 11000
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
args
.
cdesc
.
desc
(),
CUDNN_FMA_MATH
));
#endif // CUDA_VERSION >= 11000
}
#endif
algo_t
algo
;
algo_t
algo
;
if
(
!
exhaustive_search
&&
!
deterministic
)
{
if
(
!
exhaustive_search
&&
!
deterministic
)
{
...
...
paddle/fluid/platform/cudnn_desc.h
浏览文件 @
c79fa1c3
...
@@ -253,8 +253,14 @@ class ConvolutionDescriptor {
...
@@ -253,8 +253,14 @@ class ConvolutionDescriptor {
PADDLE_ENFORCE_CUDA_SUCCESS
(
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
desc
,
platform
::
dynload
::
cudnnSetConvolutionMathType
(
desc
,
CUDNN_TENSOR_OP_MATH
));
CUDNN_TENSOR_OP_MATH
));
}
else
if
(
dtype
==
CUDNN_DATA_FLOAT
&&
!
allow_tf32
)
{
#if CUDA_VERSION >= 11000
#if CUDA_VERSION >= 11000
#if CUDNN_VERSION_MIN(8, 1, 0)
}
else
if
(
dtype
==
CUDNN_DATA_BFLOAT16
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
desc
,
CUDNN_TENSOR_OP_MATH
));
#endif // CUDNN_VERSION_MIN(8,1,0)
}
else
if
(
dtype
==
CUDNN_DATA_FLOAT
&&
!
allow_tf32
)
{
PADDLE_ENFORCE_CUDA_SUCCESS
(
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnSetConvolutionMathType
(
desc
,
CUDNN_FMA_MATH
));
platform
::
dynload
::
cudnnSetConvolutionMathType
(
desc
,
CUDNN_FMA_MATH
));
#endif // CUDA_VERSION >= 11000
#endif // CUDA_VERSION >= 11000
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录