• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PROFILING_REPORTER_PROFILING_DESC_H_
18 #define MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PROFILING_REPORTER_PROFILING_DESC_H_
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 namespace mindspore {
25 namespace device {
26 namespace ascend {
27 class ProfDesc {
28  public:
ProfDesc(std::string op_name)29   explicit ProfDesc(std::string op_name) : op_name_(std::move(op_name)) {}
30   virtual ~ProfDesc() = default;
31   virtual std::string ToString() = 0;
32 
33  protected:
34   std::string op_name_;
35 };
36 
37 class TaskDesc : public ProfDesc {
38  public:
TaskDesc(std::string op_name,uint32_t task_id,uint32_t block_dim,uint32_t stream_id)39   TaskDesc(std::string op_name, uint32_t task_id, uint32_t block_dim, uint32_t stream_id)
40       : ProfDesc(std::move(op_name)), task_id_(task_id), block_dim_(block_dim), stream_id_(stream_id) {}
41   ~TaskDesc() override = default;
42   std::string ToString() override;
43 
44  private:
45   uint32_t task_id_;
46   uint32_t block_dim_;
47   uint32_t stream_id_;
48 };
49 
50 struct DataElement {
51   size_t index_;
52   std::string data_format_;
53   int data_type_;
54   std::vector<size_t> data_shape_;
55 };
56 
57 class GraphDesc : public ProfDesc {
58  public:
GraphDesc(std::string op_name,std::string op_type,std::vector<DataElement> input_data_list,std::vector<DataElement> output_data_list)59   GraphDesc(std::string op_name, std::string op_type, std::vector<DataElement> input_data_list,
60             std::vector<DataElement> output_data_list)
61       : ProfDesc(std::move(op_name)),
62         op_type_(std::move(op_type)),
63         input_data_list_(std::move(input_data_list)),
64         output_data_list_(std::move(output_data_list)) {}
65   ~GraphDesc() override = default;
66   std::string ToString() override;
67 
68  private:
69   std::string op_type_;
70   std::vector<DataElement> input_data_list_;
71   std::vector<DataElement> output_data_list_;
72   [[nodiscard]] static std::string DataShapeToString(const std::vector<size_t> &shape);
73 };
74 
75 class PointDesc : public ProfDesc {
76  public:
PointDesc(std::string op_name,uint32_t point_id)77   PointDesc(std::string op_name, uint32_t point_id) : ProfDesc(std::move(op_name)), point_id_(point_id) {}
78   ~PointDesc() override = default;
79   std::string ToString() override;
80 
81  private:
82   uint32_t point_id_;
83 };
84 
85 class TaskStreamOpNameDesc : public ProfDesc {
86  public:
TaskStreamOpNameDesc(std::string op_name,std::vector<std::pair<uint32_t,uint32_t>> stream_id_task_id_pairs)87   TaskStreamOpNameDesc(std::string op_name, std::vector<std::pair<uint32_t, uint32_t>> stream_id_task_id_pairs)
88       : ProfDesc(std::move(op_name)), stream_id_task_id_pairs_(std::move(stream_id_task_id_pairs)) {}
89 
90   ~TaskStreamOpNameDesc() override = default;
91   std::string ToString() override;
92 
93  private:
94   std::vector<std::pair<uint32_t, uint32_t>> stream_id_task_id_pairs_;
95 };
96 }  // namespace ascend
97 }  // namespace device
98 }  // namespace mindspore
99 
100 #endif  // MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PROFILING_REPORTER_PROFILING_DESC_H_
101