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_SETTING_H
11 : #define DUMP_SETTING_H
12 :
13 : #include <string>
14 : #include "adump_pub.h"
15 : #include "path.h"
16 : #include "adump_dsmi.h"
17 : #include "adump_api.h"
18 :
19 : namespace Adx {
20 : constexpr uint32_t DUMP_MODE_INPUT = 1U << 0;
21 : constexpr uint32_t DUMP_MODE_OUTPUT = 1U << 1;
22 : constexpr uint32_t DUMP_MODE_WORKSPACE = 1U << 2;
23 : constexpr char DUMP_TENSOR_DATA[] = "tensor";
24 : constexpr char DUMP_STATS_DATA[] = "stats";
25 : constexpr uint64_t DUMP_SWITCH_MASK = 0x00000000FFFFFFFF;
26 : constexpr uint64_t DUMP_EXTERN_SWITCH_MASK = 0xFFFFFFFF00000000;
27 : constexpr uint64_t DUMP_SWITCH_L0_MACK = 1U << 2;
28 : constexpr uint64_t DUMP_SWITCH_L1_MACK = 1U << 3;
29 :
30 : class DumpSetting {
31 : public:
32 582 : DumpSetting() = default;
33 : int32_t Init(const DumpType type, const DumpConfig &dumpConfig);
34 : std::string GetDumpPath() const;
35 : const char* GetDumpCPath() const;
36 : uint32_t GetDumpMode() const;
37 : bool GetDumpStatus() const;
38 : bool GetDumpStatusEx() const;
39 : bool IsDumpDataStats() const;
40 : bool GetDumpDebugStatus() const;
41 : bool InitDumpStatus(const std::string &dumpStatus, bool &status) const;
42 : const std::string GetDumpData() const;
43 : uint64_t GetDumpSwitch() const;
44 : uint64_t GetDumpStatsItem() const;
45 : PlatformType GetPlatformType() const;
46 : void InitDumpSwitch(uint64_t dumpSwitch);
47 :
48 : private:
49 : int32_t DumpOperatorInit(const DumpConfig &dumpConfig);
50 : int32_t DumpOverflowInit(const DumpConfig &dumpConfig);
51 : bool InitDumpPath(const std::string &dumpPath);
52 : bool InitDumpMode(const std::string &dumpMode);
53 : void InitDumpData(const std::string &dumpData);
54 : bool InitDumpStatsItem(const std::vector<std::string> &dumpStatsItem);
55 :
56 : Path dumpPath_;
57 : uint32_t dumpMode_{ 0 };
58 : bool dumpStatus_{ false };
59 : bool dumpDebugStatus_{ false };
60 : std::string dumpData_{ DUMP_TENSOR_DATA };
61 : uint64_t dumpSwitch_{ 0 };
62 : uint64_t dumpStatsItem_{ 0 };
63 : uint32_t platformType_{ 0 };
64 : };
65 : } // namespace Adx
66 : #endif // DUMP_SETTING_H
|