LCOV - code coverage report
Current view: top level - src/api_check - kernel_vec_gather_check.cpp (source / functions) Coverage Total Hit
Test: coverage.info_filtered Lines: 0.0 % 33 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_gather_check.cpp
      13              :  * \brief
      14              :  */
      15              : 
      16              : #include "kernel_check_params.h"
      17              : #include "kernel_vec_gather_check.h"
      18              : 
      19              : namespace AscendC {
      20              : namespace check {
      21              : 
      22            0 : bool TikcppVecGatherCheck::CommonCheck()
      23              : {
      24            0 :     const std::string supportPos = "VECIN/VECOUT/VECCALC";
      25            0 :     ASCENDC_CHECK(CheckTensorScope(param_.dstLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "dst", supportPos));
      26            0 :     ASCENDC_CHECK(CheckTensorScope(param_.srcLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "src", supportPos));
      27            0 :     ASCENDC_CHECK(
      28              :         CheckTensorScope(param_.offsetLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "offset", supportPos));
      29              : #if defined(__NPU_ARCH__) && __NPU_ARCH__ == 2002
      30            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, param_.dstDtypeBytes, "dst")); // 200: dtype align
      31              : #else
      32            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst")); // 220: 32B aligned
      33              : #endif
      34            0 :     ASCENDC_CHECK(CheckTensorAddrAlign(param_.offsetAddr, param_.offsetPos, ONE_BLK_SIZE, "offset"));
      35              : 
      36            0 :     ASCENDC_CHECK(CheckBufferSizeOverFlow(
      37              :         param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
      38              :         "check dst tensor buffersize failed"));
      39            0 :     ASCENDC_CHECK(CheckBufferSizeOverFlow(
      40              :         param_.srcSize, GlobalParams::Instance().bufferSizeMap.at(param_.srcPos),
      41              :         "check src tensor buffersize failed"));
      42            0 :     ASCENDC_CHECK(CheckBufferSizeOverFlow(
      43              :         param_.offsetSize, GlobalParams::Instance().bufferSizeMap.at(param_.offsetPos),
      44              :         "check offset tensor buffersize failed"));
      45              :     // srcLocal tensor size is unknown. Only check srcBaseOffset will not exceed srcLocal size
      46            0 :     ASCENDC_CHECK_AND_LOG(param_.srcBaseOffset <= param_.srcSize, {
      47              :         CHECK_LOG_ERROR(
      48              :             "Failed to check srcBaseOffset value in "
      49              :             "%s, its valid range is 0 ~ %lu, current value is %u",
      50              :             apiName.c_str(), param_.srcSize, param_.srcBaseOffset);
      51              :     });
      52            0 :     return true;
      53            0 : }
      54              : 
      55            0 : bool TikcppVecGatherCheck::CheckAllLowLevel(std::vector<uint64_t> maskArray)
      56              : {
      57            0 :     uint32_t maxByteLen = std::max(std::max(param_.dstDtypeBytes, param_.srcDtypeBytes), param_.offsetDtypeBytes);
      58            0 :     ASCENDC_CHECK(UpdateMaskArrayAndCheck(maskArray, maxByteLen));
      59            0 :     ASCENDC_CHECK(CommonCheck());
      60              : 
      61              :     TensorOverflowParams params = {
      62            0 :         param_.dstSize,
      63            0 :         param_.dstDtypeBytes,
      64            0 :         static_cast<uint64_t>(param_.repeatTimes),
      65            0 :         static_cast<uint64_t>(param_.dstBlockStride),
      66            0 :         static_cast<uint64_t>(param_.dstRepeatStride),
      67            0 :         false};
      68            0 :     ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "dstLocal"));
      69              :     // gather: srcBlkStride, srcRepStride must be 1
      70            0 :     params = {param_.srcSize, param_.srcDtypeBytes, static_cast<uint64_t>(param_.repeatTimes), 1, 1, false};
      71            0 :     ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "srcOffsetLocal"));
      72            0 :     return true;
      73              : }
      74              : 
      75            0 : bool TikcppVecGatherCheck::CheckAllHighLevel()
      76              : {
      77            0 :     ASCENDC_CHECK(CommonCheck());
      78            0 :     ASCENDC_CHECK(CheckTensorOverflowHigh(param_.dstDtypeBytes, param_.dstSize, param_.calCount, "dstLocal"));
      79            0 :     ASCENDC_CHECK(
      80              :         CheckTensorOverflowHigh(param_.offsetDtypeBytes, param_.offsetSize, param_.calCount, "srcOffsetLocal"));
      81            0 :     return true;
      82              : }
      83              : 
      84              : } // namespace check
      85              : } // namespace AscendC
        

Generated by: LCOV version 2.0-1