/** * Copyright (c) 2024 Huawei Technologies Co., Ltd. * This file is a part of the CANN Open Software. * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). * Please refer to the License for details. You may not use this file except in compliance with the License. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. * See LICENSE in the root of the software repository for the full text of the License. */ /*! * \file sum_tiling_intf.h * \brief */ #ifndef __ASCENDC_TIKCFW_TILING_SUM_TILINGINTF_H__ #define __ASCENDC_TIKCFW_TILING_SUM_TILINGINTF_H__ #include #include namespace AscendC { inline void GetSumMaxMinTmpSize( const uint32_t n, const uint32_t typeSize, const bool isReuseSource, uint32_t &maxSize, uint32_t &minSize) { (void)isReuseSource; assert(typeSize > 0); constexpr uint32_t sumOneBlkSize = 32; constexpr uint32_t sumOneRepeatByteSize = 256; uint32_t elementNumPerBlk = sumOneBlkSize / typeSize; // half=16 float=8 uint32_t elementNumPerRep = sumOneRepeatByteSize / typeSize; assert(elementNumPerBlk > 0 && elementNumPerRep > 0); uint32_t repeatTimes = (n + elementNumPerRep - 1) / elementNumPerRep; // workSize = repeatTimes向上取整 uint32_t finalWorkSize = (repeatTimes + elementNumPerBlk - 1) / elementNumPerBlk * elementNumPerBlk * typeSize; maxSize = minSize = finalWorkSize; } } // namespace AscendC #endif