Merged
fix(machine): fix log level mismatch, magic number and grammar errors #5720
chaizhengtongAdd on Aug 27
fix(machine): fix log level mismatch, magic number and grammar errors #5720
Merged
Merged fromchai-hw/pypto_chaipyptolog_fix2intocann/pyptomaster
Total: 22 files changed+61-33
| @@ -61,7 +61,7 @@ private: | |||
| 61 | for (const std::pair<const EnumType, std::string>& item : funcNameMap) { | 61 | for (const std::pair<const EnumType, std::string>& item : funcNameMap) { |
| 62 | void* func = libHandler_.GetFunction(item.second); | 62 | void* func = libHandler_.GetFunction(item.second); |
| 63 | if (func == nullptr) { | 63 | if (func == nullptr) { |
| 64 | - ADAPTER_LOGI("Failed to load function[%s]", item.second.c_str()); | 64 | + ADAPTER_LOGE(InternalError::COMMON_INNER_ERROR, "Failed to load function[%s]", item.second.c_str()); |
| 65 | continue; | 65 | continue; |
| 66 | } | 66 | } |
| 67 | ADAPTER_LOGD("Function[%s] has been loaded successfully.", item.second.c_str()); | 67 | ADAPTER_LOGD("Function[%s] has been loaded successfully.", item.second.c_str()); |
| @@ -48,7 +48,7 @@ public: | |||
| 48 | regex_match(c, sm, r); | 48 | regex_match(c, sm, r); |
| 49 | ASSERT(CostModel::ExternalErrorScene::INVALID_CONFIG, sm.size() == parameterNum) | 49 | ASSERT(CostModel::ExternalErrorScene::INVALID_CONFIG, sm.size() == parameterNum) |
| 50 | << "[SIMULATION]: " | 50 | << "[SIMULATION]: " |
| 51 | - << "the config regex size is 3. the format is error: " << c; | 51 | + << "the config regex size is 3. the format is invalid: " << c; |
| 52 | std::string cfgName{sm.str(1)}; | 52 | std::string cfgName{sm.str(1)}; |
| 53 | std::string cfgValue{sm.str(2)}; | 53 | std::string cfgValue{sm.str(2)}; |
| 54 | ParseConfig(cfgName, cfgValue); | 54 | ParseConfig(cfgName, cfgValue); |
| @@ -845,7 +845,7 @@ void SimSys::OutputCalendarScheduleCpp(std::string prefix) | |||
| 845 | } | 845 | } |
| 846 | std::string outPath = GetFileName(outdir, jsonPath, prefix, ".calendar.cpp"); | 846 | std::string outPath = GetFileName(outdir, jsonPath, prefix, ".calendar.cpp"); |
| 847 | calendarGenerator->GenCalendarCpp(outPath); | 847 | calendarGenerator->GenCalendarCpp(outPath); |
| 848 | - SIMULATION_LOGW("Genearte Calendar File: %s", outPath.c_str()); | 848 | + SIMULATION_LOGW("Generate Calendar File: %s", outPath.c_str()); |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | std::map<uint64_t, std::vector<uint64_t>> SimSys::ComputeTaskAmounts(const TaskMap& taskMap) | 851 | std::map<uint64_t, std::vector<uint64_t>> SimSys::ComputeTaskAmounts(const TaskMap& taskMap) |
| @@ -1142,7 +1142,7 @@ void SimSys::UpdateNextCycles(uint64_t nextCycle) | |||
| 1142 | { | 1142 | { |
| 1143 | ASSERT(npu::tile_fwk::InternalError::SIM_INNER_ERROR, nextCycle > globalCycles) | 1143 | ASSERT(npu::tile_fwk::InternalError::SIM_INNER_ERROR, nextCycle > globalCycles) |
| 1144 | << "[SIMULATION]: " | 1144 | << "[SIMULATION]: " |
| 1145 | - << "nextCycle is less than or equels to globalCycles. nextCycles=" << nextCycle | 1145 | + << "nextCycle is less than or equal to globalCycles. nextCycles=" << nextCycle |
| 1146 | << ", globalCycles=" << globalCycles; | 1146 | << ", globalCycles=" << globalCycles; |
| 1147 | nextSimulationCycles = std::min(nextSimulationCycles, nextCycle); | 1147 | nextSimulationCycles = std::min(nextSimulationCycles, nextCycle); |
| 1148 | } | 1148 | } |
| @@ -699,7 +699,7 @@ void CoreMachine::AnalysisDeadlock(std::set<int>& unissuedTileMagics) | |||
| 699 | std::set<int> deadLockSrcOpMagic; | 699 | std::set<int> deadLockSrcOpMagic; |
| 700 | for (auto& opmagic : unissuedTileMagics) { | 700 | for (auto& opmagic : unissuedTileMagics) { |
| 701 | auto& op = tileOps[opmagic]; | 701 | auto& op = tileOps[opmagic]; |
| 702 | - SIMULATION_LOGW("[AnalysisDeadlock] Uissued Tileop: %s", op->Dump().c_str()); | 702 | + SIMULATION_LOGW("[AnalysisDeadlock] Unissued Tileop: %s", op->Dump().c_str()); |
| 703 | bool srcReady = true; | 703 | bool srcReady = true; |
| 704 | for (auto& src : op->iOperand) { | 704 | for (auto& src : op->iOperand) { |
| 705 | for (auto& ptr : src->producers) { | 705 | for (auto& ptr : src->producers) { |
| @@ -489,7 +489,7 @@ void ParseInput::ParseFunction(std::shared_ptr<CostModel::SimSys> sim, | |||
| 489 | if (topoFromRootFunc) { | 489 | if (topoFromRootFunc) { |
| 490 | sim->enableExpectValue = true; | 490 | sim->enableExpectValue = true; |
| 491 | ASSERT(npu::tile_fwk::InternalError::SIM_INNER_ERROR, inputFuncs.size() == 1) | 491 | ASSERT(npu::tile_fwk::InternalError::SIM_INNER_ERROR, inputFuncs.size() == 1) |
| 492 | - << "[SIMULATION]: inputFuncs.size is not equals to 1." | 492 | + << "[SIMULATION]: inputFuncs.size is not equal to 1." |
| 493 | << "inputFuncs.size=" << inputFuncs.size(); | 493 | << "inputFuncs.size=" << inputFuncs.size(); |
| 494 | for (const auto& rootFunction : inputFuncs) { | 494 | for (const auto& rootFunction : inputFuncs) { |
| 495 | FunctionPtr func = std::make_shared<Function>(); | 495 | FunctionPtr func = std::make_shared<Function>(); |
| @@ -148,7 +148,7 @@ void FunctionCache::UpdateBinCache(const Function& func, CacheValue& value) | |||
| 148 | totalSize += binData.size() + sizeof(uint64_t); | 148 | totalSize += binData.size() + sizeof(uint64_t); |
| 149 | binMap[ele.first] = std::move(binData); | 149 | binMap[ele.first] = std::move(binData); |
| 150 | } else { | 150 | } else { |
| 151 | - MACHINE_LOGE(InternalError::MACHINE_INNER_ERROR, "bin path %s is not existed", binPath.c_str()); | 151 | + MACHINE_LOGE(InternalError::MACHINE_INNER_ERROR, "bin path %s does not exist", binPath.c_str()); |
| 152 | abort(); | 152 | abort(); |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| @@ -135,7 +135,7 @@ void CheckTensorShapeSize(const LogicalTensorPtr& tensor, const std::string& opN | |||
| 135 | for (const auto& value : shape) { | 135 | for (const auto& value : shape) { |
| 136 | if (value > INT32_MAX) { | 136 | if (value > INT32_MAX) { |
| 137 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) | 137 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) |
| 138 | - << "The dim value of tensor must less than or equal to INT32_MAX(2,147,483,647), " | 138 | + << "The dim value of tensor must be less than or equal to INT32_MAX(2,147,483,647), " |
| 139 | << "actual dim value: " << value << " for op: " << opName; | 139 | << "actual dim value: " << value << " for op: " << opName; |
| 140 | } | 140 | } |
| 141 | if (value > 0) { | 141 | if (value > 0) { |
| @@ -143,7 +143,7 @@ void CheckTensorShapeSize(const LogicalTensorPtr& tensor, const std::string& opN | |||
| 143 | } | 143 | } |
| 144 | if (shapeSize > INT32_MAX) { | 144 | if (shapeSize > INT32_MAX) { |
| 145 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) | 145 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) |
| 146 | - << "The shape size of tensor must less than or equal to INT32_MAX(2,147,483,647), " | 146 | + << "The shape size of tensor must be less than or equal to INT32_MAX(2,147,483,647), " |
| 147 | << "actual shape size: " << shapeSize << " for op: " << opName; | 147 | << "actual shape size: " << shapeSize << " for op: " << opName; |
| 148 | } | 148 | } |
| 149 | } | 149 | } |
| @@ -165,7 +165,7 @@ void CheckDstShapeSize(const std::vector<int64_t>& shape, const std::string& opN | |||
| 165 | for (const auto& value : shape) { | 165 | for (const auto& value : shape) { |
| 166 | if (value > INT32_MAX) { | 166 | if (value > INT32_MAX) { |
| 167 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) | 167 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) |
| 168 | - << "The dim value of dst shape must less than or equal to INT32_MAX(2,147,483,647), " | 168 | + << "The dim value of dst shape must be less than or equal to INT32_MAX(2,147,483,647), " |
| 169 | << "actual dim value: " << value << " for op: " << opName; | 169 | << "actual dim value: " << value << " for op: " << opName; |
| 170 | } | 170 | } |
| 171 | if (value > 0) { | 171 | if (value > 0) { |
| @@ -173,7 +173,7 @@ void CheckDstShapeSize(const std::vector<int64_t>& shape, const std::string& opN | |||
| 173 | } | 173 | } |
| 174 | if (shapeSize > INT32_MAX) { | 174 | if (shapeSize > INT32_MAX) { |
| 175 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) | 175 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, false) |
| 176 | - << "The shape size of dst must less than or equal to INT32_MAX(2,147,483,647), " | 176 | + << "The shape size of dst must be less than or equal to INT32_MAX(2,147,483,647), " |
| 177 | << "actual shape size: " << shapeSize << " for op: " << opName; | 177 | << "actual shape size: " << shapeSize << " for op: " << opName; |
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| @@ -726,7 +726,7 @@ static void SqueezeParamsValidCheck(const Tensor& input, std::vector<int>& dim) | |||
| 726 | { | 726 | { |
| 727 | Shape oriShape = input.GetShape(); | 727 | Shape oriShape = input.GetShape(); |
| 728 | size_t shapeSize = oriShape.size(); | 728 | size_t shapeSize = oriShape.size(); |
| 729 | - CHECK_OP(shapeSize <= SHAPE_DIM4) << "The input dimension only support 1~4. Cur dimension is " << shapeSize; | 729 | + CHECK_OP(shapeSize <= SHAPE_DIM4) << "The input dimension only supports 1~4. Cur dimension is " << shapeSize; |
| 730 | 730 | ||
| 731 | if (dim.empty()) { | 731 | if (dim.empty()) { |
| 732 | for (size_t i = 0; i < shapeSize; i++) { | 732 | for (size_t i = 0; i < shapeSize; i++) { |
| @@ -736,7 +736,7 @@ static void SqueezeParamsValidCheck(const Tensor& input, std::vector<int>& dim) | |||
| 736 | CHECK_OP(dim.size() <= shapeSize) << "The dim.size <= input.dim is not matched. dim.size is " << dim.size() | 736 | CHECK_OP(dim.size() <= shapeSize) << "The dim.size <= input.dim is not matched. dim.size is " << dim.size() |
| 737 | << ", input.dim is " << shapeSize; | 737 | << ", input.dim is " << shapeSize; |
| 738 | std::set<int> dupDimSet(dim.begin(), dim.end()); | 738 | std::set<int> dupDimSet(dim.begin(), dim.end()); |
| 739 | - CHECK_OP(dupDimSet.size() == dim.size()) << "There is duplicates elements in dim"; | 739 | + CHECK_OP(dupDimSet.size() == dim.size()) << "There are duplicate elements in dim"; |
| 740 | for (size_t i = 0; i < dim.size(); i++) { | 740 | for (size_t i = 0; i < dim.size(); i++) { |
| 741 | CHECK_OP(dim[i] < static_cast<int>(shapeSize) && dim[i] >= -(static_cast<int>(shapeSize))) | 741 | CHECK_OP(dim[i] < static_cast<int>(shapeSize) && dim[i] >= -(static_cast<int>(shapeSize))) |
| 742 | << "dim " << i << " in dim is out of range"; | 742 | << "dim " << i << " in dim is out of range"; |
| @@ -88,7 +88,8 @@ private: | |||
| 88 | auto data_type = tensor->Datatype(); | 88 | auto data_type = tensor->Datatype(); |
| 89 | if (tail_axis * BytesOf(data_type) % BLOCK_SIZE != 0) { | 89 | if (tail_axis * BytesOf(data_type) % BLOCK_SIZE != 0) { |
| 90 | auto opName = OpcodeManager::Inst().GetOpcodeStr(op.GetOpcode()); | 90 | auto opName = OpcodeManager::Inst().GetOpcodeStr(op.GetOpcode()); |
| 91 | - oss << "Operation: " << opName << ". The last axis of Tile shape " << tail_axis << " is not align 32B."; | 91 | + oss << "Operation: " << opName << ". The last axis of Tile shape " << tail_axis |
| 92 | + << " is not aligned to 32B."; | ||
| 92 | return false; | 93 | return false; |
| 93 | } | 94 | } |
| 94 | return true; | 95 | return true; |
| @@ -1438,7 +1438,7 @@ static void CheckIndexPutParamsInvalid(const Tensor& self, const std::vector<Ten | |||
| 1438 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, self.GetShape().size() + 1 == indices.size() + values.GetShape().size()) | 1438 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, self.GetShape().size() + 1 == indices.size() + values.GetShape().size()) |
| 1439 | << "unsupport the inputs shape combination: dimSelf + 1 != indicesSize + dimValues"; | 1439 | << "unsupport the inputs shape combination: dimSelf + 1 != indicesSize + dimValues"; |
| 1440 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, values.GetShape()[0] == indicesShape) | 1440 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, values.GetShape()[0] == indicesShape) |
| 1441 | - << "valuesFirstDim should equal to indicesShape"; | 1441 | + << "valuesFirstDim should be equal to indicesShape"; |
| 1442 | for (size_t i = 1; i < values.GetShape().size(); i++) { | 1442 | for (size_t i = 1; i < values.GetShape().size(); i++) { |
| 1443 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, | 1443 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, |
| 1444 | self.GetShape()[self.GetShape().size() - i] == values.GetShape()[values.GetShape().size() - i]) | 1444 | self.GetShape()[self.GetShape().size() - i] == values.GetShape()[values.GetShape().size() - i]) |
| @@ -915,7 +915,7 @@ std::tuple<Tensor, Tensor> sort(const Tensor& self, int axis = -1, bool descendi | |||
| 915 | if (checkIsExceedUB(vecTileShape.tile, self.GetShape(), axis, 32)) { | 915 | if (checkIsExceedUB(vecTileShape.tile, self.GetShape(), axis, 32)) { |
| 916 | int64_t tileNum = (self.GetShape()[axis] + vecTileShape[axis] - 1) / vecTileShape[axis]; | 916 | int64_t tileNum = (self.GetShape()[axis] + vecTileShape[axis] - 1) / vecTileShape[axis]; |
| 917 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, tileNum < 128) | 917 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, tileNum < 128) |
| 918 | - << "For Large Shape in GM, the number of tile on sort axis must less than 128."; | 918 | + << "For Large Shape in GM, the number of tile on sort axis must be less than 128."; |
| 919 | } | 919 | } |
| 920 | 920 | ||
| 921 | auto transposeSelf = Transpose(self, {axis, len - 1}); | 921 | auto transposeSelf = Transpose(self, {axis, len - 1}); |
| @@ -498,13 +498,13 @@ Tensor Transpose(const Tensor& self, std::vector<int> perm) | |||
| 498 | 498 | ||
| 499 | auto oldVecTileShapes = TileShape::Current().GetVecTile(); | 499 | auto oldVecTileShapes = TileShape::Current().GetVecTile(); |
| 500 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, (int)oldVecTileShapes.size() == shapeSize) | 500 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, (int)oldVecTileShapes.size() == shapeSize) |
| 501 | - << "TileShape dim num should same to input."; | 501 | + << "TileShape dim num should be the same as input."; |
| 502 | auto oldValidShapes = self.GetStorage()->GetDynValidShape(); | 502 | auto oldValidShapes = self.GetStorage()->GetDynValidShape(); |
| 503 | if (oldValidShapes.empty()) { | 503 | if (oldValidShapes.empty()) { |
| 504 | oldValidShapes = SymbolicScalar::FromConcrete(self.GetShape()); | 504 | oldValidShapes = SymbolicScalar::FromConcrete(self.GetShape()); |
| 505 | } | 505 | } |
| 506 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, (int)oldValidShapes.size() == shapeSize) | 506 | CHECK(VectorErrorCode::ERR_PARAM_INVALID, (int)oldValidShapes.size() == shapeSize) |
| 507 | - << "ValidShape dim num should same to input."; | 507 | + << "ValidShape dim num should be the same as input."; |
| 508 | 508 | ||
| 509 | std::vector<int64_t> newInputShape; | 509 | std::vector<int64_t> newInputShape; |
| 510 | std::vector<int64_t> newVecTileShape; | 510 | std::vector<int64_t> newVecTileShape; |
| @@ -172,7 +172,7 @@ void TiledWhereOperation(Function& function, const TileShape& tileShape, const L | |||
| 172 | if (condition->Datatype() == DT_UINT8) { | 172 | if (condition->Datatype() == DT_UINT8) { |
| 173 | int bitsNumOfByte = 8; | 173 | int bitsNumOfByte = 8; |
| 174 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, tileShape.GetVecTile().tile.back() % bitsNumOfByte == 0) | 174 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, tileShape.GetVecTile().tile.back() % bitsNumOfByte == 0) |
| 175 | - << "The tileShape of last axis need to 8 align!"; | 175 | + << "The tileShape of last axis must be aligned to 8 bytes!"; |
| 176 | conditionValidShape.back() = conditionValidShape.back() / bitsNumOfByte; | 176 | conditionValidShape.back() = conditionValidShape.back() / bitsNumOfByte; |
| 177 | conditionExpandShape.back() = conditionExpandShape.back() / bitsNumOfByte; | 177 | conditionExpandShape.back() = conditionExpandShape.back() / bitsNumOfByte; |
| 178 | } | 178 | } |
| @@ -321,10 +321,10 @@ LogicalTensorPtr TensorWhereOperation(Function& function, const Tensor& conditio | |||
| 321 | int broadcastFlag = 1; | 321 | int broadcastFlag = 1; |
| 322 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, input.GetStorage()->shape.back() % bitsNumOfByte == 0 || | 322 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, input.GetStorage()->shape.back() % bitsNumOfByte == 0 || |
| 323 | input.GetStorage()->shape.back() == broadcastFlag) | 323 | input.GetStorage()->shape.back() == broadcastFlag) |
| 324 | - << "The input shape of last axis need to 8 align or equal to 1"; | 324 | + << "The input shape of last axis must be 8-byte aligned or equal to 1"; |
| 325 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, other.GetStorage()->shape.back() % bitsNumOfByte == 0 || | 325 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, other.GetStorage()->shape.back() % bitsNumOfByte == 0 || |
| 326 | other.GetStorage()->shape.back() == broadcastFlag) | 326 | other.GetStorage()->shape.back() == broadcastFlag) |
| 327 | - << "The other shape of last axis need to 8 align or equal to 1"; | 327 | + << "The other shape of last axis must be 8-byte aligned or equal to 1"; |
| 328 | } | 328 | } |
| 329 | auto conditionT0 = condition.GetStorage(); | 329 | auto conditionT0 = condition.GetStorage(); |
| 330 | auto inputT1 = input.GetStorage(); | 330 | auto inputT1 = input.GetStorage(); |
| @@ -365,7 +365,7 @@ LogicalTensorPtr TensorWhereOperation(Function& function, const Tensor& conditio | |||
| 365 | int broadcastFlag = 1; | 365 | int broadcastFlag = 1; |
| 366 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, input.GetStorage()->shape.back() % bitsNumOfByte == 0 || | 366 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, input.GetStorage()->shape.back() % bitsNumOfByte == 0 || |
| 367 | input.GetStorage()->shape.back() == broadcastFlag) | 367 | input.GetStorage()->shape.back() == broadcastFlag) |
| 368 | - << "The input shape of last axis need to 8 align or equal to 1"; | 368 | + << "The input shape of last axis must be 8-byte aligned or equal to 1"; |
| 369 | } | 369 | } |
| 370 | auto conditionT0 = condition.GetStorage(); | 370 | auto conditionT0 = condition.GetStorage(); |
| 371 | auto inputT1 = input.GetStorage(); | 371 | auto inputT1 = input.GetStorage(); |
| @@ -403,7 +403,7 @@ LogicalTensorPtr TensorWhereOperation(Function& function, const Tensor& conditio | |||
| 403 | int broadcastFlag = 1; | 403 | int broadcastFlag = 1; |
| 404 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, other.GetStorage()->shape.back() % bitsNumOfByte == 0 || | 404 | CHECK(VectorErrorCode::ERR_CONFIG_ALIGNMENT, other.GetStorage()->shape.back() % bitsNumOfByte == 0 || |
| 405 | other.GetStorage()->shape.back() == broadcastFlag) | 405 | other.GetStorage()->shape.back() == broadcastFlag) |
| 406 | - << "The other shape of last axis need to 8 align or equal to 1"; | 406 | + << "The other shape of last axis must be 8-byte aligned or equal to 1"; |
| 407 | } | 407 | } |
| 408 | auto conditionT0 = condition.GetStorage(); | 408 | auto conditionT0 = condition.GetStorage(); |
| 409 | auto otherT1 = other.GetStorage(); | 409 | auto otherT1 = other.GetStorage(); |
| @@ -144,7 +144,7 @@ void RecordFunc::EndFunction() | |||
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | if (IsVerifyEnable()) { | 146 | if (IsVerifyEnable()) { |
| 147 | - FE_LOGI("FlowVerify has been enable."); | 147 | + FE_LOGI("FlowVerify has been enabled."); |
| 148 | config::SetRunDataOption(KEY_VERIFY_PATH, config::GetAbsoluteTopFolder() + "/verify"); | 148 | config::SetRunDataOption(KEY_VERIFY_PATH, config::GetAbsoluteTopFolder() + "/verify"); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| @@ -317,7 +317,7 @@ void RecordLoopFunc::EndLoopFunction() | |||
| 317 | 317 | ||
| 318 | bool RecordLoopFunc::MatchUnrollTimes(int unrollTimes) | 318 | bool RecordLoopFunc::MatchUnrollTimes(int unrollTimes) |
| 319 | { | 319 | { |
| 320 | - CHECK(FeError::INVALID_VAL, unrollTimes > 0) << "unrollTimes[" << unrollTimes << "] must larger than zero!"; | 320 | + CHECK(FeError::INVALID_VAL, unrollTimes > 0) << "unrollTimes[" << unrollTimes << "] must be larger than zero!"; |
| 321 | auto& curRlf = Program::GetInstance().GetLoopStack().back().get(); | 321 | auto& curRlf = Program::GetInstance().GetLoopStack().back().get(); |
| 322 | curRlf.customUnrollTimes_.emplace(unrollTimes); | 322 | curRlf.customUnrollTimes_.emplace(unrollTimes); |
| 323 | if (!curRlf.hasManualUnroll_) { | 323 | if (!curRlf.hasManualUnroll_) { |
| @@ -500,7 +500,7 @@ bool LogicalTensor::Overlap(const std::shared_ptr<LogicalTensor>& other) const | |||
| 500 | int64_t LogicalTensor::GetDataSize() const | 500 | int64_t LogicalTensor::GetDataSize() const |
| 501 | { | 501 | { |
| 502 | if (HasNegativeNum<int64_t>(shape)) { | 502 | if (HasNegativeNum<int64_t>(shape)) { |
| 503 | - FE_LOGD("Logical tensor shape has negative. It has dynamic axis."); | 503 | + FE_LOGD("Logical tensor shape has negative dimension(s), which indicates a dynamic axis."); |
| 504 | return INT64_MAX; | 504 | return INT64_MAX; |
| 505 | } | 505 | } |
| 506 | int64_t shapeSize = std::accumulate(shape.begin(), shape.end(), 1LL, std::multiplies<>()); | 506 | int64_t shapeSize = std::accumulate(shape.begin(), shape.end(), 1LL, std::multiplies<>()); |
| @@ -550,7 +550,7 @@ std::vector<SymbolicScalar> npu::tile_fwk::GetViewValidShape(const std::vector<S | |||
| 550 | return {}; | 550 | return {}; |
| 551 | } | 551 | } |
| 552 | FE_ASSERT(FeError::INVALID_VAL, validShape.size() == viewShape.size()) | 552 | FE_ASSERT(FeError::INVALID_VAL, validShape.size() == viewShape.size()) |
| 553 | - << "Their size actually are " << validShape.size() << " and " << viewShape.size(); | 553 | + << "Their sizes actually are " << validShape.size() << " and " << viewShape.size(); |
| 554 | 554 | ||
| 555 | std::vector<SymbolicScalar> result; | 555 | std::vector<SymbolicScalar> result; |
| 556 | for (size_t i = 0; i < validShape.size(); i++) { | 556 | for (size_t i = 0; i < validShape.size(); i++) { |
| @@ -120,7 +120,7 @@ void RawTensor::AddRefCount(int value) | |||
| 120 | int64_t RawTensor::GetRawDataSize() const | 120 | int64_t RawTensor::GetRawDataSize() const |
| 121 | { | 121 | { |
| 122 | if (HasNegativeNum<int64_t>(rawshape)) { | 122 | if (HasNegativeNum<int64_t>(rawshape)) { |
| 123 | - FE_LOGD("Raw tensor shape has negative. It has dynamic axis."); | 123 | + FE_LOGD("Raw tensor shape has negative dimension(s), which indicates a dynamic axis."); |
| 124 | return INT64_MAX; | 124 | return INT64_MAX; |
| 125 | } | 125 | } |
| 126 | return DataSizeOf(GetRawShapeSize(), datatype); | 126 | return DataSizeOf(GetRawShapeSize(), datatype); |
| @@ -91,7 +91,7 @@ public: | |||
| 91 | cachePolicy_[static_cast<int>(policy)] = value; | 91 | cachePolicy_[static_cast<int>(policy)] = value; |
| 92 | if (value && (cachePolicy_[static_cast<int>(CachePolicy::PREFETCH)] == | 92 | if (value && (cachePolicy_[static_cast<int>(CachePolicy::PREFETCH)] == |
| 93 | cachePolicy_[static_cast<int>(CachePolicy::NONE_CACHEABLE)])) { | 93 | cachePolicy_[static_cast<int>(CachePolicy::NONE_CACHEABLE)])) { |
| 94 | - FE_LOGW("Prefetch and none cacheable can not apply at same time, use the first config policy."); | 94 | + FE_LOGW("Prefetch and non-cacheable cannot be applied at the same time; using the first config policy."); |
| 95 | cachePolicy_[static_cast<int>(policy)] = false; | 95 | cachePolicy_[static_cast<int>(policy)] = false; |
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| @@ -209,7 +209,7 @@ public: | |||
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | if (devCtrlFlowCache->IsActivatedPartialCache(devStartArgs)) { | 211 | if (devCtrlFlowCache->IsActivatedPartialCache(devStartArgs)) { |
| 212 | - DEV_INFO("ControlFlowCache: 1"); | 212 | + DEV_INFO("ControlFlowCache: activated"); |
| 213 | // Actual run | 213 | // Actual run |
| 214 | if (!devCtrlFlowCache->isRelocDataDev) { | 214 | if (!devCtrlFlowCache->isRelocDataDev) { |
| 215 | devCtrlFlowCache->isRelocDataDev = true; | 215 | devCtrlFlowCache->isRelocDataDev = true; |
| @@ -163,8 +163,8 @@ struct EslModelMemoryUtils { | |||
| 163 | void* hostAddr = mmap((void*)AlignAddress(eslAddr, pageSize, false), alignSize, PROT_READ | PROT_WRITE, | 163 | void* hostAddr = mmap((void*)AlignAddress(eslAddr, pageSize, false), alignSize, PROT_READ | PROT_WRITE, |
| 164 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); | 164 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); |
| 165 | if (hostAddr == MAP_FAILED) { | 165 | if (hostAddr == MAP_FAILED) { |
| 166 | - perror("mmap failed"); | 166 | + MACHINE_LOGE(DevCommonErr::SYSTEM_CALL_FAILED, "mmap failed: Failed to map ESL address 0x%lx, size: %zu", |
| 167 | - fprintf(stderr, "Failed to map ESL address 0x%lx, size: %zu\n", eslAddr, size); | 167 | + eslAddr, size); |
| 168 | return MAP_FAILED; | 168 | return MAP_FAILED; |
| 169 | } | 169 | } |
| 170 | MmapGlobalManager::AddRecord(hostAddr, alignSize); | 170 | MmapGlobalManager::AddRecord(hostAddr, alignSize); |
| @@ -166,7 +166,7 @@ uint64_t CalcGeneralMetadataSlotWorkspace(DevAscendProgram* devProg) | |||
| 166 | uint64_t vectorMemSize = DeviceWorkspaceAllocator::CalcMetadataVectorMemSize(devProg); | 166 | uint64_t vectorMemSize = DeviceWorkspaceAllocator::CalcMetadataVectorMemSize(devProg); |
| 167 | uint64_t slotAllocatorMemSize = DeviceWorkspaceAllocator::CalcMetadataSlotAllocatorMemSize(devProg); | 167 | uint64_t slotAllocatorMemSize = DeviceWorkspaceAllocator::CalcMetadataSlotAllocatorMemSize(devProg); |
| 168 | MACHINE_LOGI("[workspaceSize] ItemPoolMemSize is: %lu bytes, vectorMemSize is: %lu bytes, slotAllocatorMemSize is " | 168 | MACHINE_LOGI("[workspaceSize] ItemPoolMemSize is: %lu bytes, vectorMemSize is: %lu bytes, slotAllocatorMemSize is " |
| 169 | - "%lu bytes.,", | 169 | + "%lu bytes.", |
| 170 | itemPoolMemSize, vectorMemSize, slotAllocatorMemSize); | 170 | itemPoolMemSize, vectorMemSize, slotAllocatorMemSize); |
| 171 | static constexpr uint64_t AICPU_SLOT_STATIC_MEMSIZE = 2 * MEBI; | 171 | static constexpr uint64_t AICPU_SLOT_STATIC_MEMSIZE = 2 * MEBI; |
| 172 | generalMetadataSlotSize = itemPoolMemSize + vectorMemSize + slotAllocatorMemSize + AICPU_SLOT_STATIC_MEMSIZE; | 172 | generalMetadataSlotSize = itemPoolMemSize + vectorMemSize + slotAllocatorMemSize + AICPU_SLOT_STATIC_MEMSIZE; |
| @@ -185,3 +185,21 @@ TEST_F(OperationOpsTest, Axpy_UnsupportedOtherDim) | |||
| 185 | 185 | ||
| 186 | FUNCTION("AxpyUnsupportedOtherDim", {self, other}) { EXPECT_THROW(Axpy(self, other, 1.0f), std::exception); } | 186 | FUNCTION("AxpyUnsupportedOtherDim", {self, other}) { EXPECT_THROW(Axpy(self, other, 1.0f), std::exception); } |
| 187 | } | 187 | } |
| 188 | + | ||
| 189 | +TEST_F(OperationOpsTest, Squeeze_DimensionExceedsMax) | ||
| 190 | +{ | ||
| 191 | + std::vector<int64_t> shape5d = {1, 2, 3, 4, 5}; | ||
| 192 | + Tensor input(DT_FP32, shape5d); | ||
| 193 | + std::vector<int> dim = {0}; | ||
| 194 | + | ||
| 195 | + FUNCTION("SqueezeDimExceedsMax", {input}) { EXPECT_THROW(Squeeze(input, dim), std::exception); } | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | +TEST_F(OperationOpsTest, Squeeze_DuplicateDimensions) | ||
| 199 | +{ | ||
| 200 | + std::vector<int64_t> shape4d = {1, 2, 1, 4}; | ||
| 201 | + Tensor input(DT_FP32, shape4d); | ||
| 202 | + std::vector<int> dim = {0, 0}; | ||
| 203 | + | ||
| 204 | + FUNCTION("SqueezeDuplicateDims", {input}) { EXPECT_THROW(Squeeze(input, dim), std::exception); } | ||
| 205 | +} | ||
| @@ -96,3 +96,12 @@ TEST_F(TestTensor, InvalidShapeValue) | |||
| 96 | std::vector<int64_t> shape = {-2, 16}; | 96 | std::vector<int64_t> shape = {-2, 16}; |
| 97 | EXPECT_THROW(Tensor(DT_FP32, shape, "A"), std::exception); | 97 | EXPECT_THROW(Tensor(DT_FP32, shape, "A"), std::exception); |
| 98 | } | 98 | } |
| 99 | + | ||
| 100 | +TEST_F(TestTensor, GetRawDataSizeWithNegativeDimension) | ||
| 101 | +{ | ||
| 102 | + std::vector<int64_t> shape = {-1, 16}; | ||
| 103 | + Tensor a(DT_FP32, shape, "A"); | ||
| 104 | + auto storage = a.GetStorage(false); | ||
| 105 | + auto rawTensor = storage->GetRawTensor(); | ||
| 106 | + EXPECT_EQ(rawTensor->GetRawDataSize(), INT64_MAX); | ||
| 107 | +} | ||