已合并
【PR】: fix compile gcc 16 failed #4377
duanpengliang创建于 17 天前
【PR】: fix compile gcc 16 failed #4377
已合并
共 10 个文件变更+30-23
| @@ -366,8 +366,8 @@ aclError TensorDatasetDeserializes(const std::vector<tdt::DataItem>& itemVec, ac | |||
| 366 | } | 366 | } |
| 367 | const aclDataType dataType = iter->second; | 367 | const aclDataType dataType = iter->second; |
| 368 | acltdtDataItem* item = new (std::nothrow) acltdtDataItem( | 368 | acltdtDataItem* item = new (std::nothrow) acltdtDataItem( |
| 369 | - aclType, &dims[0], dims.size(), itemVec[i].tensorShape_, dataType, itemVec[i].tensorType_, | 369 | + aclType, dims.empty() ? nullptr : dims.data(), dims.size(), itemVec[i].tensorShape_, dataType, |
| 370 | - itemVec[i].dataPtr_, itemVec[i].dataLen_); | 370 | + itemVec[i].tensorType_, itemVec[i].dataPtr_, itemVec[i].dataLen_); |
| 371 | if (item == nullptr) { | 371 | if (item == nullptr) { |
| 372 | ACL_LOG_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed"); | 372 | ACL_LOG_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed"); |
| 373 | std::string sizeStr = std::to_string(sizeof(acltdtDataItem)); | 373 | std::string sizeStr = std::to_string(sizeof(acltdtDataItem)); |
| @@ -438,7 +438,8 @@ aclError TensorDatasetDeserializesV2(const std::vector<acl::aclTdtDataItemInfo>& | |||
| 438 | std::vector<int64_t> dims = itemVec[i].dims; | 438 | std::vector<int64_t> dims = itemVec[i].dims; |
| 439 | const aclDataType dataType = static_cast<aclDataType>(itemVec[i].ctrlInfo.tensorType); | 439 | const aclDataType dataType = static_cast<aclDataType>(itemVec[i].ctrlInfo.tensorType); |
| 440 | acltdtDataItem* item = new (std::nothrow) acltdtDataItem( | 440 | acltdtDataItem* item = new (std::nothrow) acltdtDataItem( |
| 441 | - aclType, &dims[0], dims.size(), "", dataType, "", itemVec[i].dataPtr, itemVec[i].ctrlInfo.dataLen); | 441 | + aclType, dims.empty() ? nullptr : dims.data(), dims.size(), "", dataType, "", itemVec[i].dataPtr, |
| 442 | + itemVec[i].ctrlInfo.dataLen); | ||
| 442 | if (item == nullptr) { | 443 | if (item == nullptr) { |
| 443 | ACL_LOG_INNER_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed"); | 444 | ACL_LOG_INNER_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed"); |
| 444 | ret = ACL_ERROR_BAD_ALLOC; | 445 | ret = ACL_ERROR_BAD_ALLOC; |
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | + | ||
| 14 | + | ||
| 13 | 15 | ||
| 14 | 16 | ||
| 15 | namespace tdt { | 17 | namespace tdt { |
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | + | ||
| 14 | 15 | ||
| 15 | 16 | ||
| 16 | 17 | ||
| @@ -1050,7 +1050,7 @@ public: | |||
| 1050 | MOCK_METHOD2(rtsKernelArgsGetHandleMemSize, rtError_t(rtFuncHandle funcHandle, size_t* memSize)); | 1050 | MOCK_METHOD2(rtsKernelArgsGetHandleMemSize, rtError_t(rtFuncHandle funcHandle, size_t* memSize)); |
| 1051 | MOCK_METHOD4( | 1051 | MOCK_METHOD4( |
| 1052 | rtsKernelArgsGetPlaceHolderBuffer, | 1052 | rtsKernelArgsGetPlaceHolderBuffer, |
| 1053 | - rtError_t(rtArgsHandle argsHandle, rtParaHandle paraHandle, uint32_t dataSize, void** bufferAddr)); | 1053 | + rtError_t(rtArgsHandle argsHandle, rtParaHandle paraHandle, size_t dataSize, void** bufferAddr)); |
| 1054 | MOCK_METHOD5( | 1054 | MOCK_METHOD5( |
| 1055 | rtsMalloc, | 1055 | rtsMalloc, |
| 1056 | rtError_t(void** devPtr, uint64_t size, rtMallocPolicy policy, rtMallocAdvise advise, rtMallocConfig_t* cfg)); | 1056 | rtError_t(void** devPtr, uint64_t size, rtMallocPolicy policy, rtMallocAdvise advise, rtMallocConfig_t* cfg)); |
| @@ -8,6 +8,9 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 11 | 14 | ||
| 12 | 15 | ||
| 13 | 16 | ||
| @@ -1720,12 +1720,7 @@ TEST_F(UTEST_ACL_Common, getOpTimeOutInterval) | |||
| 1720 | Mock::VerifyAndClear((void*)(&MockFunctionTest::aclStubInstance())); | 1720 | Mock::VerifyAndClear((void*)(&MockFunctionTest::aclStubInstance())); |
| 1721 | } | 1721 | } |
| 1722 | 1722 | ||
| 1723 | -void CallBackFunc(void* arg) | 1723 | +void CallBackFunc(void* arg) { (void)arg; } |
| 1724 | -{ | ||
| 1725 | - (void)arg; | ||
| 1726 | - int a = 1; | ||
| 1727 | - a++; | ||
| 1728 | -} | ||
| 1729 | 1724 | ||
| 1730 | TEST_F(UTEST_ACL_Common, callback) | 1725 | TEST_F(UTEST_ACL_Common, callback) |
| 1731 | { | 1726 | { |
| @@ -1289,12 +1289,7 @@ TEST_F(UTEST_ACL_Runtime, aclrtSetOpWaitTimeout) | |||
| 1289 | EXPECT_EQ(ret, ACL_ERROR_RT_PARAM_INVALID); | 1289 | EXPECT_EQ(ret, ACL_ERROR_RT_PARAM_INVALID); |
| 1290 | } | 1290 | } |
| 1291 | 1291 | ||
| 1292 | -void CallBackFuncStub(void* arg) | 1292 | +void CallBackFuncStub(void* arg) { (void)arg; } |
| 1293 | -{ | ||
| 1294 | - (void)arg; | ||
| 1295 | - int a = 1; | ||
| 1296 | - a++; | ||
| 1297 | -} | ||
| 1298 | 1293 | ||
| 1299 | TEST_F(UTEST_ACL_Runtime, aclrtSubscribeReportTest) | 1294 | TEST_F(UTEST_ACL_Runtime, aclrtSubscribeReportTest) |
| 1300 | { | 1295 | { |
| @@ -393,6 +393,21 @@ TEST_F(UTEST_tensor_data_transfer, TestTensorDatasetDeserializes03) | |||
| 393 | EXPECT_EQ(acltdtDestroyDataItem(item), ACL_SUCCESS); | 393 | EXPECT_EQ(acltdtDestroyDataItem(item), ACL_SUCCESS); |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | +TEST_F(UTEST_tensor_data_transfer, TestTensorDatasetDeserializesEmptyDims) | ||
| 397 | +{ | ||
| 398 | + acltdtDataset* dataSet = acltdtCreateDataset(); | ||
| 399 | + ASSERT_NE(dataSet, nullptr); | ||
| 400 | + tdt::DataItem dataItem = {tdt::TDT_TENSOR, "tensor", "[]", "int64", 0, nullptr}; | ||
| 401 | + std::vector<tdt::DataItem> itemVec = {dataItem}; | ||
| 402 | + | ||
| 403 | + EXPECT_EQ(TensorDatasetDeserializes(itemVec, dataSet), ACL_SUCCESS); | ||
| 404 | + ASSERT_EQ(acltdtGetDatasetSize(dataSet), 1); | ||
| 405 | + acltdtDataItem* item = acltdtGetDataItem(dataSet, 0); | ||
| 406 | + ASSERT_NE(item, nullptr); | ||
| 407 | + EXPECT_EQ(acltdtGetDimNumFromItem(item), 0); | ||
| 408 | + EXPECT_EQ(acltdtDestroyDataset(dataSet), ACL_SUCCESS); | ||
| 409 | +} | ||
| 410 | + | ||
| 396 | TEST_F(UTEST_tensor_data_transfer, TestAcltdtReceiveTensor01) | 411 | TEST_F(UTEST_tensor_data_transfer, TestAcltdtReceiveTensor01) |
| 397 | { | 412 | { |
| 398 | uint32_t deviceId = 0; | 413 | uint32_t deviceId = 0; |
| @@ -535,12 +535,7 @@ TEST_F(AclRtTest, acl_stream_unnormal) | |||
| 535 | EXPECT_EQ(ret, ACL_SUCCESS); | 535 | EXPECT_EQ(ret, ACL_SUCCESS); |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | -void CallBackFuncStub(void* arg) | 538 | +void CallBackFuncStub(void* arg) { (void)arg; } |
| 539 | -{ | ||
| 540 | - (void)arg; | ||
| 541 | - int a = 1; | ||
| 542 | - a++; | ||
| 543 | -} | ||
| 544 | 539 | ||
| 545 | TEST_F(AclRtTest, callback_aclrtSubscribeReportTest) | 540 | TEST_F(AclRtTest, callback_aclrtSubscribeReportTest) |
| 546 | { | 541 | { |
| @@ -95,7 +95,7 @@ void* mmMalloc_Normal_Invoke(unsigned long long size) | |||
| 95 | void* mmMalloc_Abnormal_Invoke(unsigned long long size) | 95 | void* mmMalloc_Abnormal_Invoke(unsigned long long size) |
| 96 | { | 96 | { |
| 97 | std::cout << "called mmMalloc_AbNormal_Invoke!" << std::endl; | 97 | std::cout << "called mmMalloc_AbNormal_Invoke!" << std::endl; |
| 98 | - size++; | 98 | + (void)size; |
| 99 | return nullptr; | 99 | return nullptr; |
| 100 | } | 100 | } |
| 101 | 101 | ||