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/ffi/dtype.h>
23 #include <tvm/ffi/reflection/access_path.h>
24 #include <tvm/ffi/reflection/registry.h>
25 #include <tvm/ir/expr.h>
26 #include <tvm/ir/type.h>
27 #include <tvm/runtime/device_api.h>
29 
30 #include <string>
31 
32 namespace tvm {
33 namespace script {
34 namespace printer {
35 
37 
38 // Forward declaration
39 class Doc;
40 
46 ffi::String DocToPythonScript(Doc doc, const PrinterConfig& cfg);
47 
59 class DocNode : public ffi::Object {
60  public:
68  mutable ffi::Array<AccessPath> source_paths;
69 
70  static void RegisterReflection() {
71  namespace refl = tvm::ffi::reflection;
72  refl::ObjectDef<DocNode>().def_rw("source_paths", &DocNode::source_paths);
73  }
74 
75  static constexpr bool _type_mutable = true;
76 
77  TVM_FFI_DECLARE_OBJECT_INFO("script.printer.Doc", DocNode, ffi::Object);
78 
79  public:
80  virtual ~DocNode() = default;
81 };
82 
88 class Doc : public ffi::ObjectRef {
89  protected:
90  Doc() = default;
91  explicit Doc(ffi::ObjectPtr<DocNode> data) : ffi::ObjectRef(data) {}
92 
93  public:
95 };
96 
97 class ExprDoc;
98 
104 class ExprDocNode : public DocNode {
105  public:
110  ExprDoc Attr(ffi::String attr) const;
111 
116  ExprDoc operator[](ffi::Array<Doc> indices) const;
117 
122  ExprDoc Call(ffi::Array<ExprDoc, void> args) const;
123 
130  ExprDoc Call(ffi::Array<ExprDoc, void> args, //
131  ffi::Array<ffi::String> kwargs_keys, //
132  ffi::Array<ExprDoc, void> kwargs_values) const;
133 
134  static void RegisterReflection() {
135  namespace refl = tvm::ffi::reflection;
136  refl::ObjectDef<ExprDocNode>();
137  }
138  TVM_FFI_DECLARE_OBJECT_INFO("script.printer.ExprDoc", ExprDocNode, DocNode);
139 };
140 
146 class ExprDoc : public Doc {
147  protected:
148  ExprDoc() = default;
149 
150  public:
155  ExprDoc operator[](ffi::Array<Doc> indices) const;
156 
157  explicit ExprDoc(ffi::ObjectPtr<ExprDocNode> data) : Doc(data) {
158  TVM_FFI_ICHECK(data != nullptr);
159  }
160 
162 };
163 
169 class StmtDocNode : public DocNode {
170  public:
179  mutable ffi::Optional<ffi::String> comment{std::nullopt};
180 
181  static void RegisterReflection() {
182  namespace refl = tvm::ffi::reflection;
183  refl::ObjectDef<StmtDocNode>().def_rw("comment", &StmtDocNode::comment);
184  }
185  TVM_FFI_DECLARE_OBJECT_INFO("script.printer.StmtDoc", StmtDocNode, DocNode);
186 };
187 
193 class StmtDoc : public Doc {
194  protected:
195  StmtDoc() = default;
196 
197  public:
199 };
200 
207 class StmtBlockDocNode : public DocNode {
208  public:
210  ffi::Array<StmtDoc> stmts;
211 
212  static void RegisterReflection() {
213  namespace refl = tvm::ffi::reflection;
214  refl::ObjectDef<StmtBlockDocNode>().def_ro("stmts", &StmtBlockDocNode::stmts);
215  }
217 };
218 
223 class StmtBlockDoc : public Doc {
224  public:
229  explicit StmtBlockDoc(ffi::Array<StmtDoc> stmts);
231 };
232 
238 class LiteralDocNode : public ExprDocNode {
239  public:
249  ffi::Any value;
250 
251  static void RegisterReflection() {
252  namespace refl = tvm::ffi::reflection;
253  refl::ObjectDef<LiteralDocNode>().def_ro("value", &LiteralDocNode::value);
254  }
256 };
257 
263 class LiteralDoc : public ExprDoc {
264  protected:
265  explicit LiteralDoc(ffi::Any value, const ffi::Optional<AccessPath>& object_path);
266 
267  public:
272  static LiteralDoc None(const ffi::Optional<AccessPath>& p) {
273  return LiteralDoc(ffi::Any(nullptr), p);
274  }
280  static LiteralDoc Int(int64_t v, const ffi::Optional<AccessPath>& p) {
281  return LiteralDoc(IntImm::Int64(v), p);
282  }
288  static LiteralDoc Boolean(bool v, const ffi::Optional<AccessPath>& p) {
289  return LiteralDoc(IntImm::Bool(v), p);
290  }
296  static LiteralDoc Float(double v, const ffi::Optional<AccessPath>& p) {
297  return LiteralDoc(FloatImm(PrimType::Float(64), v), p);
298  }
304  static LiteralDoc Str(const ffi::String& v, const ffi::Optional<AccessPath>& p) {
305  return LiteralDoc(v, p);
306  }
312  static LiteralDoc DataType(DLDataType v, const ffi::Optional<AccessPath>& p) {
313  std::string dtype =
314  v == DLDataType{kDLOpaqueHandle, 0, 0} ? "void" : ffi::DLDataTypeToString(v);
315  return LiteralDoc::Str(dtype, p);
316  }
322  static LiteralDoc Device(const DLDevice& v, const ffi::Optional<AccessPath>& p) {
323  std::ostringstream os;
324  runtime::operator<<(os, v);
325  return LiteralDoc::Str(os.str(), p);
326  }
327 
329 };
330 
337  public:
339  ExprDoc value{ffi::UnsafeInit()};
340 
341  static void RegisterReflection() {
342  namespace refl = tvm::ffi::reflection;
343  refl::ObjectDef<ExprStringDocNode>().def_ro("value", &ExprStringDocNode::value);
344  }
346 };
347 
353 class ExprStringDoc : public ExprDoc {
354  public:
360  explicit ExprStringDoc(ExprDoc value, const ffi::Optional<AccessPath>& object_path);
361 
363 };
364 
370 class IdDocNode : public ExprDocNode {
371  public:
373  ffi::String name;
374 
375  static void RegisterReflection() {
376  namespace refl = tvm::ffi::reflection;
377  refl::ObjectDef<IdDocNode>().def_ro("name", &IdDocNode::name);
378  }
380 };
381 
387 class IdDoc : public ExprDoc {
388  public:
393  explicit IdDoc(ffi::String name);
394  explicit IdDoc(std::nullptr_t) : ExprDoc(nullptr) {}
396 };
397 
404  public:
406  ExprDoc value{ffi::UnsafeInit()};
408  ffi::String name;
409 
410  static void RegisterReflection() {
411  namespace refl = tvm::ffi::reflection;
412  refl::ObjectDef<AttrAccessDocNode>()
413  .def_ro("value", &AttrAccessDocNode::value)
414  .def_ro("name", &AttrAccessDocNode::name);
415  }
417 };
418 
424 class AttrAccessDoc : public ExprDoc {
425  public:
431  explicit AttrAccessDoc(ExprDoc value, ffi::String name);
433 };
434 
440 class IndexDocNode : public ExprDocNode {
441  public:
443  ExprDoc value{ffi::UnsafeInit()};
451  ffi::Array<Doc> indices; // Each element is union of: Slice / ExprDoc
452 
453  static void RegisterReflection() {
454  namespace refl = tvm::ffi::reflection;
455  refl::ObjectDef<IndexDocNode>()
456  .def_ro("value", &IndexDocNode::value)
457  .def_ro("indices", &IndexDocNode::indices);
458  }
460 };
461 
467 class IndexDoc : public ExprDoc {
468  public:
474  explicit IndexDoc(ExprDoc value, ffi::Array<Doc> indices);
476 };
477 
483 class CallDocNode : public ExprDocNode {
484  public:
486  ExprDoc callee{ffi::UnsafeInit()};
488  ffi::Array<ExprDoc> args;
490  ffi::Array<ffi::String> kwargs_keys;
497  ffi::Array<ExprDoc> kwargs_values;
498 
499  static void RegisterReflection() {
500  namespace refl = tvm::ffi::reflection;
501  refl::ObjectDef<CallDocNode>()
502  .def_ro("callee", &CallDocNode::callee)
503  .def_ro("args", &CallDocNode::args)
504  .def_ro("kwargs_keys", &CallDocNode::kwargs_keys)
505  .def_ro("kwargs_values", &CallDocNode::kwargs_values);
506  }
508 };
509 
515 class CallDoc : public ExprDoc {
516  public:
524  CallDoc(ExprDoc callee, ffi::Array<ExprDoc> args, ffi::Array<ffi::String> kwargs_keys,
525  ffi::Array<ExprDoc> kwargs_values);
527 };
528 
538  public:
539  enum class Kind : int32_t {
540  // Unary operators
541  kUnaryStart = 0,
542  kUSub = 1, // -x
543  kInvert = 2, // ~x
544  kNot = 3, // not x
545  kUnaryEnd = 4,
546 
547  // Binary operators
548  kBinaryStart = 5,
549  kAdd = 6, // +
550  kSub = 7, // -
551  kMult = 8, // *
552  kDiv = 9, // /
553  kFloorDiv = 10, // // in Python
554  kMod = 11, // % in Python
555  kPow = 12, // ** in Python
556  kLShift = 13, // <<
557  kRShift = 14, // >>
558  kBitAnd = 15, // &
559  kBitOr = 16, // |
560  kBitXor = 17, // ^
561  kLt = 18, // <
562  kLtE = 19, // <=
563  kEq = 20, // ==
564  kNotEq = 21, // !=
565  kGt = 22, // >
566  kGtE = 23, // >=
567  kAnd = 24, // and
568  kOr = 25, // or
569  kMatMul = 26, // @
570  kBinaryEnd = 27,
571 
572  // Special
573  kSpecialStart = 28,
574  kIfThenElse = 29, // <operands[1]> if <operands[0]> else <operands[2]>
575  kSpecialEnd = 30
576  };
577 
581  ffi::Array<ExprDoc> operands;
582 
583  static void RegisterReflection() {
584  namespace refl = tvm::ffi::reflection;
585  refl::ObjectDef<OperationDocNode>()
586  .def_ro("kind", &OperationDocNode::kind)
587  .def_ro("operands", &OperationDocNode::operands);
588  }
590 };
591 
597 class OperationDoc : public ExprDoc {
598  public:
604  explicit OperationDoc(OperationDocNode::Kind kind, ffi::Array<ExprDoc> operands);
606 };
607 
616 class LambdaDocNode : public ExprDocNode {
617  public:
619  ffi::Array<IdDoc> args;
621  ExprDoc body{ffi::UnsafeInit()};
622 
623  static void RegisterReflection() {
624  namespace refl = tvm::ffi::reflection;
625  refl::ObjectDef<LambdaDocNode>()
626  .def_ro("args", &LambdaDocNode::args)
627  .def_ro("body", &LambdaDocNode::body);
628  }
630 };
631 
637 class LambdaDoc : public ExprDoc {
638  public:
644  explicit LambdaDoc(ffi::Array<IdDoc> args, ExprDoc body);
646 };
647 
653 class TupleDocNode : public ExprDocNode {
654  public:
656  ffi::Array<ExprDoc> elements;
657 
658  static void RegisterReflection() {
659  namespace refl = tvm::ffi::reflection;
660  refl::ObjectDef<TupleDocNode>().def_ro("elements", &TupleDocNode::elements);
661  }
663 };
664 
670 class TupleDoc : public ExprDoc {
671  public:
675  TupleDoc() : ExprDoc(ffi::make_object<TupleDocNode>()) {}
680  explicit TupleDoc(ffi::Array<ExprDoc> elements);
682 };
683 
689 class ListDocNode : public ExprDocNode {
690  public:
692  ffi::Array<ExprDoc> elements;
693 
694  static void RegisterReflection() {
695  namespace refl = tvm::ffi::reflection;
696  refl::ObjectDef<ListDocNode>().def_ro("elements", &ListDocNode::elements);
697  }
699 };
700 
706 class ListDoc : public ExprDoc {
707  public:
711  ListDoc() : ExprDoc(ffi::make_object<ListDocNode>()) {}
716  explicit ListDoc(ffi::Array<ExprDoc> elements);
718 };
719 
725 class DictDocNode : public ExprDocNode {
726  public:
728  ffi::Array<ExprDoc> keys;
735  ffi::Array<ExprDoc> values;
736 
737  static void RegisterReflection() {
738  namespace refl = tvm::ffi::reflection;
739  refl::ObjectDef<DictDocNode>()
740  .def_ro("keys", &DictDocNode::keys)
741  .def_ro("values", &DictDocNode::values);
742  }
744 };
745 
751 class DictDoc : public ExprDoc {
752  public:
756  DictDoc() : ExprDoc(ffi::make_object<DictDocNode>()) {}
762  explicit DictDoc(ffi::Array<ExprDoc> keys, ffi::Array<ExprDoc> values);
764 };
765 
773 class SliceDocNode : public DocNode {
774  public:
776  ffi::Optional<ExprDoc> start;
778  ffi::Optional<ExprDoc> stop;
780  ffi::Optional<ExprDoc> step;
781 
782  static void RegisterReflection() {
783  namespace refl = tvm::ffi::reflection;
784  refl::ObjectDef<SliceDocNode>()
785  .def_ro("start", &SliceDocNode::start)
786  .def_ro("stop", &SliceDocNode::stop)
787  .def_ro("step", &SliceDocNode::step);
788  }
790 };
791 
797 class SliceDoc : public Doc {
798  public:
805  explicit SliceDoc(ffi::Optional<ExprDoc> start, ffi::Optional<ExprDoc> stop,
806  ffi::Optional<ExprDoc> step);
808 };
809 
815 class AssignDocNode : public StmtDocNode {
816  public:
818  ExprDoc lhs{ffi::UnsafeInit()};
824  ffi::Optional<ExprDoc> rhs;
826  ffi::Optional<ExprDoc> annotation;
827 
828  static void RegisterReflection() {
829  namespace refl = tvm::ffi::reflection;
830  refl::ObjectDef<AssignDocNode>()
831  .def_ro("lhs", &AssignDocNode::lhs)
832  .def_ro("rhs", &AssignDocNode::rhs)
833  .def_ro("annotation", &AssignDocNode::annotation);
834  }
836 };
837 
843 class AssignDoc : public StmtDoc {
844  public:
851  explicit AssignDoc(ExprDoc lhs, ffi::Optional<ExprDoc> rhs, ffi::Optional<ExprDoc> annotation);
853 };
854 
860 class IfDocNode : public StmtDocNode {
861  public:
863  ExprDoc predicate{ffi::UnsafeInit()};
865  ffi::Array<StmtDoc> then_branch;
867  ffi::Array<StmtDoc> else_branch;
868 
869  static void RegisterReflection() {
870  namespace refl = tvm::ffi::reflection;
871  refl::ObjectDef<IfDocNode>()
872  .def_ro("predicate", &IfDocNode::predicate)
873  .def_ro("then_branch", &IfDocNode::then_branch)
874  .def_ro("else_branch", &IfDocNode::else_branch);
875  }
877 };
878 
884 class IfDoc : public StmtDoc {
885  public:
892  explicit IfDoc(ExprDoc predicate, ffi::Array<StmtDoc> then_branch,
893  ffi::Array<StmtDoc> else_branch);
895 };
896 
902 class WhileDocNode : public StmtDocNode {
903  public:
905  ExprDoc predicate{ffi::UnsafeInit()};
907  ffi::Array<StmtDoc> body;
908 
909  static void RegisterReflection() {
910  namespace refl = tvm::ffi::reflection;
911  refl::ObjectDef<WhileDocNode>()
912  .def_ro("predicate", &WhileDocNode::predicate)
913  .def_ro("body", &WhileDocNode::body);
914  }
916 };
917 
923 class WhileDoc : public StmtDoc {
924  public:
930  explicit WhileDoc(ExprDoc predicate, ffi::Array<StmtDoc> body);
932 };
933 
939 class BreakDocNode : public StmtDocNode {
940  public:
941  static void RegisterReflection() {
942  namespace refl = tvm::ffi::reflection;
943  refl::ObjectDef<BreakDocNode>();
944  }
945 
947 };
948 
954 class BreakDoc : public StmtDoc {
955  public:
959  explicit BreakDoc();
961 };
962 
968 class ContinueDocNode : public StmtDocNode {
969  public:
970  static void RegisterReflection() {
971  namespace refl = tvm::ffi::reflection;
972  refl::ObjectDef<ContinueDocNode>();
973  }
974 
976 };
977 
983 class ContinueDoc : public StmtDoc {
984  public:
988  explicit ContinueDoc();
990 };
991 
1001 class ForDocNode : public StmtDocNode {
1002  public:
1004  ExprDoc lhs{ffi::UnsafeInit()};
1006  ExprDoc rhs{ffi::UnsafeInit()};
1008  ffi::Array<StmtDoc> body;
1009 
1010  static void RegisterReflection() {
1011  namespace refl = tvm::ffi::reflection;
1012  refl::ObjectDef<ForDocNode>()
1013  .def_ro("lhs", &ForDocNode::lhs)
1014  .def_ro("rhs", &ForDocNode::rhs)
1015  .def_ro("body", &ForDocNode::body);
1016  }
1018 };
1019 
1025 class ForDoc : public StmtDoc {
1026  public:
1033  explicit ForDoc(ExprDoc lhs, ExprDoc rhs, ffi::Array<StmtDoc> body);
1035 };
1036 
1047 class ScopeDocNode : public StmtDocNode {
1048  public:
1050  ffi::Optional<ExprDoc> lhs{std::nullopt};
1052  ExprDoc rhs{ffi::UnsafeInit()};
1054  ffi::Array<StmtDoc> body;
1055 
1056  static void RegisterReflection() {
1057  namespace refl = tvm::ffi::reflection;
1058  refl::ObjectDef<ScopeDocNode>()
1059  .def_ro("lhs", &ScopeDocNode::lhs)
1060  .def_ro("rhs", &ScopeDocNode::rhs)
1061  .def_ro("body", &ScopeDocNode::body);
1062  }
1064 };
1065 
1071 class ScopeDoc : public StmtDoc {
1072  public:
1079  explicit ScopeDoc(ffi::Optional<ExprDoc> lhs, ExprDoc rhs, ffi::Array<StmtDoc> body);
1080 
1086  explicit ScopeDoc(ExprDoc rhs, ffi::Array<StmtDoc> body);
1087 
1089 };
1090 
1097  public:
1099  ExprDoc expr{ffi::UnsafeInit()};
1100 
1101  static void RegisterReflection() {
1102  namespace refl = tvm::ffi::reflection;
1103  refl::ObjectDef<ExprStmtDocNode>().def_ro("expr", &ExprStmtDocNode::expr);
1104  }
1106 };
1107 
1113 class ExprStmtDoc : public StmtDoc {
1114  public:
1119  explicit ExprStmtDoc(ExprDoc expr);
1121 };
1122 
1128 class AssertDocNode : public StmtDocNode {
1129  public:
1131  ExprDoc test{ffi::UnsafeInit()};
1133  ffi::Optional<ExprDoc> msg{std::nullopt};
1134 
1135  static void RegisterReflection() {
1136  namespace refl = tvm::ffi::reflection;
1137  refl::ObjectDef<AssertDocNode>()
1138  .def_ro("test", &AssertDocNode::test)
1139  .def_ro("msg", &AssertDocNode::msg);
1140  }
1142 };
1143 
1149 class AssertDoc : public StmtDoc {
1150  public:
1156  explicit AssertDoc(ExprDoc test, ffi::Optional<ExprDoc> msg = std::nullopt);
1158 };
1159 
1165 class ReturnDocNode : public StmtDocNode {
1166  public:
1168  ExprDoc value{ffi::UnsafeInit()};
1169 
1170  static void RegisterReflection() {
1171  namespace refl = tvm::ffi::reflection;
1172  refl::ObjectDef<ReturnDocNode>().def_ro("value", &ReturnDocNode::value);
1173  }
1175 };
1176 
1182 class ReturnDoc : public StmtDoc {
1183  public:
1188  explicit ReturnDoc(ExprDoc value);
1190 };
1191 
1198  public:
1200  IdDoc name{ffi::UnsafeInit{}};
1208  ffi::Array<AssignDoc> args;
1210  ffi::Array<ExprDoc> decorators;
1212  ffi::Optional<ExprDoc> return_type{std::nullopt};
1214  ffi::Array<StmtDoc> body;
1215 
1216  static void RegisterReflection() {
1217  namespace refl = tvm::ffi::reflection;
1218  refl::ObjectDef<FunctionDocNode>()
1219  .def_ro("name", &FunctionDocNode::name)
1220  .def_ro("args", &FunctionDocNode::args)
1221  .def_ro("decorators", &FunctionDocNode::decorators)
1222  .def_ro("return_type", &FunctionDocNode::return_type)
1223  .def_ro("body", &FunctionDocNode::body);
1224  }
1226 };
1227 
1233 class FunctionDoc : public StmtDoc {
1234  public:
1243  explicit FunctionDoc(IdDoc name, ffi::Array<AssignDoc> args, ffi::Array<ExprDoc> decorators,
1244  ffi::Optional<ExprDoc> return_type, ffi::Array<StmtDoc> body);
1246 };
1247 
1253 class ClassDocNode : public StmtDocNode {
1254  public:
1256  IdDoc name{ffi::UnsafeInit{}};
1258  ffi::Array<ExprDoc> decorators;
1260  ffi::Array<StmtDoc> body;
1261 
1262  static void RegisterReflection() {
1263  namespace refl = tvm::ffi::reflection;
1264  refl::ObjectDef<ClassDocNode>()
1265  .def_ro("name", &ClassDocNode::name)
1266  .def_ro("decorators", &ClassDocNode::decorators)
1267  .def_ro("body", &ClassDocNode::body);
1268  }
1270 };
1271 
1277 class ClassDoc : public StmtDoc {
1278  public:
1285  explicit ClassDoc(IdDoc name, ffi::Array<ExprDoc> decorators, ffi::Array<StmtDoc> body);
1287 };
1288 
1294 class CommentDocNode : public StmtDocNode {
1295  public:
1296  static void RegisterReflection() {
1297  namespace refl = tvm::ffi::reflection;
1298  refl::ObjectDef<CommentDocNode>();
1299  }
1301 };
1302 
1308 class CommentDoc : public StmtDoc {
1309  public:
1310  explicit CommentDoc(ffi::String comment);
1312 };
1313 
1320  public:
1321  static void RegisterReflection() {
1322  namespace refl = tvm::ffi::reflection;
1323  refl::ObjectDef<DocStringDocNode>();
1324  }
1326 };
1327 
1333 class DocStringDoc : public StmtDoc {
1334  public:
1335  explicit DocStringDoc(ffi::String docs);
1337 };
1338 
1344 class OpCallDocNode : public StmtDocNode {
1345  public:
1347  ExprDoc callee{ffi::UnsafeInit()};
1349  ffi::Array<Doc> args;
1351  ffi::Optional<DictDoc> workspace{std::nullopt};
1353  ffi::Optional<DictDoc> config{std::nullopt};
1355  ffi::Optional<ExprDoc> dispatch{std::nullopt};
1356 
1357  static void RegisterReflection() {
1358  namespace refl = tvm::ffi::reflection;
1359  refl::ObjectDef<OpCallDocNode>()
1360  .def_ro("callee", &OpCallDocNode::callee)
1361  .def_ro("args", &OpCallDocNode::args)
1362  .def_ro("workspace", &OpCallDocNode::workspace)
1363  .def_ro("config", &OpCallDocNode::config)
1364  .def_ro("dispatch", &OpCallDocNode::dispatch);
1365  }
1366 
1368 };
1369 
1375 class OpCallDoc : public StmtDoc {
1376  public:
1385  explicit OpCallDoc(ExprDoc callee, ffi::Array<Doc> args, ffi::Optional<DictDoc> workspace,
1386  ffi::Optional<DictDoc> config, ffi::Optional<ExprDoc> dispatch = std::nullopt);
1388 };
1389 
1390 } // namespace printer
1391 } // namespace script
1392 } // namespace tvm
1393 
1394 #endif // TVM_SCRIPT_PRINTER_DOC_H_
Managed reference class to FloatImmNode.
Definition: expr.h:441
static IntImm Bool(bool value, Span span=Span())
Construct a scalar boolean constant.
Definition: expr.h:393
static IntImm Int64(int64_t value, Span span=Span())
Construct a scalar int64 constant.
Definition: expr.h:411
static PrimType Float(int bits, int lanes=1)
Construct a floating-point type with fixed lanes.
Definition: config.h:146
Doc that represents assert statement.
Definition: doc.h:1128
ffi::Optional< ExprDoc > msg
The optional error message when assertion failed.
Definition: doc.h:1133
static void RegisterReflection()
Definition: doc.h:1135
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.AssertDoc", AssertDocNode, StmtDocNode)
ExprDoc test
The expression to test.
Definition: doc.h:1131
Reference type of AssertDocNode.
Definition: doc.h:1149
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertDoc, StmtDoc, AssertDocNode)
AssertDoc(ExprDoc test, ffi::Optional< ExprDoc > msg=std::nullopt)
Constructor of AssertDoc.
Doc that represents assign statement.
Definition: doc.h:815
ffi::Optional< ExprDoc > annotation
The type annotation of this assignment.
Definition: doc.h:826
ffi::Optional< ExprDoc > rhs
The right hand side of the assignment.
Definition: doc.h:824
ExprDoc lhs
The left hand side of the assignment.
Definition: doc.h:818
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.AssignDoc", AssignDocNode, StmtDocNode)
static void RegisterReflection()
Definition: doc.h:828
Reference type of AssignDocNode.
Definition: doc.h:843
AssignDoc(ExprDoc lhs, ffi::Optional< ExprDoc > rhs, ffi::Optional< ExprDoc > annotation)
Constructor of AssignDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssignDoc, StmtDoc, AssignDocNode)
Doc that represents attribute access on another expression.
Definition: doc.h:403
ffi::String name
The attribute to be accessed.
Definition: doc.h:408
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.AttrAccessDoc", AttrAccessDocNode, ExprDocNode)
ExprDoc value
The target expression to be accessed.
Definition: doc.h:406
static void RegisterReflection()
Definition: doc.h:410
Reference type of AttrAccessDocNode.
Definition: doc.h:424
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrAccessDoc, ExprDoc, AttrAccessDocNode)
AttrAccessDoc(ExprDoc value, ffi::String name)
Constructor of AttrAccessDoc.
Doc that represents break statement.
Definition: doc.h:939
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.BreakDoc", BreakDocNode, StmtDocNode)
static void RegisterReflection()
Definition: doc.h:941
Reference type of BreakDocNode.
Definition: doc.h:954
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BreakDoc, StmtDoc, BreakDocNode)
BreakDoc()
Constructor of BreakDoc.
Doc that represents function call.
Definition: doc.h:483
ffi::Array< ffi::String > kwargs_keys
The keys of keyword arguments.
Definition: doc.h:490
ffi::Array< ExprDoc > kwargs_values
The values of keyword arguments.
Definition: doc.h:497
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.CallDoc", CallDocNode, ExprDocNode)
static void RegisterReflection()
Definition: doc.h:499
ffi::Array< ExprDoc > args
The positional arguments.
Definition: doc.h:488
ExprDoc callee
The callee of this function call.
Definition: doc.h:486
Reference type of CallDocNode.
Definition: doc.h:515
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(CallDoc, ExprDoc, CallDocNode)
CallDoc(ExprDoc callee, ffi::Array< ExprDoc > args, ffi::Array< ffi::String > kwargs_keys, ffi::Array< ExprDoc > kwargs_values)
Constructor of CallDoc.
Doc that represents class definition.
Definition: doc.h:1253
ffi::Array< ExprDoc > decorators
Decorators of class.
Definition: doc.h:1258
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ClassDoc", ClassDocNode, StmtDocNode)
static void RegisterReflection()
Definition: doc.h:1262
IdDoc name
The name of class.
Definition: doc.h:1256
ffi::Array< StmtDoc > body
The body of class.
Definition: doc.h:1260
Reference type of ClassDocNode.
Definition: doc.h:1277
ClassDoc(IdDoc name, ffi::Array< ExprDoc > decorators, ffi::Array< StmtDoc > body)
Constructor of ClassDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ClassDoc, StmtDoc, ClassDocNode)
Doc that represents comment.
Definition: doc.h:1294
static void RegisterReflection()
Definition: doc.h:1296
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.CommentDoc", CommentDocNode, StmtDocNode)
Reference type of CommentDocNode.
Definition: doc.h:1308
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(CommentDoc, StmtDoc, CommentDocNode)
CommentDoc(ffi::String comment)
Doc that represents continue statement.
Definition: doc.h:968
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ContinueDoc", ContinueDocNode, StmtDocNode)
static void RegisterReflection()
Definition: doc.h:970
Reference type of ContinueDocNode.
Definition: doc.h:983
ContinueDoc()
Constructor of ContinueDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ContinueDoc, StmtDoc, ContinueDocNode)
Doc that represents dictionary literal.
Definition: doc.h:725
ffi::Array< ExprDoc > keys
keys of dictionary
Definition: doc.h:728
static void RegisterReflection()
Definition: doc.h:737
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.DictDoc", DictDocNode, ExprDocNode)
ffi::Array< ExprDoc > values
Values of dictionary.
Definition: doc.h:735
Reference type of DictDocNode.
Definition: doc.h:751
DictDoc(ffi::Array< ExprDoc > keys, ffi::Array< ExprDoc > values)
Constructor of DictDoc.
DictDoc()
Create an empty dictionary.
Definition: doc.h:756
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DictDoc, ExprDoc, DictDocNode)
The base class of all Doc.
Definition: doc.h:59
static constexpr bool _type_mutable
Definition: doc.h:75
virtual ~DocNode()=default
TVM_FFI_DECLARE_OBJECT_INFO("script.printer.Doc", DocNode, ffi::Object)
static void RegisterReflection()
Definition: doc.h:70
ffi::Array< AccessPath > source_paths
The list of object paths of the source IR node.
Definition: doc.h:68
Doc that represents docstring.
Definition: doc.h:1319
static void RegisterReflection()
Definition: doc.h:1321
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.DocStringDoc", DocStringDocNode, StmtDocNode)
Reference type of DocStringDocNode.
Definition: doc.h:1333
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DocStringDoc, StmtDoc, DocStringDocNode)
Reference type of DocNode.
Definition: doc.h:88
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Doc, ffi::ObjectRef, DocNode)
Doc(ffi::ObjectPtr< DocNode > data)
Definition: doc.h:91
The base class of expression doc.
Definition: doc.h:104
ExprDoc Attr(ffi::String attr) const
Create a doc representing attribute access on the current ExprDoc.
static void RegisterReflection()
Definition: doc.h:134
TVM_FFI_DECLARE_OBJECT_INFO("script.printer.ExprDoc", ExprDocNode, DocNode)
ExprDoc Call(ffi::Array< ExprDoc, void > args) const
Create a doc representing calling the current ExprDoc.
ExprDoc operator[](ffi::Array< Doc > indices) const
Create a doc representing index access on the current ExprDoc.
ExprDoc Call(ffi::Array< ExprDoc, void > args, ffi::Array< ffi::String > kwargs_keys, ffi::Array< ExprDoc, void > kwargs_values) const
Create a doc representing attribute access on the current ExprDoc.
Reference type of ExprDocNode.
Definition: doc.h:146
ExprDoc(ffi::ObjectPtr< ExprDocNode > data)
Definition: doc.h:157
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExprDoc, Doc, ExprDocNode)
ExprDoc operator[](ffi::Array< Doc > indices) const
Create a doc representing index access on the current ExprDoc.
Doc that represents an expression as statement.
Definition: doc.h:1096
static void RegisterReflection()
Definition: doc.h:1101
ExprDoc expr
The expression represented by this doc.
Definition: doc.h:1099
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ExprStmtDoc", ExprStmtDocNode, StmtDocNode)
Reference type of ExprStmtDocNode.
Definition: doc.h:1113
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExprStmtDoc, StmtDoc, ExprStmtDocNode)
ExprStmtDoc(ExprDoc expr)
Constructor of ExprStmtDoc.
Doc that renders an expression as a Python string literal.
Definition: doc.h:336
static void RegisterReflection()
Definition: doc.h:341
ExprDoc value
The expression to render as a string.
Definition: doc.h:339
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ExprStringDoc", ExprStringDocNode, ExprDocNode)
Reference type of ExprStringDocNode.
Definition: doc.h:353
ExprStringDoc(ExprDoc value, const ffi::Optional< AccessPath > &object_path)
Constructor of ExprStringDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExprStringDoc, ExprDoc, ExprStringDocNode)
Doc that represents for statement.
Definition: doc.h:1001
ffi::Array< StmtDoc > body
The body of the for statement.
Definition: doc.h:1008
ExprDoc lhs
The left hand side of the assignment of iterating variable.
Definition: doc.h:1004
static void RegisterReflection()
Definition: doc.h:1010
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ForDoc", ForDocNode, StmtDocNode)
ExprDoc rhs
The right hand side of the assignment of iterating variable.
Definition: doc.h:1006
Reference type of ForDocNode.
Definition: doc.h:1025
ForDoc(ExprDoc lhs, ExprDoc rhs, ffi::Array< StmtDoc > body)
Constructor of ForDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForDoc, StmtDoc, ForDocNode)
Doc that represents function definition.
Definition: doc.h:1197
ffi::Array< AssignDoc > args
The arguments of function.
Definition: doc.h:1208
ffi::Array< StmtDoc > body
The body of function.
Definition: doc.h:1214
IdDoc name
The name of function.
Definition: doc.h:1200
static void RegisterReflection()
Definition: doc.h:1216
ffi::Array< ExprDoc > decorators
Decorators of function.
Definition: doc.h:1210
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.FunctionDoc", FunctionDocNode, StmtDocNode)
ffi::Optional< ExprDoc > return_type
The return type of function.
Definition: doc.h:1212
Reference type of FunctionDocNode.
Definition: doc.h:1233
FunctionDoc(IdDoc name, ffi::Array< AssignDoc > args, ffi::Array< ExprDoc > decorators, ffi::Optional< ExprDoc > return_type, ffi::Array< StmtDoc > body)
Constructor of FunctionDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FunctionDoc, StmtDoc, FunctionDocNode)
Doc that represents identifier.
Definition: doc.h:370
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.IdDoc", IdDocNode, ExprDocNode)
ffi::String name
The name of the identifier.
Definition: doc.h:373
static void RegisterReflection()
Definition: doc.h:375
Reference type of IdDocNode.
Definition: doc.h:387
IdDoc(std::nullptr_t)
Definition: doc.h:394
IdDoc(ffi::String name)
Constructor of IdDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IdDoc, ExprDoc, IdDocNode)
Doc that represent if-then-else statement.
Definition: doc.h:860
static void RegisterReflection()
Definition: doc.h:869
ffi::Array< StmtDoc > else_branch
The else branch of the if-then-else statement.
Definition: doc.h:867
ffi::Array< StmtDoc > then_branch
The then branch of the if-then-else statement.
Definition: doc.h:865
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.IfDoc", IfDocNode, StmtDocNode)
ExprDoc predicate
The predicate of the if-then-else statement.
Definition: doc.h:863
Reference type of IfDocNode.
Definition: doc.h:884
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfDoc, StmtDoc, IfDocNode)
IfDoc(ExprDoc predicate, ffi::Array< StmtDoc > then_branch, ffi::Array< StmtDoc > else_branch)
Constructor of IfDoc.
Doc that represents index access on another expression.
Definition: doc.h:440
static void RegisterReflection()
Definition: doc.h:453
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.IndexDoc", IndexDocNode, ExprDocNode)
ffi::Array< Doc > indices
The indices to access.
Definition: doc.h:451
ExprDoc value
The container value to be accessed.
Definition: doc.h:443
Reference type of IndexDocNode.
Definition: doc.h:467
IndexDoc(ExprDoc value, ffi::Array< Doc > indices)
Constructor of IndexDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IndexDoc, ExprDoc, IndexDocNode)
Doc that represents anonymous function.
Definition: doc.h:616
static void RegisterReflection()
Definition: doc.h:623
ExprDoc body
The body of this anonymous function.
Definition: doc.h:621
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.LambdaDoc", LambdaDocNode, ExprDocNode)
ffi::Array< IdDoc > args
The arguments of this anonymous function.
Definition: doc.h:619
Reference type of LambdaDocNode.
Definition: doc.h:637
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LambdaDoc, ExprDoc, LambdaDocNode)
LambdaDoc(ffi::Array< IdDoc > args, ExprDoc body)
Constructor of LambdaDoc.
Doc that represents list literal.
Definition: doc.h:689
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ListDoc", ListDocNode, ExprDocNode)
ffi::Array< ExprDoc > elements
Elements of list.
Definition: doc.h:692
static void RegisterReflection()
Definition: doc.h:694
Reference type of ListDocNode.
Definition: doc.h:706
ListDoc()
Create an empty ListDoc.
Definition: doc.h:711
ListDoc(ffi::Array< ExprDoc > elements)
Constructor of ListDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ListDoc, ExprDoc, ListDocNode)
Doc that represents literal value.
Definition: doc.h:238
ffi::Any value
the internal representation of the literal value.
Definition: doc.h:249
static void RegisterReflection()
Definition: doc.h:251
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.LiteralDoc", LiteralDocNode, ExprDocNode)
Reference type of LiteralDocNode.
Definition: doc.h:263
LiteralDoc(ffi::Any value, const ffi::Optional< AccessPath > &object_path)
static LiteralDoc DataType(DLDataType v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent string.
Definition: doc.h:312
static LiteralDoc Boolean(bool v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent boolean.
Definition: doc.h:288
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LiteralDoc, ExprDoc, LiteralDocNode)
static LiteralDoc Device(const DLDevice &v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent device.
Definition: doc.h:322
static LiteralDoc Int(int64_t v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent integer.
Definition: doc.h:280
static LiteralDoc Float(double v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent float.
Definition: doc.h:296
static LiteralDoc None(const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent None/null/empty value.
Definition: doc.h:272
static LiteralDoc Str(const ffi::String &v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent string.
Definition: doc.h:304
Doc that represents call to an TIRX operator.
Definition: doc.h:1344
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.OpCallDoc", OpCallDocNode, StmtDocNode)
ffi::Optional< ExprDoc > dispatch
The optional dispatch variant of this op call.
Definition: doc.h:1355
ffi::Array< Doc > args
The positional arguments.
Definition: doc.h:1349
static void RegisterReflection()
Definition: doc.h:1357
ffi::Optional< DictDoc > config
The config of this op call.
Definition: doc.h:1353
ffi::Optional< DictDoc > workspace
The workspace of this op call.
Definition: doc.h:1351
ExprDoc callee
The callee of this function call.
Definition: doc.h:1347
Reference type of OpCallDocNode.
Definition: doc.h:1375
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(OpCallDoc, StmtDoc, OpCallDocNode)
OpCallDoc(ExprDoc callee, ffi::Array< Doc > args, ffi::Optional< DictDoc > workspace, ffi::Optional< DictDoc > config, ffi::Optional< ExprDoc > dispatch=std::nullopt)
Constructor of OpCallDoc.
Doc that represents operation.
Definition: doc.h:537
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.OperationDoc", OperationDocNode, ExprDocNode)
ffi::Array< ExprDoc > operands
Operands of this expression.
Definition: doc.h:581
Kind kind
The kind of operation (operator)
Definition: doc.h:579
static void RegisterReflection()
Definition: doc.h:583
Reference type of OperationDocNode.
Definition: doc.h:597
OperationDoc(OperationDocNode::Kind kind, ffi::Array< ExprDoc > operands)
Constructor of OperationDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(OperationDoc, ExprDoc, OperationDocNode)
Doc that represents return statement.
Definition: doc.h:1165
ExprDoc value
The value to return.
Definition: doc.h:1168
static void RegisterReflection()
Definition: doc.h:1170
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ReturnDoc", ReturnDocNode, StmtDocNode)
Reference type of ReturnDocNode.
Definition: doc.h:1182
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ReturnDoc, StmtDoc, ReturnDocNode)
ReturnDoc(ExprDoc value)
Constructor of ReturnDoc.
Doc that represents special scopes.
Definition: doc.h:1047
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.ScopeDoc", ScopeDocNode, StmtDocNode)
ffi::Optional< ExprDoc > lhs
The name of the scoped variable.
Definition: doc.h:1050
ExprDoc rhs
The value of the scoped variable.
Definition: doc.h:1052
static void RegisterReflection()
Definition: doc.h:1056
ffi::Array< StmtDoc > body
The body of the scope doc.
Definition: doc.h:1054
Reference type of ScopeDocNode.
Definition: doc.h:1071
ScopeDoc(ffi::Optional< ExprDoc > lhs, ExprDoc rhs, ffi::Array< StmtDoc > body)
Constructor of ScopeDoc.
ScopeDoc(ExprDoc rhs, ffi::Array< StmtDoc > body)
Constructor of ScopeDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ScopeDoc, StmtDoc, ScopeDocNode)
Doc that represents slice in Index expression.
Definition: doc.h:773
ffi::Optional< ExprDoc > start
The start of slice.
Definition: doc.h:776
ffi::Optional< ExprDoc > step
The step of slice.
Definition: doc.h:780
ffi::Optional< ExprDoc > stop
The exclusive end of slice.
Definition: doc.h:778
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.SliceDoc", SliceDocNode, DocNode)
static void RegisterReflection()
Definition: doc.h:782
Reference type of SliceDocNode.
Definition: doc.h:797
SliceDoc(ffi::Optional< ExprDoc > start, ffi::Optional< ExprDoc > stop, ffi::Optional< ExprDoc > step)
Constructor of SliceDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(SliceDoc, Doc, SliceDocNode)
The container doc that holds a list of StmtDoc.
Definition: doc.h:207
static void RegisterReflection()
Definition: doc.h:212
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.StmtBlockDoc", StmtBlockDocNode, DocNode)
ffi::Array< StmtDoc > stmts
The list of statements.
Definition: doc.h:210
Reference type of StmtBlockDocNode.
Definition: doc.h:223
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StmtBlockDoc, Doc, StmtBlockDocNode)
StmtBlockDoc(ffi::Array< StmtDoc > stmts)
Constructor of StmtBlockDoc.
The base class of statement doc.
Definition: doc.h:169
ffi::Optional< ffi::String > comment
The comment of this doc.
Definition: doc.h:179
static void RegisterReflection()
Definition: doc.h:181
TVM_FFI_DECLARE_OBJECT_INFO("script.printer.StmtDoc", StmtDocNode, DocNode)
Reference type of StmtDocNode.
Definition: doc.h:193
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StmtDoc, Doc, StmtDocNode)
Doc that represents tuple literal.
Definition: doc.h:653
ffi::Array< ExprDoc > elements
Elements of tuple.
Definition: doc.h:656
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.TupleDoc", TupleDocNode, ExprDocNode)
static void RegisterReflection()
Definition: doc.h:658
Reference type of TupleDocNode.
Definition: doc.h:670
TupleDoc(ffi::Array< ExprDoc > elements)
Constructor of TupleDoc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TupleDoc, ExprDoc, TupleDocNode)
TupleDoc()
Create an empty TupleDoc.
Definition: doc.h:675
Doc that represents while statement.
Definition: doc.h:902
static void RegisterReflection()
Definition: doc.h:909
ffi::Array< StmtDoc > body
The body of the while statement.
Definition: doc.h:907
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.printer.WhileDoc", WhileDocNode, StmtDocNode)
ExprDoc predicate
The predicate of the while statement.
Definition: doc.h:905
Reference type of WhileDocNode.
Definition: doc.h:923
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileDoc, StmtDoc, WhileDocNode)
WhileDoc(ExprDoc predicate, ffi::Array< StmtDoc > body)
Constructor of WhileDoc.
Configuration object for the TVMScript printer.
Abstract device memory management API.
Base expr nodes in TVM.
IR/AST nodes for TVM types shared across IR variants.
std::ostream & operator<<(std::ostream &os, DLDevice dev)
Definition: device_api.h:386
ffi::String DocToPythonScript(Doc doc, const PrinterConfig &cfg)
Convert Doc into Python script.
ffi::reflection::AccessPath AccessPath
Definition: doc.h:36
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40