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/tir/stmt.h>
25 
26 #include <utility>
27 
28 namespace tvm {
29 namespace script {
30 namespace ir_builder {
31 namespace tir {
32 
39  public:
41  ffi::Array<tvm::tir::Stmt> stmts;
42 
43  static void RegisterReflection() {
44  namespace refl = tvm::ffi::reflection;
45  refl::ObjectDef<TIRFrameNode>().def_ro("stmts", &TIRFrameNode::stmts);
46  }
47  TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.tir.TIRFrame", TIRFrameNode, IRBuilderFrameNode);
48 };
49 
55 class TIRFrame : public IRBuilderFrame {
56  public:
58 
59  protected:
60  TIRFrame() = default;
61  explicit TIRFrame(ObjectPtr<TIRFrameNode> data) : IRBuilderFrame(data) {}
62 };
63 
70  public:
72  ffi::Optional<ffi::String> name;
74  ffi::Array<tvm::tir::Var> args;
76  bool is_private;
78  ffi::Optional<Type> ret_type;
80  ffi::Map<tvm::tir::Var, tvm::tir::Buffer> buffer_map;
82  ffi::Map<ffi::String, Any> attrs;
84  ffi::Map<tvm::tir::Var, tvm::tir::IterVar> env_threads;
86  ffi::Array<tvm::tir::Buffer> root_alloc_buffers;
87 
88  static void RegisterReflection() {
89  namespace refl = tvm::ffi::reflection;
90  refl::ObjectDef<PrimFuncFrameNode>()
91  .def_ro("name", &PrimFuncFrameNode::name)
92  .def_ro("args", &PrimFuncFrameNode::args)
93  .def_ro("is_private", &PrimFuncFrameNode::is_private)
94  .def_ro("ret_type", &PrimFuncFrameNode::ret_type)
95  .def_ro("buffer_map", &PrimFuncFrameNode::buffer_map)
96  .def_ro("attrs", &PrimFuncFrameNode::attrs)
97  .def_ro("env_threads", &PrimFuncFrameNode::env_threads)
98  .def_ro("root_alloc_buffers", &PrimFuncFrameNode::root_alloc_buffers);
99  }
100  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.PrimFuncFrame", PrimFuncFrameNode,
101  TIRFrameNode);
102 
103  public:
108  void ExitWithScope() final;
109 };
110 
116 class PrimFuncFrame : public TIRFrame {
117  public:
118  explicit PrimFuncFrame(ObjectPtr<PrimFuncFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
119  TVM_FFI_ICHECK(data != nullptr);
120  data_ = std::move(data);
121  }
123 };
124 
130 class BlockFrameNode : public TIRFrameNode {
131  public:
133  ffi::String name;
135  ffi::Array<tvm::tir::IterVar> iter_vars;
137  ffi::Optional<ffi::Array<tvm::tir::BufferRegion>> reads;
139  ffi::Optional<ffi::Array<tvm::tir::BufferRegion>> writes;
141  ffi::Optional<tvm::tir::Stmt> init;
143  ffi::Array<tvm::tir::Buffer> alloc_buffers;
145  ffi::Array<tvm::tir::MatchBufferRegion> match_buffers;
147  ffi::Optional<ffi::Map<ffi::String, Any>> annotations;
149  ffi::Array<PrimExpr> iter_values;
154  ffi::Optional<PrimExpr> predicate;
157 
158  static void RegisterReflection() {
159  namespace refl = tvm::ffi::reflection;
160  refl::ObjectDef<BlockFrameNode>()
161  .def_ro("name", &BlockFrameNode::name)
162  .def_ro("iter_vars", &BlockFrameNode::iter_vars)
163  .def_ro("reads", &BlockFrameNode::reads)
164  .def_ro("writes", &BlockFrameNode::writes)
165  .def_ro("init", &BlockFrameNode::init)
166  .def_ro("alloc_buffers", &BlockFrameNode::alloc_buffers)
167  .def_ro("match_buffers", &BlockFrameNode::match_buffers)
168  .def_ro("annotations", &BlockFrameNode::annotations)
169  .def_ro("iter_values", &BlockFrameNode::iter_values)
170  .def_ro("predicate", &BlockFrameNode::predicate)
171  .def_ro("no_realize", &BlockFrameNode::no_realize);
172  }
173  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.BlockFrame", BlockFrameNode,
174  TIRFrameNode);
175 
176  public:
181  void ExitWithScope() final;
182 };
183 
190 class BlockFrame : public TIRFrame {
191  public:
192  explicit BlockFrame(ObjectPtr<BlockFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
193  TVM_FFI_ICHECK(data != nullptr);
194  data_ = std::move(data);
195  }
197 };
198 
205  public:
206  static void RegisterReflection() {
207  namespace refl = tvm::ffi::reflection;
208  refl::ObjectDef<BlockInitFrameNode>();
209  }
210  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.BlockInitFrame", BlockInitFrameNode,
211  TIRFrameNode);
212 
213  public:
218  void EnterWithScope() final;
223  void ExitWithScope() final;
224 };
225 
231 class BlockInitFrame : public TIRFrame {
232  public:
233  explicit BlockInitFrame(ObjectPtr<BlockInitFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
234  TVM_FFI_ICHECK(data != nullptr);
235  data_ = std::move(data);
236  }
238 };
239 
245 class ForFrameNode : public TIRFrameNode {
246  public:
254  using FMakeForLoop =
255  ffi::TypedFunction<tvm::tir::Stmt(ffi::Array<tvm::tir::Var> loop_vars,
256  ffi::Array<Range> loop_extents, tvm::tir::Stmt loop_body)>;
258  ffi::Array<tvm::tir::Var> vars;
260  ffi::Array<Range> doms;
263 
264  static void RegisterReflection() {
265  namespace refl = tvm::ffi::reflection;
266  refl::ObjectDef<ForFrameNode>()
267  .def_ro("vars", &ForFrameNode::vars)
268  .def_ro("doms", &ForFrameNode::doms);
269  // `f_make_for_loop` is not registered as it's not visited.
270  }
271  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ForFrame", ForFrameNode, TIRFrameNode);
272 
273  public:
278  void ExitWithScope() final;
279 };
280 
286 class ForFrame : public TIRFrame {
287  public:
288  explicit ForFrame(ObjectPtr<ForFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
289  TVM_FFI_ICHECK(data != nullptr);
290  data_ = std::move(data);
291  }
293 };
294 
302  public:
307 
308  static void RegisterReflection() {
309  namespace refl = tvm::ffi::reflection;
310  refl::ObjectDef<AssertFrameNode>()
311  .def_ro("condition", &AssertFrameNode::condition)
312  .def_ro("message", &AssertFrameNode::message);
313  }
314  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AssertFrame", AssertFrameNode,
315  TIRFrameNode);
316 
317  public:
322  void ExitWithScope() final;
323 };
324 
330 class AssertFrame : public TIRFrame {
331  public:
332  explicit AssertFrame(ObjectPtr<AssertFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
333  TVM_FFI_ICHECK(data != nullptr);
334  data_ = std::move(data);
335  }
337 };
338 
344 class LetFrameNode : public TIRFrameNode {
345  public:
350 
351  static void RegisterReflection() {
352  namespace refl = tvm::ffi::reflection;
353  refl::ObjectDef<LetFrameNode>()
354  .def_ro("var", &LetFrameNode::var)
355  .def_ro("value", &LetFrameNode::value);
356  }
357  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.LetFrame", LetFrameNode, TIRFrameNode);
358 
359  public:
364  void ExitWithScope() final;
365 };
366 
372 class LetFrame : public TIRFrame {
373  public:
374  explicit LetFrame(ObjectPtr<LetFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
375  TVM_FFI_ICHECK(data != nullptr);
376  data_ = std::move(data);
377  }
379 };
380 
386  public:
390  ffi::String attr_key;
393 
394  static void RegisterReflection() {
395  namespace refl = tvm::ffi::reflection;
396  refl::ObjectDef<LaunchThreadFrameNode>()
397  .def_ro("extent", &LaunchThreadFrameNode::extent)
398  .def_ro("attr_key", &LaunchThreadFrameNode::attr_key)
399  .def_ro("iter_var", &LaunchThreadFrameNode::iter_var);
400  }
401  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.LaunchThreadFrame",
403 
404  public:
409  void ExitWithScope() final;
410 };
411 
417 class LaunchThreadFrame : public TIRFrame {
418  public:
419  explicit LaunchThreadFrame(ObjectPtr<LaunchThreadFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
420  TVM_FFI_ICHECK(data != nullptr);
421  data_ = std::move(data);
422  }
424 };
425 
432  public:
436  ffi::String storage_scope;
439 
440  static void RegisterReflection() {
441  namespace refl = tvm::ffi::reflection;
442  refl::ObjectDef<RealizeFrameNode>()
443  .def_ro("buffer_slice", &RealizeFrameNode::buffer_slice)
444  .def_ro("storage_scope", &RealizeFrameNode::storage_scope)
445  .def_ro("condition", &RealizeFrameNode::condition);
446  }
447  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.RealizeFrame", RealizeFrameNode,
448  TIRFrameNode);
449 
450  public:
455  void ExitWithScope() final;
456 };
457 
463 class RealizeFrame : public TIRFrame {
464  public:
465  explicit RealizeFrame(ObjectPtr<RealizeFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
466  TVM_FFI_ICHECK(data != nullptr);
467  data_ = std::move(data);
468  }
470 };
471 
478  public:
480  ffi::Array<PrimExpr> extents;
484  ffi::String storage_scope;
488  ffi::Map<ffi::String, Any> annotations;
491 
492  static void RegisterReflection() {
493  namespace refl = tvm::ffi::reflection;
494  refl::ObjectDef<AllocateFrameNode>()
495  .def_ro("extents", &AllocateFrameNode::extents)
496  .def_ro("dtype", &AllocateFrameNode::dtype)
497  .def_ro("storage_scope", &AllocateFrameNode::storage_scope)
498  .def_ro("condition", &AllocateFrameNode::condition)
499  .def_ro("annotations", &AllocateFrameNode::annotations)
500  .def_ro("buffer_var", &AllocateFrameNode::buffer_var);
501  }
502  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AllocateFrame", AllocateFrameNode,
503  TIRFrameNode);
504 
505  public:
510  void ExitWithScope() final;
511 };
512 
518 class AllocateFrame : public TIRFrame {
519  public:
520  explicit AllocateFrame(ObjectPtr<AllocateFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
521  TVM_FFI_ICHECK(data != nullptr);
522  data_ = std::move(data);
523  }
525 };
526 
533  public:
537  ffi::Array<PrimExpr> extents;
543  ffi::Map<ffi::String, Any> annotations;
544 
545  static void RegisterReflection() {
546  namespace refl = tvm::ffi::reflection;
547  refl::ObjectDef<AllocateConstFrameNode>()
548  .def_ro("dtype", &AllocateConstFrameNode::dtype)
549  .def_ro("extents", &AllocateConstFrameNode::extents)
550  .def_ro("data", &AllocateConstFrameNode::data)
551  .def_ro("buffer_var", &AllocateConstFrameNode::buffer_var)
552  .def_ro("annotations", &AllocateConstFrameNode::annotations);
553  }
554  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AllocateConstFrame",
556 
557  public:
562  void ExitWithScope() final;
563 };
564 
570 class AllocateConstFrame : public TIRFrame {
571  public:
572  explicit AllocateConstFrame(ObjectPtr<AllocateConstFrameNode> data)
573  : TIRFrame(ffi::UnsafeInit{}) {
574  TVM_FFI_ICHECK(data != nullptr);
575  data_ = std::move(data);
576  }
579 };
585 class AttrFrameNode : public TIRFrameNode {
586  public:
588  Any node;
590  ffi::String attr_key;
593 
594  static void RegisterReflection() {
595  namespace refl = tvm::ffi::reflection;
596  refl::ObjectDef<AttrFrameNode>()
597  .def_ro("node", &AttrFrameNode::node)
598  .def_ro("attr_key", &AttrFrameNode::attr_key)
599  .def_ro("value", &AttrFrameNode::value);
600  }
601  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AttrFrame", AttrFrameNode, TIRFrameNode);
602 
603  public:
608  void ExitWithScope() final;
609 };
610 
616 class AttrFrame : public TIRFrame {
617  public:
618  explicit AttrFrame(ObjectPtr<AttrFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
619  TVM_FFI_ICHECK(data != nullptr);
620  data_ = std::move(data);
621  }
623 };
624 
630 class WhileFrameNode : public TIRFrameNode {
631  public:
634 
635  static void RegisterReflection() {
636  namespace refl = tvm::ffi::reflection;
637  refl::ObjectDef<WhileFrameNode>().def_ro("condition", &WhileFrameNode::condition);
638  }
639  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.WhileFrame", WhileFrameNode,
640  TIRFrameNode);
641 
642  public:
647  void ExitWithScope() final;
648 };
649 
655 class WhileFrame : public TIRFrame {
656  public:
657  explicit WhileFrame(ObjectPtr<WhileFrameNode> data) : TIRFrame(ffi::UnsafeInit{}) {
658  TVM_FFI_ICHECK(data != nullptr);
659  data_ = std::move(data);
660  }
662 };
663 
669 class IfFrameNode : public TIRFrameNode {
670  public:
674  ffi::Optional<ffi::Array<tvm::tir::Stmt>> then_stmts;
676  ffi::Optional<ffi::Array<tvm::tir::Stmt>> else_stmts;
677 
678  static void RegisterReflection() {
679  namespace refl = tvm::ffi::reflection;
680  refl::ObjectDef<IfFrameNode>()
681  .def_ro("condition", &IfFrameNode::condition)
682  .def_ro("then_stmts", &IfFrameNode::then_stmts)
683  .def_ro("else_stmts", &IfFrameNode::else_stmts);
684  }
685  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.IfFrame", IfFrameNode, TIRFrameNode);
686 
687  public:
692  void ExitWithScope() final;
693 };
694 
700 class IfFrame : public TIRFrame {
701  public:
702  explicit IfFrame(ObjectPtr<IfFrameNode> data) : TIRFrame(data) {
703  TVM_FFI_ICHECK(data != nullptr);
704  }
706 };
707 
713 class ThenFrameNode : public TIRFrameNode {
714  public:
715  static void RegisterReflection() {
716  namespace refl = tvm::ffi::reflection;
717  refl::ObjectDef<ThenFrameNode>();
718  }
719  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ThenFrame", ThenFrameNode, TIRFrameNode);
720 
721  public:
726  void EnterWithScope() final;
731  void ExitWithScope() final;
732 };
733 
739 class ThenFrame : public TIRFrame {
740  public:
741  explicit ThenFrame(ObjectPtr<ThenFrameNode> data) : TIRFrame(data) {
742  TVM_FFI_ICHECK(data != nullptr);
743  }
745 };
746 
752 class ElseFrameNode : public TIRFrameNode {
753  public:
754  static void RegisterReflection() {
755  namespace refl = tvm::ffi::reflection;
756  refl::ObjectDef<ElseFrameNode>();
757  }
758  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ElseFrame", ElseFrameNode, TIRFrameNode);
759 
760  public:
765  void EnterWithScope() final;
770  void ExitWithScope() final;
771 };
772 
778 class ElseFrame : public TIRFrame {
779  public:
780  explicit ElseFrame(ObjectPtr<ElseFrameNode> data) : TIRFrame(data) {
781  TVM_FFI_ICHECK(data != nullptr);
782  }
783 
785 };
786 
788  public:
792  bool allocated;
793 
794  static void RegisterReflection() {
795  namespace refl = tvm::ffi::reflection;
796  refl::ObjectDef<DeclBufferFrameNode>()
797  .def_ro("buffer", &DeclBufferFrameNode::buffer)
798  .def_ro("allocated", &DeclBufferFrameNode::allocated);
799  }
800  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.DeclBufferFrame", DeclBufferFrameNode,
801  TIRFrameNode);
802 
803  public:
804  void ExitWithScope() final;
805 };
806 
807 class DeclBufferFrame : public TIRFrame {
808  public:
809  explicit DeclBufferFrame(ObjectPtr<DeclBufferFrameNode> data) : TIRFrame(data) {
810  TVM_FFI_ICHECK(data != nullptr);
811  }
813 };
814 
815 } // namespace tir
816 } // namespace ir_builder
817 } // namespace script
818 } // namespace tvm
819 
820 #endif // TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
Reference to PrimExprNode.
Definition: expr.h:124
Runtime primitive data type.
Definition: data_type.h:47
Managed Tensor. The array is backed by reference counted blocks.
Definition: tensor.h:53
Managed reference to an IRBuilderFrameNode.
Definition: base.h:104
A frame represents the allocate constant.
Definition: frame.h:532
tvm::runtime::Tensor data
The data associated with the constant.
Definition: frame.h:539
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AllocateConstFrame", AllocateConstFrameNode, TIRFrameNode)
tvm::tir::Var buffer_var
The buffer var.
Definition: frame.h:541
ffi::Map< ffi::String, Any > annotations
Additional annotations about the allocation.
Definition: frame.h:543
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< PrimExpr > extents
The extents of the allocate.
Definition: frame.h:537
DataType dtype
The data type of the buffer.
Definition: frame.h:535
static void RegisterReflection()
Definition: frame.h:545
Managed reference to AllocateConstFrameNode.
Definition: frame.h:570
AllocateConstFrame(ObjectPtr< AllocateConstFrameNode > data)
Definition: frame.h:572
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AllocateConstFrame, TIRFrame, AllocateConstFrameNode)
A frame represents the allocate.
Definition: frame.h:477
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AllocateFrame", AllocateFrameNode, TIRFrameNode)
tvm::tir::Var buffer_var
The buffer var.
Definition: frame.h:490
ffi::Map< ffi::String, Any > annotations
Additional annotation hints.
Definition: frame.h:488
ffi::String storage_scope
The storage scope.
Definition: frame.h:484
DataType dtype
The data type of the buffer.
Definition: frame.h:482
PrimExpr condition
The condition.
Definition: frame.h:486
static void RegisterReflection()
Definition: frame.h:492
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< PrimExpr > extents
The extents of the allocate.
Definition: frame.h:480
Managed reference to AllocateFrameNode.
Definition: frame.h:518
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AllocateFrame, TIRFrame, AllocateFrameNode)
AllocateFrame(ObjectPtr< AllocateFrameNode > data)
Definition: frame.h:520
A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts wit...
Definition: frame.h:301
static void RegisterReflection()
Definition: frame.h:308
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AssertFrame", AssertFrameNode, TIRFrameNode)
PrimExpr message
The output error message when the assertion failed.
Definition: frame.h:306
PrimExpr condition
The PrimExpr to test.
Definition: frame.h:304
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to AssertFrameNode.
Definition: frame.h:330
AssertFrame(ObjectPtr< AssertFrameNode > data)
Definition: frame.h:332
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition: frame.h:585
ffi::String attr_key
Attribute type key.
Definition: frame.h:590
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:594
Any node
The node to annotate the attribute.
Definition: frame.h:588
PrimExpr value
The value of the attribute.
Definition: frame.h:592
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AttrFrame", AttrFrameNode, TIRFrameNode)
Managed reference to AttrFrameNode.
Definition: frame.h:616
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrFrame, TIRFrame, AttrFrameNode)
AttrFrame(ObjectPtr< AttrFrameNode > data)
Definition: frame.h:618
A frame that represents the block.
Definition: frame.h:130
ffi::Optional< PrimExpr > predicate
The predicate of the block realization, the block will only be executed when the predicate is true.
Definition: frame.h:154
ffi::Array< tvm::tir::IterVar > iter_vars
The variables of the block.
Definition: frame.h:135
ffi::Optional< ffi::Array< tvm::tir::BufferRegion > > writes
The write buffer regions of the block.
Definition: frame.h:139
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< tvm::tir::Buffer > alloc_buffers
The buffer allocated in the block.
Definition: frame.h:143
static void RegisterReflection()
Definition: frame.h:158
ffi::String name
The name of the block.
Definition: frame.h:133
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.BlockFrame", BlockFrameNode, TIRFrameNode)
ffi::Optional< tvm::tir::Stmt > init
The init statement of the bolck.
Definition: frame.h:141
ffi::Array< PrimExpr > iter_values
The corresponding values of the iter vars.
Definition: frame.h:149
ffi::Optional< ffi::Map< ffi::String, Any > > annotations
The annotation of the block.
Definition: frame.h:147
ffi::Array< tvm::tir::MatchBufferRegion > match_buffers
The match buffer regions.
Definition: frame.h:145
ffi::Optional< ffi::Array< tvm::tir::BufferRegion > > reads
The read buffer regions of the block.
Definition: frame.h:137
bool no_realize
The flag whether to construct BlockRealize or Block.
Definition: frame.h:156
Managed reference to BlockFrameNode.
Definition: frame.h:190
BlockFrame(ObjectPtr< BlockFrameNode > data)
Definition: frame.h:192
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BlockFrame, TIRFrame, BlockFrameNode)
A frame that represents the block initialization statment.
Definition: frame.h:204
static void RegisterReflection()
Definition: frame.h:206
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.BlockInitFrame", BlockInitFrameNode, TIRFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to BlockInitFrameNode.
Definition: frame.h:231
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BlockInitFrame, TIRFrame, BlockInitFrameNode)
BlockInitFrame(ObjectPtr< BlockInitFrameNode > data)
Definition: frame.h:233
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:794
tvm::tir::Buffer buffer
The declared buffer.
Definition: frame.h:790
bool allocated
The buffer allocated or not.
Definition: frame.h:792
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.DeclBufferFrame", DeclBufferFrameNode, TIRFrameNode)
DeclBufferFrame(ObjectPtr< DeclBufferFrameNode > data)
Definition: frame.h:809
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DeclBufferFrame, TIRFrame, DeclBufferFrameNode)
A frame that represents else.
Definition: frame.h:752
static void RegisterReflection()
Definition: frame.h:754
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ElseFrame", ElseFrameNode, TIRFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ElseFrameNode.
Definition: frame.h:778
ElseFrame(ObjectPtr< ElseFrameNode > data)
Definition: frame.h:780
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, TIRFrame, ElseFrameNode)
A frame that represents the for loop.
Definition: frame.h:245
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ForFrame", ForFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:264
ffi::Array< Range > doms
The domains of iteration.
Definition: frame.h:260
FMakeForLoop f_make_for_loop
The for loop generating function.
Definition: frame.h:262
ffi::Array< tvm::tir::Var > vars
The loop variable.
Definition: frame.h:258
ffi::TypedFunction< tvm::tir::Stmt(ffi::Array< tvm::tir::Var > loop_vars, ffi::Array< Range > loop_extents, tvm::tir::Stmt loop_body)> FMakeForLoop
Functions that generate loop nests.
Definition: frame.h:256
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to ForFrameNode.
Definition: frame.h:286
ForFrame(ObjectPtr< ForFrameNode > data)
Definition: frame.h:288
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, TIRFrame, ForFrameNode)
A frame that represents if statement.
Definition: frame.h:669
ffi::Optional< ffi::Array< tvm::tir::Stmt > > then_stmts
The statements in the true branch.
Definition: frame.h:674
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.IfFrame", IfFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
PrimExpr condition
The condition of the if statement.
Definition: frame.h:672
ffi::Optional< ffi::Array< tvm::tir::Stmt > > else_stmts
The stetements in the false branch.
Definition: frame.h:676
static void RegisterReflection()
Definition: frame.h:678
Managed reference to IfFrameNode.
Definition: frame.h:700
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, TIRFrame, IfFrameNode)
IfFrame(ObjectPtr< IfFrameNode > data)
Definition: frame.h:702
The LaunchThreadFrameNode.
Definition: frame.h:385
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.LaunchThreadFrame", LaunchThreadFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::tir::IterVar iter_var
The iteration variable.
Definition: frame.h:392
ffi::String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition: frame.h:390
static void RegisterReflection()
Definition: frame.h:394
PrimExpr extent
The extent of environment thread.
Definition: frame.h:388
Managed reference to LaunchThreadFrameNode.
Definition: frame.h:417
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
LaunchThreadFrame(ObjectPtr< LaunchThreadFrameNode > data)
Definition: frame.h:419
A frame represents the let binding expression, which binds a var.
Definition: frame.h:344
tvm::tir::Var var
The variable we bind to.
Definition: frame.h:347
PrimExpr value
The value we bind var to.
Definition: frame.h:349
static void RegisterReflection()
Definition: frame.h:351
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.LetFrame", LetFrameNode, TIRFrameNode)
Managed reference to LetFrameNode.
Definition: frame.h:372
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LetFrame, TIRFrame, LetFrameNode)
LetFrame(ObjectPtr< LetFrameNode > data)
Definition: frame.h:374
A frame that represents the PrimFunc containing TIR statements.
Definition: frame.h:69
ffi::Array< tvm::tir::Buffer > root_alloc_buffers
The buffer allocated in root block.
Definition: frame.h:86
static void RegisterReflection()
Definition: frame.h:88
ffi::Map< tvm::tir::Var, tvm::tir::Buffer > buffer_map
Maps some parameters to specific Buffer data structures.
Definition: frame.h:80
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.PrimFuncFrame", PrimFuncFrameNode, TIRFrameNode)
ffi::Optional< Type > ret_type
The return type of the function.
Definition: frame.h:78
ffi::Array< tvm::tir::Var > args
Function parameters.
Definition: frame.h:74
ffi::Optional< ffi::String > name
The name of the block.
Definition: frame.h:72
ffi::Map< ffi::String, Any > attrs
Additional attributes storing the meta-data.
Definition: frame.h:82
bool is_private
Whether the PrimFunc is annotated as private.
Definition: frame.h:76
ffi::Map< tvm::tir::Var, tvm::tir::IterVar > env_threads
The variable map bound to thread env.
Definition: frame.h:84
Managed reference to PrimFuncFrameNode.
Definition: frame.h:116
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimFuncFrame, TIRFrame, PrimFuncFrameNode)
PrimFuncFrame(ObjectPtr< PrimFuncFrameNode > data)
Definition: frame.h:118
A frame that represents realization.
Definition: frame.h:431
static void RegisterReflection()
Definition: frame.h:440
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.RealizeFrame", RealizeFrameNode, TIRFrameNode)
PrimExpr condition
The condition expression.
Definition: frame.h:438
tvm::tir::BufferRegion buffer_slice
The region of buffer access.
Definition: frame.h:434
ffi::String storage_scope
The storage scope associated with this realization.
Definition: frame.h:436
Managed reference to RealizeFrameNode.
Definition: frame.h:463
RealizeFrame(ObjectPtr< RealizeFrameNode > data)
Definition: frame.h:465
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(RealizeFrame, TIRFrame, RealizeFrameNode)
A base frame that represents the TIR fame with body of statements.
Definition: frame.h:38
ffi::Array< tvm::tir::Stmt > stmts
The Stmt within in this frame.
Definition: frame.h:41
TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.tir.TIRFrame", TIRFrameNode, IRBuilderFrameNode)
static void RegisterReflection()
Definition: frame.h:43
Managed reference to TIRFrameNode.
Definition: frame.h:55
TIRFrame(ObjectPtr< TIRFrameNode > data)
Definition: frame.h:61
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TIRFrame, IRBuilderFrame, TIRFrameNode)
A frame that represents then.
Definition: frame.h:713
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ThenFrame", ThenFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:715
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ThenFrameNode.
Definition: frame.h:739
ThenFrame(ObjectPtr< ThenFrameNode > data)
Definition: frame.h:741
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, TIRFrame, ThenFrameNode)
A frame that represents while loop.
Definition: frame.h:630
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.WhileFrame", WhileFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:635
PrimExpr condition
The termination condition of while.
Definition: frame.h:633
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to WhileFrameNode.
Definition: frame.h:655
WhileFrame(ObjectPtr< WhileFrameNode > data)
Definition: frame.h:657
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileFrame, TIRFrame, WhileFrameNode)
Managed reference to BufferRegionNode.
Definition: stmt.h:846
Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types,...
Definition: buffer.h:156
Iteration Variable, represents an iteration over an integer interval.
Definition: var.h:297
Container of all statements.
Definition: stmt.h:63
a named variable in TIR
Definition: var.h:77
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
TIR statements.