Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/_capi/pygeapi_wrapper.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-27 10:02 +0800

1#!/usr/bin/env python3 

2# -*- coding: utf-8 -*- 

3# ------------------------------------------------------------------- 

4# ----------------------------------------------------------------------------------------------------------- 

5# Copyright (c) 2025 Huawei Technologies Co., Ltd. 

6# This program is free software, you can redistribute it and/or modify it under the terms and conditions of 

7# CANN Open Software License Agreement Version 2.0 (the "License"). 

8# Please refer to the License for details. You may not use this file except in compliance with the License. 

9# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 

10# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 

11# See LICENSE in the root of the software repository for the full text of the License. 

12# ----------------------------------------------------------------------------------------------------------- 

13 

14import ctypes 

15import os 

16 

17from ._lib_loader import load_lib_from_path 

18 

19LIB_NAME = "libge_runtime_wrapper.so" 

20_dir = os.path.dirname(os.path.abspath(__file__)) 

21geapi_lib = load_lib_from_path(LIB_NAME, _dir) 

22 

23c_char_p = ctypes.c_char_p 

24c_int = ctypes.c_int 

25c_uint32 = ctypes.c_uint32 

26 

27# 初始化阶段 

28geapi_lib.GeApiWrapper_GEInitialize.argtypes = [ 

29 ctypes.POINTER(c_char_p), 

30 ctypes.POINTER(c_char_p), 

31 c_int, 

32] 

33geapi_lib.GeApiWrapper_GEInitialize.restype = c_uint32 

34 

35geapi_lib.GeApiWrapper_GEFinalize.argtypes = [] 

36geapi_lib.GeApiWrapper_GEFinalize.restype = c_uint32 

37 

38geapi_lib.GeApiWrapper_GEGetErrorMsg.argtypes = [] 

39geapi_lib.GeApiWrapper_GEGetErrorMsg.restype = c_char_p 

40 

41 

42def get_geapi_lib(): 

43 """Get the GE API wrapper library handle. 

44 

45 Returns: 

46 ctypes.CDLL: The loaded libge_runtime_wrapper.so library handle. 

47 """ 

48 return geapi_lib 

49 

50 

51def is_geapi_lib_loaded(): 

52 """Check if GE API library is loaded. 

53 

54 Returns: 

55 bool: True if library is loaded successfully. 

56 """ 

57 return geapi_lib is not None