SetGraphFixedFeatureMemoryBaseWithType
Applicability
|
Product |
Supported or Not |
|---|---|
|
|
√ |
|
|
√ |
|
|
x |
|
|
√ |
|
|
√ |
Header File/Library File
- Header file: #include <ge/ge_api_v2.h>
- Library file: libge_runner_v2.so
Function Usage
Sets the base address of the fixed feature memory of different memory types in a graph.
Before calling this API, call CompileGraph to build the 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. |
Constraints
- 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 fixed memory type is MEMORY_TYPE_DEFAULT.
- 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.