• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2023 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_DVPP_UTILS_ERROR_CODE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_DVPP_UTILS_ERROR_CODE_H_
19 
20 #include <string>
21 
22 using APP_ERROR = int;
23 // define the data tpye of error code
24 enum {
25   APP_ERR_OK = 0,
26 
27   // define the error code of ACL model, this is same with the aclError which is
28   // error code of ACL API Error codes 1~999 are reserved for the ACL. Do not
29   // add other error codes. Add it after APP_ERR_COMMON_ERR_BASE.
30   APP_ERR_ACL_FAILURE = -1,                   // ACL: general error
31   APP_ERR_ACL_INVALID_PARAM = 1,              // ACL: invalid parameter
32   APP_ERR_ACL_BAD_ALLOC = 2,                  // ACL: memory allocation fail
33   APP_ERR_ACL_RT_FAILURE = 3,                 // ACL: runtime failure
34   APP_ERR_ACL_GE_FAILURE = 4,                 // ACL: Graph Engine failure
35   APP_ERR_ACL_OP_NOT_FOUND = 5,               // ACL: operator not found
36   APP_ERR_ACL_OP_LOAD_FAILED = 6,             // ACL: fail to load operator
37   APP_ERR_ACL_READ_MODEL_FAILURE = 7,         // ACL: fail to read model
38   APP_ERR_ACL_PARSE_MODEL = 8,                // ACL: parse model failure
39   APP_ERR_ACL_MODEL_MISSING_ATTR = 9,         // ACL: model missing attribute
40   APP_ERR_ACL_DESERIALIZE_MODEL = 10,         // ACL: deserialize model failure
41   APP_ERR_ACL_EVENT_NOT_READY = 12,           // ACL: event not ready
42   APP_ERR_ACL_EVENT_COMPLETE = 13,            // ACL: event complete
43   APP_ERR_ACL_UNSUPPORTED_DATA_TYPE = 14,     // ACL: unsupported data type
44   APP_ERR_ACL_REPEAT_INITIALIZE = 15,         // ACL: repeat initialize
45   APP_ERR_ACL_COMPILER_NOT_REGISTERED = 16,   // ACL: compiler not registered
46   APP_ERR_ACL_IO = 17,                        // ACL: IO failed
47   APP_ERR_ACL_INVALID_FILE = 18,              // ACL: invalid file
48   APP_ERR_ACL_INVALID_DUMP_CONFIG = 19,       // ACL: invalid dump comfig
49   APP_ERR_ACL_INVALID_PROFILING_CONFIG = 20,  // ACL: invalid profiling config
50   APP_ERR_ACL_OP_TYPE_NOT_MATCH = 21,         // ACL: operator type not match
51   APP_ERR_ACL_OP_INPUT_NOT_MATCH = 22,        // ACL: operator input not match
52   APP_ERR_ACL_OP_OUTPUT_NOT_MATCH = 23,       // ACL: operator output not match
53   APP_ERR_ACL_OP_ATTR_NOT_MATCH = 24,         // ACL: operator attribute not match
54   APP_ERR_ACL_API_NOT_SUPPORT = 25,           // ACL: API not support
55   APP_ERR_ACL_CREATE_DATA_BUF_FAILED = 26,    // ACL: create data buffer fail
56   APP_ERR_ACL_END,                            // Not an error code, define the range of ACL error code
57 
58   // define the common error code, range: 1001~1999
59   APP_ERR_COMM_BASE = 1000,
60   APP_ERR_COMM_FAILURE = APP_ERR_COMM_BASE + 1,              // General Failed
61   APP_ERR_COMM_INNER = APP_ERR_COMM_BASE + 2,                // Internal error
62   APP_ERR_COMM_INVALID_POINTER = APP_ERR_COMM_BASE + 3,      // Invalid Pointer
63   APP_ERR_COMM_INVALID_PARAM = APP_ERR_COMM_BASE + 4,        // Invalid parameter
64   APP_ERR_COMM_UNREALIZED = APP_ERR_COMM_BASE + 5,           // Not implemented
65   APP_ERR_COMM_OUT_OF_MEM = APP_ERR_COMM_BASE + 6,           // Out of memory
66   APP_ERR_COMM_ALLOC_MEM = APP_ERR_COMM_BASE + 7,            // memory allocation error
67   APP_ERR_COMM_FREE_MEM = APP_ERR_COMM_BASE + 8,             // free memory error
68   APP_ERR_COMM_OUT_OF_RANGE = APP_ERR_COMM_BASE + 9,         // out of range
69   APP_ERR_COMM_NO_PERMISSION = APP_ERR_COMM_BASE + 10,       // NO Permission
70   APP_ERR_COMM_TIMEOUT = APP_ERR_COMM_BASE + 11,             // Timed out
71   APP_ERR_COMM_NOT_INIT = APP_ERR_COMM_BASE + 12,            // Not initialized
72   APP_ERR_COMM_INIT_FAIL = APP_ERR_COMM_BASE + 13,           // initialize failed
73   APP_ERR_COMM_INPROGRESS = APP_ERR_COMM_BASE + 14,          // Operation now in progress
74   APP_ERR_COMM_EXIST = APP_ERR_COMM_BASE + 15,               // Object, file or other resource already exist
75   APP_ERR_COMM_NO_EXIST = APP_ERR_COMM_BASE + 16,            // Object, file or other resource doesn't exist
76   APP_ERR_COMM_BUSY = APP_ERR_COMM_BASE + 17,                // Object, file or other resource is in use
77   APP_ERR_COMM_FULL = APP_ERR_COMM_BASE + 18,                // No available Device or resource
78   APP_ERR_COMM_OPEN_FAIL = APP_ERR_COMM_BASE + 19,           // Device, file or resource open failed
79   APP_ERR_COMM_READ_FAIL = APP_ERR_COMM_BASE + 20,           // Device, file or resource read failed
80   APP_ERR_COMM_WRITE_FAIL = APP_ERR_COMM_BASE + 21,          // Device, file or resource write failed
81   APP_ERR_COMM_DESTORY_FAIL = APP_ERR_COMM_BASE + 22,        // Device, file or resource destroy failed
82   APP_ERR_COMM_EXIT = APP_ERR_COMM_BASE + 23,                // End of data stream, stop the application
83   APP_ERR_COMM_CONNECTION_CLOSE = APP_ERR_COMM_BASE + 24,    // Out of connection, Communication shutdown
84   APP_ERR_COMM_CONNECTION_FAILURE = APP_ERR_COMM_BASE + 25,  // connection fail
85   APP_ERR_COMM_STREAM_INVALID = APP_ERR_COMM_BASE + 26,      // ACL stream is null pointer
86   APP_ERR_COMM_END,                                          // Not an error code, define the range of common error code
87 
88   // define the error code of DVPP
89   APP_ERR_DVPP_BASE = 2000,
90   APP_ERR_DVPP_CROP_FAIL = APP_ERR_DVPP_BASE + 1,            // DVPP: crop fail
91   APP_ERR_DVPP_RESIZE_FAIL = APP_ERR_DVPP_BASE + 2,          // DVPP: resize fail
92   APP_ERR_DVPP_CROP_RESIZE_FAIL = APP_ERR_DVPP_BASE + 3,     // DVPP: corp and resize fail
93   APP_ERR_DVPP_CONVERT_FROMAT_FAIL = APP_ERR_DVPP_BASE + 4,  // DVPP: convert image format fail
94   APP_ERR_DVPP_VPC_FAIL = APP_ERR_DVPP_BASE + 5,             // DVPP: VPC(crop, resize, convert format) fail
95   APP_ERR_DVPP_JPEG_DECODE_FAIL = APP_ERR_DVPP_BASE + 6,     // DVPP: decode jpeg or jpg fail
96   APP_ERR_DVPP_JPEG_ENCODE_FAIL = APP_ERR_DVPP_BASE + 7,     // DVPP: encode jpeg or jpg fail
97   APP_ERR_DVPP_PNG_DECODE_FAIL = APP_ERR_DVPP_BASE + 8,      // DVPP: encode png fail
98   APP_ERR_DVPP_H26X_DECODE_FAIL = APP_ERR_DVPP_BASE + 9,     // DVPP: decode H264 or H265 fail
99   APP_ERR_DVPP_H26X_ENCODE_FAIL = APP_ERR_DVPP_BASE + 10,    // DVPP: encode H264 or H265 fail
100   APP_ERR_DVPP_HANDLE_NULL = APP_ERR_DVPP_BASE + 11,         // DVPP: acldvppChannelDesc is nullptr
101   APP_ERR_DVPP_PICDESC_FAIL = APP_ERR_DVPP_BASE + 12,        // DVPP: fail to create acldvppCreatePicDesc or
102   // fail to set acldvppCreatePicDesc
103   APP_ERR_DVPP_CONFIG_FAIL = APP_ERR_DVPP_BASE + 13,  // DVPP: fail to set dvpp configuration,such as
104   // resize configuration,crop configuration
105   APP_ERR_DVPP_OBJ_FUNC_MISMATCH = APP_ERR_DVPP_BASE + 14,       // DVPP: DvppCommon object mismatch the function
106   APP_ERR_DVPP_NORMALIZE_FAIL = APP_ERR_DVPP_BASE + 15,          // DVPP: normalize fail
107   APP_ERR_DVPP_ADJUST_BRIGHTNESS_FAIL = APP_ERR_DVPP_BASE + 16,  // DVPP: adjust brightness fail
108   APP_ERR_DVPP_ADJUST_CONTRAST_FAIL = APP_ERR_DVPP_BASE + 17,    // DVPP: adjust contrast fail
109   APP_ERR_DVPP_ADJUST_HUE_FAIL = APP_ERR_DVPP_BASE + 18,         // DVPP: adjust hue fail
110   APP_ERR_DVPP_ADJUST_SATURATION_FAIL = APP_ERR_DVPP_BASE + 19,  // DVPP: adjust saturation fail
111   APP_ERR_DVPP_HORIZONTAL_FLIP_FAIL = APP_ERR_DVPP_BASE + 20,    // DVPP: Horizontal Flip
112   APP_ERR_DVPP_VERTICAL_FLIP_FAIL = APP_ERR_DVPP_BASE + 21,      // DVPP: vertical Flip
113   APP_ERR_DVPP_PERSPECTIVE_FAIL = APP_ERR_DVPP_BASE + 22,        // DVPP: perspective fail
114   APP_ERR_DVPP_RESIZED_CROP_FAIL = APP_ERR_DVPP_BASE + 23,       // DVPP: crop and resize fail
115   APP_ERR_DVPP_PAD_FAIL = APP_ERR_DVPP_BASE + 24,                // DVPP: pad fail
116   APP_ERR_DVPP_AFFINE_FAIL = APP_ERR_DVPP_BASE + 25,             // DVPP: affine fail
117   APP_ERR_DVPP_GAUSSIAN_BLUR_FAIL = APP_ERR_DVPP_BASE + 26,      // DVPP: gaussian blur fail
118   APP_ERR_DVPP_EQUALIZE_FAIL = APP_ERR_DVPP_BASE + 27,           // DVPP: equalize blur fail
119   APP_ERR_DVPP_ROTATE_FAIL = APP_ERR_DVPP_BASE + 28,             // DVPP: rotate fail
120   APP_ERR_DVPP_AUTO_CONTRAST_FAIL = APP_ERR_DVPP_BASE + 29,      // DVPP: auto contrast fail
121   APP_ERR_DVPP_POSTERIZE_FAIL = APP_ERR_DVPP_BASE + 30,          // DVPP: posterize fail
122   APP_ERR_DVPP_ADJUST_SHARPNESS_FAIL = APP_ERR_DVPP_BASE + 31,   // DVPP: adjust sharpness fail
123   APP_ERR_DVPP_INVERT_FAIL = APP_ERR_DVPP_BASE + 32,             // DVPP: invert fail
124   APP_ERR_DVPP_SOLARIZE_FAIL = APP_ERR_DVPP_BASE + 33,           // DVPP: solarize fail
125   APP_ERR_DVPP_CONVERT_COLOR_FAIL = APP_ERR_DVPP_BASE + 34,      // DVPP: convert color fail
126   APP_ERR_DVPP_ERASE_FAIL = APP_ERR_DVPP_BASE + 35,              // DVPP: erase fail
127   APP_ERR_DVPP_END,  // Not an error code, define the range of common error code
128 
129   // define the error code of inference
130   APP_ERR_INFER_BASE = 3000,
131   APP_ERR_INFER_SET_INPUT_FAIL = APP_ERR_INFER_BASE + 1,          // Infer: set input fail
132   APP_ERR_INFER_SET_OUTPUT_FAIL = APP_ERR_INFER_BASE + 2,         // Infer: set output fail
133   APP_ERR_INFER_CREATE_OUTPUT_FAIL = APP_ERR_INFER_BASE + 3,      // Infer: create output fail
134   APP_ERR_INFER_OP_SET_ATTR_FAIL = APP_ERR_INFER_BASE + 4,        // Infer: set op attribute fail
135   APP_ERR_INFER_GET_OUTPUT_FAIL = APP_ERR_INFER_BASE + 5,         // Infer: get model output fail
136   APP_ERR_INFER_FIND_MODEL_ID_FAIL = APP_ERR_INFER_BASE + 6,      // Infer: find model id fail
137   APP_ERR_INFER_FIND_MODEL_DESC_FAIL = APP_ERR_INFER_BASE + 7,    // Infer: find model description fail
138   APP_ERR_INFER_FIND_MODEL_MEM_FAIL = APP_ERR_INFER_BASE + 8,     // Infer: find model memory fail
139   APP_ERR_INFER_FIND_MODEL_WEIGHT_FAIL = APP_ERR_INFER_BASE + 9,  // Infer: find model weight fail
140 
141   APP_ERR_INFER_END,  // Not an error code, define the range of inference error
142   // code
143 
144   // define the error code of transmission
145   APP_ERR_TRANS_BASE = 4000,
146 
147   APP_ERR_TRANS_END,  // Not an error code, define the range of transmission
148   // error code
149 
150   // define the error code of blocking queue
151   APP_ERR_QUEUE_BASE = 5000,
152   APP_ERR_QUEUE_EMPTY = APP_ERR_QUEUE_BASE + 1,   // Queue: empty queue
153   APP_ERR_QUEUE_STOPED = APP_ERR_QUEUE_BASE + 2,  // Queue: queue stopped
154   APP_ERROR_QUEUE_FULL = APP_ERR_QUEUE_BASE + 3,  // Queue: full queue
155 
156   // define the error code of destory
157   APP_ERR_DESTORY_BASE = 6000,
158   APP_ERR_DESTORY_TENSOR = APP_ERR_DESTORY_BASE + 1,
159   APP_ERR_DESTORY_SCALAR = APP_ERR_DESTORY_BASE + 2,
160   APP_ERR_DESTORY_INT_ARRAY = APP_ERR_DESTORY_BASE + 3,
161   APP_ERR_DESTORY_FLOAT_ARRAY = APP_ERR_DESTORY_BASE + 4,
162   APP_ERR_DESTORY_BOOL_ARRAY = APP_ERR_DESTORY_BASE + 5,
163   APP_ERR_DESTORY_TENSOR_LIST = APP_ERR_DESTORY_BASE + 6,
164   APP_ERR_DESTORY_SCALAR_LIST = APP_ERR_DESTORY_BASE + 7,
165 
166   // define the idrecognition web error code
167   APP_ERROR_FACE_WEB_USE_BASE = 10000,
168   APP_ERROR_FACE_WEB_USE_SYSTEM_ERROR = APP_ERROR_FACE_WEB_USE_BASE + 1,  // Web: system error
169   APP_ERROR_FACE_WEB_USE_MUL_FACE = APP_ERROR_FACE_WEB_USE_BASE + 2,      // Web: multiple cheeks
170   APP_ERROR_FACE_WEB_USE_REPEAT_REG = APP_ERROR_FACE_WEB_USE_BASE + 3,    // Web: repeat registration
171   APP_ERROR_FACE_WEB_USE_PART_SUCCESS = APP_ERROR_FACE_WEB_USE_BASE + 4,  // Web: partial search succeeded
172   APP_ERROR_FACE_WEB_USE_NO_FACE = APP_ERROR_FACE_WEB_USE_BASE + 5,       // Web: no cheek detected
173   APP_ERR_QUEUE_END,  // Not an error code, define the range of blocking queue
174   // error code
175 };
176 
177 const std::string APP_ERR_ACL_LOG_STRING[] = {
178   "Success",                            // APP_ERR_OK
179   "ACL: invalid parameter",             // APP_ERR_ACL_INVALID_PARAM
180   "ACL: memory allocation fail",        // APP_ERR_ACL_BAD_ALLOC
181   "ACL: runtime failure",               // APP_ERR_ACL_RT_FAILURE
182   "ACL: Graph Engine failure",          // APP_ERR_ACL_GE_FAILURE
183   "ACL: operator not found",            // APP_ERR_ACL_OP_NOT_FOUND
184   "ACL: fail to load operator",         // APP_ERR_ACL_OP_LOAD_FAILED
185   "ACL: fail to read model",            // APP_ERR_ACL_READ_MODEL_FAILURE
186   "ACL: parse model failure",           // APP_ERR_ACL_PARSE_MODEL
187   "ACL: model missing attribute",       // APP_ERR_ACL_MODEL_MISSING_ATTR
188   "ACL: deserialize model failure",     // APP_ERR_ACL_DESERIALIZE_MODEL
189   "Placeholder",                        // 11
190   "ACL: event not ready",               // APP_ERR_ACL_EVENT_NOT_READY
191   "ACL: event complete",                // APP_ERR_ACL_EVENT_COMPLETE
192   "ACL: unsupported data type",         // APP_ERR_ACL_UNSUPPORTED_DATA_TYPE
193   "ACL: repeat initialize",             // APP_ERR_ACL_REPEAT_INITIALIZE
194   "ACL: compiler not registered",       // APP_ERR_ACL_COMPILER_NOT_REGISTERED
195   "ACL: IO failed",                     // APP_ERR_ACL_IO
196   "ACL: invalid file",                  // APP_ERR_ACL_INVALID_FILE
197   "ACL: invalid dump comfig",           // APP_ERR_ACL_INVALID_DUMP_CONFIG
198   "ACL: invalid profiling config",      // APP_ERR_ACL_INVALID_PROFILING_CONFIG
199   "ACL: operator type not match",       // APP_ERR_ACL_OP_TYPE_NOT_MATCH
200   "ACL: operator input not match",      // APP_ERR_ACL_OP_INPUT_NOT_MATCH
201   "ACL: operator output not match",     // APP_ERR_ACL_OP_OUTPUT_NOT_MATCH
202   "ACL: operator attribute not match",  // APP_ERR_ACL_OP_ATTR_NOT_MATCH
203   "ACL: API not supported",             // APP_ERR_ACL_API_NOT_SUPPORT
204   "ACL: create data buffer fail",       // APP_ERR_ACL_CREATE_DATA_BUF_FAILED
205 };
206 
207 const std::string APP_ERR_COMMON_LOG_STRING[] = {
208   "Placeholder",  // 0
209   "General Failed",
210   "Internal error",
211   "Invalid Pointer",  // 3
212   "Invalid parameter",
213   "Not implemented",  // 5
214   "Out of memory",
215   "memory allocation error",
216   "free memory error",  // 8
217   "out of range",
218   "NO Permission ",  // 10
219   "Timed out",
220   "Not initialized",
221   "initialize failed",  // 13
222   "Operation now in progress ",
223   "Object, file or other resource already exist",  // 15
224   "Object, file or other resource already doesn't exist",
225   "Object, file or other resource is in use",
226   "No available Device or resource",  // 18
227   "Device, file or resource open failed",
228   "Device, file or resource read failed",  // 20
229   "Device, file or resource write failed",
230   "Device, file or resource destory failed",  // 22
231   " ",
232   "Out of connection, Communication shutdown",  // 24
233   "connection fail",
234   "ACL stream is null pointer",  // 26
235 };
236 
237 const std::string APP_ERR_DVPP_LOG_STRING[] = {
238   "Placeholder",  // 0
239   "DVPP: crop fail",
240   "DVPP: resize fail",
241   "DVPP: corp and resize fail",
242   "DVPP: convert image format fail",
243   "DVPP: VPC(crop, resize, convert format) fail",  // 5
244   "DVPP: decode jpeg or jpg fail",
245   "DVPP: encode jpeg or jpg fail",
246   "DVPP: encode png fail",
247   "DVPP: decode H264 or H265 fail",
248   "DVPP: encode H264 or H265 fail",  // 10
249   "DVPP: acldvppChannelDesc is nullptr",
250   "DVPP: fail to create or set acldvppCreatePicDesc",
251   "DVPP: fail to set dvpp configuration",
252   "DVPP: DvppCommon object mismatch the function",  // 14
253 };
254 
255 const std::string APP_ERR_INFER_LOG_STRING[] = {
256   "Placeholder",  // 0
257   "Infer: set input fail",
258   "Infer: set output fail",
259   "Infer: create output fail",
260   "Infer: set op attribute fail",
261   "Infer: get model output fail",  // 5
262   "Infer: find model id fail",
263   "Infer: find model description fail",
264   "Infer: find model memory fail",
265   "Infer: find model weight fail",  // 9
266 };
267 
268 const std::string APP_ERR_QUEUE_LOG_STRING[] = {
269   "Placeholder",
270   "empty queue",
271   "queue stopped",
272   "full queue",
273 };
274 
275 const std::string APP_ERR_FACE_LOG_STRING[] = {
276   "Placeholder",               // 0
277   "system error",              // 1
278   "multiple faces",            // 2
279   "repeat registration",       // 3
280   "partial search succeeded",  // 4
281   "no face detected",          // 5
282 };
283 
284 std::string GetAppErrCodeInfo(APP_ERROR err);
285 void AssertErrorCode(int code, const std::string &file, const std::string &function, int line);
286 void CheckErrorCode(int code, const std::string &file, const std::string &function, int line);
287 
288 #define RtAssert(code) AssertErrorCode(code, DATASET_SRC_FILE_NAME, __FUNCTION__, __LINE__);
289 #define RtCheckError(code) CheckErrorCode(code, DATASET_SRC_FILE_NAME, __FUNCTION__, __LINE__);
290 
291 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_DVPP_UTILS_ERROR_CODE_H_
292