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-25 10: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 "InferMetaContext", 

21 "WorkspaceAddr", 

22 "clear_registered_op_impls", 

23 "get_declare_launch_args_ctx", 

24 "get_execute_ctx", 

25 "get_registered_op_impl_by_descriptor_key", 

26 "get_registered_op_impl_dicts", 

27 "get_registered_op_impls", 

28 "register_op", 

29 "register_op_impl", 

30] 

31 

32_LAZY_EXPORTS = { 

33 "AnnotatedArgsContext": "._native", 

34 "AnnotatedKernelArgs": "._native", 

35 "AnnotatedKernelLaunchInfo": "._native", 

36 "EagerOpExecutionContext": "._native", 

37 "InferMetaContext": "._native", 

38 "clear_registered_op_impls": ".registry", 

39 "get_declare_launch_args_ctx": ".context", 

40 "get_execute_ctx": ".context", 

41 "get_registered_op_impl_by_descriptor_key": ".registry", 

42 "get_registered_op_impl_dicts": ".registry", 

43 "get_registered_op_impls": ".registry", 

44 "register_op": ".proto", 

45 "register_op_impl": ".registry", 

46 "WorkspaceAddr": "._native", 

47} 

48 

49 

50def __getattr__(name: str): 

51 module_name = _LAZY_EXPORTS.get(name) 

52 if module_name is None: 

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

54 

55 import importlib 

56 

57 module = importlib.import_module(module_name, __name__) 

58 value = getattr(module, name) 

59 globals()[name] = value 

60 return value 

61 

62 

63def __dir__(): 

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