LCOV - code coverage report
Current view: top level - aicpu_schedule/core/operator_kernel/control_flow - operator_kernel_stream_repeat.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 16 16
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 2 2

            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              : #include "operator_kernel_stream_repeat.h"
      12              : 
      13              : #include "aicpusd_status.h"
      14              : #include "aicpusd_model_execute.h"
      15              : 
      16              : namespace AicpuSchedule {
      17              : namespace {
      18              : const std::string KERNEL_STREAM_REPEAT = "streamRepeat";
      19              : } // namespace
      20              : 
      21            6 : int32_t OperatorKernelStreamRepeat::Compute(const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext)
      22              : {
      23            6 :     aicpusd_info(
      24              :         "Start repeat model stream. modelId=%u, streamId=%u, taskId=%u", taskContext.modelId, kernelTaskInfo.streamID,
      25              :         kernelTaskInfo.taskID);
      26              :     const StreamRepeatTaskParam* const repeatStreamInfo =
      27            6 :         PtrToPtr<void, StreamRepeatTaskParam>(ValueToPtr(kernelTaskInfo.paraBase));
      28            6 :     if (repeatStreamInfo == nullptr) {
      29            1 :         aicpusd_err(
      30              :             "Model repeat stream info is nullptr. modelId=%u, streamId=%u, taskId=%u", taskContext.modelId,
      31              :             kernelTaskInfo.streamID, kernelTaskInfo.taskID);
      32            1 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      33              :     }
      34              : 
      35            5 :     if ((repeatStreamInfo->modelId != taskContext.modelId) || (repeatStreamInfo->streamId != taskContext.streamId)) {
      36            1 :         aicpusd_warn(
      37              :             "Model repeat stream is diff with context. rptModelId=%u, modelId=%u, rptStreamId=%u, streamId=%u",
      38              :             repeatStreamInfo->modelId, taskContext.modelId, repeatStreamInfo->streamId, taskContext.streamId);
      39            1 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      40              :     }
      41              : 
      42            4 :     const AicpuModel* model = AicpuModelManager::GetInstance().GetModel(taskContext.modelId);
      43            4 :     if ((model != nullptr) && (model->GetModelRetCode() != 0) && (model->AbnormalNeedBreak())) {
      44            2 :         aicpusd_err("Model stream repeat failed, model execute failed. modelId=%d.", taskContext.modelId);
      45            2 :         return AICPU_SCHEDULE_ERROR_TASK_EXECUTE_FAILED;
      46              :     }
      47            2 :     *(const_cast<int32_t*>(&taskContext.gotoTaskIndex)) = 0;
      48            2 :     return AICPU_SCHEDULE_OK;
      49              : }
      50              : 
      51            6 : REGISTER_OPERATOR_KERNEL(KERNEL_STREAM_REPEAT, OperatorKernelStreamRepeat);
      52              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1