Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
86d92092
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看板
未验证
提交
86d92092
编写于
11月 28, 2022
作者:
MarDino
提交者:
GitHub
11月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use phi layernorm (#48276)
上级
d7540a4a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
7 deletion
+30
-7
paddle/fluid/operators/fused/fused_dropout_helper.h
paddle/fluid/operators/fused/fused_dropout_helper.h
+29
-7
paddle/phi/kernels/gpu/layer_norm_kernel.cu
paddle/phi/kernels/gpu/layer_norm_kernel.cu
+1
-0
未找到文件。
paddle/fluid/operators/fused/fused_dropout_helper.h
浏览文件 @
86d92092
...
...
@@ -20,6 +20,7 @@ limitations under the License. */
#include "paddle/fluid/operators/fused/fused_layernorm_residual_dropout_bias.h"
#include "paddle/fluid/operators/fused/fused_residual_dropout_bias.h"
#include "paddle/phi/kernels/funcs/functors.h"
#include "paddle/phi/kernels/layer_norm_kernel.h"
DECLARE_bool
(
use_fast_math
);
...
...
@@ -347,6 +348,18 @@ class FusedDropoutHelper {
DropoutParam
dropout_param_
;
};
template
<
typename
T
>
struct
PDDataTypeTraits
{
using
DataType
=
T
;
};
template
<
>
struct
PDDataTypeTraits
<
phi
::
dtype
::
float16
>
{
// Since LayerNormDirectCUDAFunctor register half type, we need to convert
// phi::float16 to half.
using
DataType
=
half
;
};
template
<
typename
T
,
typename
MaskType
,
typename
InType
=
T
,
...
...
@@ -383,13 +396,22 @@ class FusedDropoutLayerNormHelper
OutType
*
out
,
LayerNormParamType
<
T
>*
mean
,
LayerNormParamType
<
T
>*
variance
)
{
using
U
=
LayerNormParamType
<
T
>
;
switch
(
GetDesiredBlockDim
(
this
->
cols_
))
{
FIXED_BLOCK_DIM_CASE
(
LayerNormForward
<
T
,
U
,
kBlockDim
,
false
,
InType
,
OutType
>
<<<
this
->
rows_
,
kBlockDim
,
0
,
ctx
.
stream
()
>>>
(
src
,
gamma
,
beta
,
out
,
mean
,
variance
,
epsilon_
,
this
->
cols_
));
}
using
InDataType
=
typename
PDDataTypeTraits
<
InType
>::
DataType
;
using
OutDataType
=
typename
PDDataTypeTraits
<
OutType
>::
DataType
;
phi
::
LayerNormDirectCUDAFunctor
<
InDataType
,
LayerNormParamType
<
T
>>
layer_norm
;
std
::
vector
<
int
>
src_shape
{
this
->
rows_
,
this
->
cols_
};
layer_norm
(
ctx
.
stream
(),
reinterpret_cast
<
const
InDataType
*>
(
src
),
src_shape
,
beta
,
gamma
,
reinterpret_cast
<
OutDataType
*>
(
out
),
mean
,
variance
,
1
,
epsilon_
);
}
void
LayerNormGrad
(
const
phi
::
GPUContext
&
ctx
,
...
...
paddle/phi/kernels/gpu/layer_norm_kernel.cu
浏览文件 @
86d92092
...
...
@@ -50,6 +50,7 @@ void LayerNormDirectCUDAFunctor<T, U>::operator()(gpuStream_t stream,
}
template
class
LayerNormDirectCUDAFunctor
<
float
,
float
>;
template
class
LayerNormDirectCUDAFunctor
<
double
,
double
>;
#if defined(PADDLE_WITH_CUDA) && !defined(PADDLE_WITH_HIP)
template
class
LayerNormDirectCUDAFunctor
<
half
,
float
>;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录