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 
255 class ForFrameNode : public TIRFrameNode {
256  public:
264  using FMakeForLoop = ffi::TypedFunction<tvm::tirx::Stmt(
265  ffi::Array<tvm::tirx::Var> loop_vars, ffi::Array<Range> loop_extents,
266  ffi::Array<ffi::Optional<PrimExpr>> loop_steps, tvm::tirx::Stmt loop_body)>;
268  ffi::Array<tvm::tirx::Var> vars;
270  ffi::Array<Range> doms;
272  ffi::Array<ffi::Optional<PrimExpr>> steps;
275 
276  static void RegisterReflection() {
277  namespace refl = tvm::ffi::reflection;
278  refl::ObjectDef<ForFrameNode>()
279  .def_ro("vars", &ForFrameNode::vars)
280  .def_ro("doms", &ForFrameNode::doms);
281  // `f_make_for_loop` is not registered as it's not visited.
282  }
283  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ForFrame", ForFrameNode, TIRFrameNode);
284 
285  public:
290  void ExitWithScope() final;
291 };
292 
298 class ForFrame : public TIRFrame {
299  public:
300  explicit ForFrame(ffi::ObjectPtr<ForFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
301  TVM_FFI_ICHECK(data != nullptr);
302  data_ = std::move(data);
303  }
305 };
306 
314  public:
320  ffi::Array<tvm::tirx::StringImm> message_parts;
321 
322  static void RegisterReflection() {
323  namespace refl = tvm::ffi::reflection;
324  refl::ObjectDef<AssertFrameNode>()
325  .def_ro("condition", &AssertFrameNode::condition)
326  .def_ro("error_kind", &AssertFrameNode::error_kind)
327  .def_ro("message_parts", &AssertFrameNode::message_parts);
328  }
329  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AssertFrame", AssertFrameNode,
330  TIRFrameNode);
331 
332  public:
337  void ExitWithScope() final;
338 };
339 
345 class AssertFrame : public TIRFrame {
346  public:
347  explicit AssertFrame(ffi::ObjectPtr<AssertFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
348  TVM_FFI_ICHECK(data != nullptr);
349  data_ = std::move(data);
350  }
352 };
353 
359  public:
363  ffi::String attr_key;
366 
367  static void RegisterReflection() {
368  namespace refl = tvm::ffi::reflection;
369  refl::ObjectDef<LaunchThreadFrameNode>()
370  .def_ro("extent", &LaunchThreadFrameNode::extent)
371  .def_ro("attr_key", &LaunchThreadFrameNode::attr_key)
372  .def_ro("iter_var", &LaunchThreadFrameNode::iter_var);
373  }
374  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.LaunchThreadFrame",
376 
377  public:
382  void ExitWithScope() final;
383 };
384 
390 class LaunchThreadFrame : public TIRFrame {
391  public:
392  explicit LaunchThreadFrame(ffi::ObjectPtr<LaunchThreadFrameNode> data)
393  : TIRFrame(ffi::UnsafeInit{}) {
394  TVM_FFI_ICHECK(data != nullptr);
395  data_ = std::move(data);
396  }
398 };
399 
405 class AttrFrameNode : public TIRFrameNode {
406  public:
408  Any node;
410  ffi::String attr_key;
413 
414  static void RegisterReflection() {
415  namespace refl = tvm::ffi::reflection;
416  refl::ObjectDef<AttrFrameNode>()
417  .def_ro("node", &AttrFrameNode::node)
418  .def_ro("attr_key", &AttrFrameNode::attr_key)
419  .def_ro("value", &AttrFrameNode::value);
420  }
421  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AttrFrame", AttrFrameNode,
422  TIRFrameNode);
423 
424  public:
429  void ExitWithScope() final;
430 };
431 
437 class AttrFrame : public TIRFrame {
438  public:
439  explicit AttrFrame(ffi::ObjectPtr<AttrFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
440  TVM_FFI_ICHECK(data != nullptr);
441  data_ = std::move(data);
442  }
444 };
445 
451 class WhileFrameNode : public TIRFrameNode {
452  public:
455 
456  static void RegisterReflection() {
457  namespace refl = tvm::ffi::reflection;
458  refl::ObjectDef<WhileFrameNode>().def_ro("condition", &WhileFrameNode::condition);
459  }
460  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameNode,
461  TIRFrameNode);
462 
463  public:
468  void ExitWithScope() final;
469 };
470 
476 class WhileFrame : public TIRFrame {
477  public:
478  explicit WhileFrame(ffi::ObjectPtr<WhileFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
479  TVM_FFI_ICHECK(data != nullptr);
480  data_ = std::move(data);
481  }
483 };
484 
490 class IfFrameNode : public TIRFrameNode {
491  public:
495  ffi::Optional<ffi::Array<tvm::tirx::Stmt>> then_stmts;
497  ffi::Optional<ffi::Array<tvm::tirx::Stmt>> else_stmts;
498 
499  static void RegisterReflection() {
500  namespace refl = tvm::ffi::reflection;
501  refl::ObjectDef<IfFrameNode>()
502  .def_ro("condition", &IfFrameNode::condition)
503  .def_ro("then_stmts", &IfFrameNode::then_stmts)
504  .def_ro("else_stmts", &IfFrameNode::else_stmts);
505  }
506  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.IfFrame", IfFrameNode, TIRFrameNode);
507 
508  public:
513  void ExitWithScope() final;
514 };
515 
521 class IfFrame : public TIRFrame {
522  public:
523  explicit IfFrame(ffi::ObjectPtr<IfFrameNode> data) : TIRFrame(data) {
524  TVM_FFI_ICHECK(data != nullptr);
525  }
527 };
528 
534 class ThenFrameNode : public TIRFrameNode {
535  public:
536  static void RegisterReflection() {
537  namespace refl = tvm::ffi::reflection;
538  refl::ObjectDef<ThenFrameNode>();
539  }
540  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ThenFrame", ThenFrameNode,
541  TIRFrameNode);
542 
543  public:
548  void EnterWithScope() final;
553  void ExitWithScope() final;
554 };
555 
561 class ThenFrame : public TIRFrame {
562  public:
563  explicit ThenFrame(ffi::ObjectPtr<ThenFrameNode> data) : TIRFrame(data) {
564  TVM_FFI_ICHECK(data != nullptr);
565  }
567 };
568 
574 class ElseFrameNode : public TIRFrameNode {
575  public:
576  static void RegisterReflection() {
577  namespace refl = tvm::ffi::reflection;
578  refl::ObjectDef<ElseFrameNode>();
579  }
580  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameNode,
581  TIRFrameNode);
582 
583  public:
588  void EnterWithScope() final;
593  void ExitWithScope() final;
594 };
595 
601 class ElseFrame : public TIRFrame {
602  public:
603  explicit ElseFrame(ffi::ObjectPtr<ElseFrameNode> data) : TIRFrame(data) {
604  TVM_FFI_ICHECK(data != nullptr);
605  }
606 
608 };
609 
611  public:
615  bool allocated;
616 
617  static void RegisterReflection() {
618  namespace refl = tvm::ffi::reflection;
619  refl::ObjectDef<DeclBufferFrameNode>()
620  .def_ro("buffer", &DeclBufferFrameNode::buffer)
621  .def_ro("allocated", &DeclBufferFrameNode::allocated);
622  }
623  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.DeclBufferFrame", DeclBufferFrameNode,
624  TIRFrameNode);
625 
626  public:
627  void ExitWithScope() final;
628 };
629 
630 class DeclBufferFrame : public TIRFrame {
631  public:
632  explicit DeclBufferFrame(ffi::ObjectPtr<DeclBufferFrameNode> data) : TIRFrame(data) {
633  TVM_FFI_ICHECK(data != nullptr);
634  }
636 };
637 
639  public:
641  ffi::Map<ffi::String, tvm::tirx::Buffer> workspace;
643  ffi::Map<ffi::String, ffi::Any> config;
645  ffi::Optional<ffi::String> dispatch{std::nullopt};
646 
647  static void RegisterReflection() {
648  namespace refl = tvm::ffi::reflection;
649  refl::ObjectDef<ComposeOpFrameNode>()
650  .def_ro("workspace", &ComposeOpFrameNode::workspace)
651  .def_ro("config", &ComposeOpFrameNode::config)
652  .def_ro("dispatch", &ComposeOpFrameNode::dispatch);
653  }
654  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ComposeOpFrame", ComposeOpFrameNode,
655  TIRFrameNode);
656 
657  public:
658  void ExitWithScope() final;
659 };
660 
661 class ComposeOpFrame : public TIRFrame {
662  public:
663  explicit ComposeOpFrame(ffi::ObjectPtr<ComposeOpFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
664  TVM_FFI_ICHECK(data != nullptr);
665  data_ = std::move(data);
666  }
668 };
670  public:
673 
674  static void RegisterReflection() {
675  namespace refl = tvm::ffi::reflection;
676  refl::ObjectDef<AllocBufferFrameNode>().def_ro("buffer", &AllocBufferFrameNode::buffer);
677  }
678 
679  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AllocBufferFrame", AllocBufferFrameNode,
680  TIRFrameNode);
681 
682  public:
683  void ExitWithScope() final;
684 };
685 
686 class AllocBufferFrame : public TIRFrame {
687  public:
688  explicit AllocBufferFrame(ffi::ObjectPtr<AllocBufferFrameNode> data)
689  : TIRFrame(ffi::UnsafeInit{}) {
690  TVM_FFI_ICHECK(data != nullptr);
691  data_ = std::move(data);
692  }
694 };
695 
701 class HintFrameNode : public TIRFrameNode {
702  public:
704  ffi::String message;
706  ffi::Map<ffi::String, ffi::Any> attrs;
707 
708  static void RegisterReflection() {
709  namespace refl = tvm::ffi::reflection;
710  refl::ObjectDef<HintFrameNode>()
711  .def_ro("message", &HintFrameNode::message)
712  .def_ro("attrs", &HintFrameNode::attrs);
713  }
714  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.HintFrame", HintFrameNode,
715  TIRFrameNode);
716 
717  public:
718  void ExitWithScope() final;
719 };
720 
726 class HintFrame : public TIRFrame {
727  public:
728  explicit HintFrame(ffi::ObjectPtr<HintFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
729  TVM_FFI_ICHECK(data != nullptr);
730  data_ = std::move(data);
731  }
733 };
734 
735 } // namespace tirx
736 } // namespace ir_builder
737 } // namespace script
738 } // namespace tvm
739 
740 #endif // TVM_TIRX_SCRIPT_BUILDER_FRAME_H_
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition: base_expr.h:354
Managed reference to an IRBuilderFrameNode.
Definition: base.h:103
tvm::tirx::Buffer buffer
The allocated buffer.
Definition: frame.h:672
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:674
AllocBufferFrame(ffi::ObjectPtr< AllocBufferFrameNode > data)
Definition: frame.h:688
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:313
static void RegisterReflection()
Definition: frame.h:322
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:318
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:320
PrimExpr condition
The PrimExpr to test.
Definition: frame.h:316
Managed reference to AssertFrameNode.
Definition: frame.h:345
AssertFrame(ffi::ObjectPtr< AssertFrameNode > data)
Definition: frame.h:347
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition: frame.h:405
ffi::String attr_key
Attribute type key.
Definition: frame.h:410
Any node
The node to annotate the attribute.
Definition: frame.h:408
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:414
PrimExpr value
The value of the attribute.
Definition: frame.h:412
Managed reference to AttrFrameNode.
Definition: frame.h:437
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrFrame, TIRFrame, AttrFrameNode)
AttrFrame(ffi::ObjectPtr< AttrFrameNode > data)
Definition: frame.h:439
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:645
static void RegisterReflection()
Definition: frame.h:647
ffi::Map< ffi::String, tvm::tirx::Buffer > workspace
The workspace of the compose op.
Definition: frame.h:641
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:643
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:663
static void RegisterReflection()
Definition: frame.h:617
bool allocated
The buffer allocated or not.
Definition: frame.h:615
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::tirx::Buffer buffer
The declared buffer.
Definition: frame.h:613
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:632
A frame that represents else.
Definition: frame.h:574
void EnterWithScope() final
The method called when entering RAII scope.
static void RegisterReflection()
Definition: frame.h:576
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameNode, TIRFrameNode)
Managed reference to ElseFrameNode.
Definition: frame.h:601
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, TIRFrame, ElseFrameNode)
ElseFrame(ffi::ObjectPtr< ElseFrameNode > data)
Definition: frame.h:603
A frame that represents the for loop.
Definition: frame.h:255
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:266
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:274
static void RegisterReflection()
Definition: frame.h:276
ffi::Array< Range > doms
The domains of iteration.
Definition: frame.h:270
ffi::Array< tvm::tirx::Var > vars
The loop variable.
Definition: frame.h:268
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< ffi::Optional< PrimExpr > > steps
The optional steps of iteration.
Definition: frame.h:272
Managed reference to ForFrameNode.
Definition: frame.h:298
ForFrame(ffi::ObjectPtr< ForFrameNode > data)
Definition: frame.h:300
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, TIRFrame, ForFrameNode)
A frame that represents a hint directive for the sketch language.
Definition: frame.h:701
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:704
static void RegisterReflection()
Definition: frame.h:708
ffi::Map< ffi::String, ffi::Any > attrs
Optional structured key-value attributes.
Definition: frame.h:706
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to HintFrameNode.
Definition: frame.h:726
HintFrame(ffi::ObjectPtr< HintFrameNode > data)
Definition: frame.h:728
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(HintFrame, TIRFrame, HintFrameNode)
A frame that represents if statement.
Definition: frame.h:490
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:497
ffi::Optional< ffi::Array< tvm::tirx::Stmt > > then_stmts
The statements in the true branch.
Definition: frame.h:495
void ExitWithScope() final
The method called when exiting RAII scope.
PrimExpr condition
The condition of the if statement.
Definition: frame.h:493
static void RegisterReflection()
Definition: frame.h:499
Managed reference to IfFrameNode.
Definition: frame.h:521
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, TIRFrame, IfFrameNode)
IfFrame(ffi::ObjectPtr< IfFrameNode > data)
Definition: frame.h:523
The LaunchThreadFrameNode.
Definition: frame.h:358
PrimExpr extent
The extent of environment thread.
Definition: frame.h:361
tvm::tirx::IterVar iter_var
The iteration variable.
Definition: frame.h:365
ffi::String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition: frame.h:363
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:367
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.LaunchThreadFrame", LaunchThreadFrameNode, TIRFrameNode)
Managed reference to LaunchThreadFrameNode.
Definition: frame.h:390
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
LaunchThreadFrame(ffi::ObjectPtr< LaunchThreadFrameNode > data)
Definition: frame.h:392
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:534
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:536
Managed reference to ThenFrameNode.
Definition: frame.h:561
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, TIRFrame, ThenFrameNode)
ThenFrame(ffi::ObjectPtr< ThenFrameNode > data)
Definition: frame.h:563
A frame that represents while loop.
Definition: frame.h:451
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameNode, TIRFrameNode)
PrimExpr condition
The termination condition of while.
Definition: frame.h:454
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:456
Managed reference to WhileFrameNode.
Definition: frame.h:476
WhileFrame(ffi::ObjectPtr< WhileFrameNode > data)
Definition: frame.h:478
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:187
Iteration Variable, represents an iteration over an integer interval.
Definition: var.h:274
Container of all statements.
Definition: stmt.h:64
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:40
TIR statements.