aclrtAllocatorRegister

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product

Atlas training product

Function

Registers a user-provided Allocator and its callback function, so that the Allocator can be used later.

Prototype

1
aclError aclrtAllocatorRegister(aclrtStream stream, aclrtAllocatorDesc allocatorDesc)

Parameters

Parameter

Input/Output

Description

stream

Input

Stream to be registered by the Allocator. For the type definition, see aclrtStream.

The value cannot be NULL. Otherwise, an error is reported.

allocatorDesc

Input

Pointer to the allocator descriptor. For the type definition, see aclrtAllocatorDesc.

Returns

0 on success; otherwise, failure. For details, see aclError.

Restrictions

  • Currently, this API can be used only in single-operator model execution and dynamic shape model inference scenarios.

    In the single-operator model scenario, call this API before executing an operator API (such as aclopExecuteV2).

    In the dynamic-shape model inference scenario, call this API together with aclmdlExecuteAsync, and this API must be called before aclmdlExecuteAsync.

  • Before you call this API, call aclrtAllocatorCreateDesc to create an Allocator descriptor, and then call aclrtAllocatorSetObjToDesc, aclrtAllocatorSetAllocFuncToDesc, aclrtAllocatorSetGetAddrFromBlockFuncToDesc, and aclrtAllocatorSetFreeFuncToDesc to set the Allocator object and callback function. After the Allocator descriptor is used, call aclrtAllocatorDestroyDesc to destroy the Allocator descriptor.
  • If you call this API multiple times for the same stream, the last registration applies.
  • If you call this API for different streams using the same Allocator, concurrent execution of these streams is not allowed. Before you execute the next stream, synchronize the previous one.
  • Before releasing the memory from the Allocator back to the operating system, call aclrtSynchronizeStream to synchronize the stream and ensure that tasks in the stream have been executed.

Reference

For the API call example, see Dynamic Shape Input (Setting the Shape Range).