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_compare_scalar_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_vec_compare_scalar_check.h"
18 : namespace AscendC {
19 : namespace check {
20 0 : bool TikcppVecCompareScalarCheck::CommonCheck()
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), "src", supportPos));
25 :
26 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
27 : param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
28 : "check dst tensor buffersize failed"));
29 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
30 : param_.src0Size, GlobalParams::Instance().bufferSizeMap.at(param_.src0Pos),
31 : "check src tensor buffersize failed"));
32 0 : ASCENDC_CHECK(CheckAddrAlign());
33 0 : return true;
34 0 : }
35 :
36 0 : bool TikcppVecCompareScalarCheck::CheckAllLowLevel(std::vector<uint64_t> maskArray)
37 : {
38 0 : ASCENDC_CHECK(CommonCheck());
39 : (void)maskArray;
40 0 : return true;
41 : }
42 :
43 0 : bool TikcppVecCompareScalarCheck::CheckAllHighLevel()
44 : {
45 0 : ASCENDC_CHECK(CommonCheck());
46 0 : ASCENDC_CHECK(CheckTensorOverflowHigh(
47 : param_.dstDtypeBytes, param_.dstSize,
48 : static_cast<uint32_t>(std::ceil(param_.calCount / static_cast<float>(TypeBitLen::K_B8_BITS))), "dstLocal"));
49 : #if defined(__NPU_ARCH__) && ((__NPU_ARCH__ == 3510) || (__NPU_ARCH__ == 5102))
50 : if (param_.enableFlexibleScalar != 0) {
51 : if (param_.scalarPos == 1) {
52 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.src0DtypeBytes, param_.src0Size, param_.calCount, "src0"));
53 : } else {
54 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.src0DtypeBytes, param_.src0Size, param_.calCount, "src1"));
55 : }
56 : } else {
57 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.src0DtypeBytes, param_.src0Size, param_.calCount, "srcLocal"));
58 : }
59 : #else
60 0 : ASCENDC_CHECK(CheckTensorOverflowHigh(param_.src0DtypeBytes, param_.src0Size, param_.calCount, "srcLocal"));
61 : #endif
62 0 : return true;
63 : }
64 :
65 0 : bool TikcppVecCompareScalarCheck::CheckAddrAlign()
66 : {
67 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.dstAddr, param_.dstPos, ONE_BLK_SIZE, "dst"));
68 0 : ASCENDC_CHECK(CheckTensorAddrAlign(param_.src0Addr, param_.src0Pos, ONE_BLK_SIZE, "src"));
69 0 : return true;
70 : }
71 : } // namespace check
72 : } // namespace AscendC
|