25 #ifndef MXNET_RESOURCE_H_ 26 #define MXNET_RESOURCE_H_ 28 #include <dmlc/logging.h> 47 #if MXNET_USE_CUDNN == 1 51 #endif // MXNET_USE_CUDNN == 1 91 template<
typename xpu,
typename DType>
97 ret->set_stream(stream);
107 template<
typename xpu,
typename DType>
129 template<
typename xpu,
int ndim>
132 return get_space_typed<xpu, ndim, real_t>(shape, stream);
145 return get_host_space_typed<cpu, ndim, real_t>(shape);
157 template<
typename xpu,
int ndim,
typename DType>
162 reinterpret_cast<DType*
>(get_space_internal(shape.
Size() *
sizeof(DType))),
163 shape, shape[ndim - 1], stream);
165 #if MXNET_USE_CUDNN == 1 173 void get_cudnn_dropout_desc(
174 cudnnDropoutDescriptor_t* dropout_desc,
177 uint64_t seed)
const;
178 #endif // MXNET_USE_CUDNN == 1 189 template<
int ndim,
typename DType>
193 reinterpret_cast<DType*
>(get_host_space_internal(shape.
Size() *
sizeof(DType))),
194 shape, shape[ndim - 1],
nullptr);
201 void* get_space_internal(
size_t size)
const;
207 void *get_host_space_internal(
size_t size)
const;
226 virtual void SeedRandom(uint32_t seed) = 0;
231 virtual void SeedRandom(
Context ctx, uint32_t seed) = 0;
240 #endif // MXNET_RESOURCE_H_ random number generator
Definition: random.h:53
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:145
Engine that schedules all the operations according to dependency.
engine::VarHandle var
engine variable
Definition: resource.h:75
namespace of mxnet
Definition: api_registry.h:33
shape of a tensor
Definition: tensor.h:54
Definition: stream_gpu-inl.h:38
#define DMLC_THROW_EXCEPTION
Definition: base.h:224
int32_t id
identifier of id information, used for debug purpose
Definition: resource.h:77
The resources that can be requested by Operator.
Definition: resource.h:38
ResourceRequest(Type type)
constructor, allow implicit conversion
Definition: resource.h:61
Parallel random number generator.
ResourceRequest req
The original request.
Definition: resource.h:73
Type type
type of resources
Definition: resource.h:54
A dynamic temp space that can be arbitrary size.
Definition: resource.h:44
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:190
base class of engine variables.
Definition: engine.h:44
Global resource manager.
Definition: resource.h:211
Resources used by mxnet operations. A resource is something special other than NDArray, but will still participate.
Definition: resource.h:71
mshadow::Random< xpu, DType > * get_random(mshadow::Stream< xpu > *stream) const
Get random number generator.
Definition: resource.h:92
common::RandGenerator<xpu> object, which can be used in GPU kernel functions
Definition: resource.h:46
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:158
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:130
ResourceRequest()
default constructor
Definition: resource.h:56
virtual ~ResourceManager() DMLC_THROW_EXCEPTION
virtual destructor
Definition: resource.h:233
Type
Resource type, indicating what the pointer type is.
Definition: resource.h:40
Resource()
default constructor
Definition: resource.h:84
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:143
mshadow::Random<xpu> object
Definition: resource.h:42
Definition: random_generator.h:42
void * ptr_
pointer to the resource, do not use directly, access using member functions
Definition: resource.h:82
Context information about the execution environment.
Definition: base.h:102
general tensor
Definition: tensor.h:421
common::random::RandGenerator< xpu, DType > * get_parallel_random() const
Get parallel random number generator.
Definition: resource.h:108
computaion stream structure, used for asynchronous computations
Definition: tensor.h:384