Class ObjectRef#
Defined in File object.h
Inheritance Relationships#
Derived Types#
public tvm::ffi::Array< tvm::ffi::Any >
(Template Class Array)public tvm::ffi::Map< tvm::ffi::String, tvm::ffi::Function >
(Template Class Map)public tvm::ffi::Array< T, typename >
(Template Class Array)public tvm::ffi::Error
(Class Error)public tvm::ffi::Function
(Class Function)public tvm::ffi::Map< K, V, typename >
(Template Class Map)public tvm::ffi::Module
(Class Module)public tvm::ffi::Optional< T, std::enable_if_t< use_ptr_based_optional_v< T > > >
public tvm::ffi::Shape
(Class Shape)public tvm::ffi::Tensor
(Class Tensor)public tvm::ffi::Tuple< Types >
(Template Class Tuple)public tvm::ffi::details::VariantBase< true >
public tvm::ffi::reflection::AccessPath
(Class AccessPath)public tvm::ffi::reflection::AccessStep
(Class AccessStep)
Class Documentation#
-
class ObjectRef#
Base class of all object reference.
Subclassed by tvm::ffi::Array< tvm::ffi::Any >, tvm::ffi::Map< tvm::ffi::String, tvm::ffi::Function >, tvm::ffi::Array< T, typename >, tvm::ffi::Error, tvm::ffi::Function, tvm::ffi::Map< K, V, typename >, tvm::ffi::Module, tvm::ffi::Optional< T, std::enable_if_t< use_ptr_based_optional_v< T > > >, tvm::ffi::Shape, tvm::ffi::Tensor, tvm::ffi::Tuple< Types >, tvm::ffi::details::VariantBase< true >, tvm::ffi::reflection::AccessPath, tvm::ffi::reflection::AccessStep
Public Functions
-
ObjectRef() = default#
default constructor
-
inline explicit ObjectRef(UnsafeInit)#
Constructor from UnsafeInit.
-
inline bool same_as(const ObjectRef &other) const#
Comparator.
- Parameters:
other – Another object ref.
- Returns:
the compare result.
-
inline bool defined() const#
- Returns:
whether the object is defined.
-
inline bool unique() const#
- Returns:
whether the reference is unique
-
inline int use_count() const#
- Returns:
The use count of the ptr, for debug purposes
-
template<typename ObjectType, typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>>
inline const ObjectType *as() const# Try to downcast the internal Object to a raw pointer of a corresponding type.
The function will return a nullptr if the cast failed.
if (const AddNode *ptr = node_ref.as<AddNode>()) { // This is an add node }
- Template Parameters:
ObjectType – the target type, must be a subtype of Object
- Returns:
The pointer to the requested type.
-
template<typename ObjectRefType, typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
inline std::optional<ObjectRefType> as() const# Try to downcast the ObjectRef to Optional<T> of the requested type.
The function will return a std::nullopt if the cast or if the pointer is nullptr.
- Template Parameters:
ObjectRefType – the target type, must be a subtype of ObjectRef’
- Returns:
The optional value of the requested type.
Public Static Attributes
-
static constexpr bool _type_is_nullable = true#
Whether the reference can point to nullptr.
Protected Functions
Friends
- friend struct ObjectPtrHash
-
ObjectRef() = default#