Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
cf95db58
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
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看板
未验证
提交
cf95db58
编写于
2月 22, 2023
作者:
Z
zhangkaihuo
提交者:
GitHub
2月 22, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[sparse]Fix mask_kernel name (#50713)
上级
500a8bc2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
58 deletion
+58
-58
paddle/phi/kernels/sparse/cpu/mask_kernel.cc
paddle/phi/kernels/sparse/cpu/mask_kernel.cc
+24
-24
paddle/phi/kernels/sparse/gpu/mask_kernel.cu
paddle/phi/kernels/sparse/gpu/mask_kernel.cu
+24
-24
paddle/phi/kernels/sparse/mask_kernel.h
paddle/phi/kernels/sparse/mask_kernel.h
+8
-8
paddle/phi/kernels/sparse/sparse_utils_grad_kernel.cc
paddle/phi/kernels/sparse/sparse_utils_grad_kernel.cc
+1
-1
paddle/phi/kernels/sparse/sparse_utils_grad_kernel.h
paddle/phi/kernels/sparse/sparse_utils_grad_kernel.h
+1
-1
未找到文件。
paddle/phi/kernels/sparse/cpu/mask_kernel.cc
浏览文件 @
cf95db58
...
...
@@ -28,10 +28,10 @@ namespace phi {
namespace
sparse
{
template
<
typename
T
,
typename
IntT
>
void
SparseMask
CPUKernel
(
const
CPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
void
MaskCoo
CPUKernel
(
const
CPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
const
DDim
&
dims
=
x
.
dims
();
PADDLE_ENFORCE_EQ
(
x
.
dims
(),
...
...
@@ -75,21 +75,21 @@ void SparseMaskCPUKernel(const CPUContext& dev_ctx,
* x and mask must have the same shape.
**/
template
<
typename
T
,
typename
Context
>
void
SparseMask
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
void
MaskCoo
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
PD_VISIT_BASE_INTEGRAL_TYPES
(
mask
.
indices
().
dtype
(),
"
SparseMask
CPUKernel"
,
([
&
]
{
SparseMask
CPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask
,
out
);
mask
.
indices
().
dtype
(),
"
MaskCoo
CPUKernel"
,
([
&
]
{
MaskCoo
CPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask
,
out
);
}));
}
template
<
typename
T
,
typename
IntT
>
void
SparseMaskHelper
CPUKernel
(
const
CPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
void
MaskHelperCoo
CPUKernel
(
const
CPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
PADDLE_ENFORCE_EQ
(
mask_indices
.
dims
().
size
(),
2
,
...
...
@@ -142,23 +142,23 @@ void SparseMaskHelperCPUKernel(const CPUContext& dev_ctx,
* @brief filter values from x.values() using mask_indices
*/
template
<
typename
T
,
typename
Context
>
void
SparseMaskHelper
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
void
MaskHelperCoo
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
PD_VISIT_BASE_INTEGRAL_TYPES
(
x
.
indices
().
dtype
(),
"
SparseMaskHelper
CPUKernel"
,
([
&
]
{
SparseMaskHelper
CPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask_indices
,
out
);
x
.
indices
().
dtype
(),
"
MaskHelperCoo
CPUKernel"
,
([
&
]
{
MaskHelperCoo
CPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask_indices
,
out
);
}));
}
}
// namespace sparse
}
// namespace phi
PD_REGISTER_KERNEL
(
sparse_mask
,
PD_REGISTER_KERNEL
(
mask_coo
,
CPU
,
ALL_LAYOUT
,
phi
::
sparse
::
SparseMask
Kernel
,
phi
::
sparse
::
MaskCoo
Kernel
,
float
,
double
,
uint8_t
,
...
...
@@ -169,10 +169,10 @@ PD_REGISTER_KERNEL(sparse_mask,
kernel
->
InputAt
(
1
).
SetDataLayout
(
phi
::
DataLayout
::
SPARSE_COO
);
}
PD_REGISTER_KERNEL
(
sparse_mask_helper
,
PD_REGISTER_KERNEL
(
mask_helper_coo
,
CPU
,
ALL_LAYOUT
,
phi
::
sparse
::
SparseMaskHelper
Kernel
,
phi
::
sparse
::
MaskHelperCoo
Kernel
,
float
,
double
,
uint8_t
,
...
...
paddle/phi/kernels/sparse/gpu/mask_kernel.cu
浏览文件 @
cf95db58
...
...
@@ -50,10 +50,10 @@ __global__ void MaskKernel(const T* x_ptr,
}
template
<
typename
T
,
typename
IntT
>
void
SparseMask
GPUKernel
(
const
GPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
void
MaskCoo
GPUKernel
(
const
GPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
const
DDim
&
dims
=
x
.
dims
();
PADDLE_ENFORCE_EQ
(
x
.
dims
(),
...
...
@@ -108,13 +108,13 @@ void SparseMaskGPUKernel(const GPUContext& dev_ctx,
* x and mask must have the same shape.
**/
template
<
typename
T
,
typename
Context
>
void
SparseMask
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
void
MaskCoo
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
PD_VISIT_BASE_INTEGRAL_TYPES
(
mask
.
indices
().
dtype
(),
"
SparseMask
GPUKernel"
,
([
&
]
{
SparseMask
GPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask
,
out
);
mask
.
indices
().
dtype
(),
"
MaskCoo
GPUKernel"
,
([
&
]
{
MaskCoo
GPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask
,
out
);
}));
}
...
...
@@ -155,10 +155,10 @@ __global__ void MaskCopy(const IntT* mask_indexs,
}
template
<
typename
T
,
typename
IntT
>
void
SparseMaskHelper
GPUKernel
(
const
GPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
void
MaskHelperCoo
GPUKernel
(
const
GPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
PADDLE_ENFORCE_EQ
(
mask_indices
.
dims
().
size
(),
2
,
...
...
@@ -279,23 +279,23 @@ void SparseMaskHelperGPUKernel(const GPUContext& dev_ctx,
}
template
<
typename
T
,
typename
Context
>
void
SparseMaskHelper
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
void
MaskHelperCoo
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
PD_VISIT_BASE_INTEGRAL_TYPES
(
x
.
indices
().
dtype
(),
"
SparseMaskHelper
GPUKernel"
,
([
&
]
{
SparseMaskHelper
GPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask_indices
,
out
);
x
.
indices
().
dtype
(),
"
MaskHelperCoo
GPUKernel"
,
([
&
]
{
MaskHelperCoo
GPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask_indices
,
out
);
}));
}
}
// namespace sparse
}
// namespace phi
PD_REGISTER_KERNEL
(
mask
,
PD_REGISTER_KERNEL
(
mask
_coo
,
GPU
,
ALL_LAYOUT
,
phi
::
sparse
::
SparseMask
Kernel
,
phi
::
sparse
::
MaskCoo
Kernel
,
float
,
double
,
phi
::
dtype
::
float16
,
...
...
@@ -307,10 +307,10 @@ PD_REGISTER_KERNEL(mask,
kernel
->
InputAt
(
1
).
SetDataLayout
(
phi
::
DataLayout
::
SPARSE_COO
);
}
PD_REGISTER_KERNEL
(
mask_helper
,
PD_REGISTER_KERNEL
(
mask_helper
_coo
,
GPU
,
ALL_LAYOUT
,
phi
::
sparse
::
SparseMaskHelper
Kernel
,
phi
::
sparse
::
MaskHelperCoo
Kernel
,
float
,
double
,
phi
::
dtype
::
float16
,
...
...
paddle/phi/kernels/sparse/mask_kernel.h
浏览文件 @
cf95db58
...
...
@@ -21,16 +21,16 @@ namespace phi {
namespace
sparse
{
template
<
typename
T
,
typename
Context
>
void
SparseMask
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
);
void
MaskCoo
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
);
template
<
typename
T
,
typename
Context
>
void
SparseMaskHelper
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
);
void
MaskHelperCoo
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
);
}
// namespace sparse
}
// namespace phi
paddle/phi/kernels/sparse/sparse_utils_grad_kernel.cc
浏览文件 @
cf95db58
...
...
@@ -32,7 +32,7 @@ void CooToDenseGradKernel(const Context& dev_ctx,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
out_grad
,
SparseCooTensor
*
x_grad
)
{
SparseMask
Kernel
<
T
,
Context
>
(
dev_ctx
,
out_grad
,
x
,
x_grad
);
MaskCoo
Kernel
<
T
,
Context
>
(
dev_ctx
,
out_grad
,
x
,
x_grad
);
}
}
// namespace sparse
...
...
paddle/phi/kernels/sparse/sparse_utils_grad_kernel.h
浏览文件 @
cf95db58
...
...
@@ -38,7 +38,7 @@ void SparseCooTensorGradKernel(const Context& dev_ctx,
const
DenseTensor
&
indices
,
const
SparseCooTensor
&
out_grad
,
DenseTensor
*
values_grad
)
{
SparseMaskHelper
Kernel
<
T
,
Context
>
(
dev_ctx
,
out_grad
,
indices
,
values_grad
);
MaskHelperCoo
Kernel
<
T
,
Context
>
(
dev_ctx
,
out_grad
,
indices
,
values_grad
);
}
}
// namespace sparse
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录