Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c9f4cfad
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
c9f4cfad
编写于
12月 12, 2022
作者:
N
Netpunk
提交者:
GitHub
12月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PHI decoupling] replace dependency of inclusive_scan.h from phi (#48980)
* replace dependency of inclusive_scan.h from phi * format code
上级
00f20313
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
33 deletion
+31
-33
paddle/phi/kernels/gpu/cumprod_grad_kernel.cu
paddle/phi/kernels/gpu/cumprod_grad_kernel.cu
+21
-23
paddle/phi/kernels/gpu/cumprod_kernel.cu
paddle/phi/kernels/gpu/cumprod_kernel.cu
+10
-10
未找到文件。
paddle/phi/kernels/gpu/cumprod_grad_kernel.cu
浏览文件 @
c9f4cfad
...
...
@@ -16,13 +16,13 @@
#include <thrust/transform.h>
#include "paddle/fluid/operators/math/inclusive_scan.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/complex_functors.h"
#include "paddle/phi/kernels/funcs/cumprod.h"
#include "paddle/phi/kernels/funcs/elementwise_functor.h"
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/inclusive_scan.h"
// NOTE(@xiongkun): use of IsComplex<>
#include "paddle/phi/core/utils/data_type.h"
...
...
@@ -194,16 +194,15 @@ void CumprodGradKernel(const Context &dev_ctx,
auto
zero_mask
=
const_cast
<
Allocator
&>
(
dev_ctx
.
GetAllocator
())
.
Allocate
(
numel
*
sizeof
(
uint8_t
));
auto
*
zero_mask_data
=
reinterpret_cast
<
uint8_t
*>
(
zero_mask
->
ptr
());
paddle
::
operators
::
math
::
InclusiveScan
<
uint8_t
,
cub
::
Max
>
(
zero_mask_without_cummax_data
,
zero_mask_data
,
outer_dim
,
mid_dim
,
inner_dim
,
static_cast
<
uint8_t
>
(
0
),
cub
::
Max
(),
/*reverse=*/
false
,
dev_ctx
);
phi
::
funcs
::
InclusiveScan
<
uint8_t
,
cub
::
Max
>
(
zero_mask_without_cummax_data
,
zero_mask_data
,
outer_dim
,
mid_dim
,
inner_dim
,
static_cast
<
uint8_t
>
(
0
),
cub
::
Max
(),
/*reverse=*/
false
,
dev_ctx
);
zero_mask_without_cummax
=
nullptr
;
// Step 2: calculate reversed cumsum(dy * y)
...
...
@@ -222,16 +221,15 @@ void CumprodGradKernel(const Context &dev_ctx,
.
Allocate
(
numel
*
sizeof
(
T
));
auto
*
dy_mul_y_reversed_cumsum_data
=
reinterpret_cast
<
T
*>
(
dy_mul_y_reversed_cumsum
->
ptr
());
paddle
::
operators
::
math
::
InclusiveScan
<
T
,
cub
::
Sum
>
(
dy_mul_y_data
,
dy_mul_y_reversed_cumsum_data
,
outer_dim
,
mid_dim
,
inner_dim
,
static_cast
<
T
>
(
0
),
cub
::
Sum
(),
/*reverse=*/
true
,
dev_ctx
);
phi
::
funcs
::
InclusiveScan
<
T
,
cub
::
Sum
>
(
dy_mul_y_data
,
dy_mul_y_reversed_cumsum_data
,
outer_dim
,
mid_dim
,
inner_dim
,
static_cast
<
T
>
(
0
),
cub
::
Sum
(),
/*reverse=*/
true
,
dev_ctx
);
// Step 3: calculate the gradient value except the first zero position.
// The gradient value of the first zero position is filled with out[idx-1],
...
...
@@ -262,7 +260,7 @@ void CumprodGradKernel(const Context &dev_ctx,
// Step 4: calculate cumprod of x_filled_one
auto
*
x_filled_one_cumprod_data
=
dy_mul_y_reversed_cumsum_data
;
// reuse former allocated memory
p
addle
::
operators
::
math
::
InclusiveScan
<
T
,
funcs
::
MultiplyFunctor
<
T
>>
(
p
hi
::
funcs
::
InclusiveScan
<
T
,
funcs
::
MultiplyFunctor
<
T
>>
(
x_filled_one_data
,
x_filled_one_cumprod_data
,
outer_dim
,
...
...
@@ -284,7 +282,7 @@ void CumprodGradKernel(const Context &dev_ctx,
funcs
::
MultiplyFunctor
<
T
>
());
auto
*
dy_mul_x_filled_one_cumprod_reversed_cumsum
=
dy_mul_y_reversed_cumsum_data
;
// reuse former allocated memory
p
addle
::
operators
::
math
::
InclusiveScan
<
T
,
cub
::
Sum
>
(
p
hi
::
funcs
::
InclusiveScan
<
T
,
cub
::
Sum
>
(
dy_mul_x_filled_one_cumprod
,
dy_mul_x_filled_one_cumprod_reversed_cumsum
,
outer_dim
,
...
...
paddle/phi/kernels/gpu/cumprod_kernel.cu
浏览文件 @
c9f4cfad
...
...
@@ -14,12 +14,12 @@
#include "paddle/phi/kernels/cumprod_kernel.h"
#include "paddle/fluid/operators/math/inclusive_scan.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/complex_functors.h"
#include "paddle/phi/kernels/funcs/cumprod.h"
#include "paddle/phi/kernels/funcs/elementwise_functor.h"
#include "paddle/phi/kernels/funcs/inclusive_scan.h"
namespace
phi
{
...
...
@@ -35,15 +35,15 @@ void CumprodKernel(const Context &dev_ctx,
const
auto
*
x_data
=
x
->
data
<
T
>
();
auto
*
y_data
=
dev_ctx
.
template
Alloc
<
T
>(
y
);
p
addle
::
operators
::
math
::
InclusiveScan
(
x_data
,
y_data
,
outer_dim
,
mid_dim
,
inner_dim
,
static_cast
<
T
>
(
1
),
funcs
::
MultiplyFunctor
<
T
>
(),
/*reverse=*/
false
,
dev_ctx
);
p
hi
::
funcs
::
InclusiveScan
(
x_data
,
y_data
,
outer_dim
,
mid_dim
,
inner_dim
,
static_cast
<
T
>
(
1
),
funcs
::
MultiplyFunctor
<
T
>
(),
/*reverse=*/
false
,
dev_ctx
);
}
}
// namespace phi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录