* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef FFTS_ENGINE_INC_FFTS_ERROR_CODES_H_
#define FFTS_ENGINE_INC_FFTS_ERROR_CODES_H_
#include <cstdint>
#include <string>
namespace ffts {
const uint8_t SYSID_FFTS = 18U;
const uint8_t FFTS_MODID_COMMON = 50U;
const uint8_t FFTS_MODID_ITF = 51U;
const uint8_t FFTS_MODID_SHAPE_FORMAT_TRANSFER = 52U;
const uint8_t FFTS_MODID_GRAPH_OPTIMIZER = 53U;
const uint8_t FFTS_MODID_OP_JUDGE = 54U;
const uint8_t FFTS_MODID_OP_COMPILER = 55U;
const uint8_t FFTS_MODID_OP_KERNEL_STORE = 56U;
const uint8_t FFTS_MODID_GRAPH_MATCHER = 58U;
const uint8_t FFTS_MODID_GRAPH_REPLACE = 59U;
const uint8_t FFTS_MODID_FUSION_RULE_PARSER = 60U;
const uint8_t FFTS_MODID_OP_STORE_ADAPTER = 61U;
const uint8_t FFTS_MODID_OP_CALCULATOR = 62U;
const uint8_t FFTS_MODID_LX_FUSION = 63U;
using Status = uint32_t;
#define FFTS_DEF_ERRORNO(sysid, modid, name, value, desc) \
static constexpr Status name = \
((((static_cast<uint32_t>((0xFF) & (static_cast<uint8_t>(sysid)))) << 24) | \
((static_cast<uint32_t>((0xFF) & (static_cast<uint8_t>(modid)))) << 16)) | \
((0xFFFF) & (static_cast<uint16_t>(value))));
#define FFTS_DEF_ERRORNO_COMMON(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_COMMON, name, value, desc)
FFTS_DEF_ERRORNO(0, 0, SUCCESS, 0, "success");
FFTS_DEF_ERRORNO(0xFFU, 0xFFU, FAILED, 0xFFFFU, "failed");
FFTS_DEF_ERRORNO_COMMON(PARAM_INVALID, 1, "Parameter's invalid!");
FFTS_DEF_ERRORNO_COMMON(NOT_CHANGED, 2, "Not changed!");
#define FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_SHAPE_FORMAT_TRANSFER, name, value, desc)
#define FFTS_DEF_ERRORNO_ITF(name, value, desc) FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_ITF, name, value, desc)
#define FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_GRAPH_OPTIMIZER, name, value, desc)
#define FFTS_DEF_ERRORNO_OP_JUDGE(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_OP_JUDGE, name, value, desc)
#define FFTS_DEF_ERRORNO_OP_COMPILER(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_OP_COMPILER, name, value, desc)
#define FFTS_DEF_ERRORNO_OP_KERNEL_STORE(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_OP_KERNEL_STORE, name, value, desc)
#define FFTS_DEF_ERRORNO_GRAPH_MATCHER(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_GRAPH_MATCHER, name, value, desc)
#define FFTS_DEF_ERRORNO_GRAPH_REPLACE(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_GRAPH_REPLACE, name, value, desc)
#define FFTS_DEF_ERRORNO_FUSION_RULE_PARSER(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_FUSION_RULE_PARSER, name, value, desc)
#define FFTS_DEF_ERRORNO_OP_STORE_ADAPTER(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_OP_STORE_ADAPTER, name, value, desc)
#define FFTS_DEF_ERRORNO_OP_CALCULATOR(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_OP_CALCULATOR, name, value, desc)
#define FFTS_DEF_ERRORNO_LX_FUSION(name, value, desc) \
FFTS_DEF_ERRORNO(SYSID_FFTS, FFTS_MODID_LX_FUSION, name, value, desc)
FFTS_DEF_ERRORNO_COMMON(MEMALLOC_FAILED, 0, "Failed to allocate memory!");
FFTS_DEF_ERRORNO_COMMON(CALL_CCE_FAILED, 2, "Failed to call CCE API!");
FFTS_DEF_ERRORNO_COMMON(CALL_RT_FAILED, 3, "Failed to call runtime API!");
FFTS_DEF_ERRORNO_COMMON(INTERNAL_ERROR, 4, "Internal errors");
FFTS_DEF_ERRORNO_COMMON(CALL_CSEC_ERROR, 5, "Failed to call libc_sec API!");
FFTS_DEF_ERRORNO_COMMON(CALL_TEE_ERROR, 6, "Failed to call tee API!");
FFTS_DEF_ERRORNO_COMMON(FILE_NOT_EXIST, 8, "The file does not exist.");
FFTS_DEF_ERRORNO_COMMON(TENSOR_FORMAT_NOT_FOUND, 18, "This format has not been found.");
FFTS_DEF_ERRORNO_COMMON(INVALID_TENSOR_FORMAT, 19, "This format is not valid.");
FFTS_DEF_ERRORNO_COMMON(INVALID_TENSOR_DATATYPE, 20, "This data type is not valid.");
FFTS_DEF_ERRORNO_COMMON(INVALID_DIM_VALUE, 21, "The dim value must be great than zero.");
FFTS_DEF_ERRORNO_COMMON(INVALID_DIM_SIZE, 22, "The size of dim must be greater than 4.");
FFTS_DEF_ERRORNO_COMMON(INVALID_NC1KHKWHWC0_SIZE, 23, "The size of NC1KHKWHWC0 format is not valid.");
FFTS_DEF_ERRORNO_COMMON(INVALID_C1HWNCoC0_SIZE, 24, "The size of C1HWNCoC0 format is not valid.");
FFTS_DEF_ERRORNO_COMMON(NOT_SUPPORT_TENSOR_FORMAT, 25, "This data type is not supported.");
FFTS_DEF_ERRORNO_COMMON(NOT_SUPPORT_TENSOR_DATATYPE, 26, "This tensor format is not supported.");
FFTS_DEF_ERRORNO_COMMON(BEYONG_MAX_TENSOR_ELEMENT_COUNT, 27,
"The amount of tensor element is more than the max amount.");
FFTS_DEF_ERRORNO_COMMON(VECTOR_INT64_EMPTY, 30, "The vector of int64 number is empty.");
FFTS_DEF_ERRORNO_COMMON(ADD_OVERFLOW_INT64, 31, "The addition between int64 number is overflow.");
FFTS_DEF_ERRORNO_COMMON(MUL_OVERFLOW_INT64, 32, "The multiplication between int64 number is overflow.");
FFTS_DEF_ERRORNO_COMMON(ADD_OVERFLOW_SIZET, 33, "The addition between size_t number is overflow.");
FFTS_DEF_ERRORNO_COMMON(CONTINUING_TRANSFORMAT, 34,
"We need to transformat in this case of one dimensional shape padding.");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(SHAPE_FORMAT_TRANSFER_SORTING_FAILED, 0, "Failed to sort!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(SHAPE_FORMAT_TRANSFER_INSERTING_FAILED, 1, "Failed to insert!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(SHAPE_FORMAT_TRANSFER_CHECKING_FAILED, 2, "Failed to check!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(CREATE_CAST_OP_FAILED, 3, "Failed to create CAST op!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(ADD_CAST_OP_NODE_FAILED, 4, "Failed to add CAST op node!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(RESHAPE_TYPE_NOT_SUPPORTED, 5,
"Failed to insert Reshape! Reshape type is invalid!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(RESHAPE_NOT_NECESSARY, 6,
"Failed to insert Reshape! Uncessary to reshape!");
FFTS_DEF_ERRORNO_SHAPE_FORMAT_TRANSFER(MERGE_TRANS_OP_NO_MORE_PREDECESSOR, 7,
"There is no more trans op for merging!");
FFTS_DEF_ERRORNO_ITF(OPINFO_STORES_INIT_FAILED, 0, "Failed to init opinfo_kernel_stores!");
FFTS_DEF_ERRORNO_ITF(GRAPH_OPTIMIZER_INIT_FAILED, 1, "Failed to init graphoptimizer!");
FFTS_DEF_ERRORNO_ITF(OPINFO_STORES_FINI_FAILED, 2, "Failed to finilize opinfo_kernel_stores!");
FFTS_DEF_ERRORNO_ITF(GRAPHOPTIMIZER_FINI_FAILED, 3, "Failed to finilize graphoptimizer!");
FFTS_DEF_ERRORNO_ITF(CONFIGURATION_INIT_FAILED, 4, "Failed to initialize configuration!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(GRAPH_OPTIMIZER_MAKE_SHARED_FAILED, 0,
"Failed to make shared in graph optimizer!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(GRAPH_OPTIMIZER_STOP_TRAVERSING_OTHER_ANCHORS, 1,
"We will not traverse any other node!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(GRAPH_OPTIMIZER_NOT_HEAVY_FORMAT, 2,
"Still Set other input or output but not traverse farther!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(GRAPH_OPTIMIZER_STOP_TRAVERSING_SCALAR_WEIGHT, 3,
"We will not distribute from scalar weight!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(GRAPH_OPTIMIZER_STOP_TRAVERSING_SCALAR_TENSOR, 4,
"We will not distribute from result op!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(GRAPH_OPTIMIZER_NOT_FUSE_TWO_SCOPE, 5, "We will not fuse two scope!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(SKIP_SUB_GRAPH_DATA_OR_NETOUTPUT, 6,
"We will skip this kind of sub graph data or netoutput!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(CONTINUE_TO_SET_FORMAT, 6,
"We will continue to set format for this op!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(STOP_PROPAGATION_FROM_WEIGHT, 7,
"We will stop propagation from this weight!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(AI_CORE_GRAPH_PASS_OWNER_ERROR, 8,
"The owner of ai core pass is invalid!");
FFTS_DEF_ERRORNO_GRAPH_OPTIMIZER(VECTOR_CORE_GRAPH_PASS_OWNER_ERROR, 9,
"The owner of vector core pass is invalid!");
FFTS_DEF_ERRORNO_OP_JUDGE(OP_JUDGE_MAP_KEY_FIND_FAILED, 0, "Failed to find map key in op judge!");
FFTS_DEF_ERRORNO_OP_JUDGE(OP_JUDGE_CHECK_FALSE_FAILED, 1, "Failed to check false in op judge!");
FFTS_DEF_ERRORNO_OP_JUDGE(OP_JUDGE_OPSTORE_NOT_FOUND, 2, "Failed to find op store info!");
FFTS_DEF_ERRORNO_OP_JUDGE(OP_JUDGE_SET_CORE_TYPE_FAILED, 3, "Failed to set op core type!");
FFTS_DEF_ERRORNO_OP_COMPILER(OP_COMPILER_MAKE_SHARED_FAILED, 0, "Failed to make shared in op compiler!");
FFTS_DEF_ERRORNO_OP_COMPILER(OP_COMPILER_CHECK_FALSE_FAILED, 1, "Failed to check false in op compiler!");
FFTS_DEF_ERRORNO_OP_COMPILER(OP_COMPILER_L1_FUSION_FAILED, 2, "Failed to compile l1 fusion op!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_PARSE_FAILED, 0, "Failed to parse the op kernel store cfg file!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_MAP_KEY_FIND_FAILED, 1,
"Failed to find the map key in FEOpKernelStore!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_STRING_CONVERT_FAILED, 2,
"Failed to convert string in FEOpKernelStore!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_READ_CFG_FILE_FAILED, 3, "Failed to read cfg file. I/O failed!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_CFG_FILE_EMPTY, 4,
"Failed to read cfg file. Empty configuration file path!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_CFG_NAME_EMPTY, 5, "Failed to get sub store name!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_CFG_FILE_NOT_EXIST, 6,
"Failed to read op information. Configuration file is not exist!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_STORE_MAKE_SHARED_FAILED, 7, "Failed to make shared in ops store!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OPS_SUB_STORE_NOT_EXIST, 8, "Failed to find specific sub store!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OPS_SUB_STORE_PTR_NULL, 9, "Failed to get sub store pointer!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_NOT_FOUND_IN_QUERY_HIGH_PRIO_IMPL, 10,
"Failed to find op in all sub stores!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_ATTR_NOT_FOUND_IN_OP_KERNEL_INFO, 11,
"Failed to find attr name in op kernel info!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_ATTR_EMPTY_IN_OP_KERNEL_INFO, 12,
"None attribute found in op kernel info!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_INPUT_NOT_FOUND_IN_OP_KERNEL_INFO, 13,
"Failed to find input info in op kernel info!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_OUTPUT_NOT_FOUND_IN_OP_KERNEL_INFO, 14,
"Failed to find output info in op kernel info!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_NOT_FOUND_IN_GET_HIGH_PRIO_OP_KERNEL, 15,
"Failed to find op in all sub stores in GetHighPrioOpKernelInfoPtr!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_KERNEL_INFO_NULL_PTR, 16, "Param is null ptr!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_SUB_STORE_PLGUIN_INIT_FAILED, 17,
"Failed to init plugin tbe sub op store!");
FFTS_DEF_ERRORNO_OP_KERNEL_STORE(OP_SUB_STORE_ILLEGAL_JSON, 18,
"Illegal json file, fail to parse json file!");
FFTS_DEF_ERRORNO_GRAPH_MATCHER(GRAPH_MATCHER_GET_RULE_OUTPUT_NODE_FAILED, 0,
"Get rule output node failed!");
FFTS_DEF_ERRORNO_GRAPH_REPLACE(GRAPH_REPLACE_CREATE_FUSION_NODES_FAILED, 0,
"Graph Replace:Create fusion nodes failed!");
FFTS_DEF_ERRORNO_GRAPH_REPLACE(GRAPH_REPLACE_UPDATE_ATTR_FAILED, 1,
"Graph Replace:Update attributes failed!");
FFTS_DEF_ERRORNO_GRAPH_REPLACE(GRAPH_REPLACE_REPLACE_INPUT_FAILED, 2,
"Graph Replace:Replace input failed!");
FFTS_DEF_ERRORNO_GRAPH_REPLACE(GRAPH_REPLACE_REPLACE_OUTPUT_FAILED, 3,
"Graph Replace:Replace output failed!");
FFTS_DEF_ERRORNO_GRAPH_REPLACE(GRAPH_REPLACE_DELETE_NODE_FAILED, 4,
"Graph Replace:Delete node failed!");
FFTS_DEF_ERRORNO_GRAPH_REPLACE(GRAPH_REPLACE_CHECKSUPPORTED_FAILED, 5,
"Graph Replace:Check supported failed!");
FFTS_DEF_ERRORNO_FUSION_RULE_PARSER(ILLEGAL_JSON, 0,
"Illegal json expression, parse fusion rule "
"from json failed!");
FFTS_DEF_ERRORNO_FUSION_RULE_PARSER(INVALID_RULE, 1,
"Exist FEOpKernelStore not supported op in fusion rule!");
FFTS_DEF_ERRORNO_FUSION_RULE_PARSER(ILLEGAL_RULE, 2,
"Illegal fusion rule structure, topological check failed!");
FFTS_DEF_ERRORNO_OP_STORE_ADAPTER(OP_STORE_ADAPTER_MANAGER_INIT_FAILED, 0,
"Failed to init op store adapter manager.");
FFTS_DEF_ERRORNO_OP_STORE_ADAPTER(OP_ADAPTER_TYPE_CHECK_FAILED, 1,
"Cannot find the corresponding adapter type.");
FFTS_DEF_ERRORNO_OP_STORE_ADAPTER(OP_STORE_ADAPTER_MAKE_SHARED_FAILED, 2,
"Failed to make shared in op store adapter.");
FFTS_DEF_ERRORNO_OP_STORE_ADAPTER(OP_ADAPTER_CHECK_FAILED, 3, "Cannot find the corresponding adapter.");
FFTS_DEF_ERRORNO_OP_CALCULATOR(FAIL_GET_OP_IMPL_TYPE, 0, "Failed to get the op impl type of op desc.");
const std::string EM_INNER_ERROR = "E29999";
}
#endif