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_mask_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_vec_gather_mask_check.h"
18 : namespace AscendC {
19 : namespace check {
20 0 : bool TikcppGatherMaskCheck::CheckAllLowLevel(std::vector<uint64_t> maskArray)
21 : {
22 0 : const std::string supportPos = "VECIN/VECOUT/VECCALC";
23 0 : ASCENDC_CHECK(CheckTensorScope(param_.dstLogicPos, static_cast<uint8_t>(HardWareIndex::UB), "dst", supportPos));
24 0 : ASCENDC_CHECK(CheckTensorScope(param_.src0LogicPos, static_cast<uint8_t>(HardWareIndex::UB), "src0", supportPos));
25 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst"));
26 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.src0Addr, param_.src0Pos, ONE_BLK_SIZE, "src0"));
27 0 : if (param_.src1Pattern == 0) {
28 0 : ASCENDC_CHECK(
29 : CheckTensorScope(param_.src1LogicPos, static_cast<uint8_t>(HardWareIndex::UB), "src1", supportPos));
30 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.src1Addr, param_.src1Pos, ONE_BLK_SIZE, "src1"));
31 : }
32 :
33 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
34 : param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
35 : "check dst tensor buffersize failed"));
36 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
37 : param_.src0Size, GlobalParams::Instance().bufferSizeMap.at(param_.src0Pos),
38 : "check src0 tensor buffersize failed"));
39 0 : if (param_.src1Pattern == 0) {
40 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
41 : param_.src1Size, GlobalParams::Instance().bufferSizeMap.at(param_.src1Pos),
42 : "check src1 tensor buffersize failed"));
43 : }
44 :
45 : // mask is invalid in normal mode. When counter mode, update mask array
46 0 : if (param_.reduceMode) {
47 0 : uint32_t maxByteLen = std::max(std::max(param_.dstDtypeBytes, param_.src0DtypeBytes), param_.src1DtypeBytes);
48 0 : ASCENDC_CHECK(UpdateMaskArrayAndCheck(maskArray, maxByteLen));
49 : }
50 :
51 : TensorOverflowParams params = {
52 0 : param_.src0Size,
53 0 : param_.src0DtypeBytes,
54 0 : static_cast<uint64_t>(param_.repeatTimes),
55 0 : static_cast<uint64_t>(param_.src0BlockStride),
56 0 : static_cast<uint64_t>(param_.src0RepeatStride),
57 0 : param_.reduceMode};
58 0 : ASCENDC_CHECK(CheckTensorOverflowLowGathermask(maskArray, params, "src0Local"));
59 0 : return true;
60 0 : }
61 : } // namespace check
62 : } // namespace AscendC
|