Skip to content

Commit 75088bb

Browse files
author
zhangkaihuo
authored
[Sparse] Unified api args name (#47529) (#47627)
Unified api args name
1 parent d4bf8b1 commit 75088bb

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

paddle/phi/api/yaml/sparse_backward.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
func : softmax_csr_grad{sparse_csr, sparse_csr -> sparse_csr}
326326

327327
- backward_op : sparse_coo_tensor_grad
328-
forward : sparse_coo_tensor(Tensor values, Tensor indices, IntArray dense_shape) -> Tensor(out)
328+
forward : sparse_coo_tensor(Tensor values, Tensor indices, int64_t[] shape) -> Tensor(out)
329329
args : (Tensor indices, Tensor out_grad)
330330
output : Tensor(values_grad)
331331
infer_meta :

paddle/phi/api/yaml/sparse_ops.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
backward : softmax_grad
270270

271271
- op : sparse_coo_tensor
272-
args : (Tensor values, Tensor indices, IntArray dense_shape)
272+
args : (Tensor values, Tensor indices, int64_t[] shape={})
273273
output : Tensor(out)
274274
infer_meta :
275275
func : sparse::SparseCooTensorInferMeta

paddle/phi/infermeta/sparse/binary.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ void Pool3dInferMeta(const MetaTensor& x,
136136

137137
void SparseCooTensorInferMeta(const MetaTensor& values,
138138
const MetaTensor& indices,
139-
const IntArray& dense_shape,
139+
const std::vector<int64_t>& shape,
140140
MetaTensor* out) {
141-
out->set_dims(phi::make_ddim(dense_shape.GetData()));
141+
out->set_dims(phi::make_ddim(shape));
142142
out->set_dtype(values.dtype());
143143
out->set_layout(values.layout());
144144
}

paddle/phi/infermeta/sparse/binary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void Pool3dInferMeta(const MetaTensor& x,
4545

4646
void SparseCooTensorInferMeta(const MetaTensor& values,
4747
const MetaTensor& indices,
48-
const IntArray& dense_shape,
48+
const std::vector<int64_t>& shape,
4949
MetaTensor* out);
5050

5151
} // namespace sparse

paddle/phi/kernels/sparse/sparse_utils_kernel.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,9 @@ template <typename T, typename Context>
168168
void SparseCooTensorKernel(const Context& dev_ctx,
169169
const DenseTensor& values,
170170
const DenseTensor& indices,
171-
const IntArray& dense_shape,
171+
const std::vector<int64_t>& shape,
172172
SparseCooTensor* out) {
173-
*out =
174-
SparseCooTensor(indices, values, phi::make_ddim(dense_shape.GetData()));
173+
*out = SparseCooTensor(indices, values, phi::make_ddim(shape));
175174
}
176175

177176
} // namespace sparse

python/paddle/sparse/creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def sparse_coo_tensor(
180180
inputs = {'values': values, 'indices': indices}
181181
if shape[0] is None:
182182
shape[0] = -1
183-
attrs = {'dense_shape': shape}
183+
attrs = {'shape': shape}
184184
helper = LayerHelper(op_type)
185185
out = helper.create_sparse_variable_for_type_inference(dtype)
186186
helper.append_op(

0 commit comments

Comments
 (0)