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_; }
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition: with.h:58
With & operator=(With &&other)=delete
With(Args &&... args)
constructor. Enter the scope of the context.
Definition: with.h:65
const ContextType * operator*() const
Definition: with.h:86
With(With &&other)=delete
const ContextType * operator->() const
Definition: with.h:84
ContextType * get()
Definition: with.h:80
With & operator=(const With &other)=delete
ContextType operator()()
Definition: with.h:88
ContextType & operator*()
Definition: with.h:85
With(const With &other)=delete
const ContextType * get() const
Definition: with.h:81
ContextType * operator->()
Definition: with.h:83
~With() DMLC_THROW_EXCEPTION
destructor, leaves the scope of the context.
Definition: with.h:69
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36