aclrtAllocatorRegister
Applicability
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
☓ |
|
|
√ |
|
|
√ |
Description
Registers a user-provided Allocator and its callback function, so that the Allocator can be used later.
Prototype
aclError aclrtAllocatorRegister(aclrtStream stream, aclrtAllocatorDesc allocatorDesc)
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
stream |
Input |
Stream to be registered by the Allocator. The value cannot be null. Otherwise, an error is reported. |
|
allocatorDesc |
Input |
Pointer to the Allocator descriptor. |
Returns
0 on success; else, 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 and aclopCompileAndExecuteV2).
In the dynamic-shape model inference scenario, this API must be used together with the aclmdlExecuteAsync API, and this API must be called before the aclmdlExecuteAsync API.
- 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 the aclrtAllocatorDestroyDesc API to destroy the Allocator descriptor.
- For the same stream, if this API is called multiple times, the last registration is used.
- For different streams, if you use the same Allocator, concurrent execution on multiple streams is not allowed. Before you execute the next stream, synchronize the previous one.
- Before the buffer is released by the Allocator to the operating system, call aclrtSynchronizeStream to synchronize the stream and make sure that tasks in the stream have been executed.