24 #ifndef TVM_IR_SCOPE_STACK_H_
25 #define TVM_IR_SCOPE_STACK_H_
27 #include <tvm/ffi/error.h>
30 #include <type_traits>
61 size_t size()
const {
return stack_.size(); }
64 bool empty()
const {
return stack_.empty(); }
75 TVM_FFI_ICHECK(!stack_.empty());
81 TVM_FFI_ICHECK(!stack_.empty());
95 stack_.emplace_back();
98 ~Guard() noexcept(
false) {
stack->pop_back(); }
100 if constexpr (std::is_void_v<decltype(body())>) {
118 std::deque<T> stack_;
A scope stack for maintaining hierarchical state during IR visiting.
Definition: scope_stack.h:55
ScopeStack()
Construct with one initial scope level.
Definition: scope_stack.h:58
bool empty() const
Return true if no scopes are active.
Definition: scope_stack.h:64
auto WithNewScope(F &&body) -> decltype(body())
Execute body within a new scope.
Definition: scope_stack.h:94
size_t size() const
Return the number of active scopes.
Definition: scope_stack.h:61
const T & Current() const
Const access to the current (innermost) scope element.
Definition: scope_stack.h:80
T & Current()
Access the current (innermost) scope element.
Definition: scope_stack.h:74
Tensor stack(const ffi::Array< Tensor > &inputs, int axis=0, std::string name="T_stack", std::string tag=kInjective)
Join a sequence of tensors along a new axis.
Definition: transform.h:541
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37