Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
urhero
Paddle
提交
b4b6763a
P
Paddle
项目概览
urhero
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b4b6763a
编写于
4月 12, 2020
作者:
Z
zhongpu
提交者:
GitHub
4月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug for exhaustive_search in conv_fusion_op, test=develop (#23727)
上级
d77bc12e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
43 deletion
+71
-43
paddle/fluid/framework/conv_search_cache.h
paddle/fluid/framework/conv_search_cache.h
+62
-0
paddle/fluid/operators/conv_cudnn_helper.h
paddle/fluid/operators/conv_cudnn_helper.h
+5
-41
paddle/fluid/operators/fused/conv_fusion_op.cu
paddle/fluid/operators/fused/conv_fusion_op.cu
+4
-2
未找到文件。
paddle/fluid/framework/conv_search_cache.h
0 → 100644
浏览文件 @
b4b6763a
/* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator_kernel_configs.h"
#include "paddle/fluid/platform/cudnn_helper.h"
namespace
paddle
{
namespace
framework
{
using
framework
::
AlgorithmsCache
;
// ConvSearchCache using framework::AlgorithmsCache to search
// cudnnConvolutionFwdAlgo_t, cudnnConvolutionBwdDataAlgo_t or
// cudnnConvolutionBwdFilterAlgo_t
class
ConvSearchCache
{
public:
static
ConvSearchCache
&
Instance
()
{
static
ConvSearchCache
instance
;
return
instance
;
}
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>*
GetForward
()
{
return
&
forward_cache_
;
}
AlgorithmsCache
<
cudnnConvolutionBwdDataAlgo_t
>*
GetBackwardData
()
{
return
&
backward_data_cache_
;
}
AlgorithmsCache
<
cudnnConvolutionBwdFilterAlgo_t
>*
GetBackwardFilter
()
{
return
&
backward_filter_cache_
;
}
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>*
GetConvFusion
()
{
return
&
fusion_forward_cache_
;
}
private:
ConvSearchCache
()
{}
~
ConvSearchCache
()
{}
ConvSearchCache
(
const
ConvSearchCache
&
)
{}
ConvSearchCache
&
operator
=
(
const
ConvSearchCache
&
)
{}
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>
forward_cache_
;
AlgorithmsCache
<
cudnnConvolutionBwdDataAlgo_t
>
backward_data_cache_
;
AlgorithmsCache
<
cudnnConvolutionBwdFilterAlgo_t
>
backward_filter_cache_
;
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>
fusion_forward_cache_
;
};
}
// namespace framework
}
// namespace paddle
paddle/fluid/operators/conv_cudnn_helper.h
浏览文件 @
b4b6763a
...
@@ -18,10 +18,10 @@ limitations under the License. */
...
@@ -18,10 +18,10 @@ limitations under the License. */
#include <array>
#include <array>
#include <memory>
#include <memory>
#include <vector>
#include <vector>
#include "paddle/fluid/framework/conv_search_cache.h"
#include "paddle/fluid/framework/operator_kernel_configs.h"
#include "paddle/fluid/framework/operator_kernel_configs.h"
#include "paddle/fluid/operators/conv_cudnn_op_cache.h"
#include "paddle/fluid/operators/conv_cudnn_op_cache.h"
#include "paddle/fluid/platform/cudnn_desc.h"
#include "paddle/fluid/platform/cudnn_desc.h"
// #include "paddle/fluid/platform/device_context.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
@@ -90,43 +90,7 @@ std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
...
@@ -90,43 +90,7 @@ std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
return
out
;
return
out
;
}
}
// ConvSearchCache using framework::AlgorithmsCache to search
using
framework
::
ConvSearchCache
;
// cudnnConvolutionFwdAlgo_t, cudnnConvolutionBwdDataAlgo_t or
// cudnnConvolutionBwdFilterAlgo_t
class
ConvSearchCache
{
public:
static
ConvSearchCache
&
Instance
()
{
static
ConvSearchCache
instance
;
return
instance
;
}
framework
::
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>*
GetForward
()
{
return
&
forward_cache_
;
}
framework
::
AlgorithmsCache
<
cudnnConvolutionBwdDataAlgo_t
>*
GetBackwardData
()
{
return
&
backward_data_cache_
;
}
framework
::
AlgorithmsCache
<
cudnnConvolutionBwdFilterAlgo_t
>*
GetBackwardFilter
()
{
return
&
backward_filter_cache_
;
}
framework
::
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>*
GetConvFusion
()
{
return
&
fusion_forward_cache_
;
}
private:
ConvSearchCache
()
{}
~
ConvSearchCache
()
{}
ConvSearchCache
(
const
ConvSearchCache
&
)
{}
ConvSearchCache
&
operator
=
(
const
ConvSearchCache
&
)
{}
framework
::
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>
forward_cache_
;
framework
::
AlgorithmsCache
<
cudnnConvolutionBwdDataAlgo_t
>
backward_data_cache_
;
framework
::
AlgorithmsCache
<
cudnnConvolutionBwdFilterAlgo_t
>
backward_filter_cache_
;
framework
::
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>
fusion_forward_cache_
;
};
struct
ConvArgs
{
struct
ConvArgs
{
cudnnHandle_t
handle
;
cudnnHandle_t
handle
;
...
@@ -228,7 +192,7 @@ struct SearchAlgorithm<cudnnConvolutionFwdAlgoPerf_t> {
...
@@ -228,7 +192,7 @@ struct SearchAlgorithm<cudnnConvolutionFwdAlgoPerf_t> {
auto
&
temp
=
ctx
.
cuda_device_context
();
auto
&
temp
=
ctx
.
cuda_device_context
();
AlgorithmsCache
<
algo_t
>&
algo_cache
=
AlgorithmsCache
<
algo_t
>&
algo_cache
=
*
(
ConvSearchCache
::
Instance
().
GetForward
());
*
(
framework
::
ConvSearchCache
::
Instance
().
GetForward
());
auto
x_dims
=
framework
::
vectorize
(
args
.
x
->
dims
());
auto
x_dims
=
framework
::
vectorize
(
args
.
x
->
dims
());
auto
w_dims
=
framework
::
vectorize
(
args
.
w
->
dims
());
auto
w_dims
=
framework
::
vectorize
(
args
.
w
->
dims
());
...
@@ -367,7 +331,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdDataAlgoPerf_t> {
...
@@ -367,7 +331,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdDataAlgoPerf_t> {
auto
workspace_handle
=
dev_ctx
.
cudnn_workspace_handle
();
auto
workspace_handle
=
dev_ctx
.
cudnn_workspace_handle
();
AlgorithmsCache
<
algo_t
>&
algo_cache
=
AlgorithmsCache
<
algo_t
>&
algo_cache
=
*
(
ConvSearchCache
::
Instance
().
GetBackwardData
());
*
(
framework
::
ConvSearchCache
::
Instance
().
GetBackwardData
());
auto
x_dims
=
framework
::
vectorize
(
args
.
x
->
dims
());
auto
x_dims
=
framework
::
vectorize
(
args
.
x
->
dims
());
auto
w_dims
=
framework
::
vectorize
(
args
.
w
->
dims
());
auto
w_dims
=
framework
::
vectorize
(
args
.
w
->
dims
());
...
@@ -495,7 +459,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdFilterAlgoPerf_t> {
...
@@ -495,7 +459,7 @@ struct SearchAlgorithm<cudnnConvolutionBwdFilterAlgoPerf_t> {
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
auto
workspace_handle
=
dev_ctx
.
cudnn_workspace_handle
();
auto
workspace_handle
=
dev_ctx
.
cudnn_workspace_handle
();
AlgorithmsCache
<
algo_t
>&
algo_cache
=
AlgorithmsCache
<
algo_t
>&
algo_cache
=
*
(
ConvSearchCache
::
Instance
().
GetBackwardFilter
());
*
(
framework
::
ConvSearchCache
::
Instance
().
GetBackwardFilter
());
auto
x_dims
=
framework
::
vectorize
(
args
.
x
->
dims
());
auto
x_dims
=
framework
::
vectorize
(
args
.
x
->
dims
());
auto
w_dims
=
framework
::
vectorize
(
args
.
w
->
dims
());
auto
w_dims
=
framework
::
vectorize
(
args
.
w
->
dims
());
...
...
paddle/fluid/operators/fused/conv_fusion_op.cu
浏览文件 @
b4b6763a
...
@@ -13,11 +13,12 @@ See the License for the specific language governing permissions and
...
@@ -13,11 +13,12 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include <array>
#include <array>
#include "paddle/fluid/framework/conv_search_cache.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/conv_cudnn_helper.h"
#include "paddle/fluid/operators/conv_cudnn_op_cache.h"
#include "paddle/fluid/operators/conv_cudnn_op_cache.h"
#include "paddle/fluid/operators/conv_op.h"
#include "paddle/fluid/operators/conv_op.h"
#include "paddle/fluid/operators/math/padding.h"
#include "paddle/fluid/operators/math/padding.h"
#include "paddle/fluid/platform/cudnn_helper.h"
DECLARE_int64
(
cudnn_exhaustive_search_times
);
DECLARE_int64
(
cudnn_exhaustive_search_times
);
...
@@ -32,6 +33,7 @@ using ScopedConvolutionDescriptor = platform::ScopedConvolutionDescriptor;
...
@@ -32,6 +33,7 @@ using ScopedConvolutionDescriptor = platform::ScopedConvolutionDescriptor;
using
ScopedActivationDescriptor
=
platform
::
ScopedActivationDescriptor
;
using
ScopedActivationDescriptor
=
platform
::
ScopedActivationDescriptor
;
using
DataLayout
=
platform
::
DataLayout
;
using
DataLayout
=
platform
::
DataLayout
;
using
framework
::
AlgorithmsCache
;
using
framework
::
AlgorithmsCache
;
using
framework
::
ConvSearchCache
;
template
<
typename
T
>
template
<
typename
T
>
using
ScalingParamType
=
typename
platform
::
CudnnDataType
<
T
>::
ScalingParamType
;
using
ScalingParamType
=
typename
platform
::
CudnnDataType
<
T
>::
ScalingParamType
;
...
@@ -233,7 +235,7 @@ class CUDNNConvFusionOpKernel : public framework::OpKernel<T> {
...
@@ -233,7 +235,7 @@ class CUDNNConvFusionOpKernel : public framework::OpKernel<T> {
return
fwd_perf_stat
[
0
].
algo
;
return
fwd_perf_stat
[
0
].
algo
;
};
};
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>&
algo_cache
=
AlgorithmsCache
<
cudnnConvolutionFwdAlgo_t
>&
algo_cache
=
*
(
ConvSearchCache
::
Instance
().
GetConvFusion
());
*
(
framework
::
ConvSearchCache
::
Instance
().
GetConvFusion
());
int
search_times
=
ctx
.
Attr
<
int
>
(
"search_times"
);
int
search_times
=
ctx
.
Attr
<
int
>
(
"search_times"
);
search_times
=
std
::
max
(
search_times
=
std
::
max
(
static_cast
<
int
>
(
FLAGS_cudnn_exhaustive_search_times
),
search_times
);
static_cast
<
int
>
(
FLAGS_cudnn_exhaustive_search_times
),
search_times
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录