• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 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 #ifndef MINDSPORE_PI_JIT_DEBUG_INFO__H_
17 #define MINDSPORE_PI_JIT_DEBUG_INFO__H_
18 
19 #include <memory>
20 #include <string>
21 
22 namespace mindspore {
23 namespace pijit {
24 namespace ir {
25 /// \brief DebugInfo is a container, which is used to store information such as line No. and file name etc.
26 class DebugInfo : public std::enable_shared_from_this<DebugInfo> {
27  public:
28   /**
29    * \brief The constructor of DebugInfo.
30    *
31    * \param[in] desc The description of the host node.
32    *
33    * \return The instance of DebugInfo.
34    */
DebugInfo(const std::string & desc)35   explicit DebugInfo(const std::string &desc) : DebugInfo(desc, "", 0) {}
36 
37   /**
38    * \brief The constructor of DebugInfo.
39    *
40    * \param[in] desc The description of the host node.
41    * \param[in] file_name The file name where the host is located.
42    * \param[in] line_no The line number of the host node.
43    *
44    * \return The instance of DebugInfo.
45    */
DebugInfo(const std::string & desc,const std::string & file_name,int line_no)46   DebugInfo(const std::string &desc, const std::string &file_name, int line_no)
47       : desc_(desc), file_name_(file_name), line_no_(line_no) {}
48 
49   /// \brief Destructor.
50   virtual ~DebugInfo() = default;
51 
52   /**
53    * \brief Get the description of the host node.
54    *
55    * \return The description of the host node.
56    */
GetDesc()57   const std::string &GetDesc() const { return desc_; }
58 
59   /**
60    * \brief Set the description of the host node..
61    */
SetDesc(const std::string & desc)62   void SetDesc(const std::string &desc) { desc_ = desc; }
63 
64   /**
65    * \brief Get the file name where the host is located.
66    *
67    * \return The file name where the host is located.
68    */
GetFileName()69   const std::string &GetFileName() const { return file_name_; }
70 
71   /**
72    * \brief Set the file name where the host is located.
73    *
74    * \param[in] file_name The file name where the host is located.
75    */
SetFileName(const std::string & file_name)76   void SetFileName(const std::string &file_name) { file_name_ = file_name; }
77 
78   /**
79    * \brief Get the line number of the host node.
80    *
81    * \return The line number of the host node.
82    */
GetLineNo()83   int GetLineNo() const { return line_no_; }
84 
85   /**
86    * \brief Set the line number of the host node.
87    *
88    * \param[in] line_no The line number of the host node.
89    */
SetLineNo(int line_no)90   void SetLineNo(int line_no) { line_no_ = line_no; }
91 
92  private:
93   /// \brief The description of the host node.
94   std::string desc_;
95   /// \brief The file name where the host is located.
96   std::string file_name_;
97   /// \brief The line number of the host node.
98   int line_no_;
99 };
100 
101 using DebugInfoPtr = std::shared_ptr<DebugInfo>;
102 }  // namespace ir
103 }  // namespace pijit
104 }  // namespace mindspore
105 
106 #endif  // MINDSPORE_PI_JIT_DEBUG_INFO__H_
107