/**
 * Copyright (c) 2026 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.
 *
 * Generated By CANNBot
 */

/**
 * NOTE: Portions of this code were AI-generated and have been
 * technically reviewed for functional accuracy and security
 */
/*!
 * \file apply_rms_prop.cpp
 * \brief ApplyRMSProp kernel entry (arch35), aligned to canndev REG_OP
 *
 * GE IR signature (canndev REG_OP(ApplyRMSProp)):
 *   Inputs (8 Tensor):  var, ms, mom, lr, rho, momentum, epsilon, grad
 *   Outputs (1 Tensor): var (alias of input var; inplace)
 *
 * Template parameters (matching apply_rms_prop_tiling_key.h):
 *   - D_T_X:        Data type, from ASCENDC_TPL_DATATYPE_DECL
 *   - BUFFER_MODE:  Buffer mode (0=single, 1=double), from ASCENDC_TPL_UINT_DECL
 */

#include "arch35/apply_rms_prop.h"

// Kernel 函数名必须与 CANN 编译器的 main_func 期望一致:apply_rms_prop
// (CANN 对 OpType 中的 acronym 'RMS' 按整体处理,不拆为 r_m_s。
//  build/tbe/dynamic/apply_rms_prop.py 中 origin_func_name="apply_rms_prop",
//  与 apply_adamax/apply_adadelta 等同样以 acronym 整段命名的算子一致。)
template <typename D_T_X, int BUFFER_MODE>
__global__ __aicore__ void apply_rms_prop(GM_ADDR var, GM_ADDR ms, GM_ADDR mom, GM_ADDR lr, GM_ADDR rho,
                                          GM_ADDR momentum, GM_ADDR epsilon, GM_ADDR grad, GM_ADDR var_out,
                                          GM_ADDR workspace, GM_ADDR tiling)
{
    REGISTER_TILING_DEFAULT(ApplyRmsPropTilingData);
    GET_TILING_DATA_WITH_STRUCT(ApplyRmsPropTilingData, tilingData, tiling);
    NsApplyRmsProp::ApplyRmsProp<D_T_X, BUFFER_MODE> op;
    op.Init(var, ms, mom, lr, rho, momentum, epsilon, grad, var_out, &tilingData);
    op.Process();
}