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_copy_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_copy_check.h"
18 :
19 : namespace AscendC {
20 : namespace check {
21 :
22 0 : bool TikcppCopyCheck::CheckAllHighLevel()
23 : {
24 0 : ASCENDC_CHECK(
25 : CheckTensorScope(param_.dstLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "dst", "VECIN/VECOUT/VECCALC"));
26 0 : ASCENDC_CHECK(
27 : CheckTensorScope(param_.srcLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "src", "VECIN/VECOUT/VECCALC"));
28 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst"));
29 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.srcAddr, param_.srcPos, ONE_BLK_SIZE, "src"));
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 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.dstDtypeBytes, param_.dstSize, param_.calCount, "dstLocal"));
37 0 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.srcDtypeBytes, param_.srcSize, param_.calCount, "srcLocal"));
38 0 : return true;
39 : }
40 :
41 32 : bool TikcppCopyCheck::CheckAllLowLevel(std::vector<uint64_t> maskArray)
42 : {
43 32 : uint32_t maxByteLen = std::max(param_.dstDtypeBytes, param_.srcDtypeBytes);
44 32 : ASCENDC_CHECK(UpdateMaskArrayAndCheck(maskArray, maxByteLen));
45 :
46 32 : const std::string supportPos = "VECIN/VECOUT/VECCALC";
47 96 : ASCENDC_CHECK(CheckTensorScope(param_.dstLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "dst", supportPos));
48 72 : ASCENDC_CHECK(CheckTensorScope(param_.srcLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "src", supportPos));
49 :
50 72 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst"));
51 72 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.srcAddr, param_.srcPos, ONE_BLK_SIZE, "src"));
52 :
53 72 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
54 : param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
55 : "check dst tensor buffersize failed"));
56 72 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
57 : param_.srcSize, GlobalParams::Instance().bufferSizeMap.at(param_.srcPos),
58 : "check src tensor buffersize failed"));
59 :
60 : TensorOverflowParams params = {
61 24 : param_.dstSize,
62 24 : static_cast<uint64_t>(param_.dstDtypeBytes),
63 24 : static_cast<uint64_t>(param_.repeatTimes),
64 24 : static_cast<uint64_t>(param_.dstStride),
65 24 : static_cast<uint64_t>(param_.dstRepeatSize),
66 24 : false};
67 72 : ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "dstLocal"));
68 16 : params = {
69 16 : param_.srcSize,
70 16 : static_cast<uint64_t>(param_.srcDtypeBytes),
71 16 : static_cast<uint64_t>(param_.repeatTimes),
72 16 : static_cast<uint64_t>(param_.srcStride),
73 16 : static_cast<uint64_t>(param_.srcRepeatSize),
74 16 : false};
75 48 : ASCENDC_CHECK(CheckTensorOverflowLow(maskArray, params, "srcLocal"));
76 :
77 16 : return true;
78 32 : }
79 :
80 : } // namespace check
81 : } // namespace AscendC
|