Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
f419e341
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f419e341
编写于
8月 05, 2022
作者:
Z
zhangkaihuo
提交者:
GitHub
8月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sparse visit (#44847)
上级
d4ca7ffb
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
39 addition
and
25 deletion
+39
-25
paddle/phi/core/visit_type.h
paddle/phi/core/visit_type.h
+14
-0
paddle/phi/kernels/funcs/sparse/sparse_blas_impl.cu.h
paddle/phi/kernels/funcs/sparse/sparse_blas_impl.cu.h
+2
-2
paddle/phi/kernels/sparse/gpu/coalesce_kernel.cu
paddle/phi/kernels/sparse/gpu/coalesce_kernel.cu
+1
-1
paddle/phi/kernels/sparse/gpu/conv_grad_kernel.cu
paddle/phi/kernels/sparse/gpu/conv_grad_kernel.cu
+1
-1
paddle/phi/kernels/sparse/gpu/conv_kernel.cu
paddle/phi/kernels/sparse/gpu/conv_kernel.cu
+1
-1
paddle/phi/kernels/sparse/gpu/mask_kernel.cu
paddle/phi/kernels/sparse/gpu/mask_kernel.cu
+2
-2
paddle/phi/kernels/sparse/gpu/mv_grad_kernel.cu
paddle/phi/kernels/sparse/gpu/mv_grad_kernel.cu
+2
-2
paddle/phi/kernels/sparse/gpu/pool_grad_kernel.cu
paddle/phi/kernels/sparse/gpu/pool_grad_kernel.cu
+1
-1
paddle/phi/kernels/sparse/gpu/pool_kernel.cu
paddle/phi/kernels/sparse/gpu/pool_kernel.cu
+1
-1
paddle/phi/kernels/sparse/gpu/softmax_grad_kernel.cu
paddle/phi/kernels/sparse/gpu/softmax_grad_kernel.cu
+1
-1
paddle/phi/kernels/sparse/gpu/softmax_kernel.cu
paddle/phi/kernels/sparse/gpu/softmax_kernel.cu
+9
-9
paddle/phi/kernels/sparse/gpu/sparse_utils_kernel.cu
paddle/phi/kernels/sparse/gpu/sparse_utils_kernel.cu
+3
-3
python/paddle/fluid/tests/unittests/test_sparse_unary_op.py
python/paddle/fluid/tests/unittests/test_sparse_unary_op.py
+1
-1
未找到文件。
paddle/phi/core/visit_type.h
浏览文件 @
f419e341
...
...
@@ -87,6 +87,20 @@ namespace phi {
} \
}()
#define PD_VISIT_BASE_INTEGRAL_TYPES(TYPE, NAME, ...) \
[&] { \
const auto& __dtype__ = TYPE; \
switch (__dtype__) { \
PD_PRIVATE_CASE_TYPE(NAME, ::paddle::DataType::INT32, int, __VA_ARGS__) \
PD_PRIVATE_CASE_TYPE( \
NAME, ::paddle::DataType::INT64, int64_t, __VA_ARGS__) \
default: \
PD_THROW("function " #NAME " is not implemented for data type `", \
__dtype__, \
"`"); \
} \
}()
///////// Complex Dispatch Marco ///////////
#define PD_VISIT_COMPLEX_TYPES(TYPE, NAME, ...) \
...
...
paddle/phi/kernels/funcs/sparse/sparse_blas_impl.cu.h
浏览文件 @
f419e341
...
...
@@ -174,7 +174,7 @@ class CuSparseSpMatDescriptor {
explicit
CuSparseSpMatDescriptor
(
const
phi
::
SparseCsrTensor
&
x
,
const
phi
::
GPUContext
&
dev_ctx
)
:
dev_ctx_
(
dev_ctx
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_crows
().
dtype
(),
"Csr CuSparseSpMatDescriptor"
,
([
&
]
{
CreateCsrDescriptor
<
T
,
data_t
>
(
x
,
dev_ctx_
,
&
descriptor_
);
}));
...
...
@@ -184,7 +184,7 @@ class CuSparseSpMatDescriptor {
explicit
CuSparseSpMatDescriptor
(
const
phi
::
SparseCooTensor
&
x
,
const
phi
::
GPUContext
&
dev_ctx
)
:
dev_ctx_
(
dev_ctx
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Coo CuSparseSpMatDescriptor"
,
([
&
]
{
CreateCooDescriptor
<
T
,
data_t
>
(
x
,
dev_ctx_
,
&
descriptor_
);
}));
...
...
paddle/phi/kernels/sparse/gpu/coalesce_kernel.cu
浏览文件 @
f419e341
...
...
@@ -175,7 +175,7 @@ template <typename T, typename Context>
void
CoalesceKernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
SparseCooTensor
*
out
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"CoalesceGPUKernel"
,
([
&
]
{
CoalesceGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
out
);
}));
...
...
paddle/phi/kernels/sparse/gpu/conv_grad_kernel.cu
浏览文件 @
f419e341
...
...
@@ -233,7 +233,7 @@ void Conv3dCooGradKernel(const Context& dev_ctx,
const
std
::
string
&
key
,
SparseCooTensor
*
x_grad
,
DenseTensor
*
kernel_grad
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Conv3dCooGradGPUKernel"
,
([
&
]
{
Conv3dCooGradGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
...
...
paddle/phi/kernels/sparse/gpu/conv_kernel.cu
浏览文件 @
f419e341
...
...
@@ -221,7 +221,7 @@ void Conv3dCooKernel(const Context& dev_ctx,
SparseCooTensor
*
out
,
DenseTensor
*
rulebook
,
DenseTensor
*
counter
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Conv3dCooGPUKernel"
,
([
&
]
{
Conv3dCooGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
...
...
paddle/phi/kernels/sparse/gpu/mask_kernel.cu
浏览文件 @
f419e341
...
...
@@ -111,7 +111,7 @@ void SparseMaskKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
SparseCooTensor
&
mask
,
SparseCooTensor
*
out
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
mask
.
non_zero_indices
().
dtype
(),
"SparseMaskGPUKernel"
,
([
&
]
{
SparseMaskGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask
,
out
);
}));
...
...
@@ -270,7 +270,7 @@ void SparseMaskHelperKernel(const Context& dev_ctx,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
mask_indices
,
DenseTensor
*
out
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"SparseMaskHelperGPUKernel"
,
([
&
]
{
SparseMaskHelperGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
mask_indices
,
out
);
}));
...
...
paddle/phi/kernels/sparse/gpu/mv_grad_kernel.cu
浏览文件 @
f419e341
...
...
@@ -70,7 +70,7 @@ void MvCooGradKernel(const Context &dev_ctx,
// InferMeta of SparseCooTensor 'dx', CreateLikeInferMeta
EmptyLikeCooKernel
<
T
,
Context
>
(
dev_ctx
,
x
,
dx
);
auto
config
=
phi
::
backends
::
gpu
::
GetGpuLaunchConfig1D
(
dev_ctx
,
dx
->
nnz
());
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
dx
->
non_zero_indices
().
dtype
(),
"MvCooGradKernel"
,
([
&
]
{
MvCooGradGpuKernel
<
T
>
<<<
config
.
block_per_grid
.
x
,
...
...
@@ -117,7 +117,7 @@ void MvCsrGradKernel(const Context &dev_ctx,
int
col_number
=
dx
->
dims
()[
1
];
auto
config
=
phi
::
backends
::
gpu
::
GetGpuLaunchConfig2D
(
dev_ctx
,
col_number
,
row_number
);
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
dx
->
non_zero_crows
().
dtype
(),
"MvCsrGradKernel"
,
([
&
]
{
MvCsrGradGpuKernel
<
T
>
<<<
config
.
block_per_grid
.
x
,
...
...
paddle/phi/kernels/sparse/gpu/pool_grad_kernel.cu
浏览文件 @
f419e341
...
...
@@ -116,7 +116,7 @@ void MaxPoolCooGradKernel(const Context& dev_ctx,
const
SparseCooTensor
&
out_grad
,
const
std
::
vector
<
int
>&
kernel_sizes
,
SparseCooTensor
*
x_grad
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"MaxPoolCooGradGPUKernel"
,
([
&
]
{
MaxPoolCooGradGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
rulebook
,
counter
,
out
,
out_grad
,
kernel_sizes
,
x_grad
);
...
...
paddle/phi/kernels/sparse/gpu/pool_kernel.cu
浏览文件 @
f419e341
...
...
@@ -139,7 +139,7 @@ void MaxPoolCooKernel(const Context& dev_ctx,
SparseCooTensor
*
out
,
DenseTensor
*
rulebook
,
DenseTensor
*
counter
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"MaxPoolCooGPUKernel"
,
([
&
]
{
MaxPoolCooGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
...
...
paddle/phi/kernels/sparse/gpu/softmax_grad_kernel.cu
浏览文件 @
f419e341
...
...
@@ -92,7 +92,7 @@ void SoftmaxCsrGradKernel(const Context& dev_ctx,
dim3
grid
((
total_row_number
+
3
)
/
4
);
dim3
block
(
32
,
4
);
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
out
.
non_zero_crows
().
dtype
(),
"SoftmaxCsrGradKernel"
,
([
&
]
{
SoftmaxGradGpuKernel
<
T
,
data_t
><<<
grid
,
block
,
0
,
dev_ctx
.
stream
()
>>>
(
out
.
non_zero_crows
().
data
<
data_t
>
(),
...
...
paddle/phi/kernels/sparse/gpu/softmax_kernel.cu
浏览文件 @
f419e341
...
...
@@ -105,15 +105,15 @@ void SoftmaxCsrKernel(const Context& dev_ctx,
dim3
grid
((
total_row_number
+
3
)
/
4
);
dim3
block
(
32
,
4
);
PD_VISIT_
INTEGRAL_TYPES
(
x
.
non_zero_crows
().
dtype
(),
"CsrSoftmaxKernel"
,
([
&
]
{
SoftmaxGpuKernel
<
T
,
data_t
>
<<<
grid
,
block
,
0
,
dev_ctx
.
stream
()
>>>
(
x
.
non_zero_crows
().
data
<
data_t
>
(),
x
.
non_zero_elements
().
data
<
T
>
(),
out
->
mutable_non_zero_elements
()
->
data
<
T
>
(),
row_number
,
total_row_number
);
}));
PD_VISIT_
BASE_INTEGRAL_TYPES
(
x
.
non_zero_crows
().
dtype
(),
"CsrSoftmaxKernel"
,
([
&
]
{
SoftmaxGpuKernel
<
T
,
data_t
>
<<<
grid
,
block
,
0
,
dev_ctx
.
stream
()
>>>
(
x
.
non_zero_crows
().
data
<
data_t
>
(),
x
.
non_zero_elements
().
data
<
T
>
(),
out
->
mutable_non_zero_elements
()
->
data
<
T
>
(),
row_number
,
total_row_number
);
}));
}
}
// namespace sparse
...
...
paddle/phi/kernels/sparse/gpu/sparse_utils_kernel.cu
浏览文件 @
f419e341
...
...
@@ -277,7 +277,7 @@ template <typename T, typename Context>
void
SparseCsrToCooKernel
(
const
Context
&
dev_ctx
,
const
SparseCsrTensor
&
x
,
SparseCooTensor
*
out
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_crows
().
dtype
(),
"SparseCsrToCooGPUKernel"
,
([
&
]
{
SparseCsrToCooGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
out
);
}));
...
...
@@ -421,7 +421,7 @@ template <typename T, typename Context>
void
SparseCooToCsrKernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
SparseCsrTensor
*
out
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"SparseCooToCsrGPUKernel"
,
([
&
]
{
SparseCooToCsrGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
out
);
}));
...
...
@@ -510,7 +510,7 @@ template <typename T, typename Context>
void
SparseCooToDenseKernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
DenseTensor
*
out
)
{
PD_VISIT_INTEGRAL_TYPES
(
PD_VISIT_
BASE_
INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"SparseCooToDenseGPUKernel"
,
([
&
]
{
SparseCooToDenseGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
out
);
}));
...
...
python/paddle/fluid/tests/unittests/test_sparse_unary_op.py
浏览文件 @
f419e341
...
...
@@ -160,7 +160,7 @@ class TestSparseUnary(unittest.TestCase):
def
test_sparse_cast
(
self
):
self
.
compare_with_dense_two_attr
(
paddle
.
cast
,
paddle
.
incubate
.
sparse
.
cast
,
'int
16
'
,
paddle
.
incubate
.
sparse
.
cast
,
'int
32
'
,
'float32'
)
self
.
compare_with_dense_two_attr
(
paddle
.
cast
,
paddle
.
incubate
.
sparse
.
cast
,
'int32'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录