fix csrtensor/cootensor docs

This commit is contained in:
wangrao124 2022-03-14 16:27:06 +08:00
parent a6454e02e4
commit 82b80d3cb7
2 changed files with 37 additions and 3 deletions

View File

@ -5,6 +5,16 @@ mindspore.COOTensor
用来表示某一张量在给定索引上非零元素的集合,其中索引(indices)指示了每一个非零元素的位置。
对一个稠密Tensor `dense` 来说它对应的COOTensor(indices, values, dense_shape),满足 `dense[indices[i]] = values[i]`
如果 `indices` 是[[0, 1], [1, 2]] `values` 是[1, 2] `dense_shape` 是(3, 4)那么它对应的稠密Tensor如下
.. code-block::
[[0, 1, 0, 0],
[0, 0, 2, 0],
[0, 0, 0, 0]]
.. note::
这是一个实验特性在未来可能会发生API的变化。

View File

@ -2585,11 +2585,27 @@ class COOTensor(COOTensor_):
return COOTensor(self.indices, data, self.shape)
def to_tuple(self):
"""Return indices, values and shape as a tuple."""
"""
Return indices, values and shape as a tuple.
Returns:
Tuple.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
"""
return self.indices, self.values, self.shape
def abs(self):
"""Return absolute value element-wisely."""
"""
Return absolute value element-wisely.
Returns:
COOTensor.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
"""
data = self.values.abs()
return COOTensor(self.indices, data, self.shape)
@ -2709,7 +2725,15 @@ class CSRTensor(CSRTensor_):
return len(self.shape)
def to_tuple(self):
"""Return indptr, indices, values and shape as a tuple."""
"""
Return indptr, indices, values and shape as a tuple.
Returns:
Tuple.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
"""
return self.indptr, self.indices, self.values, self.shape
def to_coo(self):