LCOV - code coverage report
Current view: top level - ut/activation/relu_grad/op_host/arch35 - relu_grad_tiling_arch35.cpp Coverage Total Hit
Test: CHG Lines: 0.0 % 1 0
Test Date: 2026-08-26 16:41:30
Legend: Lines: hit not hit

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 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 relu_grad_tiling_arch35.cpp
      13              :  * \brief relu_grad_tiling
      14              :  */
      15              : 
      16              : #include "relu_grad_tiling_arch35.h"
      17              : #include <graph/utils/type_utils.h>
      18              : #include "op_host/tiling_base.h"
      19              : #include "atvoss/broadcast/broadcast_tiling.h"
      20              : #include "activation/relu_grad/op_kernel/arch35/relu_grad_struct.h"
      21              : #include "activation/relu_grad/op_kernel/arch35/relu_grad_dag.h"
      22              : #include "log/log.h"
      23              : #include "register/op_impl_registry.h"
      24              : #include "op_host/tiling_templates_registry.h"
      25              : 
      26              : using namespace Ops::Base;
      27              : using namespace ge;
      28              : using namespace ReluGradOp;
      29              : 
      30              : namespace optiling {
      31              : static constexpr uint64_t RELU_GRAD_COMMON_TILING_PRIORITY = 0;
      32              : 
      33              : ge::graphStatus ReluGradTiling::GetShapeAttrsInfo() { return ge::GRAPH_SUCCESS; }
      34              : 
      35              : bool ReluGradTiling::IsCapable() { return true; }
      36              : 
      37              : ge::graphStatus ReluGradTiling::DoOpTiling()
      38              : {
      39              :     auto inputDesc = context_->GetInputDesc(0);
      40              :     OP_CHECK_NULL_WITH_CONTEXT(context_, inputDesc);
      41              :     ge::DataType inputDtype = inputDesc->GetDataType();
      42              :     ge::graphStatus status = ge::GRAPH_FAILED;
      43              :     if (inputDtype == ge::DT_FLOAT16) {
      44              :         BroadcastBaseTiling<ReluGradDag<half>::OpDag> brcBaseTiling(context_);
      45              :         status = brcBaseTiling.DoTiling();
      46              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_FP16);
      47              :     } else if (inputDtype == ge::DT_BF16) {
      48              :         BroadcastBaseTiling<ReluGradDag<bfloat16_t>::OpDag> brcBaseTiling(context_);
      49              :         status = brcBaseTiling.DoTiling();
      50              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_BF16);
      51              :     } else if (inputDtype == ge::DT_FLOAT) {
      52              :         BroadcastBaseTiling<ReluGradDag<float>::OpDag> brcBaseTiling(context_);
      53              :         status = brcBaseTiling.DoTiling();
      54              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_FP32);
      55              :     } else if (inputDtype == ge::DT_INT8) {
      56              :         BroadcastBaseTiling<ReluGradCastDag<int8_t>::OpDag> brcBaseTiling(context_);
      57              :         status = brcBaseTiling.DoTiling();
      58              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_INT8);
      59              :     } else if (inputDtype == ge::DT_UINT8) {
      60              :         BroadcastBaseTiling<ReluGradCastDag<uint8_t>::OpDag> brcBaseTiling(context_);
      61              :         status = brcBaseTiling.DoTiling();
      62              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_UINT8);
      63              :     } else if (inputDtype == ge::DT_INT32) {
      64              :         BroadcastBaseTiling<ReluGradDag<int32_t>::OpDag> brcBaseTiling(context_);
      65              :         status = brcBaseTiling.DoTiling();
      66              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_INT32);
      67              :     } else if (inputDtype == ge::DT_INT64) {
      68              :         BroadcastBaseTiling<ReluGradDag<int64_t>::OpDag> brcBaseTiling(context_);
      69              :         status = brcBaseTiling.DoTiling();
      70              :         tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode(), RELU_GRAD_TPL_INT32);
      71              :     } else {
      72              :         OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "x", ge::TypeUtils::DataTypeToSerialString(inputDtype),
      73              :                                   "DT_FLOAT16, DT_BF16, DT_FLOAT, DT_INT8, DT_UINT8, DT_INT32, DT_INT64");
      74              :         return ge::GRAPH_FAILED;
      75              :     }
      76              : 
      77            0 :     OP_CHECK_IF(status != ge::GRAPH_SUCCESS,
      78              :                 OP_LOGE(context_->GetNodeName(), "BroadcastBaseTiling do tiling failed, input dtype: %s.",
      79              :                         ge::TypeUtils::DataTypeToSerialString(inputDtype).c_str()),
      80              :                 return ge::GRAPH_FAILED);
      81              :     return ge::GRAPH_SUCCESS;
      82              : }
      83              : 
      84              : ge::graphStatus ReluGradTiling::DoLibApiTiling() { return ge::GRAPH_SUCCESS; }
      85              : 
      86              : uint64_t ReluGradTiling::GetTilingKey() const { return tilingKey; }
      87              : 
      88              : ge::graphStatus ReluGradTiling::GetWorkspaceSize() { return ge::GRAPH_SUCCESS; }
      89              : 
      90              : ge::graphStatus ReluGradTiling::PostTiling() { return ge::GRAPH_SUCCESS; }
      91              : 
      92              : ge::graphStatus ReluGradTiling::GetPlatformInfo() { return ge::GRAPH_SUCCESS; }
      93              : 
      94              : static ge::graphStatus TilingForReluGrad(gert::TilingContext* context)
      95              : {
      96              :     OP_LOGD("ReluGradTiling", "Enter TilingForReluGrad");
      97              :     if (context == nullptr) {
      98              :         OP_LOGE("ReluGradTiling", "Tiling context is null");
      99              :         return ge::GRAPH_FAILED;
     100              :     }
     101              :     auto compileInfo = context->GetCompileInfo<BroadcastCompileInfo>();
     102              :     OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);
     103              :     ReluGradTiling tiling(context);
     104              :     return tiling.DoTiling();
     105              : }
     106              : 
     107              : static ge::graphStatus TilingPrepareForBroadcast(gert::TilingParseContext* context)
     108              : {
     109              :     auto compileInfoPtr = context->GetCompiledInfo<Ops::Base::BroadcastCompileInfo>();
     110              :     OP_CHECK_NULL_WITH_CONTEXT(context, compileInfoPtr);
     111              :     fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo();
     112              :     OP_CHECK_NULL_WITH_CONTEXT(context, platformInfoPtr);
     113              :     auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr);
     114              :     compileInfoPtr->coreNum = ascendcPlatform.GetCoreNumAiv();
     115              :     ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize);
     116              :     return ge::GRAPH_SUCCESS;
     117              : }
     118              : 
     119              : IMPL_OP_OPTILING(ReluGrad).Tiling(TilingForReluGrad).TilingParse<BroadcastCompileInfo>(TilingPrepareForBroadcast);
     120              : REGISTER_OPS_TILING_TEMPLATE(ReluGrad, ReluGradTiling, RELU_GRAD_COMMON_TILING_PRIORITY);
     121              : } // namespace optiling
        

Generated by: LCOV version 2.0-1