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_data_copy_pad_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_data_copy_pad_check.h"
18 :
19 : namespace AscendC {
20 : namespace check {
21 0 : bool TikcppDataCopyPadCheck::CheckPadParamters()
22 : {
23 : static constexpr uint32_t dataCopyPadPaddingSizeLimit = 32; // pad element * sizeof(dtype) <= 32
24 0 : uint64_t paddingLimit = dataCopyPadPaddingSizeLimit / param_.srcDtypeBytes;
25 0 : if (param_.leftPadding > paddingLimit) {
26 0 : CHECK_LOG_ERROR(
27 : "Failed to check leftPadding value in DataCopyPad, its valid range is 0 ~ %lu, current value "
28 : "is %u.",
29 : paddingLimit, param_.leftPadding);
30 0 : return false;
31 : }
32 0 : if (param_.rightPadding > paddingLimit) {
33 0 : CHECK_LOG_ERROR(
34 : "Failed to check rightPadding value in DataCopyPad, its valid range is 0 ~ %lu, current value "
35 : "is %u.",
36 : paddingLimit, param_.rightPadding);
37 0 : return false;
38 : }
39 :
40 0 : if (param_.isPad && param_.srcDtypeBytes == B64_BYTE_SIZE && param_.paddingValue != 0) {
41 0 : CHECK_LOG_ERROR(
42 : "Failed to check paddingValue value in DataCopyPad when dtype is B64, it must be 0, current "
43 : "value is %s.",
44 : std::to_string(param_.paddingValue).c_str());
45 0 : return false;
46 : }
47 0 : return true;
48 : }
49 :
50 0 : bool TikcppDataCopyPadCheck::CheckAllHighLevel()
51 : {
52 0 : ASCENDC_CHECK(CheckPadParamters());
53 0 : return true;
54 : }
55 : } // namespace check
56 : } // namespace AscendC
|