Merged
fix(frontend): resolve CodeCheck G.FMT/G.STD/G.CNS/G.PRE/G.EXP/G.SCRIPT warnings #6523
HuYiShengAdd on Sep 20
fix(frontend): resolve CodeCheck G.FMT/G.STD/G.CNS/G.PRE/G.EXP/G.SCRIPT warnings #6523
Merged
Merged fromHuYiSheng01/Hys_pypto9.2.0intocann/pypto9.2.0
Total: 8 files changed+11-12
| @@ -3154,7 +3154,7 @@ static const SymbolicScalar RUNTIME_COA_GetParam = AddRuntimeCoaPrefix("GET_PARA | |||
| 3154 | 3154 | ||
| 3155 | static int64_t MakeTensorIndex(int64_t magic) | 3155 | static int64_t MakeTensorIndex(int64_t magic) |
| 3156 | { | 3156 | { |
| 3157 | - return magic | (1UL << 62); | 3157 | + return magic | RAW_TENSOR_INDEX_BIT_MASK; |
| 3158 | } // Create tensor index by setting bit 62 of magic number | 3158 | } // Create tensor index by setting bit 62 of magic number |
| 3159 | 3159 | ||
| 3160 | static void MaybeNormalizeValue(const SymbolicScalar& coaFunc, std::vector<SymbolicScalar>& operandCoaList, | 3160 | static void MaybeNormalizeValue(const SymbolicScalar& coaFunc, std::vector<SymbolicScalar>& operandCoaList, |
| @@ -42,6 +42,7 @@ using namespace pypto; | |||
| 42 | namespace npu::tile_fwk { | 42 | namespace npu::tile_fwk { |
| 43 | constexpr int FUNCTION_MAX_INCASTS = 10000; | 43 | constexpr int FUNCTION_MAX_INCASTS = 10000; |
| 44 | constexpr int FUNCTION_MAX_CV_CORES = 10000; | 44 | constexpr int FUNCTION_MAX_CV_CORES = 10000; |
| 45 | +constexpr int64_t RAW_TENSOR_INDEX_BIT_MASK = 1L << 62; | ||
| 45 | 46 | ||
| 46 | inline const BiMap<FunctionType>& GetFunctionTypeNameDict() | 47 | inline const BiMap<FunctionType>& GetFunctionTypeNameDict() |
| 47 | { | 48 | { |
| @@ -118,7 +118,7 @@ struct RebuildableAttrInitContext { | |||
| 118 | const std::string name = typeid(TyAttr).name(); \ | 118 | const std::string name = typeid(TyAttr).name(); \ |
| 119 | ctx->manager->InitAttr(ctx->func, name, base); \ | 119 | ctx->manager->InitAttr(ctx->func, name, base); \ |
| 120 | } \ | 120 | } \ |
| 121 | - static EntryRegistrarNode node##TyAttr(RebuildableAttributeManager::GetRegistrarGroup(), Entry##TyAttr, #TyAttr); | 121 | + static EntryRegistrarNode node##TyAttr(RebuildableAttributeManager::GetRegistrarGroup(), Entry##TyAttr, #TyAttr) |
| 122 | 122 | ||
| 123 | struct RebuildableRequiresSimt : RebuildableAttribute<bool> { | 123 | struct RebuildableRequiresSimt : RebuildableAttribute<bool> { |
| 124 | RebuildableRequiresSimt() { data = false; } | 124 | RebuildableRequiresSimt() { data = false; } |
| @@ -976,8 +976,8 @@ SymbolicScalar SymbolicScalar::SubstituteVars(const std::unordered_map<ir::VarPt | |||
| 976 | SymbolicScalar SymbolicScalar::Substitute( | 976 | SymbolicScalar SymbolicScalar::Substitute( |
| 977 | const std::vector<std::pair<RawSymbolicScalarPtr, RawSymbolicScalarPtr>>& vals) | 977 | const std::vector<std::pair<RawSymbolicScalarPtr, RawSymbolicScalarPtr>>& vals) |
| 978 | { | 978 | { |
| 979 | - std::function<RawSymbolicScalarPtr(const RawSymbolicScalarPtr&)> substitute; | 979 | + std::function<RawSymbolicScalarPtr(const RawSymbolicScalarPtr&)> substitute = |
| 980 | - substitute = [&](const RawSymbolicScalarPtr& raw) -> RawSymbolicScalarPtr { | 980 | + [&](const RawSymbolicScalarPtr& raw) -> RawSymbolicScalarPtr { |
| 981 | if (!raw) { | 981 | if (!raw) { |
| 982 | return raw; | 982 | return raw; |
| 983 | } | 983 | } |
| @@ -456,9 +456,9 @@ private: | |||
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | // RUNTIME_TernaryOP(c, lhs, rhs) with a decided condition folds to the selected operand | 458 | // RUNTIME_TernaryOP(c, lhs, rhs) with a decided condition folds to the selected operand |
| 459 | - if (newOps.size() == 4 && e->IsExpressionCall(TernaryOpCallName())) { | 459 | + if (newOps.size() == 0x4 && e->IsExpressionCall(TernaryOpCallName())) { |
| 460 | - if (auto condVal = GetConstVal(newOps[1])) { | 460 | + if (auto condVal = GetConstVal(newOps[0x1])) { |
| 461 | - return condVal.value() != 0 ? newOps[2] : newOps[3]; | 461 | + return condVal.value() != 0 ? newOps[0x2] : newOps[0x3]; |
| 462 | } | 462 | } |
| 463 | } | 463 | } |
| 464 | 464 | ||
| @@ -659,13 +659,12 @@ void DevAscendFunction::PopulateOperationEncodedContent( | |||
| 659 | 659 | ||
| 660 | static int64_t MaybeRawTensorIndex(int64_t val, const OrderedSet<std::shared_ptr<RawTensor>>& rawList) | 660 | static int64_t MaybeRawTensorIndex(int64_t val, const OrderedSet<std::shared_ptr<RawTensor>>& rawList) |
| 661 | { | 661 | { |
| 662 | - const int64_t kRawTensorIndexBit = 1L << 62; | 662 | + if ((val == -1) || !(val & RAW_TENSOR_INDEX_BIT_MASK)) { |
| 663 | - if ((val == -1) || !(val & kRawTensorIndexBit)) { | ||
| 664 | // concrete may -1, ignore this bad case | 663 | // concrete may -1, ignore this bad case |
| 665 | return val; | 664 | return val; |
| 666 | } | 665 | } |
| 667 | 666 | ||
| 668 | - auto magic = val & (~kRawTensorIndexBit); | 667 | + auto magic = val & (~RAW_TENSOR_INDEX_BIT_MASK); |
| 669 | for (auto rawTensor : rawList) { | 668 | for (auto rawTensor : rawList) { |
| 670 | if (rawTensor->GetRawMagic() == magic) { | 669 | if (rawTensor->GetRawMagic() == magic) { |
| 671 | return rawList.GetIndex(rawTensor); | 670 | return rawList.GetIndex(rawTensor); |
| @@ -239,7 +239,7 @@ static std::any ConvertListList(const std::string& key, const py::list& lst) | |||
| 239 | ". Expected list, but got " + GetElemTypeName(lst[i])); | 239 | ". Expected list, but got " + GetElemTypeName(lst[i])); |
| 240 | } | 240 | } |
| 241 | py::list innerList = py::cast<py::list>(lst[i]); | 241 | py::list innerList = py::cast<py::list>(lst[i]); |
| 242 | - if (innerList.size() != 2) { | 242 | + if (innerList.size() != 0x2) { |
| 243 | throw py::type_error("Option '" + key + "' has invalid inner list length at index " + std::to_string(i) + | 243 | throw py::type_error("Option '" + key + "' has invalid inner list length at index " + std::to_string(i) + |
| 244 | ". Expected 2 elements [device_name, cpu_name], but got " + | 244 | ". Expected 2 elements [device_name, cpu_name], but got " + |
| 245 | std::to_string(innerList.size())); | 245 | std::to_string(innerList.size())); |
| @@ -202,7 +202,6 @@ int TorchTensorConverter::Convert(py::sequence& tensors, py::sequence& tensor_de | |||
| 202 | tensors_data.emplace_back(); | 202 | tensors_data.emplace_back(); |
| 203 | 203 | ||
| 204 | TensorDeviceInfo tensorDeviceInfo = ConvertSingleTensor(torchTensor, tensorDef, torch_npu, tensors_data.back()); | 204 | TensorDeviceInfo tensorDeviceInfo = ConvertSingleTensor(torchTensor, tensorDef, torch_npu, tensors_data.back()); |
| 205 | - | ||
| 206 | // Skip device consistency check for cpu tensors (used as host-side data for value-depend). | 205 | // Skip device consistency check for cpu tensors (used as host-side data for value-depend). |
| 207 | if (tensorDeviceInfo.type == "cpu") { | 206 | if (tensorDeviceInfo.type == "cpu") { |
| 208 | continue; | 207 | continue; |