mindspore.ops.coo_concat
- mindspore.ops.coo_concat(sp_input, concat_dim=0)[source]
concatenates the input SparseTensor(COO format) along the specified dimension.
Warning
This is an experimental API that is subjected to change or deletion. Only supported on CPU now.
- Parameters
- Returns
output (COOtensor) - the result of concatenates the input SparseTensor along the specified dimension. OutShape: OutShape[non concat_dim] is equal to InShape[non concat_dim] and OutShape[concat_dim] is all input concat_dim axis shape accumulate.
- Raises
ValueError – If only one sparse tensor input.
ValueError – If Input COOTensor shape dim > 3. COOtensor shape dim size must be 2 now.
- Supported Platforms:
CPU
Examples
>>> from mindspore import Tensor, ops, COOTensor >>> from mindspore import dtype as mstype >>> indices0 = Tensor([[0, 1], [1, 2]], dtype=mstype.int64) >>> values0 = Tensor([1, 2], dtype=mstype.int32) >>> shape0 = (3, 4) >>> input0 = COOTensor(indices0, values0, shape0) >>> indices1 = Tensor([[0, 0], [1, 1]], dtype=mstype.int64) >>> values1 = Tensor([3, 4], dtype=mstype.int32) >>> shape1 = (3, 4) >>> input1 = COOTensor(indices1, values1, shape1) >>> concat_dim = 1 >>> out = ops.coo_concat((input0, input1), concat_dim) >>> print(out) COOTensor(shape=[3, 8], dtype=Int32, indices=Tensor(shape=[4, 2], dtype=Int64, value= [[0 1] [0 4] [1 2] [1 5]]), values=Tensor(shape=[4], dtype=Int32, value=[1 3 2 4]))