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