aclgrphBuildModel

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 an input graph into an offline model adapted to the Ascend AI Processor and saves it to the memory buffer.

Prototype

APIs taking string arguments will be deprecated in future releases. Use APIs taking non-string arguments instead.

1
2
graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string, std::string> &build_options, ModelBufferData &model)
graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<AscendString, AscendString> &build_options, ModelBufferData &model)

Parameters

Parameter

Input/Output

Description

graph

Input

Graph to be built.

build_options

Input

Graph-level configuration parameter.

A key-value mapping table, for the build configuration of the offline model. key indicates the options type, and value indicates the options value, both of type string.

For details about the configuration parameters supported by the map, see aclgrphBuildModel Configuration Parameters.

model

Output

Buffer for storing the generated offline model. The model is stored in the memory buffer. 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

  • For the same build arguments passed to aclgrphBuildModel and aclgrphBuildInitialize, you need to configure them once only. If the same arguments are passed repeatedly, the arguments passed to aclgrphBuildModel are used.
  • When the aclgrphBuildModel API is used to pass the build_options parameter in the multi-graph scenario, and the input parameter is ge::ir_option::PRECISION_MODE or ge::ir_option::PRECISION_MODE_V2, the parameter values of these graphs must be the same.
  • The offline model compiled by using the aclgrphBuildModel API is stored in the memory buffer.
    • aclgrphSaveModel: serializes the offline model in the memory buffer to the xx.om file. If acl APIs are to be used for inference, use the APIs that load a model from a file, for example, aclmdlLoadFromFile, and then use the aclmdlExecute API to perform inference.
    • If the offline model is stored in the memory buffer:

      If acl APIs are to be used for inference, use the APIs that load a model from the memory, for example, aclmdlLoadFromMem, and then use the aclmdlExecute API to perform inference.

    For details about acl APIs, see "Model Management".