SetGraphFixedFeatureMemoryBaseWithType

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.h>
  • Library file: libge_runner.so

Function Usage

Sets the base address of the fixed feature memory of different memory types in a graph.

The memory size is obtained from GetCompiledGraphSummary > GetAllFeatureMemoryTypeSize. Feature memory refers to the intermediate memory required during model execution (for example, the input and output memories of intermediate nodes).

  • If the graph contains the fixed memory which is not specified by the user, the fixed memory is allocated by default.
  • If you do not want the fixed memory to be allocated by default, set the address to a nullptr and size to 0. (This is not applicable to the scenario where the memory type is MEMORY_TYPE_P2P.)

Prototype

1
Status SetGraphFixedFeatureMemoryBaseWithType(uint32_t graph_id, MemoryType type, const void *const memory, size_t size)

Parameters

Parameter

Input/Output

Description

graph_id

Input

Subgraph ID.

type

Input

Memory type, such as MemoryType::MEMORY_TYPE_DEFAULT and MemoryType::MEMORY_TYPE_P2P.

memory

Input

Base address of the fixed feature memory.

size

Input

Size of the fixed feature memory. The value must be greater than or equal to that obtained from GetCompiledGraphSummary > GetAllFeatureMemoryTypeSize.

Returns

Parameter

Type

Description

-

Status

SUCCESS: The setting is successful.

FAILED: The setting fails.

Restrictions

  • Before calling this API, you must call CompileGraph to compile the graph.
  • Each graph can be set only once for each memory type and cannot be updated.
  • This API cannot be used together with UpdateGraphFeatureMemoryBase when the memory type is MEMORY_TYPE_DEFAULT.
  • This API cannot be used together with SetGraphFixedFeatureMemoryBase. SetGraphFixedFeatureMemoryBaseWithType is used to set the fixed memory base addresses for different memory types, while SetGraphFixedFeatureMemoryBase is used to specify the fixed memory base address and size for a specified memory type.
  • When the fixed memory length is 0, calling this API does not take effect, and a warning log will be generated.
  • When ge.exec.staticMemoryPolicy in Command-Line Options is set to 4 or the GE_USE_STATIC_MEMORY environment variable is set to 4, memory reuse is supported for dynamic and static graphs. However, this API does not support address update. Therefore, in the memory reuse scenario of dynamic and static graphs, the default fixed memory allocation cannot be disabled by setting the address to nullptr and size to 0.