Overview

TensorDesc class is used to represent tensor metadata.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
The following is an example:
from ge.graph import TensorDesc, Shape, Format, DataType

# Create a TensorDesc object.
desc = TensorDesc(shape=[1, 3, 224, 224], format=Format.FORMAT_NCHW, data_type=DataType.DT_FLOAT)

# Obtain tensor information based on attributes.
print(desc.shape)       # [1, 3, 224, 224]
print(desc.format)      # Format.FORMAT_NCHW
print(desc.data_type)   # DataType.DT_FLOAT

# Obtain tensor information using methods.
shape = desc.get_shape()
fmt = desc.get_format()
dtype = desc.get_data_type()

# Set attributes for the chain call.
desc.set_shape([2, 3]).set_data_type(DataType.DT_INT32).set_format(Format.FORMAT_ND)