Coverage for  / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / platform / mindspore / symmetric_memory / aclshmem_ms / __init__.py: 0%

34 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-05-20 07:18 +0800

1# Copyright 2025 Huawei Technologies Co., Ltd 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14# ============================================================================ 

15 

16"""MS acl shmem Ops Package 

17 

18This module provides the public API for one-sided communication Operations for MindSpore framework 

19based on aclshmem backend. 

20It includes functions for registering one-sided communication operators and managing 

21their lifecycle within the MindSpore framework. 

22 

23Example usage: 

24 >>> import aclshmem_ms 

25 >>> aclshmem_ms.register_op("my_custom_op", ...) 

26""" 

27 

28import os 

29import glob 

30 

31def _find_plugin(): 

32 """Find plugin .so file path automatically.""" 

33 current_path = os.path.dirname(os.path.abspath(__file__)) 

34 pattern = os.path.join(current_path, "aclshmem_ms.so") 

35 matches = glob.glob(pattern) 

36 if not matches: 

37 raise FileNotFoundError(f"Plugin .so not found in {current_path}") 

38 return matches[0] 

39 

40 

41_find_plugin() 

42 

43# pylint: disable=wrong-import-position 

44from .aclshmem_ms import * 

45 

46# Import generated ops interfaces 

47try: 

48 from .gen_ops_def import * 

49except ImportError: 

50 pass # Generated files may not exist during development 

51 

52try: 

53 from .gen_ops_prim import * 

54except ImportError: 

55 pass # Generated files may not exist during development 

56 

57__all__ = [] 

58# Add ops from gen_ops_def if available 

59try: 

60 import aclshmem_ms.gen_ops_def as gen_ops_def # pylint: disable=consider-using-from-import 

61 if hasattr(gen_ops_def, '__all__'): 

62 __all__.extend(gen_ops_def.__all__) 

63 else: 

64 # If no __all__ defined, add all public functions 

65 __all__.extend([name for name in dir(gen_ops_def) if not name.startswith('_')]) 

66except ImportError: 

67 pass 

68 

69# Add ops from gen_ops_prim if available 

70try: 

71 import aclshmem_ms.gen_ops_prim as gen_ops_prim # pylint: disable=consider-using-from-import 

72 if hasattr(gen_ops_prim, '__all__'): 

73 __all__.extend(gen_ops_prim.__all__) 

74 else: 

75 # If no __all__ defined, add all public functions 

76 __all__.extend([name for name in dir(gen_ops_prim) if not name.startswith('_')]) 

77except ImportError: 

78 pass