mxnet
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
mxnet::runtime::ObjectRef Class Reference

Base class of all object reference. More...

#include <object.h>

Inheritance diagram for mxnet::runtime::ObjectRef:
Inheritance graph
Collaboration diagram for mxnet::runtime::ObjectRef:
Collaboration graph

Public Types

using ContainerType = Object
 type indicate the container type. More...
 

Public Member Functions

 ObjectRef ()=default
 default constructor More...
 
 ObjectRef (ObjectPtr< Object > data)
 Constructor from existing object ptr. More...
 
bool same_as (const ObjectRef &other) const
 Comparator. More...
 
bool operator== (const ObjectRef &other) const
 Comparator. More...
 
bool operator!= (const ObjectRef &other) const
 Comparator. More...
 
bool operator< (const ObjectRef &other) const
 Comparator. More...
 
bool defined () const
 
const Objectget () const
 
const Objectoperator-> () const
 
bool unique () const
 
template<typename ObjectType >
const ObjectType * as () const
 Try to downcast the internal Object to a raw pointer of a corresponding type. More...
 

Protected Member Functions

Objectget_mutable () const
 

Static Protected Member Functions

template<typename T >
static T DowncastNoCheck (ObjectRef ref)
 Internal helper function downcast a ref without check. More...
 
template<typename ObjectType >
static ObjectPtr< ObjectType > GetDataPtr (const ObjectRef &ref)
 Internal helper function get data_ as ObjectPtr of ObjectType. More...
 

Protected Attributes

ObjectPtr< Objectdata_
 Internal pointer that backs the reference. More...
 

Friends

struct ObjectHash
 
class MXNetRetValue
 
class MXNetArgsSetter
 
template<typename SubRef , typename BaseRef >
SubRef Downcast (BaseRef ref)
 Downcast a base reference type to a more specific type. More...
 

Detailed Description

Base class of all object reference.

Member Typedef Documentation

◆ ContainerType

type indicate the container type.

Constructor & Destructor Documentation

◆ ObjectRef() [1/2]

mxnet::runtime::ObjectRef::ObjectRef ( )
default

default constructor

◆ ObjectRef() [2/2]

mxnet::runtime::ObjectRef::ObjectRef ( ObjectPtr< Object data)
inlineexplicit

Constructor from existing object ptr.

Member Function Documentation

◆ as()

template<typename ObjectType >
const ObjectType * mxnet::runtime::ObjectRef::as ( ) const
inline

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 Add *add = node_ref.As<Add>()) { // This is an add node }

Template Parameters
ObjectTypethe target type, must be a subtype of Object/

◆ defined()

bool mxnet::runtime::ObjectRef::defined ( ) const
inline
Returns
whether the expression is null

◆ DowncastNoCheck()

template<typename T >
static T mxnet::runtime::ObjectRef::DowncastNoCheck ( ObjectRef  ref)
inlinestaticprotected

Internal helper function downcast a ref without check.

Note
Only used for internal dev purposes.
Template Parameters
TThe target reference type.
Returns
The casted result.

◆ get()

const Object* mxnet::runtime::ObjectRef::get ( ) const
inline
Returns
the internal object pointer

◆ get_mutable()

Object* mxnet::runtime::ObjectRef::get_mutable ( ) const
inlineprotected
Returns
return a mutable internal ptr, can be used by sub-classes.

◆ GetDataPtr()

template<typename ObjectType >
static ObjectPtr<ObjectType> mxnet::runtime::ObjectRef::GetDataPtr ( const ObjectRef ref)
inlinestaticprotected

Internal helper function get data_ as ObjectPtr of ObjectType.

Note
only used for internal dev purpose.
Template Parameters
ObjectTypeThe corresponding object type.
Returns
the corresponding type.

◆ operator!=()

bool mxnet::runtime::ObjectRef::operator!= ( const ObjectRef other) const
inline

Comparator.

Parameters
otherAnother object ref.
Returns
the compare result.

◆ operator->()

const Object* mxnet::runtime::ObjectRef::operator-> ( ) const
inline
Returns
the internal object pointer

◆ operator<()

bool mxnet::runtime::ObjectRef::operator< ( const ObjectRef other) const
inline

Comparator.

Parameters
otherAnother object ref by address.
Returns
the compare result.

◆ operator==()

bool mxnet::runtime::ObjectRef::operator== ( const ObjectRef other) const
inline

Comparator.

Parameters
otherAnother object ref.
Returns
the compare result.

◆ same_as()

bool mxnet::runtime::ObjectRef::same_as ( const ObjectRef other) const
inline

Comparator.

Parameters
otherAnother object ref.
Returns
the compare result.

◆ unique()

bool mxnet::runtime::ObjectRef::unique ( ) const
inline
Returns
whether the reference is unique

Friends And Related Function Documentation

◆ Downcast

template<typename SubRef , typename BaseRef >
SubRef Downcast ( BaseRef  ref)
friend

Downcast a base reference type to a more specific type.

Parameters
refThe inptut reference
Returns
The corresponding SubRef.
Template Parameters
SubRefThe target specific reference type.
BaseRefthe current reference type.

◆ MXNetArgsSetter

friend class MXNetArgsSetter
friend

◆ MXNetRetValue

friend class MXNetRetValue
friend

◆ ObjectHash

friend struct ObjectHash
friend

Member Data Documentation

◆ data_

ObjectPtr<Object> mxnet::runtime::ObjectRef::data_
protected

Internal pointer that backs the reference.


The documentation for this class was generated from the following file: