Coverage for  / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / auto_parallel / sapp_nd / perf_estimation / utils_classes.py: 100%

30 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-07-06 05:41 +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"""Custom Config options""" 

16from enum import Enum, auto 

17 

18 

19class RatioType(Enum): 

20 "comm/comp" 

21 

22 COMM_ONLY = auto() 

23 COMPUTE_ONLY = auto() 

24 STATIC = auto() 

25 DYNAMIC = auto() 

26 

27 

28class PerformanceType(Enum): 

29 "metric" 

30 

31 FLOP = auto() 

32 TIME = auto() # to fix 

33 

34 

35class P2PCommType(Enum): 

36 """flags""" 

37 

38 NONE = auto() 

39 MANUAL = auto() 

40 

41 

42class RecType(Enum): 

43 """flags""" 

44 

45 NONE = auto() 

46 WITH = auto() 

47 COMM_ONLY = auto() 

48 COMPUTE_ONLY = auto() 

49 

50 

51class NetworkLevel(Enum): 

52 """device network""" 

53 

54 NODE = auto() 

55 CLUSTER = auto() 

56 

57 

58class CustomConfig: 

59 r"""Custom Config for Base Performance Estimator""" 

60 

61 def __init__( 

62 self, 

63 rtype=RatioType.DYNAMIC, 

64 # ttype = PerformanceType.TIME, 

65 ttype=PerformanceType.FLOP, 

66 ptype=P2PCommType.NONE, # MANUAL, 

67 retype=RecType.COMPUTE_ONLY, 

68 ): 

69 self.rtype = rtype 

70 self.ttype = ttype 

71 self.ptype = ptype 

72 self.retype = retype 

73 

74 def __repr__(self): 

75 return ( 

76 f"CustomConfig(rtype={self.rtype}, " 

77 f"ttype={self.ttype}, " 

78 f"ptype={self.ptype}, " 

79 f"retype={self.retype})" 

80 ) 

81 

82 def __str__(self): 

83 return self.__repr__()