mindspore.ops.TupleToArray

View Source On Gitee
class mindspore.ops.TupleToArray[source]

Converts a tuple to a tensor.

Refer to mindspore.ops.tuple_to_array() for more details.

Inputs:
  • input_x (tuple) - A tuple of numbers. These numbers have the same type. The shape is \((N,*)\) where \(*\) means any number of additional dimensions.

Outputs:

Tensor, if the input tuple contains N numbers, then the shape of the output tensor is \((N,)\).

Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore import ops
>>> input_x = (1,2,3)
>>> print(type(input_x))
<class 'tuple'>
>>> output = ops.TupleToArray()(input_x)
>>> print(type(output))
<class 'mindspore.common.tensor.Tensor'>
>>> print(output)
[1 2 3]