Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/custom_op/__init__.py: 92%

13 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# 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"""Python GE custom op public package.""" 

14 

15__all__ = [ 

16 "BaseCustomOp", 

17 "EagerExecuteOp", 

18 "EagerOpExecutionContext", 

19 "clear_registered_op_impls", 

20 "get_registered_op_impl_by_descriptor_key", 

21 "get_registered_op_impl_dicts", 

22 "get_registered_op_impls", 

23 "register_op_impl", 

24] 

25 

26_LAZY_EXPORTS = { 

27 "BaseCustomOp": ".base", 

28 "EagerExecuteOp": ".base", 

29 "EagerOpExecutionContext": ".base", 

30 "clear_registered_op_impls": ".registry", 

31 "get_registered_op_impl_by_descriptor_key": ".registry", 

32 "get_registered_op_impl_dicts": ".registry", 

33 "get_registered_op_impls": ".registry", 

34 "register_op_impl": ".registry", 

35} 

36 

37 

38def __getattr__(name: str): 

39 module_name = _LAZY_EXPORTS.get(name) 

40 if module_name is None: 

41 raise AttributeError(f"module {__name__!r} has no attribute {name!r}") 

42 

43 import importlib 

44 

45 module = importlib.import_module(module_name, __name__) 

46 value = getattr(module, name) 

47 globals()[name] = value 

48 return value 

49 

50 

51def __dir__(): 

52 return sorted(set(globals()) | set(__all__))