LCOV - code coverage report
Current view: top level - src/api_check - kernel_vec_sort_check.cpp (source / functions) Coverage Total Hit
Test: coverage.info_filtered Lines: 0.0 % 35 0
Test Date: 2026-07-27 14:41:20 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : /*!
      12              :  * \file kernel_vec_sort_check.cpp
      13              :  * \brief
      14              :  */
      15              : 
      16              : #include "kernel_check_params.h"
      17              : #include "kernel_vec_sort_check.h"
      18              : 
      19              : namespace AscendC {
      20              : namespace check {
      21              : const uint32_t ONE_REPEAT_CAL_NUM = 16; // 1 repeat = 16 region proposals
      22              : const uint32_t PROPOSAL_SIZE = 8;       // 1 proposal = 8 element
      23              : constexpr uint32_t REGION_PROPOSAL_DATA_SIZE_V200 = 8;
      24              : constexpr uint32_t REGION_PROPOSAL_DATA_SIZE_HALF_V220 = 4;
      25              : constexpr uint32_t REGION_PROPOSAL_DATA_SIZE_FLOAT_V220 = 2;
      26              : 
      27            0 : bool TikcppVecSortCheck::Sort32Check()
      28              : {
      29            0 :     ASCENDC_CHECK_AND_LOG(param_.dstDtypeBytes != 0, { CHECK_LOG_ERROR("dstDtypeBytes should not be 0."); });
      30              :     // dst: 256 Bytes per repeat
      31            0 :     const uint32_t dstTotalElements = ONE_REPEAT_BYTE_SIZE / param_.dstDtypeBytes * param_.repeatTimes;
      32            0 :     ASCENDC_CHECK(CheckTensorOverflowHigh(param_.dstDtypeBytes, param_.dstSize, dstTotalElements, "dstLocal"));
      33              :     // concat + index: 32 elements per repeat
      34            0 :     const uint32_t totalElements = 32 * param_.repeatTimes;
      35            0 :     ASCENDC_CHECK(CheckTensorOverflowHigh(param_.concatDtypeBytes, param_.concatSize, totalElements, "concatLocal"));
      36            0 :     ASCENDC_CHECK(CheckTensorOverflowHigh(param_.indexDtypeBytes, param_.indexSize, totalElements, "indexLocal"));
      37              : 
      38            0 :     if (param_.isFullSort) {
      39            0 :         uint64_t coefficient = (param_.tmpDtypeBytes == sizeof(float)) ? REGION_PROPOSAL_DATA_SIZE_FLOAT_V220 :
      40              :                                                                          REGION_PROPOSAL_DATA_SIZE_HALF_V220;
      41            0 :         uint64_t tmpElements = totalElements * coefficient;
      42            0 :         ASCENDC_CHECK(CheckTensorOverflowHigh(param_.tmpDtypeBytes, param_.tmpSize, tmpElements, "tmpLocal"));
      43              :     }
      44            0 :     return true;
      45              : }
      46              : 
      47            0 : bool TikcppVecSortCheck::RpSort16Check()
      48              : {
      49              :     // 1 repeat = 16 proposals, 1 proposals = 8 * element. Data are continuously stored.
      50            0 :     uint64_t calCount = param_.repeatTimes * ONE_REPEAT_CAL_NUM * PROPOSAL_SIZE;
      51            0 :     ASCENDC_CHECK(CheckTensorOverflowHigh(param_.dstDtypeBytes, param_.dstSize, calCount, "dstLocal"));
      52            0 :     ASCENDC_CHECK(CheckTensorOverflowHigh(param_.concatDtypeBytes, param_.concatSize, calCount, "concatLocal"));
      53              : 
      54            0 :     if (param_.isFullSort) {
      55            0 :         uint64_t tmpElements = (param_.repeatTimes * ONE_REPEAT_CAL_NUM) * REGION_PROPOSAL_DATA_SIZE_V200;
      56            0 :         ASCENDC_CHECK(CheckTensorOverflowHigh(param_.tmpDtypeBytes, param_.tmpSize, tmpElements, "tmpLocal"));
      57              :     }
      58            0 :     return true;
      59              : }
      60              : 
      61            0 : bool TikcppVecSortCheck::CheckAllHighLevel()
      62              : {
      63            0 :     const std::string supportPos = "VECIN/VECOUT/VECCALC";
      64            0 :     const uint8_t ubPos = static_cast<uint8_t>(HardWareIndex::UB);
      65            0 :     ASCENDC_CHECK(CheckTensorScope(param_.dstLogicPos, ubPos, "dstLocal", supportPos));
      66            0 :     ASCENDC_CHECK(CheckTensorScope(param_.concatLogicPos, ubPos, "concatLocal", supportPos));
      67            0 :     ASCENDC_CHECK(CheckTensorScope(param_.indexLogicPos, ubPos, "indexLocal", supportPos));
      68            0 :     ASCENDC_CHECK(CheckTensorScope(param_.tmpLogicPos, ubPos, "tmpLocal", supportPos));
      69              : 
      70            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dstLocal"));
      71            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.concatAddr, param_.concatPos, ONE_BLK_SIZE, "concatLocal"));
      72            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.indexAddr, param_.indexPos, ONE_BLK_SIZE, "indexLocal"));
      73            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.tmpAddr, param_.tmpPos, ONE_BLK_SIZE, "tmpLocal"));
      74              : 
      75              : #if defined(__NPU_ARCH__) && ((__NPU_ARCH__ == 2201) || (__NPU_ARCH__ == 3002) || (__NPU_ARCH__ == 3102) || \
      76              :                               (__NPU_ARCH__ == 3510) || (__NPU_ARCH__ == 5102))
      77            0 :     ASCENDC_CHECK(Sort32Check());
      78              : #elif defined(__NPU_ARCH__) && ((__NPU_ARCH__ == 1001) || (__NPU_ARCH__ == 2002))
      79            0 :     ASCENDC_CHECK(RpSort16Check());
      80              : #endif
      81            0 :     return true;
      82            0 : }
      83              : 
      84              : } // namespace check
      85              : } // namespace AscendC
        

Generated by: LCOV version 2.0-1