23 #ifndef TVM_IR_SOURCE_MAP_H_
24 #define TVM_IR_SOURCE_MAP_H_
59 static constexpr
const char*
_type_key =
"SourceName";
103 v->Visit(
"line", &
line);
104 v->Visit(
"column", &
column);
122 TVM_DLL
Span(
SourceName source_name,
int line,
int end_line,
int column,
int end_column);
141 v->Visit(
"spans", &
spans);
144 static constexpr
const char*
_type_key =
"SequentialSpan";
152 for (
size_t i = 0, e =
spans.size(); i != e; ++i) {
195 v->Visit(
"source", &
source);
237 explicit SourceMap(std::initializer_list<std::pair<SourceName, Source>> source_map)
245 ICHECK(
get() !=
nullptr);
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:137
Store a list of spans for an expr generated from mulitple source exprs.
Definition: source_map.h:133
void VisitAttrs(AttrVisitor *v)
Definition: source_map.h:139
bool SEqualReduce(const SequentialSpanNode *other, SEqualReducer equal) const
Definition: source_map.h:147
Array< Span > spans
The original source list of spans to construct a sequential span.
Definition: source_map.h:136
static constexpr const char * _type_key
Definition: source_map.h:144
TVM_DECLARE_FINAL_OBJECT_INFO(SequentialSpanNode, SpanNode)
Reference class of SequentialSpanNode.
Definition: source_map.h:165
SequentialSpan(Array< Span > spans)
TVM_DEFINE_OBJECT_REF_METHODS(SequentialSpan, Span, SequentialSpanNode)
SequentialSpan(std::initializer_list< Span > init)
Stores locations in frontend source that generated a node.
Definition: source_map.h:217
TVM_DECLARE_FINAL_OBJECT_INFO(SourceMapNode, Object)
bool SEqualReduce(const SourceMapNode *other, SEqualReducer equal) const
Definition: source_map.h:225
static constexpr const char * _type_key
Definition: source_map.h:229
Map< SourceName, Source > source_map
The source mapping.
Definition: source_map.h:220
void VisitAttrs(AttrVisitor *v)
Definition: source_map.h:223
Definition: source_map.h:233
void Add(const Source &source)
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(SourceMap, ObjectRef, SourceMapNode)
SourceMap()
Definition: source_map.h:240
SourceMap(Map< SourceName, Source > source_map)
SourceMapNode * operator->()
Definition: source_map.h:244
SourceMap(std::initializer_list< std::pair< SourceName, Source >> source_map)
Definition: source_map.h:237
The name of a source fragment.
Definition: source_map.h:46
static constexpr bool _type_has_method_sequal_reduce
Definition: source_map.h:53
static constexpr const char * _type_key
Definition: source_map.h:59
TVM_DECLARE_FINAL_OBJECT_INFO(SourceNameNode, Object)
void VisitAttrs(AttrVisitor *v)
Definition: source_map.h:51
String name
The source name.
Definition: source_map.h:49
bool SEqualReduce(const SourceNameNode *other, SEqualReducer equal) const
Definition: source_map.h:55
The source name of a file span.
Definition: source_map.h:67
static SourceName Get(const String &name)
Get an SourceName for a given operator name. Will raise an error if the source name has not been regi...
TVM_DEFINE_OBJECT_REF_METHODS(SourceName, ObjectRef, SourceNameNode)
Definition: source_map.h:181
std::vector< std::pair< int, int > > line_map
A mapping of line breaks into the raw source.
Definition: source_map.h:190
void VisitAttrs(AttrVisitor *v)
Definition: source_map.h:193
TVM_DECLARE_FINAL_OBJECT_INFO(SourceNode, Object)
String source
The raw source.
Definition: source_map.h:187
static constexpr const char * _type_key
Definition: source_map.h:198
SourceName source_name
The source name.
Definition: source_map.h:184
Definition: source_map.h:202
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(Source, ObjectRef, SourceNode)
Source(SourceName src_name, std::string source)
tvm::String GetLine(int line)
Stores locations in frontend source that generated a node.
Definition: source_map.h:87
static constexpr bool _type_has_method_sequal_reduce
Definition: source_map.h:108
TVM_DECLARE_BASE_OBJECT_INFO(SpanNode, Object)
static constexpr const char * _type_key
Definition: source_map.h:116
int column
The column offset.
Definition: source_map.h:94
int line
The line number.
Definition: source_map.h:92
int end_line
The end line number.
Definition: source_map.h:96
SourceName source_name
The source name.
Definition: source_map.h:90
void VisitAttrs(AttrVisitor *v)
Definition: source_map.h:101
int end_column
The end column number.
Definition: source_map.h:98
bool SEqualReduce(const SpanNode *other, SEqualReducer equal) const
Definition: source_map.h:110
Definition: source_map.h:120
TVM_DEFINE_OBJECT_REF_METHODS(Span, ObjectRef, SpanNode)
Span(SourceName source_name, int line, int end_line, int column, int end_column)
Span Merge(const Span &other) const
Merge two spans into one which captures the combined regions.
Content-aware structural equality comparator for objects.
Definition: structural_equal.h:114
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Base class of all object reference.
Definition: object.h:519
const Object * get() const
Definition: object.h:554
Object * get_mutable() const
Definition: object.h:607
base class of all object containers.
Definition: object.h:171
Reference to string objects.
Definition: string.h:98
tvm::SourceName SourceName
Definition: base.h:64
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Definitions and helper macros for IR/AST nodes.
A managed object in the TVM runtime.
Type-erased function used across TVM API.
This file defines the TVM global function registry.