diff --git a/paddle/phi/api/yaml/sparse_backward.yaml b/paddle/phi/api/yaml/sparse_backward.yaml index b0a4a97ca5f633a084269394ffbb99727e57fec1..54dec292efb9d833802777497b0b99155e3845a4 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 6e6fd07a240fb6edfe7085c68d4171459355c493..ea35737a704b83d7e3c5ee79445a6971f4a9d10c 100644 --- a/paddle/phi/api/yaml/sparse_ops.yaml +++ b/paddle/phi/api/yaml/sparse_ops.yaml @@ -280,7 +280,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 6f0c9cb42e430abcd2ade370cae59a497fa0e36f..7b23d7326058e7f6f0b4c3675290fda8de8f1649 100644 --- a/python/paddle/sparse/creation.py +++ b/python/paddle/sparse/creation.py @@ -169,7 +169,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(