CompileGraph
Description
Synchronously compiles the graph corresponding to the specified ID. Compared with BuildGraph, this API provides only the graph compilation function and does not generate executable models. BuildGraph contains the graph build process, initializes the memory resources required by the model after the process, and generates an executable model.
This API does not provide the memory resource management function. Instead, users can customize the memory management. This API can be used together with the API for querying the graph resource usage after compilation, and the API for updating the memory base address. In this way, you can manage the model memory with higher flexibility.
After calling this API, call GetCompiledGraphSummary to obtain the brief information about the graph compilation result (such as the memory size required for model execution and whether the memory can be updated and reused). Allocate and manage the memory based on the queried memory size. Then, call SetGraphConstMemoryBase and UpdateGraphFeatureMemoryBase to set and update the memory base address.
Prototype
Status CompileGraph(uint32_t graph_id);
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
graph_id |
Input |
Subgraph ID. |
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
Status |
SUCCESS: Subgraph build successful. FAILED: Subgraph build failed. PARAM_INVALID: The input graph information is abnormal when the subgraph is compiled. |
Restrictions
- This API can be used only with RunGraphWithStreamAsync or ExecuteGraphWithStreamAsync and cannot be used with RunGraph or RunGraphAsync.
- Graphs containing the Variable operator do not support this API.