RegisterCallBackFunc

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

x

Atlas inference products

Atlas training products

Header File/Library File

  • Header file: #include <ge/ge_api_v2.h>
  • Library file: libge_runner_v2.so

Function Usage

Registers a callback function.

Registers the Summary and Checkpoint callback APIs specified by users. If the graph sent to the GE contains the Summary and Checkpoint operators, the GE calls the registered callback function.

Prototype

1
Status RegisterCallBackFunc(const char *key, const RunCallBack &callback)

Parameters

Parameter

Input/Output

Description

key

Input

Keyword of the callback function to be registered, indicating the callback function type. The value is a string or character, such as Summary and Save.

callback

Input

Information to be returned by the callback function.

1
typedef uint32_t session::(*RunCallBack)(uint32_t graph_id, const std::map<AscendString, gert::Tensor> &params_list);

Returns

Parameter

Type

Description

-

Status

GE_SESSION_MANAGER_NOT_INIT: Session management is not initialized.

SUCCESS: The callback function is successfully registered.

FAILED: The callback function fails to be registered.

Constraints

  • The callback function type can only be Summary or Save.
  • If the function fails to be registered and the Summary and Checkpoint operators are delivered, an error is reported.
  • Currently, the callback function can be called only once after a graph is executed.