diff --git a/paddle/phi/api/yaml/sparse_backward.yaml b/paddle/phi/api/yaml/sparse_backward.yaml index ffb5406436faa2f37eb0c6108366594b778ddadc..6503dbb46e85765c57945d2e02e9c8b707f3f233 100644 --- a/paddle/phi/api/yaml/sparse_backward.yaml +++ b/paddle/phi/api/yaml/sparse_backward.yaml @@ -325,7 +325,7 @@ func : softmax_csr_grad{sparse_csr, sparse_csr -> sparse_csr} - backward_op : sparse_coo_tensor_grad - forward : sparse_coo_tensor(Tensor values, Tensor indices, IntArray dense_shape) -> Tensor(out) + forward : sparse_coo_tensor(Tensor values, Tensor indices, int64_t[] shape) -> Tensor(out) args : (Tensor indices, Tensor out_grad) output : Tensor(values_grad) infer_meta : diff --git a/paddle/phi/api/yaml/sparse_ops.yaml b/paddle/phi/api/yaml/sparse_ops.yaml index fb1562520f9a093868c4221567043221fab9e3e1..015e7aef0ff0b01f8655f059671eb9f29d19aea4 100644 --- a/paddle/phi/api/yaml/sparse_ops.yaml +++ b/paddle/phi/api/yaml/sparse_ops.yaml @@ -269,7 +269,7 @@ backward : softmax_grad - op : sparse_coo_tensor - args : (Tensor values, Tensor indices, IntArray dense_shape) + args : (Tensor values, Tensor indices, int64_t[] shape={}) output : Tensor(out) infer_meta : func : sparse::SparseCooTensorInferMeta diff --git a/paddle/phi/infermeta/sparse/binary.cc b/paddle/phi/infermeta/sparse/binary.cc index 1b86f00ac2eb71e9f0055ea19126a6800d3ae19e..650ab646639bbb3c3c234db531f4d1cb94d17e24 100644 --- a/paddle/phi/infermeta/sparse/binary.cc +++ b/paddle/phi/infermeta/sparse/binary.cc @@ -136,9 +136,9 @@ void Pool3dInferMeta(const MetaTensor& x, void SparseCooTensorInferMeta(const MetaTensor& values, const MetaTensor& indices, - const IntArray& dense_shape, + const std::vector& shape, MetaTensor* out) { - out->set_dims(phi::make_ddim(dense_shape.GetData())); + out->set_dims(phi::make_ddim(shape)); out->set_dtype(values.dtype()); out->set_layout(values.layout()); } diff --git a/paddle/phi/infermeta/sparse/binary.h b/paddle/phi/infermeta/sparse/binary.h index 39d58bb539e42fa70d1a663d2388d3e6be3f0008..a2c3e6fe5705c51ed2b76cfd31fa43cb61eec829 100644 --- a/paddle/phi/infermeta/sparse/binary.h +++ b/paddle/phi/infermeta/sparse/binary.h @@ -45,7 +45,7 @@ void Pool3dInferMeta(const MetaTensor& x, void SparseCooTensorInferMeta(const MetaTensor& values, const MetaTensor& indices, - const IntArray& dense_shape, + const std::vector& shape, MetaTensor* out); } // namespace sparse diff --git a/paddle/phi/kernels/sparse/sparse_utils_kernel.h b/paddle/phi/kernels/sparse/sparse_utils_kernel.h index fa16114e0f9f1e7394d60600cb7230908dd537b9..8639f91469454d1625773b287f4a17a87f6e7ff8 100644 --- a/paddle/phi/kernels/sparse/sparse_utils_kernel.h +++ b/paddle/phi/kernels/sparse/sparse_utils_kernel.h @@ -168,10 +168,9 @@ template void SparseCooTensorKernel(const Context& dev_ctx, const DenseTensor& values, const DenseTensor& indices, - const IntArray& dense_shape, + const std::vector& shape, SparseCooTensor* out) { - *out = - SparseCooTensor(indices, values, phi::make_ddim(dense_shape.GetData())); + *out = SparseCooTensor(indices, values, phi::make_ddim(shape)); } } // namespace sparse diff --git a/python/paddle/sparse/creation.py b/python/paddle/sparse/creation.py index 1237dff35225fe1310d128bcafbfd220b351420d..a960e895ff2d3f3035b4e3255290deda40f6f893 100644 --- a/python/paddle/sparse/creation.py +++ b/python/paddle/sparse/creation.py @@ -180,7 +180,7 @@ def sparse_coo_tensor( inputs = {'values': values, 'indices': indices} if shape[0] is None: shape[0] = -1 - attrs = {'dense_shape': shape} + attrs = {'shape': shape} helper = LayerHelper(op_type) out = helper.create_sparse_variable_for_type_inference(dtype) helper.append_op(