Closed
feat(nn): 9 个算子支持 InferDataType(op_graph 注册,同步 rt1.0 dtype 推导策略) #10792
zzz2048Add on Sep 20Closed at 23 days ago
feat(nn): 9 个算子支持 InferDataType(op_graph 注册,同步 rt1.0 dtype 推导策略) #10792
Closed
Merged fromzzz2048/ops-nnfeat/infer-dtype-op-graphintocann/ops-nnmaster
Total: 10 files changed+295-0
Aactivation/confusion_softmax_grad/op_graph/confusion_softmax_grad_graph_infer.cpp+28-0File content is under review, please try again later
Aactivation/log_softmax_grad/op_graph/log_softmax_grad_graph_infer.cpp+28-0File content is under review, please try again later
Aactivation/log_softmax_v2/op_graph/log_softmax_v2_graph_infer.cpp+28-0File content is under review, please try again later
| @@ -0,0 +1,32 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This program is free software: you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | + * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +/*! | ||
| 12 | + * \file softmax_grad_graph_infer.cpp | ||
| 13 | + * \brief InferDataType for SoftmaxGrad synced from rt1.0 (canndev) dtype strategy: grad_x=softmax | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +#include "register/op_impl_registry.h" | ||
| 17 | +#include "log/log.h" | ||
| 18 | + | ||
| 19 | +using namespace ge; | ||
| 20 | +namespace ops { | ||
| 21 | +static ge::graphStatus InferDataTypeForSoftmaxGrad(gert::InferDataTypeContext* context) | ||
| 22 | +{ | ||
| 23 | + OP_LOGI("Begin InferDataTypeForSoftmaxGrad"); | ||
| 24 | + auto yGradDtype = context->GetInputDataType(0); | ||
| 25 | + auto yDtype = context->GetInputDataType(1); | ||
| 26 | + OP_CHECK_IF(yGradDtype != yDtype, OP_LOGE(context->GetNodeName(), "yGrad and y datatypes are not the same"), | ||
| 27 | + return ge::GRAPH_FAILED); | ||
| 28 | + context->SetOutputDataType(0, yGradDtype); | ||
| 29 | + return ge::GRAPH_SUCCESS; | ||
| 30 | +} | ||
| 31 | +IMPL_OP(SoftmaxGrad).InferDataType(InferDataTypeForSoftmaxGrad); | ||
| 32 | +} // namespace ops | ||
Aactivation/softmax_grad/op_host/softmax_grad_infershape.cpp+29-0File content is under review, please try again later
Anorm/layer_norm/op_graph/layer_norm_graph_infer.cpp+30-0File content is under review, please try again later
Anorm/layer_norm_v3/op_graph/layer_norm_v3_graph_infer.cpp+30-0File content is under review, please try again later
Anorm/sync_batch_norm_backward_elemt/op_graph/sync_batch_norm_backward_elemt_graph_infer.cpp+29-0File content is under review, please try again later
Anorm/sync_batch_norm_backward_reduce/op_graph/sync_batch_norm_backward_reduce_graph_infer.cpp+29-0File content is under review, please try again later
Anorm/sync_batch_norm_gather_stats/op_graph/sync_batch_norm_gather_stats_graph_infer.cpp+32-0File content is under review, please try again later