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

14 

15__all__ = [ 

16 "AnnotatedArgsContext", 

17 "AnnotatedKernelArgs", 

18 "AnnotatedKernelLaunchInfo", 

19 "EagerOpExecutionContext", 

20 "CompilePlatformInfo", 

21 "OpCompileContext", 

22 "InferMetaContext", 

23 "WorkspaceAddr", 

24 "clear_registered_op_impls", 

25 "get_declare_launch_args_ctx", 

26 "get_compile_ctx", 

27 "get_compile_platform_info", 

28 "get_execute_ctx", 

29 "get_registered_op_impl_by_descriptor_key", 

30 "get_registered_op_impl_dicts", 

31 "get_registered_op_impls", 

32 "register_op", 

33 "register_op_impl", 

34] 

35 

36_LAZY_EXPORTS = { 

37 "AnnotatedArgsContext": "._native", 

38 "AnnotatedKernelArgs": "._native", 

39 "AnnotatedKernelLaunchInfo": "._native", 

40 "EagerOpExecutionContext": "._native", 

41 "InferMetaContext": "._native", 

42 "clear_registered_op_impls": ".registry", 

43 "get_declare_launch_args_ctx": ".context", 

44 "get_compile_ctx": ".context", 

45 "get_compile_platform_info": ".context", 

46 "get_execute_ctx": ".context", 

47 "get_registered_op_impl_by_descriptor_key": ".registry", 

48 "get_registered_op_impl_dicts": ".registry", 

49 "get_registered_op_impls": ".registry", 

50 "register_op": ".proto", 

51 "register_op_impl": ".registry", 

52 "WorkspaceAddr": "._native", 

53 "OpCompileContext": "._native", 

54 "CompilePlatformInfo": "._native", 

55} 

56 

57 

58def __getattr__(name: str): 

59 module_name = _LAZY_EXPORTS.get(name) 

60 if module_name is None: 

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

62 

63 import importlib 

64 

65 module = importlib.import_module(module_name, __name__) 

66 value = getattr(module, name) 

67 globals()[name] = value 

68 return value 

69 

70 

71def __dir__(): 

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