tvm
doc.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 #ifndef TVM_SCRIPT_PRINTER_DOC_H_
20 #define TVM_SCRIPT_PRINTER_DOC_H_
21 
22 #include <tvm/ir/expr.h>
23 #include <tvm/node/node.h>
24 #include <tvm/runtime/data_type.h>
26 
27 namespace tvm {
28 namespace script {
29 namespace printer {
30 
42 class DocNode : public Object {
43  public:
52 
53  void VisitAttrs(AttrVisitor* v) { v->Visit("source_paths", &source_paths); }
54 
55  static constexpr const char* _type_key = "script.printer.Doc";
57 
58  public:
59  virtual ~DocNode() = default;
60 };
61 
67 class Doc : public ObjectRef {
68  protected:
69  Doc() = default;
70 
71  public:
72  virtual ~Doc() = default;
74 };
75 
76 class ExprDoc;
77 
83 class ExprDocNode : public DocNode {
84  public:
89  ExprDoc Attr(String attr) const;
90 
98  ExprDoc Attr(TracedObject<String> attr) const;
99 
104  ExprDoc operator[](Array<Doc> indices) const;
105 
110  ExprDoc Call(Array<ExprDoc, void> args) const;
111 
118  ExprDoc Call(Array<ExprDoc, void> args, //
119  Array<String> kwargs_keys, //
120  Array<ExprDoc, void> kwargs_values) const;
121 
123 
124  static constexpr const char* _type_key = "script.printer.ExprDoc";
126 };
127 
133 class ExprDoc : public Doc {
134  protected:
135  ExprDoc() = default;
136 
137  public:
142  ExprDoc operator[](Array<Doc> indices) const;
143 
145 };
146 
152 class StmtDocNode : public DocNode {
153  public:
162  mutable Optional<String> comment{NullOpt};
163 
166  v->Visit("comment", &comment);
167  }
168 
169  static constexpr const char* _type_key = "script.printer.StmtDoc";
171 };
172 
178 class StmtDoc : public Doc {
179  protected:
180  StmtDoc() = default;
181 
182  public:
184 };
185 
192 class StmtBlockDocNode : public DocNode {
193  public:
196 
199  v->Visit("stmts", &stmts);
200  }
201 
202  static constexpr const char* _type_key = "script.printer.StmtBlockDoc";
204 };
205 
210 class StmtBlockDoc : public Doc {
211  public:
216  explicit StmtBlockDoc(Array<StmtDoc> stmts);
218 };
219 
225 class LiteralDocNode : public ExprDocNode {
226  public:
237 
240  v->Visit("value", &value);
241  }
242 
243  static constexpr const char* _type_key = "script.printer.LiteralDoc";
245 };
246 
252 class LiteralDoc : public ExprDoc {
253  protected:
254  explicit LiteralDoc(ObjectRef value);
255  LiteralDoc(ObjectRef value, ObjectPath object_path);
256 
257  public:
261  static LiteralDoc None() { return LiteralDoc(ObjectRef(nullptr)); }
262 
267  static LiteralDoc None(ObjectPath object_path) {
268  return LiteralDoc(ObjectRef(nullptr), object_path);
269  }
270 
275  static LiteralDoc Int(int v) { return LiteralDoc(IntImm(DataType::Int(64), v)); }
276 
283  static LiteralDoc Int(const TracedObject<IntImm>& v) { return LiteralDoc(v.Get(), v.GetPath()); }
284 
292  return LiteralDoc(IntImm(DataType::Int(64), v.Get()), v.GetPath());
293  }
298  static LiteralDoc Boolean(bool v) { return LiteralDoc(IntImm(DataType::Bool(), v)); }
299 
307  return LiteralDoc(IntImm(DataType::Bool(), v.Get()), v.GetPath());
308  }
309 
314  static LiteralDoc Float(double v) { return LiteralDoc(FloatImm(DataType::Float(64), v)); }
315 
323  return LiteralDoc(v.Get(), v.GetPath());
324  }
325 
330  static LiteralDoc Str(const String& v) { return LiteralDoc(v); }
331 
338  static LiteralDoc Str(const TracedObject<String>& v) { return LiteralDoc(v.Get(), v.GetPath()); }
339 
341 };
342 
348 class IdDocNode : public ExprDocNode {
349  public:
352 
355  v->Visit("name", &name);
356  }
357 
358  static constexpr const char* _type_key = "script.printer.IdDoc";
360 };
361 
367 class IdDoc : public ExprDoc {
368  public:
373  explicit IdDoc(String name);
374  explicit IdDoc(std::nullptr_t) : ExprDoc(nullptr) {}
376 };
377 
384  public:
386  ExprDoc value{nullptr};
389 
392  v->Visit("value", &value);
393  v->Visit("name", &name);
394  }
395 
396  static constexpr const char* _type_key = "script.printer.AttrAccessDoc";
398 };
399 
405 class AttrAccessDoc : public ExprDoc {
406  public:
412  explicit AttrAccessDoc(ExprDoc value, String name);
414 };
415 
421 class IndexDocNode : public ExprDocNode {
422  public:
424  ExprDoc value{nullptr};
432  Array<Doc> indices; // Each element is union of: Slice / ExprDoc
433 
436  v->Visit("value", &value);
437  v->Visit("indices", &indices);
438  }
439 
440  static constexpr const char* _type_key = "script.printer.IndexDoc";
442 };
443 
449 class IndexDoc : public ExprDoc {
450  public:
456  explicit IndexDoc(ExprDoc value, Array<Doc> indices);
458 };
459 
465 class CallDocNode : public ExprDocNode {
466  public:
468  ExprDoc callee{nullptr};
480 
483  v->Visit("callee", &callee);
484  v->Visit("args", &args);
485  v->Visit("kwargs_keys", &kwargs_keys);
486  v->Visit("kwargs_values", &kwargs_values);
487  }
488 
489  static constexpr const char* _type_key = "script.printer.CallDoc";
491 };
492 
498 class CallDoc : public ExprDoc {
499  public:
507  CallDoc(ExprDoc callee, Array<ExprDoc> args, Array<String> kwargs_keys,
508  Array<ExprDoc> kwargs_values);
510 };
511 
521  public:
522  enum class Kind : int32_t {
523  // Unary operators
524  kUnaryStart = 0,
525  kUSub = 1, // -x
526  kInvert = 2, // ~x
527  kNot = 3, // not x
528  kUnaryEnd = 4,
529 
530  // Binary operators
531  kBinaryStart = 5,
532  kAdd = 6, // +
533  kSub = 7, // -
534  kMult = 8, // *
535  kDiv = 9, // /
536  kFloorDiv = 10, // // in Python
537  kMod = 11, // % in Python
538  kPow = 12, // ** in Python
539  kLShift = 13, // <<
540  kRShift = 14, // >>
541  kBitAnd = 15, // &
542  kBitOr = 16, // |
543  kBitXor = 17, // ^
544  kLt = 18, // <
545  kLtE = 19, // <=
546  kEq = 20, // ==
547  kNotEq = 21, // !=
548  kGt = 22, // >
549  kGtE = 23, // >=
550  kAnd = 24, // and
551  kOr = 25, // or
552  kBinaryEnd = 26,
553 
554  // Special
555  kSpecialStart = 27,
556  kIfThenElse = 28, // <operands[1]> if <operands[0]> else <operands[2]>
557  kSpecialEnd = 29
558  };
559 
564 
567  v->Visit("kind", &kind);
568  v->Visit("operands", &operands);
569  }
570 
571  static constexpr const char* _type_key = "script.printer.OperationDoc";
573 };
574 
580 class OperationDoc : public ExprDoc {
581  public:
587  explicit OperationDoc(OperationDocNode::Kind kind, Array<ExprDoc> operands);
589 };
590 
599 class LambdaDocNode : public ExprDocNode {
600  public:
604  ExprDoc body{nullptr};
605 
608  v->Visit("args", &args);
609  v->Visit("body", &body);
610  }
611 
612  static constexpr const char* _type_key = "script.printer.LambdaDoc";
614 };
615 
621 class LambdaDoc : public ExprDoc {
622  public:
628  explicit LambdaDoc(Array<IdDoc> args, ExprDoc body);
630 };
631 
637 class TupleDocNode : public ExprDocNode {
638  public:
641 
644  v->Visit("elements", &elements);
645  }
646 
647  static constexpr const char* _type_key = "script.printer.TupleDoc";
649 };
650 
656 class TupleDoc : public ExprDoc {
657  public:
666  explicit TupleDoc(Array<ExprDoc> elements);
668 };
669 
675 class ListDocNode : public ExprDocNode {
676  public:
679 
682  v->Visit("elements", &elements);
683  }
684 
685  static constexpr const char* _type_key = "script.printer.ListDoc";
687 };
688 
694 class ListDoc : public ExprDoc {
695  public:
704  explicit ListDoc(Array<ExprDoc> elements);
706 };
707 
713 class DictDocNode : public ExprDocNode {
714  public:
724 
727  v->Visit("keys", &keys);
728  v->Visit("values", &values);
729  }
730 
731  static constexpr const char* _type_key = "script.printer.DictDoc";
733 };
734 
740 class DictDoc : public ExprDoc {
741  public:
751  explicit DictDoc(Array<ExprDoc> keys, Array<ExprDoc> values);
753 };
754 
762 class SliceDocNode : public DocNode {
763  public:
770 
773  v->Visit("start", &start);
774  v->Visit("stop", &stop);
775  v->Visit("step", &step);
776  }
777 
778  static constexpr const char* _type_key = "script.printer.SliceDoc";
780 };
781 
787 class SliceDoc : public Doc {
788  public:
797 };
798 
804 class AssignDocNode : public StmtDocNode {
805  public:
807  ExprDoc lhs{nullptr};
816 
819  v->Visit("lhs", &lhs);
820  v->Visit("rhs", &rhs);
821  v->Visit("annotation", &annotation);
822  }
823 
824  static constexpr const char* _type_key = "script.printer.AssignDoc";
826 };
827 
833 class AssignDoc : public StmtDoc {
834  public:
841  explicit AssignDoc(ExprDoc lhs, Optional<ExprDoc> rhs, Optional<ExprDoc> annotation);
843 };
844 
850 class IfDocNode : public StmtDocNode {
851  public:
853  ExprDoc predicate{nullptr};
858 
861  v->Visit("predicate", &predicate);
862  v->Visit("then_branch", &then_branch);
863  v->Visit("else_branch", &else_branch);
864  }
865 
866  static constexpr const char* _type_key = "script.printer.IfDoc";
868 };
869 
875 class IfDoc : public StmtDoc {
876  public:
883  explicit IfDoc(ExprDoc predicate, Array<StmtDoc> then_branch, Array<StmtDoc> else_branch);
885 };
886 
892 class WhileDocNode : public StmtDocNode {
893  public:
895  ExprDoc predicate{nullptr};
898 
901  v->Visit("predicate", &predicate);
902  v->Visit("body", &body);
903  }
904 
905  static constexpr const char* _type_key = "script.printer.WhileDoc";
907 };
908 
914 class WhileDoc : public StmtDoc {
915  public:
921  explicit WhileDoc(ExprDoc predicate, Array<StmtDoc> body);
923 };
924 
934 class ForDocNode : public StmtDocNode {
935  public:
937  ExprDoc lhs{nullptr};
939  ExprDoc rhs{nullptr};
942 
945  v->Visit("lhs", &lhs);
946  v->Visit("rhs", &rhs);
947  v->Visit("body", &body);
948  }
949 
950  static constexpr const char* _type_key = "script.printer.ForDoc";
952 };
953 
959 class ForDoc : public StmtDoc {
960  public:
967  explicit ForDoc(ExprDoc lhs, ExprDoc rhs, Array<StmtDoc> body);
969 };
970 
981 class ScopeDocNode : public StmtDocNode {
982  public:
986  ExprDoc rhs{nullptr};
989 
992  v->Visit("lhs", &lhs);
993  v->Visit("rhs", &rhs);
994  v->Visit("body", &body);
995  }
996 
997  static constexpr const char* _type_key = "script.printer.ScopeDoc";
999 };
1000 
1006 class ScopeDoc : public StmtDoc {
1007  public:
1014  explicit ScopeDoc(Optional<ExprDoc> lhs, ExprDoc rhs, Array<StmtDoc> body);
1015 
1021  explicit ScopeDoc(ExprDoc rhs, Array<StmtDoc> body);
1022 
1024 };
1025 
1032  public:
1034  ExprDoc expr{nullptr};
1035 
1038  v->Visit("expr", &expr);
1039  }
1040 
1041  static constexpr const char* _type_key = "script.printer.ExprStmtDoc";
1043 };
1044 
1050 class ExprStmtDoc : public StmtDoc {
1051  public:
1056  explicit ExprStmtDoc(ExprDoc expr);
1058 };
1059 
1065 class AssertDocNode : public StmtDocNode {
1066  public:
1068  ExprDoc test{nullptr};
1071 
1074  v->Visit("test", &test);
1075  v->Visit("msg", &msg);
1076  }
1077 
1078  static constexpr const char* _type_key = "script.printer.AssertDoc";
1080 };
1081 
1087 class AssertDoc : public StmtDoc {
1088  public:
1094  explicit AssertDoc(ExprDoc test, Optional<ExprDoc> msg = NullOpt);
1096 };
1097 
1103 class ReturnDocNode : public StmtDocNode {
1104  public:
1106  ExprDoc value{nullptr};
1107 
1110  v->Visit("value", &value);
1111  }
1112 
1113  static constexpr const char* _type_key = "script.printer.ReturnDoc";
1115 };
1116 
1122 class ReturnDoc : public StmtDoc {
1123  public:
1128  explicit ReturnDoc(ExprDoc value);
1130 };
1131 
1138  public:
1140  IdDoc name{nullptr};
1155 
1158  v->Visit("name", &name);
1159  v->Visit("args", &args);
1160  v->Visit("decorators", &decorators);
1161  v->Visit("return_type", &return_type);
1162  v->Visit("body", &body);
1163  }
1164 
1165  static constexpr const char* _type_key = "script.printer.FunctionDoc";
1167 };
1168 
1174 class FunctionDoc : public StmtDoc {
1175  public:
1184  explicit FunctionDoc(IdDoc name, Array<AssignDoc> args, Array<ExprDoc> decorators,
1185  Optional<ExprDoc> return_type, Array<StmtDoc> body);
1187 };
1188 
1194 class ClassDocNode : public StmtDocNode {
1195  public:
1197  IdDoc name{nullptr};
1202 
1205  v->Visit("name", &name);
1206  v->Visit("decorators", &decorators);
1207  v->Visit("body", &body);
1208  }
1209 
1210  static constexpr const char* _type_key = "script.printer.ClassDoc";
1212 };
1213 
1219 class ClassDoc : public StmtDoc {
1220  public:
1227  explicit ClassDoc(IdDoc name, Array<ExprDoc> decorators, Array<StmtDoc> body);
1229 };
1230 
1231 } // namespace printer
1232 } // namespace script
1233 } // namespace tvm
1234 
1235 #endif // TVM_SCRIPT_PRINTER_DOC_H_
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:1108
Array< IdDoc > args
The arguments of this anonymous function.
Definition: doc.h:602
IdDoc(std::nullptr_t)
Definition: doc.h:374
Array< AssignDoc > args
The arguments of function.
Definition: doc.h:1148
static LiteralDoc Int(const TracedBasicValue< int > &v)
Create a LiteralDoc to represent integer.
Definition: doc.h:291
Reference type of IfDocNode.
Definition: doc.h:875
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:164
Array< StmtDoc > body
The body of class.
Definition: doc.h:1201
Traced wrapper for regular (non-container) TVM objects.
Definition: traced_object.h:39
Doc that represents dictionary literal.
Definition: doc.h:713
Optional< ExprDoc > step
The step of slice.
Definition: doc.h:769
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:1203
Array< ExprDoc > elements
Elements of tuple.
Definition: doc.h:640
Doc that represents assign statement.
Definition: doc.h:804
Reference type of IdDocNode.
Definition: doc.h:367
Definitions and helper macros for IR/AST nodes.
The container doc that holds a list of StmtDoc.
Definition: doc.h:192
Reference type of StmtDocNode.
Definition: doc.h:178
const T & Get() const
Access the wrapped value.
Definition: traced_object.h:442
Array< ExprDoc > elements
Elements of list.
Definition: doc.h:678
Array< ExprDoc > operands
Operands of this expression.
Definition: doc.h:563
static LiteralDoc Boolean(const TracedBasicValue< bool > &v)
Create a LiteralDoc to represent boolean.
Definition: doc.h:306
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:238
Array< ExprDoc > decorators
Decorators of function.
Definition: doc.h:1150
Base expr nodes in TVM.
static constexpr const char * _type_key
Definition: doc.h:55
virtual ~DocNode()=default
ObjectPtr< ArrayNode > make_object()
Definition: array.h:844
Array< StmtDoc > body
The body of function.
Definition: doc.h:1154
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Doc that represents literal value.
Definition: doc.h:225
Reference type of ForDocNode.
Definition: doc.h:959
Reference type of DocNode.
Definition: doc.h:67
ObjectRef value
the internal representation of the literal value.
Definition: doc.h:236
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:680
The base class of expression doc.
Definition: doc.h:83
Doc that represents for statement.
Definition: doc.h:934
The base class of statement doc.
Definition: doc.h:152
Reference type of WhileDocNode.
Definition: doc.h:914
Doc that represents an expression as statement.
Definition: doc.h:1031
Doc that represents special scopes.
Definition: doc.h:981
Reference type of ScopeDocNode.
Definition: doc.h:1006
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:817
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:353
Reference type of AttrAccessDocNode.
Definition: doc.h:405
Reference type of ClassDocNode.
Definition: doc.h:1219
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:565
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:1036
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:725
const RefT & Get() const
Access the wrapped object.
Definition: traced_object.h:115
Optional< ExprDoc > rhs
The right hand side of the assignment.
Definition: doc.h:813
base class of all object containers.
Definition: object.h:167
Reference type of OperationDocNode.
Definition: doc.h:580
Array< StmtDoc > body
The body of the scope doc.
Definition: doc.h:988
static LiteralDoc Float(double v)
Create a LiteralDoc to represent float.
Definition: doc.h:314
String name
The attribute to be accessed.
Definition: doc.h:388
Array< Doc > indices
The indices to access.
Definition: doc.h:432
static LiteralDoc None()
Create a LiteralDoc to represent None/null/empty value.
Definition: doc.h:261
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:390
Managed reference class to FloatImmNode.
Definition: expr.h:564
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:122
Doc that represents function definition.
Definition: doc.h:1137
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
AttrFrame Attr(ObjectRef node, String attr_key, PrimExpr value)
Create an attribute.
Reference type of LiteralDocNode.
Definition: doc.h:252
Array< StmtDoc > else_branch
The else branch of the if-then-else statement.
Definition: doc.h:857
Array< ExprDoc > kwargs_values
The values of keyword arguments.
Definition: doc.h:479
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:53
The base class of all Doc.
Definition: doc.h:42
Floor division.
Definition: analyzer.h:59
Doc that represents assert statement.
Definition: doc.h:1065
Reference type of DictDocNode.
Definition: doc.h:740
static LiteralDoc Str(const String &v)
Create a LiteralDoc to represent string.
Definition: doc.h:330
Doc that represents operation.
Definition: doc.h:520
static DataType Float(int bits, int lanes=1)
Construct an float type.
Definition: data_type.h:168
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:990
Managed reference class to IntImmNode.
Definition: expr.h:518
Reference type of CallDocNode.
Definition: doc.h:498
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:606
static LiteralDoc None(ObjectPath object_path)
Create a LiteralDoc to represent None/null/empty value.
Definition: doc.h:267
Optional< ExprDoc > start
The start of slice.
Definition: doc.h:765
Reference to string objects.
Definition: string.h:97
Array< ObjectPath > source_paths
The list of object paths of the source IR node.
Definition: doc.h:51
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:1156
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:899
TVM_DECLARE_BASE_OBJECT_INFO(DocNode, Object)
const ObjectPath & GetPath() const
Get the path of the wrapped object.
Definition: traced_object.h:157
DictDoc()
Create an empty dictionary.
Definition: doc.h:745
Array< ExprDoc > args
The positional arguments.
Definition: doc.h:470
Doc that represents anonymous function.
Definition: doc.h:599
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:481
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:771
Doc that represent if-then-else statement.
Definition: doc.h:850
Array< StmtDoc > body
The body of the while statement.
Definition: doc.h:897
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:1072
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:859
Reference type of IndexDocNode.
Definition: doc.h:449
Reference type of ExprStmtDocNode.
Definition: doc.h:1050
Kind kind
The kind of operation (operator)
Definition: doc.h:561
Reference type of SliceDocNode.
Definition: doc.h:787
Base class of all object reference.
Definition: object.h:511
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:197
Reference type of ListDocNode.
Definition: doc.h:694
Doc that represents function call.
Definition: doc.h:465
Reference type of AssertDocNode.
Definition: doc.h:1087
static LiteralDoc Int(int v)
Create a LiteralDoc to represent integer.
Definition: doc.h:275
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
String name
The name of the identifier.
Definition: doc.h:351
Doc that represents identifier.
Definition: doc.h:348
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:642
static DataType Bool(int lanes=1)
Construct a bool type.
Definition: data_type.h:181
Definition: object_path.h:122
ListDoc()
Create an empty ListDoc.
Definition: doc.h:699
static LiteralDoc Boolean(bool v)
Create a LiteralDoc to represent boolean.
Definition: doc.h:298
static LiteralDoc Int(const TracedObject< IntImm > &v)
Create a LiteralDoc to represent integer.
Definition: doc.h:283
Array< StmtDoc > stmts
The list of statements.
Definition: doc.h:195
static LiteralDoc Str(const TracedObject< String > &v)
Create a LiteralDoc to represent string.
Definition: doc.h:338
const ObjectPath & GetPath() const
Get the path of the wrapped value.
Definition: traced_object.h:447
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Doc that represents class definition.
Definition: doc.h:1194
Reference type of ReturnDocNode.
Definition: doc.h:1122
Doc that represents index access on another expression.
Definition: doc.h:421
Array< ExprDoc > keys
keys of dictionary
Definition: doc.h:716
Reference type of ExprDocNode.
Definition: doc.h:133
Array< ExprDoc > values
Values of dictionary.
Definition: doc.h:723
Reference type of StmtBlockDocNode.
Definition: doc.h:210
Array< StmtDoc > then_branch
The then branch of the if-then-else statement.
Definition: doc.h:855
Array< StmtDoc > body
The body of the for statement.
Definition: doc.h:941
Traced wrapper for basic values (i.e. non-TVM objects)
Definition: traced_object.h:47
Doc that represents while statement.
Definition: doc.h:892
Array< String > kwargs_keys
The keys of keyword arguments.
Definition: doc.h:472
constexpr runtime::NullOptType NullOpt
Definition: optional.h:160
Doc that represents return statement.
Definition: doc.h:1103
Reference type of FunctionDocNode.
Definition: doc.h:1174
Array< ExprDoc > decorators
Decorators of class.
Definition: doc.h:1199
TupleDoc()
Create an empty TupleDoc.
Definition: doc.h:661
Optional< ExprDoc > annotation
The type annotation of this assignment.
Definition: doc.h:815
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:434
#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:728
Doc that represents slice in Index expression.
Definition: doc.h:762
Reference type of AssignDocNode.
Definition: doc.h:833
Reference type of LambdaDocNode.
Definition: doc.h:621
static LiteralDoc Float(const TracedObject< FloatImm > &v)
Create a LiteralDoc to represent float.
Definition: doc.h:322
Doc that represents list literal.
Definition: doc.h:675
void VisitAttrs(AttrVisitor *v)
Definition: doc.h:943
Doc that represents attribute access on another expression.
Definition: doc.h:383
Doc that represents tuple literal.
Definition: doc.h:637
static DataType Int(int bits, int lanes=1)
Construct an int type.
Definition: data_type.h:154
Reference type of TupleDocNode.
Definition: doc.h:656
Optional< ExprDoc > stop
The exclusive end of slice.
Definition: doc.h:767