tvm
frame.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_IR_BUILDER_TIR_FRAME_H_
20 #define TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
21 
24 #include <tvm/tirx/exec_scope.h>
25 #include <tvm/tirx/stmt.h>
26 
27 #include <utility>
28 
29 namespace tvm {
30 namespace script {
31 namespace ir_builder {
32 namespace tirx {
33 
40  public:
42  ffi::Array<tvm::tirx::Stmt> stmts;
43 
44  static void RegisterReflection() {
45  namespace refl = tvm::ffi::reflection;
46  refl::ObjectDef<TIRFrameNode>().def_ro("stmts", &TIRFrameNode::stmts);
47  }
48  TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.tirx.TIRFrame", TIRFrameNode, IRBuilderFrameNode);
49 };
50 
56 class TIRFrame : public IRBuilderFrame {
57  public:
59 
60  protected:
61  TIRFrame() = default;
62  explicit TIRFrame(ffi::ObjectPtr<TIRFrameNode> data) : IRBuilderFrame(data) {}
63 };
64 
71  public:
73  ffi::Optional<ffi::String> name;
75  ffi::Array<tvm::tirx::Var> args;
77  bool is_private;
79  ffi::Optional<Type> ret_type;
81  ffi::Map<tvm::tirx::Var, tvm::tirx::Buffer> buffer_map;
83  ffi::Map<ffi::String, Any> attrs;
85  ffi::Map<tvm::tirx::Var, tvm::tirx::IterVar> env_threads;
87  ffi::Array<tvm::tirx::Buffer> root_alloc_buffers;
88 
89  // TIR utils
92  bool s_tir;
94  bool persistent;
95 
96  static void RegisterReflection() {
97  namespace refl = tvm::ffi::reflection;
98  refl::ObjectDef<PrimFuncFrameNode>()
99  .def_ro("name", &PrimFuncFrameNode::name)
100  .def_ro("args", &PrimFuncFrameNode::args)
101  .def_ro("is_private", &PrimFuncFrameNode::is_private)
102  .def_ro("ret_type", &PrimFuncFrameNode::ret_type)
103  .def_ro("buffer_map", &PrimFuncFrameNode::buffer_map)
104  .def_ro("attrs", &PrimFuncFrameNode::attrs)
105  .def_ro("env_threads", &PrimFuncFrameNode::env_threads)
106  .def_ro("root_alloc_buffers", &PrimFuncFrameNode::root_alloc_buffers)
107  .def_ro("s_tir", &PrimFuncFrameNode::s_tir)
108  .def_ro("persistent", &PrimFuncFrameNode::persistent);
109  }
110  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.PrimFuncFrame", PrimFuncFrameNode,
111  TIRFrameNode);
112 
113  public:
118  void ExitWithScope() final;
119 };
120 
126 class PrimFuncFrame : public TIRFrame {
127  public:
128  explicit PrimFuncFrame(ffi::ObjectPtr<PrimFuncFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
129  TVM_FFI_ICHECK(data != nullptr);
130  data_ = std::move(data);
131  }
133 };
134 
141  public:
143  ffi::String name;
145  ffi::Array<tvm::tirx::IterVar> iter_vars;
147  ffi::Optional<ffi::Array<tvm::tirx::BufferRegion>> reads;
149  ffi::Optional<ffi::Array<tvm::tirx::BufferRegion>> writes;
151  ffi::Optional<tvm::tirx::Stmt> init;
153  ffi::Array<tvm::tirx::Buffer> alloc_buffers;
155  ffi::Array<tvm::tirx::MatchBufferRegion> match_buffers;
157  ffi::Optional<ffi::Map<ffi::String, Any>> annotations;
159  ffi::Array<PrimExpr> iter_values;
164  ffi::Optional<PrimExpr> predicate;
167 
168  static void RegisterReflection() {
169  namespace refl = tvm::ffi::reflection;
170  refl::ObjectDef<SBlockFrameNode>()
171  .def_ro("name", &SBlockFrameNode::name)
172  .def_ro("iter_vars", &SBlockFrameNode::iter_vars)
173  .def_ro("reads", &SBlockFrameNode::reads)
174  .def_ro("writes", &SBlockFrameNode::writes)
175  .def_ro("init", &SBlockFrameNode::init)
176  .def_ro("alloc_buffers", &SBlockFrameNode::alloc_buffers)
177  .def_ro("match_buffers", &SBlockFrameNode::match_buffers)
178  .def_ro("annotations", &SBlockFrameNode::annotations)
179  .def_ro("iter_values", &SBlockFrameNode::iter_values)
180  .def_ro("predicate", &SBlockFrameNode::predicate)
181  .def_ro("no_realize", &SBlockFrameNode::no_realize);
182  }
183  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.SSBlockFrame", SBlockFrameNode,
184  TIRFrameNode);
185 
186  public:
191  void ExitWithScope() final;
192 };
193 
200 class SBlockFrame : public TIRFrame {
201  public:
202  explicit SBlockFrame(ffi::ObjectPtr<SBlockFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
203  TVM_FFI_ICHECK(data != nullptr);
204  data_ = std::move(data);
205  }
207 };
208 
215  public:
216  static void RegisterReflection() {
217  namespace refl = tvm::ffi::reflection;
218  refl::ObjectDef<BlockInitFrameNode>();
219  }
220  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.SBlockInitFrame", BlockInitFrameNode,
221  TIRFrameNode);
222 
223  public:
228  void EnterWithScope() final;
233  void ExitWithScope() final;
234 };
235 
241 class BlockInitFrame : public TIRFrame {
242  public:
243  explicit BlockInitFrame(ffi::ObjectPtr<BlockInitFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
244  TVM_FFI_ICHECK(data != nullptr);
245  data_ = std::move(data);
246  }
248 };
249 
259  public:
261  ffi::Optional<tvm::tirx::ExecScope> exec_scope;
263  ffi::Array<PrimExpr> guards;
264 
265  static void RegisterReflection() {
266  namespace refl = tvm::ffi::reflection;
267  refl::ObjectDef<ExecScopeFrameNode>()
268  .def_ro("exec_scope", &ExecScopeFrameNode::exec_scope)
269  .def_ro("guards", &ExecScopeFrameNode::guards);
270  }
271  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ExecScopeFrame", ExecScopeFrameNode,
272  TIRFrameNode);
273 
274  public:
279  void ExitWithScope() final;
280 };
281 
287 class ExecScopeFrame : public TIRFrame {
288  public:
289  explicit ExecScopeFrame(ffi::ObjectPtr<ExecScopeFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
290  TVM_FFI_ICHECK(data != nullptr);
291  data_ = std::move(data);
292  }
294 };
295 
301 class ForFrameNode : public TIRFrameNode {
302  public:
310  using FMakeForLoop = ffi::TypedFunction<tvm::tirx::Stmt(
311  ffi::Array<tvm::tirx::Var> loop_vars, ffi::Array<Range> loop_extents,
312  ffi::Array<ffi::Optional<PrimExpr>> loop_steps, tvm::tirx::Stmt loop_body)>;
314  ffi::Array<tvm::tirx::Var> vars;
316  ffi::Array<Range> doms;
318  ffi::Array<ffi::Optional<PrimExpr>> steps;
321 
322  static void RegisterReflection() {
323  namespace refl = tvm::ffi::reflection;
324  refl::ObjectDef<ForFrameNode>()
325  .def_ro("vars", &ForFrameNode::vars)
326  .def_ro("doms", &ForFrameNode::doms);
327  // `f_make_for_loop` is not registered as it's not visited.
328  }
329  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ForFrame", ForFrameNode, TIRFrameNode);
330 
331  public:
336  void ExitWithScope() final;
337 };
338 
344 class ForFrame : public TIRFrame {
345  public:
346  explicit ForFrame(ffi::ObjectPtr<ForFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
347  TVM_FFI_ICHECK(data != nullptr);
348  data_ = std::move(data);
349  }
351 };
352 
360  public:
366  ffi::Array<tvm::tirx::StringImm> message_parts;
367 
368  static void RegisterReflection() {
369  namespace refl = tvm::ffi::reflection;
370  refl::ObjectDef<AssertFrameNode>()
371  .def_ro("condition", &AssertFrameNode::condition)
372  .def_ro("error_kind", &AssertFrameNode::error_kind)
373  .def_ro("message_parts", &AssertFrameNode::message_parts);
374  }
375  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AssertFrame", AssertFrameNode,
376  TIRFrameNode);
377 
378  public:
383  void ExitWithScope() final;
384 };
385 
391 class AssertFrame : public TIRFrame {
392  public:
393  explicit AssertFrame(ffi::ObjectPtr<AssertFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
394  TVM_FFI_ICHECK(data != nullptr);
395  data_ = std::move(data);
396  }
398 };
399 
405  public:
409  ffi::String attr_key;
412 
413  static void RegisterReflection() {
414  namespace refl = tvm::ffi::reflection;
415  refl::ObjectDef<LaunchThreadFrameNode>()
416  .def_ro("extent", &LaunchThreadFrameNode::extent)
417  .def_ro("attr_key", &LaunchThreadFrameNode::attr_key)
418  .def_ro("iter_var", &LaunchThreadFrameNode::iter_var);
419  }
420  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.LaunchThreadFrame",
422 
423  public:
428  void ExitWithScope() final;
429 };
430 
436 class LaunchThreadFrame : public TIRFrame {
437  public:
438  explicit LaunchThreadFrame(ffi::ObjectPtr<LaunchThreadFrameNode> data)
439  : TIRFrame(ffi::UnsafeInit{}) {
440  TVM_FFI_ICHECK(data != nullptr);
441  data_ = std::move(data);
442  }
444 };
445 
451 class AttrFrameNode : public TIRFrameNode {
452  public:
454  Any node;
456  ffi::String attr_key;
459 
460  static void RegisterReflection() {
461  namespace refl = tvm::ffi::reflection;
462  refl::ObjectDef<AttrFrameNode>()
463  .def_ro("node", &AttrFrameNode::node)
464  .def_ro("attr_key", &AttrFrameNode::attr_key)
465  .def_ro("value", &AttrFrameNode::value);
466  }
467  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AttrFrame", AttrFrameNode,
468  TIRFrameNode);
469 
470  public:
475  void ExitWithScope() final;
476 };
477 
483 class AttrFrame : public TIRFrame {
484  public:
485  explicit AttrFrame(ffi::ObjectPtr<AttrFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
486  TVM_FFI_ICHECK(data != nullptr);
487  data_ = std::move(data);
488  }
490 };
491 
497 class WhileFrameNode : public TIRFrameNode {
498  public:
501 
502  static void RegisterReflection() {
503  namespace refl = tvm::ffi::reflection;
504  refl::ObjectDef<WhileFrameNode>().def_ro("condition", &WhileFrameNode::condition);
505  }
506  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameNode,
507  TIRFrameNode);
508 
509  public:
514  void ExitWithScope() final;
515 };
516 
522 class WhileFrame : public TIRFrame {
523  public:
524  explicit WhileFrame(ffi::ObjectPtr<WhileFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
525  TVM_FFI_ICHECK(data != nullptr);
526  data_ = std::move(data);
527  }
529 };
530 
536 class IfFrameNode : public TIRFrameNode {
537  public:
541  ffi::Optional<ffi::Array<tvm::tirx::Stmt>> then_stmts;
543  ffi::Optional<ffi::Array<tvm::tirx::Stmt>> else_stmts;
544 
545  static void RegisterReflection() {
546  namespace refl = tvm::ffi::reflection;
547  refl::ObjectDef<IfFrameNode>()
548  .def_ro("condition", &IfFrameNode::condition)
549  .def_ro("then_stmts", &IfFrameNode::then_stmts)
550  .def_ro("else_stmts", &IfFrameNode::else_stmts);
551  }
552  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.IfFrame", IfFrameNode, TIRFrameNode);
553 
554  public:
559  void ExitWithScope() final;
560 };
561 
567 class IfFrame : public TIRFrame {
568  public:
569  explicit IfFrame(ffi::ObjectPtr<IfFrameNode> data) : TIRFrame(data) {
570  TVM_FFI_ICHECK(data != nullptr);
571  }
573 };
574 
580 class ThenFrameNode : public TIRFrameNode {
581  public:
582  static void RegisterReflection() {
583  namespace refl = tvm::ffi::reflection;
584  refl::ObjectDef<ThenFrameNode>();
585  }
586  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ThenFrame", ThenFrameNode,
587  TIRFrameNode);
588 
589  public:
594  void EnterWithScope() final;
599  void ExitWithScope() final;
600 };
601 
607 class ThenFrame : public TIRFrame {
608  public:
609  explicit ThenFrame(ffi::ObjectPtr<ThenFrameNode> data) : TIRFrame(data) {
610  TVM_FFI_ICHECK(data != nullptr);
611  }
613 };
614 
620 class ElseFrameNode : public TIRFrameNode {
621  public:
622  static void RegisterReflection() {
623  namespace refl = tvm::ffi::reflection;
624  refl::ObjectDef<ElseFrameNode>();
625  }
626  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameNode,
627  TIRFrameNode);
628 
629  public:
634  void EnterWithScope() final;
639  void ExitWithScope() final;
640 };
641 
647 class ElseFrame : public TIRFrame {
648  public:
649  explicit ElseFrame(ffi::ObjectPtr<ElseFrameNode> data) : TIRFrame(data) {
650  TVM_FFI_ICHECK(data != nullptr);
651  }
652 
654 };
655 
657  public:
661  bool allocated;
662 
663  static void RegisterReflection() {
664  namespace refl = tvm::ffi::reflection;
665  refl::ObjectDef<DeclBufferFrameNode>()
666  .def_ro("buffer", &DeclBufferFrameNode::buffer)
667  .def_ro("allocated", &DeclBufferFrameNode::allocated);
668  }
669  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.DeclBufferFrame", DeclBufferFrameNode,
670  TIRFrameNode);
671 
672  public:
673  void ExitWithScope() final;
674 };
675 
676 class DeclBufferFrame : public TIRFrame {
677  public:
678  explicit DeclBufferFrame(ffi::ObjectPtr<DeclBufferFrameNode> data) : TIRFrame(data) {
679  TVM_FFI_ICHECK(data != nullptr);
680  }
682 };
683 
685  public:
687  ffi::Map<ffi::String, tvm::tirx::Buffer> workspace;
689  ffi::Map<ffi::String, ffi::Any> config;
691  ffi::Optional<ffi::String> dispatch{std::nullopt};
692 
693  static void RegisterReflection() {
694  namespace refl = tvm::ffi::reflection;
695  refl::ObjectDef<ComposeOpFrameNode>()
696  .def_ro("workspace", &ComposeOpFrameNode::workspace)
697  .def_ro("config", &ComposeOpFrameNode::config)
698  .def_ro("dispatch", &ComposeOpFrameNode::dispatch);
699  }
700  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ComposeOpFrame", ComposeOpFrameNode,
701  TIRFrameNode);
702 
703  public:
704  void ExitWithScope() final;
705 };
706 
707 class ComposeOpFrame : public TIRFrame {
708  public:
709  explicit ComposeOpFrame(ffi::ObjectPtr<ComposeOpFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
710  TVM_FFI_ICHECK(data != nullptr);
711  data_ = std::move(data);
712  }
714 };
716  public:
719 
720  static void RegisterReflection() {
721  namespace refl = tvm::ffi::reflection;
722  refl::ObjectDef<AllocBufferFrameNode>().def_ro("buffer", &AllocBufferFrameNode::buffer);
723  }
724 
725  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AllocBufferFrame", AllocBufferFrameNode,
726  TIRFrameNode);
727 
728  public:
729  void ExitWithScope() final;
730 };
731 
732 class AllocBufferFrame : public TIRFrame {
733  public:
734  explicit AllocBufferFrame(ffi::ObjectPtr<AllocBufferFrameNode> data)
735  : TIRFrame(ffi::UnsafeInit{}) {
736  TVM_FFI_ICHECK(data != nullptr);
737  data_ = std::move(data);
738  }
740 };
741 
747 class HintFrameNode : public TIRFrameNode {
748  public:
750  ffi::String message;
752  ffi::Map<ffi::String, ffi::Any> attrs;
753 
754  static void RegisterReflection() {
755  namespace refl = tvm::ffi::reflection;
756  refl::ObjectDef<HintFrameNode>()
757  .def_ro("message", &HintFrameNode::message)
758  .def_ro("attrs", &HintFrameNode::attrs);
759  }
760  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.HintFrame", HintFrameNode,
761  TIRFrameNode);
762 
763  public:
764  void ExitWithScope() final;
765 };
766 
772 class HintFrame : public TIRFrame {
773  public:
774  explicit HintFrame(ffi::ObjectPtr<HintFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
775  TVM_FFI_ICHECK(data != nullptr);
776  data_ = std::move(data);
777  }
779 };
780 
781 } // namespace tirx
782 } // namespace ir_builder
783 } // namespace script
784 } // namespace tvm
785 
786 #endif // TVM_TIRX_SCRIPT_BUILDER_FRAME_H_
Reference to PrimExprNode.
Definition: expr.h:126
Managed reference to an IRBuilderFrameNode.
Definition: base.h:103
tvm::tirx::Buffer buffer
The allocated buffer.
Definition: frame.h:718
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AllocBufferFrame", AllocBufferFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:720
AllocBufferFrame(ffi::ObjectPtr< AllocBufferFrameNode > data)
Definition: frame.h:734
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AllocBufferFrame, TIRFrame, AllocBufferFrameNode)
A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts wit...
Definition: frame.h:359
static void RegisterReflection()
Definition: frame.h:368
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AssertFrame", AssertFrameNode, TIRFrameNode)
tvm::tirx::StringImm error_kind
The error kind, e.g. "RuntimeError", "TypeError", "ValueError".
Definition: frame.h:364
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< tvm::tirx::StringImm > message_parts
Error message fragments, concatenated at runtime when assertion fails.
Definition: frame.h:366
PrimExpr condition
The PrimExpr to test.
Definition: frame.h:362
Managed reference to AssertFrameNode.
Definition: frame.h:391
AssertFrame(ffi::ObjectPtr< AssertFrameNode > data)
Definition: frame.h:393
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition: frame.h:451
ffi::String attr_key
Attribute type key.
Definition: frame.h:456
Any node
The node to annotate the attribute.
Definition: frame.h:454
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AttrFrame", AttrFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:460
PrimExpr value
The value of the attribute.
Definition: frame.h:458
Managed reference to AttrFrameNode.
Definition: frame.h:483
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrFrame, TIRFrame, AttrFrameNode)
AttrFrame(ffi::ObjectPtr< AttrFrameNode > data)
Definition: frame.h:485
A frame that represents the block initialization statment.
Definition: frame.h:214
void EnterWithScope() final
The method called when entering RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.SBlockInitFrame", BlockInitFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:216
Managed reference to BlockInitFrameNode.
Definition: frame.h:241
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BlockInitFrame, TIRFrame, BlockInitFrameNode)
BlockInitFrame(ffi::ObjectPtr< BlockInitFrameNode > data)
Definition: frame.h:243
ffi::Optional< ffi::String > dispatch
The optional dispatch variant name of the compose op.
Definition: frame.h:691
static void RegisterReflection()
Definition: frame.h:693
ffi::Map< ffi::String, tvm::tirx::Buffer > workspace
The workspace of the compose op.
Definition: frame.h:687
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ComposeOpFrame", ComposeOpFrameNode, TIRFrameNode)
ffi::Map< ffi::String, ffi::Any > config
The config of the compose op.
Definition: frame.h:689
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ComposeOpFrame, TIRFrame, ComposeOpFrameNode)
ComposeOpFrame(ffi::ObjectPtr< ComposeOpFrameNode > data)
Definition: frame.h:709
static void RegisterReflection()
Definition: frame.h:663
bool allocated
The buffer allocated or not.
Definition: frame.h:661
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::tirx::Buffer buffer
The declared buffer.
Definition: frame.h:659
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.DeclBufferFrame", DeclBufferFrameNode, TIRFrameNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DeclBufferFrame, TIRFrame, DeclBufferFrameNode)
DeclBufferFrame(ffi::ObjectPtr< DeclBufferFrameNode > data)
Definition: frame.h:678
A frame that represents else.
Definition: frame.h:620
void EnterWithScope() final
The method called when entering RAII scope.
static void RegisterReflection()
Definition: frame.h:622
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameNode, TIRFrameNode)
Managed reference to ElseFrameNode.
Definition: frame.h:647
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, TIRFrame, ElseFrameNode)
ElseFrame(ffi::ObjectPtr< ElseFrameNode > data)
Definition: frame.h:649
A frame that represents an execution scope (e.g. cta, warp, thread).
Definition: frame.h:258
ffi::Optional< tvm::tirx::ExecScope > exec_scope
The execution scope (always plain kind; no slice).
Definition: frame.h:261
ffi::Array< PrimExpr > guards
Optional surface-syntax guards for with Tx.scope(cond).
Definition: frame.h:263
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ExecScopeFrame", ExecScopeFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:265
Managed reference to ExecScopeFrameNode.
Definition: frame.h:287
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExecScopeFrame, TIRFrame, ExecScopeFrameNode)
ExecScopeFrame(ffi::ObjectPtr< ExecScopeFrameNode > data)
Definition: frame.h:289
A frame that represents the for loop.
Definition: frame.h:301
ffi::TypedFunction< tvm::tirx::Stmt(ffi::Array< tvm::tirx::Var > loop_vars, ffi::Array< Range > loop_extents, ffi::Array< ffi::Optional< PrimExpr > > loop_steps, tvm::tirx::Stmt loop_body)> FMakeForLoop
Functions that generate loop nests.
Definition: frame.h:312
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ForFrame", ForFrameNode, TIRFrameNode)
FMakeForLoop f_make_for_loop
The for loop generating function.
Definition: frame.h:320
static void RegisterReflection()
Definition: frame.h:322
ffi::Array< Range > doms
The domains of iteration.
Definition: frame.h:316
ffi::Array< tvm::tirx::Var > vars
The loop variable.
Definition: frame.h:314
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< ffi::Optional< PrimExpr > > steps
The optional steps of iteration.
Definition: frame.h:318
Managed reference to ForFrameNode.
Definition: frame.h:344
ForFrame(ffi::ObjectPtr< ForFrameNode > data)
Definition: frame.h:346
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, TIRFrame, ForFrameNode)
A frame that represents a hint directive for the sketch language.
Definition: frame.h:747
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.HintFrame", HintFrameNode, TIRFrameNode)
ffi::String message
The free-form hint message string.
Definition: frame.h:750
static void RegisterReflection()
Definition: frame.h:754
ffi::Map< ffi::String, ffi::Any > attrs
Optional structured key-value attributes.
Definition: frame.h:752
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to HintFrameNode.
Definition: frame.h:772
HintFrame(ffi::ObjectPtr< HintFrameNode > data)
Definition: frame.h:774
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(HintFrame, TIRFrame, HintFrameNode)
A frame that represents if statement.
Definition: frame.h:536
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.IfFrame", IfFrameNode, TIRFrameNode)
ffi::Optional< ffi::Array< tvm::tirx::Stmt > > else_stmts
The stetements in the false branch.
Definition: frame.h:543
ffi::Optional< ffi::Array< tvm::tirx::Stmt > > then_stmts
The statements in the true branch.
Definition: frame.h:541
void ExitWithScope() final
The method called when exiting RAII scope.
PrimExpr condition
The condition of the if statement.
Definition: frame.h:539
static void RegisterReflection()
Definition: frame.h:545
Managed reference to IfFrameNode.
Definition: frame.h:567
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, TIRFrame, IfFrameNode)
IfFrame(ffi::ObjectPtr< IfFrameNode > data)
Definition: frame.h:569
The LaunchThreadFrameNode.
Definition: frame.h:404
PrimExpr extent
The extent of environment thread.
Definition: frame.h:407
tvm::tirx::IterVar iter_var
The iteration variable.
Definition: frame.h:411
ffi::String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition: frame.h:409
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:413
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.LaunchThreadFrame", LaunchThreadFrameNode, TIRFrameNode)
Managed reference to LaunchThreadFrameNode.
Definition: frame.h:436
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
LaunchThreadFrame(ffi::ObjectPtr< LaunchThreadFrameNode > data)
Definition: frame.h:438
A frame that represents the PrimFunc containing TIR statements.
Definition: frame.h:70
bool s_tir
Whether this PrimFunc uses s_tir semantics (root SBlock wrap, parser layout default = None)....
Definition: frame.h:92
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Map< tvm::tirx::Var, tvm::tirx::Buffer > buffer_map
Maps some parameters to specific Buffer data structures.
Definition: frame.h:81
ffi::Optional< Type > ret_type
The return type of the function.
Definition: frame.h:79
ffi::Map< ffi::String, Any > attrs
Additional attributes storing the meta-data.
Definition: frame.h:83
bool is_private
Whether the PrimFunc is annotated as private.
Definition: frame.h:77
static void RegisterReflection()
Definition: frame.h:96
ffi::Optional< ffi::String > name
The name of the block.
Definition: frame.h:73
ffi::Array< tvm::tirx::Var > args
Function parameters.
Definition: frame.h:75
bool persistent
Whether it is a persistent kernel.
Definition: frame.h:94
ffi::Map< tvm::tirx::Var, tvm::tirx::IterVar > env_threads
The variable map bound to thread env.
Definition: frame.h:85
ffi::Array< tvm::tirx::Buffer > root_alloc_buffers
The buffer allocated in root block.
Definition: frame.h:87
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.PrimFuncFrame", PrimFuncFrameNode, TIRFrameNode)
Managed reference to PrimFuncFrameNode.
Definition: frame.h:126
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimFuncFrame, TIRFrame, PrimFuncFrameNode)
PrimFuncFrame(ffi::ObjectPtr< PrimFuncFrameNode > data)
Definition: frame.h:128
A frame that represents the block.
Definition: frame.h:140
ffi::Optional< ffi::Array< tvm::tirx::BufferRegion > > writes
The write buffer regions of the block.
Definition: frame.h:149
ffi::Array< tvm::tirx::Buffer > alloc_buffers
The buffer allocated in the block.
Definition: frame.h:153
ffi::Optional< ffi::Array< tvm::tirx::BufferRegion > > reads
The read buffer regions of the block.
Definition: frame.h:147
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.SSBlockFrame", SBlockFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Optional< tvm::tirx::Stmt > init
The init statement of the bolck.
Definition: frame.h:151
ffi::Optional< ffi::Map< ffi::String, Any > > annotations
The annotation of the block.
Definition: frame.h:157
ffi::Optional< PrimExpr > predicate
The predicate of the block realization, the block will only be executed when the predicate is true.
Definition: frame.h:164
ffi::Array< tvm::tirx::IterVar > iter_vars
The variables of the block.
Definition: frame.h:145
static void RegisterReflection()
Definition: frame.h:168
ffi::Array< PrimExpr > iter_values
The corresponding values of the iter vars.
Definition: frame.h:159
bool no_realize
The flag whether to construct BlockRealize or Block.
Definition: frame.h:166
ffi::Array< tvm::tirx::MatchBufferRegion > match_buffers
The match buffer regions.
Definition: frame.h:155
ffi::String name
The name of the block.
Definition: frame.h:143
Managed reference to SBlockFrameNode.
Definition: frame.h:200
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(SBlockFrame, TIRFrame, SBlockFrameNode)
SBlockFrame(ffi::ObjectPtr< SBlockFrameNode > data)
Definition: frame.h:202
A base frame that represents the TIR fame with body of statements.
Definition: frame.h:39
TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.tirx.TIRFrame", TIRFrameNode, IRBuilderFrameNode)
static void RegisterReflection()
Definition: frame.h:44
ffi::Array< tvm::tirx::Stmt > stmts
The Stmt within in this frame.
Definition: frame.h:42
Managed reference to TIRFrameNode.
Definition: frame.h:56
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TIRFrame, IRBuilderFrame, TIRFrameNode)
TIRFrame(ffi::ObjectPtr< TIRFrameNode > data)
Definition: frame.h:62
A frame that represents then.
Definition: frame.h:580
void EnterWithScope() final
The method called when entering RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ThenFrame", ThenFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:582
Managed reference to ThenFrameNode.
Definition: frame.h:607
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, TIRFrame, ThenFrameNode)
ThenFrame(ffi::ObjectPtr< ThenFrameNode > data)
Definition: frame.h:609
A frame that represents while loop.
Definition: frame.h:497
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameNode, TIRFrameNode)
PrimExpr condition
The termination condition of while.
Definition: frame.h:500
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:502
Managed reference to WhileFrameNode.
Definition: frame.h:522
WhileFrame(ffi::ObjectPtr< WhileFrameNode > data)
Definition: frame.h:524
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileFrame, TIRFrame, WhileFrameNode)
Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types,...
Definition: buffer.h:172
Iteration Variable, represents an iteration over an integer interval.
Definition: var.h:297
Container of all statements.
Definition: stmt.h:67
Managed reference to StringImmNode.
Definition: expr.h:69
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37
TIR statements.