25 #ifndef TVM_SUPPORT_WITH_H_ 26 #define TVM_SUPPORT_WITH_H_ 28 #include <dmlc/common.h> 57 template <
typename ContextType>
64 template <
typename... Args>
65 explicit With(Args&&... args) : ctx_(
std::forward<Args>(args)...) {
66 ctx_.EnterWithScope();
69 ~With() DMLC_THROW_EXCEPTION { ctx_.ExitWithScope(); }
80 ContextType*
get() {
return &ctx_; }
81 const ContextType*
get()
const {
return &ctx_; }
86 const ContextType*
operator*()
const {
return *
get(); }
96 #endif // TVM_SUPPORT_WITH_H_ ContextType operator()()
Definition: with.h:88
~With() DMLC_THROW_EXCEPTION
destructor, leaves the scope of the context.
Definition: with.h:69
With & operator=(const With &other)=delete
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
With(Args &&... args)
constructor. Enter the scope of the context.
Definition: with.h:65
Definition: loop_state.h:456
ContextType & operator*()
Definition: with.h:85
const ContextType * operator*() const
Definition: with.h:86
RAII wrapper function to enter and exit a context object similar to python's with syntax...
Definition: with.h:58
const ContextType * operator->() const
Definition: with.h:84
ContextType * operator->()
Definition: with.h:83