Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
87443831
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
87443831
编写于
7月 15, 2022
作者:
Z
zhangkaihuo
提交者:
GitHub
7月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Standard sparse conv name (#44353)
上级
0dafbb03
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
278 addition
and
217 deletion
+278
-217
paddle/phi/api/yaml/sparse_api.yaml
paddle/phi/api/yaml/sparse_api.yaml
+1
-1
paddle/phi/api/yaml/sparse_bw_api.yaml
paddle/phi/api/yaml/sparse_bw_api.yaml
+1
-1
paddle/phi/kernels/sparse/conv_grad_kernel.h
paddle/phi/kernels/sparse/conv_grad_kernel.h
+25
-26
paddle/phi/kernels/sparse/conv_kernel.h
paddle/phi/kernels/sparse/conv_kernel.h
+62
-0
paddle/phi/kernels/sparse/cpu/conv_grad_kernel.cc
paddle/phi/kernels/sparse/cpu/conv_grad_kernel.cc
+40
-40
paddle/phi/kernels/sparse/cpu/conv_kernel.cc
paddle/phi/kernels/sparse/cpu/conv_kernel.cc
+32
-32
paddle/phi/kernels/sparse/cpu/convolution.h
paddle/phi/kernels/sparse/cpu/convolution.h
+1
-1
paddle/phi/kernels/sparse/gpu/conv_grad_kernel.cu
paddle/phi/kernels/sparse/gpu/conv_grad_kernel.cu
+40
-40
paddle/phi/kernels/sparse/gpu/conv_kernel.cu
paddle/phi/kernels/sparse/gpu/conv_kernel.cu
+34
-34
paddle/phi/kernels/sparse/gpu/convolution.cu.h
paddle/phi/kernels/sparse/gpu/convolution.cu.h
+1
-1
paddle/phi/tests/api/test_sparse_conv_api.cc
paddle/phi/tests/api/test_sparse_conv_api.cc
+1
-1
paddle/phi/tests/kernels/test_sparse_conv3d_dev_api.cc
paddle/phi/tests/kernels/test_sparse_conv3d_dev_api.cc
+40
-40
未找到文件。
paddle/phi/api/yaml/sparse_api.yaml
浏览文件 @
87443831
...
...
@@ -84,7 +84,7 @@
args
:
(Tensor x, Tensor kernel, int[] paddings, int[] dilations, int[] strides, int groups, bool subm)
output
:
Tensor(out), Tensor(rulebook)
kernel
:
func
:
sparse_conv3d
{sparse_coo, dense -> sparse_coo, dense}
func
:
conv3d_coo
{sparse_coo, dense -> sparse_coo, dense}
layout
:
x
intermediate
:
rulebook
backward
:
conv3d_grad
...
...
paddle/phi/api/yaml/sparse_bw_api.yaml
浏览文件 @
87443831
...
...
@@ -76,7 +76,7 @@
args
:
(Tensor x, Tensor kernel, Tensor rulebook, Tensor out_grad, int[] paddings, int[] dilations, int[] strides, int groups, bool subm)
output
:
Tensor(x_grad), Tensor(kernel_grad)
kernel
:
func
:
sparse_conv3d
_grad{sparse_coo, dense, dense, sparse_coo -> sparse_coo, dense}
func
:
conv3d_coo
_grad{sparse_coo, dense, dense, sparse_coo -> sparse_coo, dense}
-
backward_api
:
coo_to_dense_grad
forward
:
coo_to_dense(Tensor x) -> Tensor(out)
...
...
paddle/phi/kernels/sparse/conv
olution
_grad_kernel.h
→
paddle/phi/kernels/sparse/conv_grad_kernel.h
浏览文件 @
87443831
...
...
@@ -17,13 +17,12 @@ limitations under the License. */
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/sparse_coo_tensor.h"
#include "paddle/phi/kernels/empty_kernel.h"
#include "paddle/phi/kernels/sparse/convolution_kernel.h"
namespace
phi
{
namespace
sparse
{
template
<
typename
T
,
typename
Context
>
void
Conv3dGradKernel
(
const
Context
&
dev_ctx
,
void
Conv3d
Coo
GradKernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
DenseTensor
&
rulebook
,
...
...
@@ -37,7 +36,7 @@ void Conv3dGradKernel(const Context& dev_ctx,
DenseTensor
*
kernel_grad
);
template
<
typename
T
,
typename
Context
>
std
::
tuple
<
SparseCooTensor
,
DenseTensor
>
Conv3dGrad
(
std
::
tuple
<
SparseCooTensor
,
DenseTensor
>
Conv3d
Coo
Grad
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
...
...
@@ -52,7 +51,7 @@ std::tuple<SparseCooTensor, DenseTensor> Conv3dGrad(
DenseTensor
kernel_grad
;
// TODO(zhangkaihuo): call InferMeta func here
Conv3dGradKernel
<
T
,
Context
>
(
dev_ctx
,
Conv3d
Coo
GradKernel
<
T
,
Context
>
(
dev_ctx
,
x
,
kernel
,
rulebook
,
...
...
paddle/phi/kernels/sparse/conv
olution
_kernel.h
→
paddle/phi/kernels/sparse/conv_kernel.h
浏览文件 @
87443831
...
...
@@ -23,7 +23,7 @@ namespace phi {
namespace
sparse
{
template
<
typename
T
,
typename
Context
>
void
Conv3dKernel
(
const
Context
&
dev_ctx
,
void
Conv3d
Coo
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
std
::
vector
<
int
>&
paddings
,
...
...
@@ -35,7 +35,7 @@ void Conv3dKernel(const Context& dev_ctx,
DenseTensor
*
rulebook
);
template
<
typename
T
,
typename
Context
>
SparseCooTensor
Conv3d
(
const
Context
&
dev_ctx
,
SparseCooTensor
Conv3d
Coo
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
kernel
,
const
std
::
vector
<
int
>&
paddings
,
...
...
@@ -45,7 +45,7 @@ SparseCooTensor Conv3d(const Context& dev_ctx,
const
bool
subm
,
DenseTensor
*
rulebook
)
{
SparseCooTensor
coo
;
Conv3dKernel
<
T
,
Context
>
(
dev_ctx
,
Conv3d
Coo
Kernel
<
T
,
Context
>
(
dev_ctx
,
x
,
kernel
,
paddings
,
...
...
paddle/phi/kernels/sparse/cpu/conv
olution
_grad_kernel.cc
→
paddle/phi/kernels/sparse/cpu/conv_grad_kernel.cc
浏览文件 @
87443831
...
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/phi/kernels/sparse/conv
olution
_grad_kernel.h"
#include "paddle/phi/kernels/sparse/conv_grad_kernel.h"
#include "paddle/phi/core/visit_type.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"
...
...
@@ -31,7 +31,7 @@ namespace sparse {
// x_grad = out_grad * transpose(kenrel)
// kernel_grad = transpose(x) * out_grad
template
<
typename
T
,
typename
IntT
=
int
>
void
Conv3dGradCPUKernel
(
const
CPUContext
&
dev_ctx
,
void
Conv3d
Coo
GradCPUKernel
(
const
CPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
DenseTensor
&
rulebook
,
...
...
@@ -178,7 +178,7 @@ void Conv3dGradCPUKernel(const CPUContext& dev_ctx,
}
template
<
typename
T
,
typename
Context
>
void
Conv3dGradKernel
(
const
Context
&
dev_ctx
,
void
Conv3d
Coo
GradKernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
DenseTensor
&
rulebook
,
...
...
@@ -191,8 +191,8 @@ void Conv3dGradKernel(const Context& dev_ctx,
SparseCooTensor
*
x_grad
,
DenseTensor
*
kernel_grad
)
{
PD_VISIT_INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Conv3dGradCPUKernel"
,
([
&
]
{
Conv3dGradCPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
.
non_zero_indices
().
dtype
(),
"Conv3d
Coo
GradCPUKernel"
,
([
&
]
{
Conv3d
Coo
GradCPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
kernel
,
rulebook
,
...
...
@@ -210,10 +210,10 @@ void Conv3dGradKernel(const Context& dev_ctx,
}
// namespace sparse
}
// namespace phi
PD_REGISTER_KERNEL
(
sparse_conv3d
_grad
,
PD_REGISTER_KERNEL
(
conv3d_coo
_grad
,
CPU
,
ALL_LAYOUT
,
phi
::
sparse
::
Conv3dGradKernel
,
phi
::
sparse
::
Conv3d
Coo
GradKernel
,
float
,
double
)
{
kernel
->
InputAt
(
0
).
SetDataLayout
(
phi
::
DataLayout
::
SPARSE_COO
);
...
...
paddle/phi/kernels/sparse/cpu/conv
olution
_kernel.cc
→
paddle/phi/kernels/sparse/cpu/conv_kernel.cc
浏览文件 @
87443831
...
...
@@ -27,7 +27,7 @@ namespace sparse {
* out: (N, D, H, W, OC)
**/
template
<
typename
T
,
typename
IntT
=
int
>
void
Conv3dCPUKernel
(
const
CPUContext
&
dev_ctx
,
void
Conv3dC
ooC
PUKernel
(
const
CPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
std
::
vector
<
int
>&
paddings
,
...
...
@@ -151,7 +151,7 @@ void Conv3dCPUKernel(const CPUContext& dev_ctx,
}
template
<
typename
T
,
typename
Context
>
void
Conv3dKernel
(
const
Context
&
dev_ctx
,
void
Conv3d
Coo
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
std
::
vector
<
int
>&
paddings
,
...
...
@@ -162,8 +162,8 @@ void Conv3dKernel(const Context& dev_ctx,
SparseCooTensor
*
out
,
DenseTensor
*
rulebook
)
{
PD_VISIT_INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Conv3dCPUKernel"
,
([
&
]
{
Conv3dCPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
.
non_zero_indices
().
dtype
(),
"Conv3dC
ooC
PUKernel"
,
([
&
]
{
Conv3dC
ooC
PUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
kernel
,
paddings
,
...
...
@@ -180,6 +180,6 @@ void Conv3dKernel(const Context& dev_ctx,
}
// namespace phi
PD_REGISTER_KERNEL
(
sparse_conv3d
,
CPU
,
ALL_LAYOUT
,
phi
::
sparse
::
Conv3d
Kernel
,
float
,
double
)
{
conv3d_coo
,
CPU
,
ALL_LAYOUT
,
phi
::
sparse
::
Conv3dCoo
Kernel
,
float
,
double
)
{
kernel
->
InputAt
(
0
).
SetDataLayout
(
phi
::
DataLayout
::
SPARSE_COO
);
}
paddle/phi/kernels/sparse/cpu/convolution.h
浏览文件 @
87443831
...
...
@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/phi/core/sparse_coo_tensor.h"
#include "paddle/phi/core/tensor_meta.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"
#include "paddle/phi/kernels/sparse/conv
olution
_kernel.h"
#include "paddle/phi/kernels/sparse/conv_kernel.h"
namespace
phi
{
namespace
sparse
{
...
...
paddle/phi/kernels/sparse/gpu/conv
olution
_grad_kernel.cu
→
paddle/phi/kernels/sparse/gpu/conv_grad_kernel.cu
浏览文件 @
87443831
...
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/phi/kernels/sparse/conv
olution
_grad_kernel.h"
#include "paddle/phi/kernels/sparse/conv_grad_kernel.h"
#include "glog/logging.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
...
...
@@ -39,7 +39,7 @@ namespace sparse {
// x_grad = out_grad * transpose(kenrel)
// kernel_grad = transpose(x) * out_grad
template
<
typename
T
,
typename
IntT
>
void
Conv3dGradGPUKernel
(
const
GPUContext
&
dev_ctx
,
void
Conv3d
Coo
GradGPUKernel
(
const
GPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
DenseTensor
&
rulebook
,
...
...
@@ -220,7 +220,7 @@ void Conv3dGradGPUKernel(const GPUContext& dev_ctx,
}
template
<
typename
T
,
typename
Context
>
void
Conv3dGradKernel
(
const
Context
&
dev_ctx
,
void
Conv3d
Coo
GradKernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
DenseTensor
&
rulebook
,
...
...
@@ -233,8 +233,8 @@ void Conv3dGradKernel(const Context& dev_ctx,
SparseCooTensor
*
x_grad
,
DenseTensor
*
kernel_grad
)
{
PD_VISIT_INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Conv3dGradGPUKernel"
,
([
&
]
{
Conv3dGradGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
.
non_zero_indices
().
dtype
(),
"Conv3d
Coo
GradGPUKernel"
,
([
&
]
{
Conv3d
Coo
GradGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
kernel
,
rulebook
,
...
...
@@ -252,10 +252,10 @@ void Conv3dGradKernel(const Context& dev_ctx,
}
// namespace sparse
}
// namespace phi
PD_REGISTER_KERNEL
(
sparse_conv3d
_grad
,
PD_REGISTER_KERNEL
(
conv3d_coo
_grad
,
GPU
,
ALL_LAYOUT
,
phi
::
sparse
::
Conv3dGradKernel
,
phi
::
sparse
::
Conv3d
Coo
GradKernel
,
float
,
double
,
phi
::
dtype
::
float16
)
{
...
...
paddle/phi/kernels/sparse/gpu/conv
olution
_kernel.cu
→
paddle/phi/kernels/sparse/gpu/conv_kernel.cu
浏览文件 @
87443831
...
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/phi/kernels/sparse/conv
olution
_kernel.h"
#include "paddle/phi/kernels/sparse/conv_kernel.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
...
...
@@ -27,7 +27,7 @@ namespace phi {
namespace
sparse
{
template
<
typename
T
,
typename
IntT
>
void
Conv3dGPUKernel
(
const
GPUContext
&
dev_ctx
,
void
Conv3d
Coo
GPUKernel
(
const
GPUContext
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
std
::
vector
<
int
>&
paddings
,
...
...
@@ -190,7 +190,7 @@ void Conv3dGPUKernel(const GPUContext& dev_ctx,
* out: (N, D, H, W, OC)
**/
template
<
typename
T
,
typename
Context
>
void
Conv3dKernel
(
const
Context
&
dev_ctx
,
void
Conv3d
Coo
Kernel
(
const
Context
&
dev_ctx
,
const
SparseCooTensor
&
x
,
const
DenseTensor
&
kernel
,
const
std
::
vector
<
int
>&
paddings
,
...
...
@@ -201,8 +201,8 @@ void Conv3dKernel(const Context& dev_ctx,
SparseCooTensor
*
out
,
DenseTensor
*
rulebook
)
{
PD_VISIT_INTEGRAL_TYPES
(
x
.
non_zero_indices
().
dtype
(),
"Conv3dGPUKernel"
,
([
&
]
{
Conv3dGPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
.
non_zero_indices
().
dtype
(),
"Conv3d
Coo
GPUKernel"
,
([
&
]
{
Conv3d
Coo
GPUKernel
<
T
,
data_t
>
(
dev_ctx
,
x
,
kernel
,
paddings
,
...
...
@@ -218,10 +218,10 @@ void Conv3dKernel(const Context& dev_ctx,
}
// namespace sparse
}
// namespace phi
PD_REGISTER_KERNEL
(
sparse_conv3d
,
PD_REGISTER_KERNEL
(
conv3d_coo
,
GPU
,
ALL_LAYOUT
,
phi
::
sparse
::
Conv3dKernel
,
phi
::
sparse
::
Conv3d
Coo
Kernel
,
float
,
double
,
phi
::
dtype
::
float16
)
{
...
...
paddle/phi/kernels/sparse/gpu/convolution.cu.h
浏览文件 @
87443831
...
...
@@ -28,7 +28,7 @@ limitations under the License. */
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/funcs/sparse/utils.cu.h"
#include "paddle/phi/kernels/primitive/compute_primitives.h"
#include "paddle/phi/kernels/sparse/conv
olution
_kernel.h"
#include "paddle/phi/kernels/sparse/conv_kernel.h"
namespace
phi
{
namespace
sparse
{
...
...
paddle/phi/tests/api/test_sparse_conv_api.cc
浏览文件 @
87443831
...
...
@@ -23,7 +23,7 @@ limitations under the License. */
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/sparse_coo_tensor.h"
PD_DECLARE_KERNEL
(
sparse_conv3d
,
CPU
,
ALL_LAYOUT
);
PD_DECLARE_KERNEL
(
conv3d_coo
,
CPU
,
ALL_LAYOUT
);
template
<
typename
T
>
void
TestConv3dBase
(
const
std
::
vector
<
int
>&
indices
,
...
...
paddle/phi/tests/kernels/test_sparse_conv3d_dev_api.cc
浏览文件 @
87443831
...
...
@@ -23,8 +23,8 @@ limitations under the License. */
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/tensor_utils.h"
#include "paddle/phi/kernels/sparse/coalesce_kernel.h"
#include "paddle/phi/kernels/sparse/conv
olution
_grad_kernel.h"
#include "paddle/phi/kernels/sparse/conv
olution
_kernel.h"
#include "paddle/phi/kernels/sparse/conv_grad_kernel.h"
#include "paddle/phi/kernels/sparse/conv_kernel.h"
namespace
phi
{
namespace
tests
{
...
...
@@ -114,7 +114,7 @@ void TestConv3dBase(const std::vector<IntT>& indices,
if
(
!
std
::
is_same
<
T
,
phi
::
dtype
::
float16
>::
value
)
{
DenseTensor
rulebook
=
phi
::
Empty
(
dev_ctx_cpu
,
DenseTensorMeta
(
indices_dtype
,
{
1
},
DataLayout
::
NCHW
));
SparseCooTensor
out
=
sparse
::
Conv3d
<
T
>
(
dev_ctx_cpu
,
SparseCooTensor
out
=
sparse
::
Conv3d
Coo
<
T
>
(
dev_ctx_cpu
,
x_tensor
,
kernel_tensor
,
paddings
,
...
...
@@ -139,7 +139,7 @@ void TestConv3dBase(const std::vector<IntT>& indices,
if
(
backward
)
{
std
::
tuple
<
SparseCooTensor
,
DenseTensor
>
grads
=
sparse
::
Conv3dGrad
<
T
>
(
dev_ctx_cpu
,
sparse
::
Conv3d
Coo
Grad
<
T
>
(
dev_ctx_cpu
,
x_tensor
,
kernel_tensor
,
rulebook
,
...
...
@@ -198,7 +198,7 @@ void TestConv3dBase(const std::vector<IntT>& indices,
DenseTensor
d_rulebook
=
phi
::
Empty
(
dev_ctx_gpu
,
DenseTensorMeta
(
indices_dtype
,
{
1
},
DataLayout
::
NCHW
));
SparseCooTensor
d_out
=
sparse
::
Conv3d
<
T
>
(
dev_ctx_gpu
,
SparseCooTensor
d_out
=
sparse
::
Conv3d
Coo
<
T
>
(
dev_ctx_gpu
,
d_x_tensor
,
d_kernel_tensor
,
paddings
,
...
...
@@ -242,7 +242,7 @@ void TestConv3dBase(const std::vector<IntT>& indices,
if
(
backward
)
{
std
::
tuple
<
SparseCooTensor
,
DenseTensor
>
grads
=
sparse
::
Conv3dGrad
<
T
>
(
dev_ctx_gpu
,
sparse
::
Conv3d
Coo
Grad
<
T
>
(
dev_ctx_gpu
,
d_x_tensor
,
d_kernel_tensor
,
d_rulebook
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录