Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
806b252c
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看板
未验证
提交
806b252c
编写于
9月 28, 2022
作者:
L
limingshu
提交者:
GitHub
9月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first commit (#46525)
上级
45df9be8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
25 deletion
+29
-25
paddle/fluid/operators/transpose_op.cu.h
paddle/fluid/operators/transpose_op.cu.h
+1
-2
paddle/phi/kernels/autotune/auto_tune_base.h
paddle/phi/kernels/autotune/auto_tune_base.h
+28
-23
未找到文件。
paddle/fluid/operators/transpose_op.cu.h
浏览文件 @
806b252c
...
@@ -1196,8 +1196,7 @@ void TransposeGPUKernelDriver(const phi::GPUContext& ctx,
...
@@ -1196,8 +1196,7 @@ void TransposeGPUKernelDriver(const phi::GPUContext& ctx,
if
(
!
ret
)
{
if
(
!
ret
)
{
auto
*
tuner
=
auto
*
tuner
=
phi
::
autotune
::
MakeTransposeTuner
<
T
>
(
TransCompute
<
phi
::
GPUContext
,
T
>
);
phi
::
autotune
::
MakeTransposeTuner
<
T
>
(
TransCompute
<
phi
::
GPUContext
,
T
>
);
tuner
->
AddCallBack
(
tuner
->
AddCallBack
(
SimplifyThenLaunch
<
phi
::
GPUContext
,
T
>
);
phi
::
autotune
::
MakeCallback
<
T
>
(
SimplifyThenLaunch
<
phi
::
GPUContext
,
T
>
));
size_t
key
=
phi
::
autotune
::
TransposeKey
(
size_t
key
=
phi
::
autotune
::
TransposeKey
(
phi
::
vectorize
(
in
.
dims
()),
phi
::
vectorize
(
in
.
dims
()),
...
...
paddle/phi/kernels/autotune/auto_tune_base.h
浏览文件 @
806b252c
...
@@ -22,26 +22,26 @@
...
@@ -22,26 +22,26 @@
namespace
phi
{
namespace
phi
{
namespace
autotune
{
namespace
autotune
{
template
<
typename
T
,
typename
Retur
e
Type
,
typename
...
Args
>
template
<
typename
T
,
typename
Retur
n
Type
,
typename
...
Args
>
class
KernelCallback
{
class
KernelCallback
{
public:
public:
using
ReturnT
=
Retur
e
Type
;
using
ReturnT
=
Retur
n
Type
;
using
FuncType
=
Retur
e
Type
(
*
)(
Args
...);
using
FuncType
=
Retur
n
Type
(
*
)(
Args
...);
KernelCallback
()
{}
KernelCallback
()
{}
explicit
KernelCallback
(
FuncType
func_
)
:
func
(
func_
)
{}
explicit
KernelCallback
(
FuncType
func_
)
:
func
(
func_
)
{}
virtual
~
KernelCallback
()
{}
virtual
~
KernelCallback
()
{}
Retur
e
Type
Run
(
Args
...
args
)
{
return
func
(
args
...);
}
Retur
n
Type
Run
(
Args
...
args
)
{
return
func
(
args
...);
}
private:
private:
FuncType
func
;
FuncType
func
;
};
};
template
<
typename
T
,
typename
Retur
e
Type
,
typename
...
Args
>
template
<
typename
T
,
typename
Retur
n
Type
,
typename
...
Args
>
static
KernelCallback
<
T
,
Retur
e
Type
,
Args
...
>
MakeCallback
(
static
KernelCallback
<
T
,
Retur
n
Type
,
Args
...
>
MakeCallback
(
Retur
e
Type
(
*
cb
)(
Args
...))
{
Retur
n
Type
(
*
cb
)(
Args
...))
{
return
KernelCallback
<
T
,
Retur
e
Type
,
Args
...
>
(
cb
);
return
KernelCallback
<
T
,
Retur
n
Type
,
Args
...
>
(
cb
);
}
}
template
<
typename
T
,
typename
KernelType
>
template
<
typename
T
,
typename
KernelType
>
...
@@ -54,10 +54,11 @@ class AutoTuneBase {
...
@@ -54,10 +54,11 @@ class AutoTuneBase {
kernels_
.
push_back
(
/*default=*/
kernel
);
kernels_
.
push_back
(
/*default=*/
kernel
);
}
}
void
AddCallBack
(
KernelType
kernel
)
{
template
<
typename
ReturnType
,
typename
...
Args
>
void
AddCallBack
(
ReturnType
(
*
func
)(
Args
...))
{
if
(
!
is_init_
)
{
if
(
!
is_init_
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
kernels_
.
push_back
(
kernel
);
kernels_
.
push_back
(
MakeCallback
<
T
>
(
func
)
);
}
}
}
}
...
@@ -142,31 +143,35 @@ class AutoTuneBase {
...
@@ -142,31 +143,35 @@ class AutoTuneBase {
}
}
};
};
template
<
typename
T
,
typename
Retur
e
Type
,
typename
...
Args
>
template
<
typename
T
,
typename
Retur
n
Type
,
typename
...
Args
>
static
AutoTuneBase
<
T
,
KernelCallback
<
T
,
Retur
e
Type
,
Args
...
>>
MakeAutoTuner
(
static
AutoTuneBase
<
T
,
KernelCallback
<
T
,
Retur
n
Type
,
Args
...
>>
MakeAutoTuner
(
Retur
e
Type
(
*
func
)(
Args
...))
{
Retur
n
Type
(
*
func
)(
Args
...))
{
auto
obj
=
MakeCallback
<
T
>
(
func
);
auto
obj
=
MakeCallback
<
T
>
(
func
);
return
AutoTuneBase
<
T
,
decltype
(
obj
)
>
(
obj
);
return
AutoTuneBase
<
T
,
decltype
(
obj
)
>
(
obj
);
}
}
template
<
typename
T
,
typename
KernelType
>
template
<
typename
T
,
typename
ReturnType
,
typename
...
Args
>
class
TransposeAutoTuner
:
public
AutoTuneBase
<
T
,
KernelType
>
{
class
TransposeAutoTuner
:
public
AutoTuneBase
<
T
,
KernelCallback
<
T
,
ReturnType
,
Args
...
>>
{
public:
public:
static
AutoTuneBase
<
T
,
KernelType
>*
Instance
(
KernelType
kernel
)
{
static
AutoTuneBase
<
T
,
KernelCallback
<
T
,
ReturnType
,
Args
...
>>*
Instance
(
ReturnType
(
*
func
)(
Args
...))
{
static
std
::
once_flag
transpose_init_flag_
;
static
std
::
once_flag
transpose_init_flag_
;
static
std
::
unique_ptr
<
AutoTuneBase
<
T
,
KernelType
>>
instance_
;
static
std
::
unique_ptr
<
AutoTuneBase
<
T
,
KernelCallback
<
T
,
ReturnType
,
Args
...
>>>
instance_
;
std
::
call_once
(
transpose_init_flag_
,
[
&
]
{
std
::
call_once
(
transpose_init_flag_
,
[
&
]
{
instance_
.
reset
(
new
AutoTuneBase
<
T
,
KernelType
>
(
kernel
));
auto
obj
=
MakeCallback
<
T
>
(
func
);
instance_
.
reset
(
new
AutoTuneBase
<
T
,
decltype
(
obj
)
>
(
obj
));
});
});
return
instance_
.
get
();
return
instance_
.
get
();
}
}
};
};
template
<
typename
T
,
typename
RetureType
,
typename
...
Args
>
template
<
typename
T
,
typename
ReturnType
,
typename
...
Args
>
static
AutoTuneBase
<
T
,
KernelCallback
<
T
,
RetureType
,
Args
...
>>*
static
AutoTuneBase
<
T
,
KernelCallback
<
T
,
ReturnType
,
Args
...
>>*
MakeTransposeTuner
(
RetureType
(
*
func
)(
Args
...))
{
MakeTransposeTuner
(
ReturnType
(
*
func
)(
Args
...))
{
auto
obj
=
MakeCallback
<
T
>
(
func
);
return
TransposeAutoTuner
<
T
,
ReturnType
,
Args
...
>::
Instance
(
func
);
return
TransposeAutoTuner
<
T
,
decltype
(
obj
)
>::
Instance
(
obj
);
}
}
}
// namespace autotune
}
// namespace autotune
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录