Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/graph/types.py: 100%

128 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) 2025 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# ---------------------------------------------------------------------------- 

12from enum import IntEnum 

13 

14 

15class DataType(IntEnum): 

16 # The enum value of DataType must be the same with the value in c++. 

17 # c++ file path: metadef/inc/external/graph/types.h 

18 DT_FLOAT = 0 # float type 

19 DT_FLOAT16 = 1 # fp16 type 

20 DT_INT8 = 2 # int8 type 

21 DT_INT32 = 3 # int32 type 

22 DT_UINT8 = 4 # uint8 type 

23 # reserved 

24 DT_INT16 = 6 # int16 type 

25 DT_UINT16 = 7 # uint16 type 

26 DT_UINT32 = 8 # unsigned int32 

27 DT_INT64 = 9 # int64 type 

28 DT_UINT64 = 10 # unsigned int64 

29 DT_DOUBLE = 11 # double type 

30 DT_BOOL = 12 # bool type 

31 DT_STRING = 13 # string type 

32 DT_DUAL_SUB_INT8 = 14 # dual output int8 type 

33 DT_DUAL_SUB_UINT8 = 15 # dual output uint8 type 

34 DT_COMPLEX64 = 16 # complex64 type 

35 DT_COMPLEX128 = 17 # complex128 type 

36 DT_QINT8 = 18 # qint8 type 

37 DT_QINT16 = 19 # qint16 type 

38 DT_QINT32 = 20 # qint32 type 

39 DT_QUINT8 = 21 # quint8 type 

40 DT_QUINT16 = 22 # quint16 type 

41 DT_RESOURCE = 23 # resource type 

42 DT_STRING_REF = 24 # string ref type 

43 DT_DUAL = 25 # dual output type 

44 DT_VARIANT = 26 # dt_variant type 

45 DT_BF16 = 27 # bf16 type 

46 DT_UNDEFINED = 28 # Used to indicate a DataType field has not been set. 

47 DT_INT4 = 29 # int4 type 

48 DT_UINT1 = 30 # uint1 type 

49 DT_INT2 = 31 # int2 type 

50 DT_UINT2 = 32 # uint2 type 

51 DT_COMPLEX32 = 33 # complex32 type 

52 DT_HIFLOAT8 = 34 # hifloat8 type 

53 DT_FLOAT8_E5M2 = 35 # float8_e5m2 type 

54 DT_FLOAT8_E4M3FN = 36 # float8_e4m3fn type 

55 DT_FLOAT8_E8M0 = 37 # float8_e8m0 type 

56 DT_FLOAT6_E3M2 = 38 # float6_e3m2 type 

57 DT_FLOAT6_E2M3 = 39 # float6_e2m3 type 

58 DT_FLOAT4_E2M1 = 40 # float4_e2m1 type 

59 DT_FLOAT4_E1M2 = 41 # float4_e1m2 type 

60 DT_HIFLOAT4 = 42 # hifloat4 type 

61 DT_MAX = 43 # Mark the boundaries of data types 

62 

63 

64class Format(IntEnum): 

65 # The enum value of Format must be the same with the value in c++. 

66 # c++ file path: metadef/inc/external/graph/types.h 

67 

68 FORMAT_NCHW = 0 # NCHW 

69 FORMAT_NHWC = 1 # NHWC 

70 FORMAT_ND = 2 # Nd Tensor 

71 FORMAT_NC1HWC0 = 3 # NC1HWC0 

72 FORMAT_FRACTAL_Z = 4 # FRACTAL_Z 

73 FORMAT_NC1C0HWPAD = 5 

74 FORMAT_NHWC1C0 = 6 

75 FORMAT_FSR_NCHW = 7 

76 FORMAT_FRACTAL_DECONV = 8 

77 FORMAT_C1HWNC0 = 9 

78 FORMAT_FRACTAL_DECONV_TRANSPOSE = 10 

79 FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11 

80 FORMAT_NC1HWC0_C04 = 12 # NC1HWC0, C0 is 4 

81 FORMAT_FRACTAL_Z_C04 = 13 # FRACZ, C0 is 4 

82 FORMAT_CHWN = 14 

83 FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15 

84 FORMAT_HWCN = 16 

