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_cube_initconstvalue_check.cpp
13 : * \brief
14 : */
15 :
16 : #include "kernel_check_params.h"
17 : #include "kernel_cube_initconstvalue_check.h"
18 :
19 : namespace AscendC {
20 : namespace check {
21 0 : bool TikcppCubeInitConstValueCheck::CheckAllLowLevel()
22 : {
23 0 : uint16_t repeatTimes = param_.repeatTimes;
24 0 : uint16_t blockNum = param_.blockNum;
25 0 : uint16_t dstGap = param_.dstGap;
26 :
27 0 : ASCENDC_CHECK(CheckBufferSizeOverFlow(
28 : param_.dstSize, GlobalParams::Instance().bufferSizeMap.at(param_.dstPos),
29 : "Failed to check dstLocal tensor buffersize in InitConstValue"));
30 : // repeatTimes + block + dstGap not exceed dstLocal
31 : #if defined(__NPU_ARCH__) && __NPU_ARCH__ == 2002
32 0 : uint32_t blockLen = 512; // 310P fix one repeat is 512B
33 : #else
34 0 : uint32_t blockLen = 32; // one block length is 32B
35 0 : if (param_.dstPos == static_cast<uint8_t>(HardWareIndex::L0A) ||
36 0 : param_.dstPos == static_cast<uint8_t>(HardWareIndex::L0B)) {
37 0 : blockLen = 512; // when L0A / L0B, block is in unit of 512B
38 : }
39 : #endif
40 0 : uint64_t bufferSize = ((blockNum + dstGap) * repeatTimes - dstGap) * blockLen;
41 0 : if (param_.dstSize < bufferSize) {
42 0 : CHECK_LOG_ERROR("Failed to check dstLocal tensor calculate size overflow in InitConstValue, please check "
43 : "value of repeatTimes, blockNum, dstGap");
44 0 : return false;
45 : }
46 :
47 0 : return true;
48 : }
49 : } // namespace check
50 : } // namespace AscendC
|