Basic Tensor Concepts

A tensor is a container for operator computing data. A tensor descriptor (TensorDesc) describes the data in a tensor. Table 1 describes the attributes of the TensorDesc data structure.

Table 1 TensorDesc attributes

Attribute

Definition

name

Indexes a tensor and must be unique.

shape

Specifies the shape of a tensor. For example, (10,), (1024, 1024), or (2, 3, 4). For example, the shape (3, 4) indicates a 3 x 4 matrix (3 rows and 4 columns), where the first dimension has three elements, and the second dimension has four elements.

Format: (i1, i2, ..., in), where i1 to in are positive integers.

NOTE:

Due to the restrictions of the AI Core operator compiler, empty tensors whose shape contain 0 cannot be transferred. Therefore, you need to avoid transferring empty tensors when constructing the input.

dtype

Specifies the data types of a tensor object.

Value range: float16, float32, int8, int16, int32, uint8, uint16, bfloat16, bool, and more

format

Defines the tensor format.

For details, see Format.