85 FORMAT_NC1KHKWHWC0 = 17 # KH,KW kernel h& kernel w maxpooling max output format 

86 FORMAT_BN_WEIGHT = 18 

87 FORMAT_FILTER_HWCK = 19 # filter input tensor format 

88 FORMAT_HASHTABLE_LOOKUP_LOOKUPS = 20 

89 FORMAT_HASHTABLE_LOOKUP_KEYS = 21 

90 FORMAT_HASHTABLE_LOOKUP_VALUE = 22 

91 FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23 

92 FORMAT_HASHTABLE_LOOKUP_HITS = 24 

93 FORMAT_C1HWNCoC0 = 25 

94 FORMAT_MD = 26 

95 FORMAT_NDHWC = 27 

96 FORMAT_FRACTAL_ZZ = 28 

97 FORMAT_FRACTAL_NZ = 29 

98 FORMAT_NCDHW = 30 

99 FORMAT_DHWCN = 31 # 3D filter input tensor format 

100 FORMAT_NDC1HWC0 = 32 

101 FORMAT_FRACTAL_Z_3D = 33 

102 FORMAT_CN = 34 

103 FORMAT_NC = 35 

104 FORMAT_DHWNC = 36 

105 FORMAT_FRACTAL_Z_3D_TRANSPOSE = 37 # 3D filter(transpose) input tensor format 

106 FORMAT_FRACTAL_ZN_LSTM = 38 

107 FORMAT_FRACTAL_Z_G = 39 

108 FORMAT_RESERVED = 40 

109 FORMAT_ALL = 41 

110 FORMAT_NULL = 42 

111 FORMAT_ND_RNN_BIAS = 43 

112 FORMAT_FRACTAL_ZN_RNN = 44 

113 FORMAT_NYUV = 45 

114 FORMAT_NYUV_A = 46 

115 FORMAT_NCL = 47 

116 FORMAT_FRACTAL_Z_WINO = 48 

117 FORMAT_C1HWC0 = 49 

118 FORMAT_FRACTAL_NZ_C0_16 = 50 

119 FORMAT_FRACTAL_NZ_C0_32 = 51 

120 FORMAT_END = 52 

121 FORMAT_MAX = 53 

122 

123 

124class Placement(IntEnum): 

125 # The enum value of Placement must be the same with the value in c++. 

126 # c++ file path: metadef/inc/external/graph/types.h 

127 PLACEMENT_HOST = 0 

128 PLACEMENT_DEVICE = 1 

129 

130 

131class AttrValueType(IntEnum): 

132 # The enum value of AttrDataType must be the same with the value in c++(enum ValueType. 

133 # c++ file path: metadef/inc/graph/any_value.h 

134 VT_NONE = 0 

135 VT_STRING = 1 

136 VT_FLOAT = 2 

137 VT_BOOL = 3 

138 VT_INT = 4 

139 VT_TENSOR_DESC = 5 

140 VT_TENSOR = 6 

141 VT_BYTES = 7 

142 VT_GRAPH = 8 

143 VT_NAMED_ATTRS = 9 

144 VT_LIST_LIST_INT = 10 

145 VT_DATA_TYPE = 11 

146 VT_LIST_LIST_FLOAT = 12 

147 

148 VT_LIST_BASE = 1000 

149 VT_LIST_STRING = VT_LIST_BASE + VT_STRING 

150 VT_LIST_FLOAT = VT_LIST_BASE + VT_FLOAT 

151 VT_LIST_BOOL = VT_LIST_BASE + VT_BOOL 

152 VT_LIST_INT = VT_LIST_BASE + VT_INT 

153 VT_LIST_TENSOR_DESC = VT_LIST_BASE + VT_TENSOR_DESC 

154 VT_LIST_TENSOR = VT_LIST_BASE + VT_TENSOR 

155 VT_LIST_BYTES = VT_LIST_BASE + VT_BYTES 

156 VT_LIST_GRAPH = VT_LIST_BASE + VT_GRAPH 

157 VT_LIST_NAMED_ATTRS = VT_LIST_BASE + VT_NAMED_ATTRS 

158 VT_LIST_DATA_TYPE = VT_LIST_BASE + VT_DATA_TYPE