* 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.
*
* Disclaimer: This file is generated with the assistance of an AI tool.
* Please review carefully before use.
*/
#include "fresnel_sin.h"
#include "opdev/op_log.h"
#include "opdev/op_dfx.h"
#include "opdev/shape_utils.h"
#include "opdev/make_op_executor.h"
#include "opdev/platform.h"
using namespace op;
namespace l0op {
OP_TYPE_REGISTER(FresnelSin);
static const std::initializer_list<op::DataType> AICORE_DTYPE_SUPPORT_LIST = {
DataType::DT_FLOAT, DataType::DT_FLOAT16, DataType::DT_BF16
};
static bool IsAiCoreSupport(const aclTensor* x)
{
auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch();
OP_CHECK(npuArch == NpuArch::DAV_3510,
OP_LOGE(ACLNN_ERR_PARAM_INVALID,
"FresnelSin only supports Ascend950 (DAV_3510): npuArch=%d",
static_cast<int>(npuArch)),
return false);
OP_CHECK(CheckType(x->GetDataType(), AICORE_DTYPE_SUPPORT_LIST),
OP_LOGE(ACLNN_ERR_PARAM_INVALID,
"FresnelSin dtype not supported: %d",
static_cast<int>(x->GetDataType())),
return false);
return true;
}
static const aclTensor* FresnelSinAiCore(
const aclTensor* x, const aclTensor* out, aclOpExecutor* executor)
{
L0_DFX(FresnelSinAiCore, x, out);
auto ret = ADD_TO_LAUNCHER_LIST_AICORE(FresnelSin,
OP_INPUT(x), OP_OUTPUT(out));
OP_CHECK(ret == ACLNN_SUCCESS,
OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "FresnelSinAiCore failed."),
return nullptr);
return out;
}
const aclTensor* FresnelSin(const aclTensor* x, aclOpExecutor* executor)
{
OP_CHECK(IsAiCoreSupport(x),
OP_LOGE(ACLNN_ERR_PARAM_INVALID, "IsAiCoreSupport check failed."),
return nullptr);
auto out = executor->AllocTensor(x->GetViewShape(), x->GetDataType());
return FresnelSinAiCore(x, out, executor);
}
}