LCOV - code coverage report
Current view: top level - adump/exception - dump_operator.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 72.2 % 18 13
Test Date: 2026-07-28 10:54:24 Functions: 80.0 % 5 4

            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 DUMP_OPERATOR_H
      11              : #define DUMP_OPERATOR_H
      12              : 
      13              : #include <string>
      14              : #include <vector>
      15              : #include <sstream>
      16              : #include "adump_pub.h"
      17              : #include "dump_tensor.h"
      18              : #include "kernel_info_collector.h"
      19              : 
      20              : namespace Adx {
      21              : struct DumpWorkspace {
      22              :     DumpWorkspace() = default;
      23            6 :     DumpWorkspace(const void *wsAddr, uint64_t wsBytes, uint32_t wsArgsOffset)
      24            6 :         : addr(wsAddr),
      25            6 :           bytes(wsBytes),
      26            6 :           argsOffset(wsArgsOffset)
      27              :     {
      28            6 :     }
      29              :     const void *addr;
      30              :     uint64_t bytes;
      31              :     uint32_t argsOffset;
      32              : };
      33              : 
      34              : struct OpIdentity {
      35          148 :     OpIdentity() = default;
      36            0 :     OpIdentity(uint32_t deviceid, uint32_t taskid, uint32_t streamid)
      37            0 :         : deviceId(deviceid),
      38            0 :           taskId(taskid),
      39            0 :           streamId(streamid)
      40              :     {
      41            0 :     }
      42           10 :     OpIdentity(uint32_t deviceid, uint32_t taskid, uint32_t streamid, uint32_t contextid)
      43           10 :         : deviceId(deviceid),
      44           10 :           taskId(taskid),
      45           10 :           streamId(streamid),
      46           10 :           contextId(contextid)
      47              :     {
      48           10 :     }
      49              : 
      50              :     bool operator==(const OpIdentity &rhs) const;
      51              :     std::string GetString() const;
      52              : 
      53              :     uint32_t deviceId = 0U;
      54              :     uint32_t taskId = 0U;
      55              :     uint32_t streamId = 0U;
      56              :     uint32_t contextId = UINT32_MAX;
      57              : };
      58              : 
      59              : class DumpOperator {
      60              : public:
      61            1 :     DumpOperator() = default;
      62              :     void Init(const OperatorInfoV2 &opInfo);
      63              :     bool IsBelongTo(const OpIdentity &identity) const;
      64              :     int32_t LogExceptionInfo(const rtExceptionArgsInfo &argsInfo);
      65              :     int32_t CopyOpKernelFile() const;
      66              :     int32_t RefreshAddrs(const rtExceptionArgsInfo &argsInfo);
      67              :     int32_t DumpException(const uint32_t deviceId, const std::string &dumpPath);
      68              :     explicit DumpOperator(const OperatorInfoV2 &opInfo);
      69              : 
      70              : private:
      71              :     int32_t DumpExceptionFile(const uint32_t deviceId, const std::string &dumpPath);
      72              :     void InitDeviceArgs();
      73              :     bool IsTvmOperator() const;
      74              :     std::string GetTensorString(const DumpTensor &tensor);
      75              :     int32_t LogExceptionArgs(const rtExceptionArgsInfo &argsInfo) const;
      76              :     std::string GetDumpFilePath(const std::string &dumpPath) const;
      77              :     void PrintAdditionInfo(const char *flag) const;
      78              :     void PrintLog(void *const *argsOnHost, size_t argNum, const std::string &tag) const;
      79              :     void RecordCurrentLog(std::ostringstream &oss);
      80              : 
      81              :     // basic info
      82              :     std::string opName_;
      83              :     std::string opType_;
      84              :     OpIdentity identity_;
      85              : 
      86              :     std::vector<DeviceInfo> deviceInfos_;
      87              :     // args
      88              :     std::vector<void *> hostArgs_;
      89              : 
      90              :     // addition info
      91              :     std::map<std::string, std::string> additions_;
      92              :     std::string isHostArgs_;
      93              : 
      94              :     std::vector<DumpTensor> inputTensors_;
      95              :     std::vector<DumpTensor> outputTensors_;
      96              :     std::vector<DumpWorkspace> workspaces_;
      97              :     // log record
      98              :     std::vector<std::string> logRecord_;
      99              : 
     100              :     KernelInfoCollector kernelCollector_;
     101              : };
     102              : }  // namespace Adx
     103              : #endif  // DUMP_OPERATOR_H
        

Generated by: LCOV version 2.0-1