1#pragma once
2
3#include <c10/util/Optional.h>
4
5#include <string>
6#include <vector>
7
8namespace torch {
9namespace lazy {
10struct SourceLocation {
11 std::string file;
12 std::string function;
13 int line = -1;
14};
15
16TORCH_API void EmitShortFrameInfo(
17 std::ostream& stream,
18 const std::vector<SourceLocation>& frames);
19
20TORCH_API std::ostream& operator<<(
21 std::ostream& stream,
22 const std::vector<SourceLocation>& frames);
23
24// The base class for user defined metadata which is possible to attach to IR
25// nodes.
26struct TORCH_API UserMetaData {
27 virtual ~UserMetaData() = default;
28};
29
30struct TORCH_API MetaData {
31 std::string scope;
32 std::vector<SourceLocation> frame_info;
33};
34
35// TODO(whc) is this going to be used outside of in IR decompositions?
36// RAII data structure to be used a stack variable to enter a new IR scope. IR
37// scope names will appear in the IR and will help identifying the source of the
38// single IR nodes.
39struct TORCH_API ScopePusher {
40 explicit ScopePusher(const std::string& name);
41 ~ScopePusher();
42
43 static void ResetScopes();
44};
45
46TORCH_API MetaData GetMetaDataIfDebugging();
47
48} // namespace lazy
49} // namespace torch
50