reshape

Description

Reshapes a Tensor.

Prototype

reshape(new_shape)

Parameters

Table 1 Parameter description

Parameter

Input/Output

Description

new_shape

Input

New shape of the Tensor object. A list or tuple of immediates (of type int), Scalars (of type int or uint), or Exprs (of type int or uint).

Applicability

Atlas training product

Atlas inference product AI Core

Atlas inference product Vector Core

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Restrictions

  • If the data of a Tensor is partially obtained from another Tensor, the Tensor cannot be reshaped by using this API.
  • The total size of the new shape must be the same as that of the old shape.
  • The new and old Tensors point to the same memory address. If the value of the new Tensor is changed, the value of the old Tensor changes accordingly.

Returns

The new Tensor.

Example

from tbe import tik
tik_instance = tik.Tik()
data_A = tik_instance.Tensor("float16", (128,), name="data_A", scope=tik.scope_gm)
data_a_reshape = data_A.reshape((64,2))