AllocTensor

Applicable Products

Product

Supported

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

x

Atlas inference products

x

Atlas training products

x

Function Description

To reduce input and output copy overhead, the FlowBufferFactory class is provided to construct objects that use shared memory.

AllocTensor allocates tensors based on the shape, data type, and alignment size. By default, the tensor is 64-byte aligned. You can specify the alignment size for performance tuning.

Prototype

1
std::shared_ptr<Tensor> AllocTensor(const std::vector<int64_t> &shape, TensorDataType dataType, uint32_t align = 512U)

Parameters

Parameter

Input/Output

Description

shape

Input

Shape of a tensor.

dataType

Input

Data type of a tensor.

align

Input

Alignment size for the allocated memory address. The value range is [32, 64, 128, 256, 512, 1024].

Returns

Pointer to the allocated tensor.

Exception Handling

NULL is returned if the tensor allocation fails.

Constraints

None