LCOV - code coverage report
Current view: top level - aicpu_schedule/statistic - aicpusd_model_statistic.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 1 1

            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              : #ifndef STATISTIC_AICPUSD_MODEL_STATISTIC_H
      11              : #define STATISTIC_AICPUSD_MODEL_STATISTIC_H
      12              : #include <map>
      13              : #include <vector>
      14              : #include <chrono>
      15              : #include "aicpusd_status.h"
      16              : #include "aicpusd_common.h"
      17              : #include "aicpu_context.h"
      18              : #include "aicpusd_util.h"
      19              : namespace AicpuSchedule {
      20              : 
      21              : struct ParamStatInfo {
      22              :     uint64_t curSize;
      23              :     uint64_t curShape;
      24              :     ParamStatInfo() : curSize(0UL), curShape(0UL) {}
      25              : };
      26              : struct InAndOutParamStatInfo {
      27              :     uint64_t minSize;
      28              :     uint64_t maxSize;
      29              :     std::vector<int64_t> minShape;
      30              :     std::vector<int64_t> maxShape;
      31            7 :     InAndOutParamStatInfo() : minSize(0UL), maxSize(0UL) {}
      32              : };
      33              : struct ModelStatInfo {
      34              :     bool useFlag;
      35              :     uint64_t minExecTime;
      36              :     uint64_t maxExecTime;
      37              :     uint64_t subMaxExecTime;
      38              :     uint64_t totalTime;
      39              :     uint64_t totalCnt;
      40              :     std::vector<InAndOutParamStatInfo> inputStatVec;
      41              :     std::vector<InAndOutParamStatInfo> outputStatVec;
      42              :     std::chrono::steady_clock::time_point modelStartTime;
      43              : };
      44              : class AicpuSdModelStatistic {
      45              : public:
      46              :     static AicpuSdModelStatistic& GetInstance();
      47              :     void StatNNModelExecTime(const uint32_t modelId);
      48              :     void StatNNModelInput(
      49              :         const uint32_t modelId, const std::vector<uint64_t>& totalSizeList,
      50              :         std::vector<ModelConfigTensorDesc>& curStatVec);
      51              :     void InitModelStatInfo();
      52              :     void MarNNModelStartTime(const uint32_t modelId);
      53              :     void PrintOutModelStatInfo();
      54              :     void StatNNModelOutput(const uint32_t modelId, const RuntimeTensorDesc* const tensorDesc, const int32_t nextIndex);
      55              : 
      56              : private:
      57              :     void DumpOutModelMetrics(const uint32_t modelId);
      58              :     void AddNewDataToStatVec(
      59              :         std::vector<InAndOutParamStatInfo>& delVec, const uint64_t totalSize, const int64_t* shapes) const;
      60              :     void UpdateStatVecInfo(InAndOutParamStatInfo& dstStat, const uint64_t totalSize, const int64_t* shapes) const;
      61              :     std::string FormatShapeToString(const std::vector<int64_t>& shape) const;
      62              :     std::string GetRangeString(
      63              :         const std::vector<InAndOutParamStatInfo>& statInfos, size_t startIdx, size_t endIdx) const;
      64              :     AicpuSdModelStatistic();
      65              :     virtual ~AicpuSdModelStatistic();
      66              :     ModelStatInfo modelStatArray_[MAX_MODEL_COUNT];
      67              : };
      68              : } // namespace AicpuSchedule
      69              : #endif
        

Generated by: LCOV version 2.0-1