You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by kp...@apache.org on 2022/07/15 16:51:12 UTC
[tvm] branch main updated: Add member object accessors to With<> (#12100)
This is an automated email from the ASF dual-hosted git repository.
kparzysz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 770738c514 Add member object accessors to With<> (#12100)
770738c514 is described below
commit 770738c51442579b0f56eb6c6d341ec73fa33e7f
Author: Krzysztof Parzyszek <kp...@quicinc.com>
AuthorDate: Fri Jul 15 11:51:05 2022 -0500
Add member object accessors to With<> (#12100)
* Add member object accessors to With<>
Currently the With<> template constructs an object, but gives no access
to it, so it's only applicable to situations where we rely on the side-
effects of creating the object.
* Restart CI
---
include/tvm/support/with.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/tvm/support/with.h b/include/tvm/support/with.h
index d4547a304e..3651e05e74 100644
--- a/include/tvm/support/with.h
+++ b/include/tvm/support/with.h
@@ -67,6 +67,14 @@ class With {
/*! \brief destructor, leaves the scope of the context. */
~With() DMLC_THROW_EXCEPTION { ctx_.ExitWithScope(); }
+ ContextType* get() { return &ctx_; }
+ const ContextType* get() const { return &ctx_; }
+
+ ContextType* operator->() { return get(); }
+ const ContextType* operator->() const { return get(); }
+ ContextType& operator*() { return *get(); }
+ const ContextType* operator*() const { return *get(); }
+
private:
/*! \brief internal context type. */
ContextType ctx_;