* 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.
*/
* \file kl_div_graph_infer.cpp
* \brief KLDiv dtype 推导
*/
#include "register/op_impl_registry.h"
#include "log/log.h"
using namespace ge;
namespace ops {
static ge::graphStatus InferDtype4SameInput(gert::InferDataTypeContext* context)
{
OP_LOGD(context->GetNodeName(), "do inferDataType for output is same input");
auto inputXDtype = context->GetInputDataType(0);
auto inputTargetDtype = context->GetInputDataType(1);
OP_CHECK_IF(inputXDtype != inputTargetDtype,
OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON(
context->GetNodeName(), "x and target",
(Ops::Base::ToString(inputXDtype) + " and " + Ops::Base::ToString(inputTargetDtype)).c_str(),
"The dtypes of input x and target must be the same"),
return ge::GRAPH_FAILED);
context->SetOutputDataType(0, inputXDtype);
return ge::GRAPH_SUCCESS;
}
IMPL_OP(KLDiv).InferDataType(InferDtype4SameInput);
}