mxnet
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
object.h File Reference

A managed object in MXNet runtime. More...

#include <dmlc/logging.h>
#include <type_traits>
#include <string>
#include <utility>
#include "c_runtime_api.h"
#include <atomic>
Include dependency graph for object.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mxnet::runtime::Object
 base class of all object containers. More...
 
class  mxnet::runtime::ObjectPtr< T >
 A custom smart pointer for Object. More...
 
class  mxnet::runtime::ObjectRef
 Base class of all object reference. More...
 
struct  mxnet::runtime::ObjectHash
 ObjectRef hash functor. More...
 
struct  mxnet::runtime::ObjectEqual
 ObjectRef equal functor. More...
 

Namespaces

 mxnet
 namespace of mxnet
 
 mxnet::runtime
 

Macros

#define MXNET_OBJECT_ATOMIC_REF_COUNTER   1
 Whether or not use atomic reference counter. If the reference counter is not atomic, an object cannot be owned by multiple threads. We can, however, move an object across threads. More...
 
#define MXNET_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType)
 helper macro to declare a base object type that can be inheritated. More...
 
#define MXNET_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
 helper macro to declare type information in a final class. More...
 
#define MXNET_REGISTER_OBJECT_TYPE(TypeName)
 Helper macro to register the object type to runtime. Makes sure that the runtime type table is correctly populated. More...
 
#define MXNET_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
 
#define MXNET_DEFINE_OBJECT_REF_METHODS_MUT(TypeName, ParentType, ObjectName)
 

Typedefs

template<typename T >
using mxnet::NodePtr = runtime::ObjectPtr< T >
 

Enumerations

enum  mxnet::runtime::TypeIndex {
  mxnet::runtime::kRoot = 0, mxnet::runtime::kMXNetTensor = 1, mxnet::runtime::kMXNetClosure = 2, mxnet::runtime::kMXNetADT = 3,
  mxnet::runtime::kRuntimeModule = 4, mxnet::runtime::kEllipsis = 5, mxnet::runtime::kSlice = 6, mxnet::runtime::kInteger = 7,
  mxnet::runtime::kStaticIndexEnd, mxnet::runtime::kDynamic = kStaticIndexEnd
}
 list of the type index. More...
 

Functions

template<typename RefType , typename ObjectType >
RefType mxnet::runtime::GetRef (const ObjectType *ptr)
 Get a reference type from a raw object ptr type. More...
 
template<typename SubRef , typename BaseRef >
SubRef mxnet::runtime::Downcast (BaseRef ref)
 Downcast a base reference type to a more specific type. More...
 
template<typename BaseType , typename ObjectType >
ObjectPtr< BaseType > mxnet::runtime::GetObjectPtr (ObjectType *ptr)
 Get an object ptr type from a raw object ptr. More...
 
template<typename RefType , typename ObjType >
RefType mxnet::runtime::GetRef (const ObjType *ptr)
 
template<typename BaseType , typename ObjType >
ObjectPtr< BaseType > mxnet::runtime::GetObjectPtr (ObjType *ptr)
 

Detailed Description

A managed object in MXNet runtime.

Macro Definition Documentation

#define MXNET_DECLARE_BASE_OBJECT_INFO (   TypeName,
  ParentType 
)
Value:
static const uint32_t RuntimeTypeIndex() { \
if (TypeName::_type_index != ::mxnet::runtime::TypeIndex::kDynamic) { \
return TypeName::_type_index; \
} \
return _GetOrAllocRuntimeTypeIndex(); \
} \
static const uint32_t _GetOrAllocRuntimeTypeIndex() { \
static uint32_t tidx = GetOrAllocRuntimeTypeIndex( \
TypeName::_type_key, \
TypeName::_type_index, \
ParentType::_GetOrAllocRuntimeTypeIndex(), \
TypeName::_type_child_slots, \
TypeName::_type_child_slots_can_overflow); \
return tidx; \
} \
Type index is allocated during runtime.
Definition: object.h:63

helper macro to declare a base object type that can be inheritated.

Parameters
TypeNameThe name of the current type.
ParentTypeThe name of the ParentType
#define MXNET_DECLARE_FINAL_OBJECT_INFO (   TypeName,
  ParentType 
)
Value:
static const constexpr bool _type_final = true; \
static const constexpr int _type_child_slots = 0; \
MXNET_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType) \
#define MXNET_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType)
helper macro to declare a base object type that can be inheritated.
Definition: object.h:647

helper macro to declare type information in a final class.

Parameters
TypeNameThe name of the current type.
ParentTypeThe name of the ParentType
#define MXNET_DEFINE_OBJECT_REF_METHODS (   TypeName,
  ParentType,
  ObjectName 
)
Value:
TypeName() {} \
explicit TypeName( \
: ParentType(n) {} \
const ObjectName* operator->() const { \
return static_cast<const ObjectName*>(data_.get()); \
} \
operator bool() const { return data_ != nullptr; } \
using ContainerType = ObjectName;
A custom smart pointer for Object.
Definition: object.h:345
#define MXNET_DEFINE_OBJECT_REF_METHODS_MUT (   TypeName,
  ParentType,
  ObjectName 
)
Value:
TypeName() {} \
explicit TypeName( \
: ParentType(n) {} \
ObjectName* operator->() { \
return static_cast<ObjectName*>(data_.get()); \
} \
operator bool() const { return data_ != nullptr; } \
using ContainerType = ObjectName;
A custom smart pointer for Object.
Definition: object.h:345
#define MXNET_OBJECT_ATOMIC_REF_COUNTER   1

Whether or not use atomic reference counter. If the reference counter is not atomic, an object cannot be owned by multiple threads. We can, however, move an object across threads.

#define MXNET_REGISTER_OBJECT_TYPE (   TypeName)
Value:
static DMLC_ATTRIBUTE_UNUSED uint32_t __make_Object_tidx ## _ ## TypeName ## __ = \
TypeName::_GetOrAllocRuntimeTypeIndex()
#define DMLC_ATTRIBUTE_UNUSED
helper macro to supress unused warning
Definition: base.h:148

Helper macro to register the object type to runtime. Makes sure that the runtime type table is correctly populated.

Use this macro in the cc file for each terminal class.