aclgrphBundleBuildModel
Description
Compiles a group of input graphs into offline model adapted to the Ascend AI Processors. Compared with aclgrphBuildModel, this API is applicable to the weight update scenario.
After the offline model cache is generated using the aclgrphBundleBuildModel API, aclgrphBundleSaveModel needs to be called to flush the cache to disks.
Prototype
graphStatus aclgrphBundleBuildModel(const std::vector<ge::GraphWithOptions> &graph_with_options, ModelBufferData &model)
Restrictions
If multiple graphs in this API share the variable operator with the same name, the variable operator is accelerated and fused in the API. You are advised to use the aclgrphConvertToWeightRefreshableGraphs API for generation. Otherwise, the formats of the variable operators may be inconsistent.
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
graph_with_options |
Input |
A group of graphs to be compiled and compilation parameters. The input parameter is a structure, including: struct GraphWithOptions {
ge::Graph graph;
std::map<AscendString, AscendString> build_options;
};
A group of graphs include the weight initialization graph, weight update graph, and inference graph. Only the inference graph supports the following options argument. Pass the options argument to set the compilation configuration for offline model generation. For details about the supported parameters, see aclgrphBuildModel Configuration Parameters. The following is a configuration example. void PrepareOptions(std::map<AscendString, AscendString>& options) {
options.insert({
{ge::ir_option::EXEC_DISABLE_REUSED_MEMORY, "1"} // Disable memory reuse.
});
}
|
model |
Output |
Buffer of the generated offline model. struct ModelBufferData
{
std::shared_ptr<uint8_t> data = nullptr;
uint64_t length;
};
data points to the generated model data, and length indicates the actual model size. |
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
graphStatus |
GRAPH_SUCCESS: success. Other values: failure. |
Example
For details about the call example, see Example.