register_external_allocator

Function Usage

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

Prototype

1
register_external_allocator(stream: int, allocator: Allocator) -> None

Parameters

Parameter

Input/Output

Description

stream

Input

Stream on which the allocator is registered

allocator

Input

User Allocator object, which is derived from Allocator

Returns

None

Restrictions

  • If stream is not an integer, TypeError is thrown.
  • If the allocator is not an Allocator object, TypeError is thrown.
  • If the registration fails, RuntimeError is thrown.
  • 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 the buffer is released by the Allocator to the operating system, call acl.rt.synchronize_stream to synchronize the stream and make sure that tasks in the stream have been executed.