* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.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.
*/
#ifndef LIB_NORMALIZATION_BATCHNORM_TILING_H
#define LIB_NORMALIZATION_BATCHNORM_TILING_H
#include "graph/tensor.h"
#include "batchnorm_tilingdata.h"
#include "kernel_tiling/kernel_tiling.h"
namespace AscendC {
* \brief calculate max and min tmp buffer size for BatchNorm interface.
tmp buffer size is a input for GetBatchNormNDTilingInfo
*
* \note The returned set may be smaller than set that
* contains all possible values of v that satisfies the bound.
*
* \param [in] srcShape input shape
* \param [in] typeSize data type size: sizeof(TYPE)
* \param [out] maxValue max size of tmp buffer
* \param [out] minValue min size of tmp buffer
* \param [in] isBasicBlock indicate whether enable basicBlock.
When enable basicBlock, better performance will be achived and more tmp buffer will be needed
* \return flag for whether the tmp buffer size is calculated successfully
if src shape is illeagl for basic block, it will return false.
*/
bool GetBatchNormMaxMinTmpSize(const ge::Shape& srcShape, const ge::Shape& originSrcShape, const uint32_t typeSize,
const bool isReuseSource, uint32_t& maxValue, uint32_t& minValue, const bool isBasicBlock = false);
* \brief calculate tiling params for BatchNorm interface
*
* \note stackBufferByteSize should be greater than min tmpSize from GetBatchNormMaxMinTmpSize
*
* \param [in] srcShape input shape
* \param [in] originSrcShape data type size: sizeof(TYPE)
* \param [in] stackBufferByteSize input stack buffer size in uint of Byte, used as tmp buffer size for tiling
* \param [in] typeSize data type size: sizeof(TYPE)
* \param [in] isReuseSource indicate whether intermediate variables can reuse the input memory
* \param [out] tiling BatchNorm tiling
* \param [in] isBasicBlock indicate whether enable basicBlock.
When enable basicBlock, better performance will be achived and more tmp buffer will be needed
* \return flag for whether the tiling is calculated successfully
if src shape and origin src shape is illeagl or input stackBufferByteSize is not big enough, it will return false.
*/
bool GetBatchNormNDTilingInfo(const ge::Shape& srcShape, const ge::Shape& originSrcShape,
const uint32_t stackBufferByteSize, const uint32_t typeSize, const bool isReuseSource,
optiling::BatchNormTiling& tilling, const bool isBasicBlock = false);
bool GetBatchNormNDTilingInfo(const ge::Shape& srcShape, const ge::Shape& originSrcShape,
const uint32_t stackBufferByteSize, const uint32_t typeSize, const bool isReuseSource,
AscendC::tiling::BatchNormTiling& tilling, const bool isBasicBlock = false);
}
#endif