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_createvecindex_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_vec_createvecindex_check.h"
18 :
19 : namespace AscendC {
20 : namespace check {
21 :
22 0 : bool TikcppVecCreateVecIndexCheck::CommonCheck()
23 : {
24 0 : ASCENDC_CHECK(CheckTensorScope(
25 : param_.dstLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "dstLocal", "VECIN/VECOUT/VECCALC"));
26 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
27 : param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
28 : "Failed to check dstLocal tensor buffersize in CreateVecIndex"));
29 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst"));
30 0 : return true;
31 : }
32 :
33 0 : bool TikcppVecCreateVecIndexCheck::CheckAllLowLevel(std::vector<uint64_t> maskArray)
34 : {
35 0 : uint32_t maxByteLen = param_.dstDtypeBytes;
36 0 : ASCENDC_CHECK(UpdateMaskArrayAndCheck(maskArray, maxByteLen));
37 0 : ASCENDC_CHECK(CommonCheck());
38 : TensorOverflowParams params = {
39 0 : param_.dstSize,
40 0 : param_.dstDtypeBytes,
41 0 : static_cast<uint64_t>(param_.repeatTimes),
42 0 : static_cast<uint64_t>(param_.dstBlkStride),
43 0 : static_cast<uint64_t>(param_.dstRepStride),
44 0 : false};
45 0 : ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "dstLocal"));
46 0 : return true;
47 : }
48 :
49 0 : bool TikcppVecCreateVecIndexCheck::CheckAllHighLevel()
50 : {
51 0 : ASCENDC_CHECK(CommonCheck());
52 0 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.dstDtypeBytes, param_.dstSize, param_.calCount, "dstLocal"));
53 0 : return true;
54 : }
55 :
56 : } // namespace check
57 : } // namespace AscendC
|