• 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 #ifndef MINDSPORE_CORE_UTILS_TRACE_BASE_H_
17 #define MINDSPORE_CORE_UTILS_TRACE_BASE_H_
18 
19 #include <fstream>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include <utility>
24 #include <stack>
25 
26 #include "utils/info.h"
27 #include "ir/anf.h"
28 #include "ir/func_graph.h"
29 #include "utils/any.h"
30 
31 namespace mindspore {
32 namespace trace {
33 std::string GetDebugInfo(const DebugInfoPtr &info, SourceLineTip tip = kSourceLineTipNextLine);
34 std::string GetDebugInfo(const DebugInfoPtr &info, const std::string &prefix,
35                          SourceLineTip tip = kSourceLineTipNextLine);
36 // Generate the call stack of python source code to a string
37 std::string DumpSourceLines(const AnfNodePtr &node);
38 std::string DumpSourceLines(AnfNode *node);
39 // Generate the call stack of python source code to a vector
40 std::vector<std::string> GetSourceLineList(const AnfNodePtr &node);
41 // Get the locations of the call stack of python source code
42 std::vector<LocationPtr> GetSourceLocationList(const AnfNodePtr &node);
43 // Generate the call stack of python source code with relevant trace info
44 std::string GetDebugTraceInfo(const AnfNodePtr &node, bool is_debug = false);
45 }  // namespace trace
46 }  // namespace mindspore
47 
48 #endif  // MINDSPORE_CORE_UTILS_TRACE_BASE_H_
49