RegisterExternalAllocator

Applicability

Product

Supported or Not

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

Atlas training products

Header File/Library File

  • Header file: #include <ge/ge_api_v2.h>
  • Library file: libge_runner_v2.so

Function Usage

Registers a user's Allocator to the GE. This applies to the scenario where the user's memory pool is used.

This API must be used together with LoadGraph and RunGraphWithStreamAsync and must be registered before LoadGraph is called.

Prototype

1
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.

Constraints

  • 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 OS, call "aclrtSynchronizeStream" of acl to synchronize the stream and make sure that tasks in the stream have been executed.