update doc of Tensor.tolist (#9016)

it returns single value for const tensor
This commit is contained in:
chenyu
2025-02-10 16:51:23 -05:00
committed by GitHub
parent 04e64765c4
commit b741a9aae7

View File

@@ -334,11 +334,16 @@ class Tensor(SimpleMathTrait):
def tolist(self) -> Union[Sequence[ConstType], ConstType]:
"""
Returns the value of this tensor as a nested list.
Returns single value for const tensor.
```python exec="true" source="above" session="tensor" result="python"
t = Tensor([1, 2, 3, 4])
print(t.tolist())
```
```python exec="true" source="above" session="tensor" result="python"
t = Tensor(5)
print(t.tolist())
```
"""
return self.data().tolist()