mindspore.ops.TupleToArray

class mindspore.ops.TupleToArray(*args, **kwargs)[source]

Converts a tuple to a tensor.

If the type of the first number in the tuple is integer, the data type of the output tensor is int. Otherwise, the data type of the output tensor is float.

Inputs:
  • input_x (tuple) - A tuple of numbers. These numbers have the same type. Only constant value is allowed.

Outputs:

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

Raises
  • TypeError – If input_x is not a tuple.

  • ValueError – If length of input_x is less than or equal to 0.

Supported Platforms:

Ascend GPU CPU

Examples

>>> type = ops.TupleToArray()((1,2,3))
>>> print(type)
[1 2 3]