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_vector_padding_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_vector_padding_check.h"
18 :
19 : namespace AscendC {
20 : namespace check {
21 :
22 0 : bool TikcppVectorPaddingCheck::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(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst"));
28 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.srcAddr, param_.srcPos, ONE_BLK_SIZE, "src"));
29 :
30 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
31 : param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
32 : "check dst tensor buffersize failed"));
33 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
34 : param_.srcSize, GlobalParams::Instance().bufferSizeMap.at(param_.srcPos),
35 : "check src tensor buffersize failed"));
36 0 : return true;
37 0 : }
38 :
39 0 : bool TikcppVectorPaddingCheck::CheckAllLowLevel(std::vector<uint64_t> maskArray)
40 : {
41 0 : uint32_t maxByteLen = std::max(param_.dstDtypeBytes, param_.srcDtypeBytes);
42 0 : ASCENDC_CHECK(UpdateMaskArrayAndCheck(maskArray, maxByteLen));
43 0 : ASCENDC_CHECK(CommonCheck());
44 :
45 : TensorOverflowParams params = {
46 0 : param_.dstSize,
47 0 : param_.dstDtypeBytes,
48 0 : static_cast<uint64_t>(param_.repeatTimes),
49 0 : static_cast<uint64_t>(param_.dstBlockStride),
50 0 : static_cast<uint64_t>(param_.dstRepeatStride),
51 0 : false};
52 0 : ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "dstLocal"));
53 0 : params = {
54 0 : param_.srcSize,
55 0 : param_.srcDtypeBytes,
56 0 : static_cast<uint64_t>(param_.repeatTimes),
57 0 : static_cast<uint64_t>(param_.srcBlockStride),
58 0 : static_cast<uint64_t>(param_.srcRepeatStride),
59 0 : false};
60 0 : ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "srcLocal"));
61 0 : return true;
62 : }
63 :
64 0 : bool TikcppVectorPaddingCheck::CheckAllHighLevel()
65 : {
66 0 : ASCENDC_CHECK(CommonCheck());
67 0 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.dstDtypeBytes, param_.dstSize, param_.calCount, "dstLocal"));
68 0 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.srcDtypeBytes, param_.srcSize, param_.calCount, "srcLocal"));
69 0 : return true;
70 : }
71 :
72 : } // namespace check
73 : } // namespace AscendC
|