CANN/ge GE Python API GeApi类文档
2026/7/4 21:46:38 网站建设 项目流程

GeApi

【免费下载链接】geGE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力,并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge

Product Support Status

ProductSupport Status
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products

Module Import

from ge.ge_global import GeApi from ge.error import GeError

Functionality Description

GeApi class provides GE global initialization and resource release interfaces. ge_initialize must be called before using other GE interfaces, ge_finalize is called when program exits to release resources. Both methods are class methods, can be called without instantiating GeApi.

Class Definition

class GeApi: @classmethod def ge_initialize(cls, config: dict) -> None @classmethod def ge_finalize(cls) -> None

Function Description

ge_initialize

@classmethod def ge_initialize(cls, config: dict) -> None

Functionality Description: Initializes GE, prepares execution environment. This method is a class method, can be called without instantiating GeApi. Must be called before using other GE interfaces.

Parameter Description:

ParameterTypeRequired/OptionalDescription
configdictRequiredGE initialization configuration dictionary, key-value pairs are string type, used to specify GE runtime parameters.

Return Value Description: No return value.

Constraint Description:

  • config must be dict type, otherwise throws TypeError.
  • config cannot be empty dictionary, otherwise throws TypeError.
  • When GE initialization fails, will throw GeError, exception information contains GE internal error information and interface context.
  • Must call this method before using other GE interfaces.
  • Do not repeatedly call ge_initialize, repeated calls may cause undefined behavior.

ge_finalize

@classmethod def ge_finalize(cls) -> None

Functionality Description: Releases GE resources, cleans up execution environment. This method is a class method, can be called without instantiating GeApi. Should be called when program exits or no longer needs GE.

Parameter Description: No parameters.

Return Value Description: No return value.

Constraint Description:

  • Before calling ge_finalize, must ensure all Sessions are destroyed, all graph resources are released.
  • When GE resource release fails, will throw GeError, exception information contains GE internal error information and interface context.
  • Do not continue using any GE interfaces after ge_finalize.

【免费下载链接】geGE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力,并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询