RegisterExternalAllocator

Description

Registers an external allocator to the GE. This applies to the scenario where the user's memory pool is used.

Prototype

Status RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const;

Parameters

Parameter

Input/Output

Description

stream

Input

Stream on which the allocator is registered.

allocator

Input

Smart pointer to the user's allocator object. The allocator is derived from Allocator.

Returns

Parameter

Type

Description

-

Status

SUCCESS: The setting is successful.

FAILED: The setting fails.

Restrictions

  • This API must be called along with RunGraphWithStreamAsync or ExecuteGraphWithStreamAsync and must be registered before the two APIs are called.
  • For the same stream, if this API is called for 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 OS, call aclrtSynchronizeStream provided by AscendCL to synchronize the stream and make sure that tasks in the stream have been executed.