Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/onnx_plugin/_native.py: 93%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-28 17:22 +0800

1#!/usr/bin/env python3 

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

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

4# Copyright (c) 2026 Huawei Technologies Co., Ltd. 

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

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

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

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

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

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

11# ----------------------------------------------------------------------------------------------------------- 

12 

13"""Load the native ONNX plugin value module.""" 

14 

15from __future__ import annotations 

16 

17from pathlib import Path 

18from importlib import import_module 

19 

20from ge._internal.artifact_utils import ( 

21 find_compatible_artifact, 

22 iter_artifacts, 

23 load_bridge_artifact_manifest, 

24 load_module_from_path, 

25) 

26 

27_BRIDGE_ABI_VERSION = 1 

28_ARTIFACTS_ROOT = Path(__file__).resolve().parent / "python_onnx_plugin_artifacts" 

29_NATIVE_MODULE_NAME = "ge.onnx_plugin._ge_onnx_plugin_native" 

30 

31 

32def _load_native_module(): 

33 artifacts = iter_artifacts(_ARTIFACTS_ROOT, load_bridge_artifact_manifest) 

34 artifact = find_compatible_artifact(artifacts, _BRIDGE_ABI_VERSION) 

35 if artifact is not None: 

36 return load_module_from_path(_NATIVE_MODULE_NAME, artifact.native_path) 

37 return import_module(_NATIVE_MODULE_NAME) 

38 

39 

40_native = _load_native_module() 

41 

42OnnxNode = _native.OnnxNode