Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
afd5a96b
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看板
未验证
提交
afd5a96b
编写于
10月 25, 2022
作者:
H
HongyuJia
提交者:
GitHub
10月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt conv_transpose cudnn (#47294)
上级
3e7abca5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
49 deletion
+24
-49
paddle/fluid/operators/conv_transpose_op.cc
paddle/fluid/operators/conv_transpose_op.cc
+22
-47
paddle/fluid/platform/device/gpu/cuda/cudnn_helper.h
paddle/fluid/platform/device/gpu/cuda/cudnn_helper.h
+1
-1
paddle/fluid/platform/device/gpu/rocm/miopen_helper.h
paddle/fluid/platform/device/gpu/rocm/miopen_helper.h
+1
-1
未找到文件。
paddle/fluid/operators/conv_transpose_op.cc
浏览文件 @
afd5a96b
...
@@ -28,6 +28,9 @@ limitations under the License. */
...
@@ -28,6 +28,9 @@ limitations under the License. */
#ifdef PADDLE_WITH_MKLDNN
#ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h"
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
#endif
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#endif
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
@@ -38,15 +41,11 @@ framework::OpKernelType ConvTransposeOp::GetExpectedKernelType(
...
@@ -38,15 +41,11 @@ framework::OpKernelType ConvTransposeOp::GetExpectedKernelType(
const
framework
::
ExecutionContext
&
ctx
)
const
{
const
framework
::
ExecutionContext
&
ctx
)
const
{
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
if
(
platform
::
is_gpu_place
(
ctx
.
GetPlace
()))
{
if
(
platform
::
CanCUDNNBeUsed
(
ctx
))
{
auto
&
dev_ctx
=
ctx
.
template
device_context
<
phi
::
GPUContext
>();
return
framework
::
OpKernelType
(
data_type
,
if
(
ctx
.
HasAttr
(
"use_cudnn"
)
&&
ctx
.
Attr
<
bool
>
(
"use_cudnn"
)
&&
ctx
.
GetPlace
(),
dev_ctx
.
cudnn_handle
()
!=
nullptr
)
{
phi
::
DataLayout
::
kAnyLayout
,
return
framework
::
OpKernelType
(
data_type
,
framework
::
LibraryType
::
kCUDNN
);
ctx
.
GetPlace
(),
phi
::
DataLayout
::
kAnyLayout
,
framework
::
LibraryType
::
kCUDNN
);
}
}
}
#endif
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
...
@@ -268,28 +267,16 @@ Example:
...
@@ -268,28 +267,16 @@ Example:
framework
::
OpKernelType
ConvTransposeOpGrad
::
GetExpectedKernelType
(
framework
::
OpKernelType
ConvTransposeOpGrad
::
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
const
framework
::
ExecutionContext
&
ctx
)
const
{
bool
use_cudnn
=
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
ctx
.
HasAttr
(
"use_cudnn"
)
?
ctx
.
Attr
<
bool
>
(
"use_cudnn"
)
:
false
;
use_cudnn
&=
platform
::
is_gpu_place
(
ctx
.
GetPlace
());
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
if
(
platform
::
is_gpu_place
(
ctx
.
GetPlace
()))
{
if
(
platform
::
CanCUDNNBeUsed
(
ctx
))
{
auto
&
dev_ctx
=
ctx
.
template
device_context
<
phi
::
GPUContext
>();
return
framework
::
OpKernelType
(
data_type
,
use_cudnn
&=
dev_ctx
.
cudnn_handle
()
!=
nullptr
;
ctx
.
GetPlace
(),
phi
::
DataLayout
::
kAnyLayout
,
framework
::
LibraryType
::
kCUDNN
);
}
}
#endif
#endif
framework
::
LibraryType
library_
;
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
if
(
use_cudnn
)
{
library_
=
framework
::
LibraryType
::
kCUDNN
;
}
else
{
library_
=
framework
::
LibraryType
::
kPlain
;
}
phi
::
DataLayout
layout_
=
phi
::
DataLayout
::
kAnyLayout
;
return
framework
::
OpKernelType
(
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
),
ctx
.
GetPlace
(),
layout_
,
library_
);
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -355,28 +342,16 @@ class ConvTransposeDoubleGradMaker : public framework::SingleGradOpMaker<T> {
...
@@ -355,28 +342,16 @@ class ConvTransposeDoubleGradMaker : public framework::SingleGradOpMaker<T> {
framework
::
OpKernelType
ConvTransposeOpDoubleGrad
::
GetExpectedKernelType
(
framework
::
OpKernelType
ConvTransposeOpDoubleGrad
::
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
const
framework
::
ExecutionContext
&
ctx
)
const
{
bool
use_cudnn
=
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
ctx
.
HasAttr
(
"use_cudnn"
)
?
ctx
.
Attr
<
bool
>
(
"use_cudnn"
)
:
false
;
use_cudnn
&=
platform
::
is_gpu_place
(
ctx
.
GetPlace
());
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
if
(
platform
::
is_gpu_place
(
ctx
.
GetPlace
()))
{
if
(
platform
::
CanCUDNNBeUsed
(
ctx
))
{
auto
&
dev_ctx
=
ctx
.
template
device_context
<
phi
::
GPUContext
>();
return
framework
::
OpKernelType
(
data_type
,
use_cudnn
&=
dev_ctx
.
cudnn_handle
()
!=
nullptr
;
ctx
.
GetPlace
(),
phi
::
DataLayout
::
kAnyLayout
,
framework
::
LibraryType
::
kCUDNN
);
}
}
#endif
#endif
framework
::
LibraryType
library_
;
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
if
(
use_cudnn
)
{
library_
=
framework
::
LibraryType
::
kCUDNN
;
}
else
{
library_
=
framework
::
LibraryType
::
kPlain
;
}
phi
::
DataLayout
layout_
=
phi
::
DataLayout
::
kAnyLayout
;
return
framework
::
OpKernelType
(
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
),
ctx
.
GetPlace
(),
layout_
,
library_
);
}
}
}
// namespace operators
}
// namespace operators
...
...
paddle/fluid/platform/device/gpu/cuda/cudnn_helper.h
浏览文件 @
afd5a96b
...
@@ -617,7 +617,7 @@ class ScopedActivationDescriptor {
...
@@ -617,7 +617,7 @@ class ScopedActivationDescriptor {
};
};
inline
bool
CanCUDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
{
inline
bool
CanCUDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
{
bool
use_cudnn
=
ctx
.
Attr
<
bool
>
(
"use_cudnn"
);
bool
use_cudnn
=
ctx
.
HasAttr
(
"use_cudnn"
)
&&
ctx
.
Attr
<
bool
>
(
"use_cudnn"
);
use_cudnn
&=
paddle
::
platform
::
is_gpu_place
(
ctx
.
GetPlace
());
use_cudnn
&=
paddle
::
platform
::
is_gpu_place
(
ctx
.
GetPlace
());
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
if
(
use_cudnn
)
{
if
(
use_cudnn
)
{
...
...
paddle/fluid/platform/device/gpu/rocm/miopen_helper.h
浏览文件 @
afd5a96b
...
@@ -554,7 +554,7 @@ class ScopedActivationDescriptor {
...
@@ -554,7 +554,7 @@ class ScopedActivationDescriptor {
};
};
inline
bool
CanCUDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
{
inline
bool
CanCUDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
{
bool
use_cudnn
=
ctx
.
Attr
<
bool
>
(
"use_cudnn"
);
bool
use_cudnn
=
ctx
.
HasAttr
(
"use_cudnn"
)
&&
ctx
.
Attr
<
bool
>
(
"use_cudnn"
);
use_cudnn
&=
paddle
::
platform
::
is_gpu_place
(
ctx
.
GetPlace
());
use_cudnn
&=
paddle
::
platform
::
is_gpu_place
(
ctx
.
GetPlace
());
#ifdef PADDLE_WITH_HIP
#ifdef PADDLE_WITH_HIP
if
(
use_cudnn
)
{
if
(
use_cudnn
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录