RegisterCallBackFunc

Description

Registers a callback function.

Registers the specified callback function, which will be called by GE if the graph sent to GE contains summary and checkpoint operators.

Prototype

APIs using strings will be deprecated in later versions. Use APIs supporting non-string data instead.

Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback);
Status RegisterCallBackFunc(const char *key, const session::pCallBackFunc &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, for example, Summary and Save.

callback

Input

Information to be returned by the callback function.

typedef uint32_t(*pCallBackFunc)(uint32_t graph_id, const std::map<std::string, ge::Tensor> &params_list);
typedef uint32_t session::(*pCallBackFunc)(uint32_t graph_id, const std::map<AscendString, ge::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.

Restrictions

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