aclgrphBundleBuildModel

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

Atlas inference products

Atlas training products

Header File/Library File

  • Header file: #include <ge/ge_ir_build.h>
  • Library file: libge_compiler.so

Function Usage

Builds a group of input graphs into an offline model adapted to the Ascend AI Processor.

The difference between this API and aclgrphBuildModel is that this API applies 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

1
graphStatus aclgrphBundleBuildModel(const std::vector<ge::GraphWithOptions> &graph_with_options, ModelBufferData &model)

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:

1
2
3
4
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 build configuration for offline model generation. For details about the supported parameters, see aclgrphBuildModel Configuration Parameters. The following is a configuration example.

1
2
3
4
5
void PrepareOptions(std::map<AscendString, AscendString>& options) {
    options.insert({
        {ge::ir_option::EXEC_DISABLE_REUSED_MEMORY, "1"} // close reuse memory
        });
}

model

Output

Buffer of the generated offline model. For details, see ModelBufferData.

1
2
3
4
5
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(0): success.

Other values: failure. For details, see ge::graphStatus.

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.

Example

For details about the call example, see Example.