24 #ifndef MXNET_RESOURCE_H_ 25 #define MXNET_RESOURCE_H_ 27 #include <dmlc/logging.h> 82 template<
typename xpu,
typename DType>
84 mshadow::Stream<xpu> *stream)
const {
86 mshadow::Random<xpu, DType> *ret =
87 static_cast<mshadow::Random<xpu, DType>*
>(ptr_);
88 ret->set_stream(stream);
107 template<
typename xpu,
int ndim>
109 mshadow::Shape<ndim> shape, mshadow::Stream<xpu> *stream)
const {
110 return get_space_typed<xpu, ndim, real_t>(shape, stream);
122 mshadow::Shape<ndim> shape)
const {
123 return get_host_space_typed<cpu, ndim, real_t>(shape);
135 template<
typename xpu,
int ndim,
typename DType>
137 mshadow::Shape<ndim> shape, mshadow::Stream<xpu> *stream)
const {
139 return mshadow::Tensor<xpu, ndim, DType>(
140 reinterpret_cast<DType*
>(get_space_internal(shape.Size() *
sizeof(DType))),
141 shape, shape[ndim - 1], stream);
152 template<
int ndim,
typename DType>
154 mshadow::Shape<ndim> shape)
const {
155 return mshadow::Tensor<cpu, ndim, DType>(
156 reinterpret_cast<DType*
>(get_host_space_internal(shape.Size() *
sizeof(DType))),
157 shape, shape[ndim - 1], NULL);
164 void* get_space_internal(
size_t size)
const;
170 void *get_host_space_internal(
size_t size)
const;
189 virtual void SeedRandom(uint32_t seed) = 0;
198 #endif // MXNET_RESOURCE_H_ Engine that schedules all the operations according to dependency.
engine::VarHandle var
engine variable
Definition: resource.h:66
namespace of mxnet
Definition: base.h:126
int32_t id
identifier of id information, used for debug purpose
Definition: resource.h:68
The resources that can be requested by Operator.
Definition: resource.h:36
ResourceRequest(Type type)
constructor, allow implicit conversion
Definition: resource.h:52
ResourceRequest req
The original request.
Definition: resource.h:64
Type type
type of resources
Definition: resource.h:45
A dynamic temp space that can be arbitrary size.
Definition: resource.h:42
mshadow::Tensor< cpu, ndim, DType > get_host_space_typed(mshadow::Shape< ndim > shape) const
Get CPU space as mshadow Tensor in specified type. The caller can request arbitrary size...
Definition: resource.h:153
Global resource manager.
Definition: resource.h:174
Resources used by mxnet operations. A resource is something special other than NDArray, but will still participate.
Definition: resource.h:62
mshadow::Random< xpu, DType > * get_random(mshadow::Stream< xpu > *stream) const
Get random number generator.
Definition: resource.h:83
mshadow::Tensor< xpu, ndim, DType > get_space_typed(mshadow::Shape< ndim > shape, mshadow::Stream< xpu > *stream) const
Get space requested as mshadow Tensor in specified type. The caller can request arbitrary size...
Definition: resource.h:136
mshadow::Tensor< xpu, ndim, real_t > get_space(mshadow::Shape< ndim > shape, mshadow::Stream< xpu > *stream) const
Get space requested as mshadow Tensor. The caller can request arbitrary size.
Definition: resource.h:108
ResourceRequest()
default constructor
Definition: resource.h:47
virtual ~ResourceManager() DMLC_THROW_EXCEPTION
virtual destructor
Definition: resource.h:191
Type
Resource type, indicating what the pointer type is.
Definition: resource.h:38
Resource()
default constructor
Definition: resource.h:75
Var * VarHandle
Variable pointer type, usually hold by user used to specify dependencies.
Definition: engine.h:46
mshadow::Tensor< cpu, ndim, real_t > get_host_space(mshadow::Shape< ndim > shape) const
Get cpu space requested as mshadow Tensor. The caller can request arbitrary size. ...
Definition: resource.h:121
mshadow::Random<xpu> object
Definition: resource.h:40
void * ptr_
pointer to the resource, do not use directly, access using member functions
Definition: resource.h:73
Context information about the execution environment.
Definition: base.h:141