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 DATADUMP_KFC_INTERFACE_H
11 : #define DATADUMP_KFC_INTERFACE_H
12 : #include <cstdint>
13 : #include <string>
14 : #include <vector>
15 :
16 : namespace KfcDump {
17 : constexpr uint32_t INVALID = 65535U;
18 : }
19 :
20 : struct KfcDumpTask {
21 1 : KfcDumpTask() : KfcDumpTask(KfcDump::INVALID, KfcDump::INVALID, KfcDump::INVALID){};
22 67 : KfcDumpTask(const uint32_t streamId, const uint32_t taskId, const uint32_t index)
23 67 : : streamId_(streamId), taskId_(taskId), index_(index){};
24 : uint32_t streamId_ = KfcDump::INVALID;
25 : uint32_t taskId_ = KfcDump::INVALID;
26 : uint32_t index_ = KfcDump::INVALID;
27 : friend bool operator<(const KfcDumpTask& item1, const KfcDumpTask& item2);
28 : };
29 :
30 118 : inline bool operator<(const KfcDumpTask& item1, const KfcDumpTask& item2)
31 : {
32 118 : if (item1.streamId_ != item2.streamId_) {
33 30 : return item1.streamId_ < item2.streamId_;
34 : }
35 88 : if (item1.taskId_ != item2.taskId_) {
36 17 : return item1.taskId_ < item2.taskId_;
37 : }
38 71 : return item1.index_ < item2.index_;
39 : }
40 : enum SpaceType {
41 : LOG = 0,
42 : };
43 :
44 : struct Workspace {
45 : SpaceType type;
46 : uint64_t data_addr;
47 : uint64_t size;
48 : };
49 :
50 : struct InputOutputKfcDumpInfo {
51 : int32_t index; // input or output index info of op
52 : int32_t data_type; // input or output type info of op
53 : int32_t format; // input or output format info of op
54 : uint64_t address; // input or output address info of op
55 : uint64_t size; // input or output size info of op
56 : std::vector<uint64_t> shape; // input or output shape info of op
57 : std::vector<uint64_t> origin_shape; // input or output origin_shape info of op
58 : void* reserve;
59 : };
60 :
61 : struct KfcDumpInfo {
62 : std::string opName;
63 : std::string opType;
64 : std::vector<Workspace> workspace;
65 : std::vector<struct InputOutputKfcDumpInfo> inputDumpInfo; // op input info
66 : std::vector<struct InputOutputKfcDumpInfo> outputDumpInfo; // op output info
67 : void* reserve;
68 : };
69 :
70 : #ifdef __cplusplus
71 : extern "C" {
72 : #endif // __cplusplus
73 :
74 : __attribute__((weak)) __attribute__((visibility("default"))) int32_t AicpuGetOpTaskInfo(
75 : const KfcDumpTask& taskKey, KfcDumpInfo** ptr);
76 :
77 : __attribute__((weak)) __attribute__((visibility("default"))) int32_t AicpuDumpOpTaskData(
78 : const KfcDumpTask& taskKey, void* dumpPtr, uint32_t length);
79 :
80 : #ifdef __cplusplus
81 : }
82 : #endif
83 : #endif // DATADUMP_KFC_INTERFACE_H
|