* 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_adamax.cpp
* \brief ApplyAdamax Kernel 入口(arch35 架构 / Ascend950)
*
* 模板参数:
* - D_T: 输入 Tensor 数据类型(float / half)
* - K_ALIGN: 32B 对齐标记(0=非对齐, 1=对齐)
*
* 迭代一仅 fp32 + 对齐真正验证;其他分支共用相同实现路径(后续替换)。
*
* 核函数参数顺序(对齐 canndev REG_OP(ApplyAdaMax) 单输出原型):
* 9 输入 (var, m, v, beta1_power, lr, beta1, beta2, epsilon, grad)
* + 1 输出 (var)
* + workspace + tiling
* m / v 的 inplace 更新通过把输入 GM_ADDR 同时作为 kernel 内部 "mOut/vOut" 写回目标实现。
*/
#include "arch35/apply_adamax.h"
template <typename D_T, int K_ALIGN>
__global__ __aicore__ void apply_ada_max(GM_ADDR var, GM_ADDR m, GM_ADDR v, GM_ADDR beta1Power, GM_ADDR lr,
GM_ADDR beta1, GM_ADDR beta2, GM_ADDR epsilon, GM_ADDR grad, GM_ADDR varOut,
GM_ADDR workspace, GM_ADDR tiling)
{
REGISTER_TILING_DEFAULT(ApplyAdamaxTilingData);
GET_TILING_DATA_WITH_STRUCT(ApplyAdamaxTilingData, tilingData, tiling);
NsApplyAdamax::ApplyAdamax<D_T, K_ALIGN> op;
op.Init(var, m, v, beta1Power, lr, beta1, beta2, epsilon, grad, varOut, m, v, &tilingData);
op.Process();
}