24 #ifndef MXNET_RESOURCE_H_ 25 #define MXNET_RESOURCE_H_ 27 #include <dmlc/logging.h> 46 #if MXNET_USE_CUDNN == 1 50 #endif // MXNET_USE_CUDNN == 1 90 template<
typename xpu,
typename DType>
96 ret->set_stream(stream);
106 template<
typename xpu,
typename DType>
128 template<
typename xpu,
int ndim>
131 return get_space_typed<xpu, ndim, real_t>(shape, stream);
144 return get_host_space_typed<cpu, ndim, real_t>(shape);
156 template<
typename xpu,
int ndim,
typename DType>
161 reinterpret_cast<DType*
>(get_space_internal(shape.
Size() *
sizeof(DType))),
162 shape, shape[ndim - 1], stream);
164 #if MXNET_USE_CUDNN == 1 172 void get_cudnn_dropout_desc(
173 cudnnDropoutDescriptor_t* dropout_desc,
176 uint64_t seed)
const;
177 #endif // MXNET_USE_CUDNN == 1 188 template<
int ndim,
typename DType>
192 reinterpret_cast<DType*
>(get_host_space_internal(shape.
Size() *
sizeof(DType))),
193 shape, shape[ndim - 1],
nullptr);
200 void* get_space_internal(
size_t size)
const;
206 void *get_host_space_internal(
size_t size)
const;
225 virtual void SeedRandom(uint32_t seed) = 0;
230 virtual void SeedRandom(
Context ctx, uint32_t seed) = 0;
239 #endif // MXNET_RESOURCE_H_ random number generator
Definition: random.h:52
Engine that schedules all the operations according to dependency.
engine::VarHandle var
engine variable
Definition: resource.h:74
namespace of mxnet
Definition: api_registry.h:33
shape of a tensor
Definition: tensor.h:53
common::random::RandGenerator< xpu, DType > * get_parallel_random() const
Get parallel random number generator.
Definition: resource.h:107
Definition: stream_gpu-inl.h:37
#define DMLC_THROW_EXCEPTION
Definition: base.h:233
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:129
int32_t id
identifier of id information, used for debug purpose
Definition: resource.h:76
The resources that can be requested by Operator.
Definition: resource.h:37
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:157
ResourceRequest(Type type)
constructor, allow implicit conversion
Definition: resource.h:60
Parallel random number generator.
mshadow::Random< xpu, DType > * get_random(mshadow::Stream< xpu > *stream) const
Get random number generator.
Definition: resource.h:91
ResourceRequest req
The original request.
Definition: resource.h:72
Type type
type of resources
Definition: resource.h:53
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:189
A dynamic temp space that can be arbitrary size.
Definition: resource.h:43
base class of engine variables.
Definition: engine.h:43
Global resource manager.
Definition: resource.h:210
Resources used by mxnet operations. A resource is something special other than NDArray, but will still participate.
Definition: resource.h:70
common::RandGenerator<xpu> object, which can be used in GPU kernel functions
Definition: resource.h:45
ResourceRequest()
default constructor
Definition: resource.h:55
virtual ~ResourceManager() DMLC_THROW_EXCEPTION
virtual destructor
Definition: resource.h:232
Type
Resource type, indicating what the pointer type is.
Definition: resource.h:39
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:142
Resource()
default constructor
Definition: resource.h:83
mshadow::Random<xpu> object
Definition: resource.h:41
Definition: random_generator.h:41
void * ptr_
pointer to the resource, do not use directly, access using member functions
Definition: resource.h:81
Context information about the execution environment.
Definition: base.h:101
general tensor
Definition: tensor.h:420
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:144
computaion stream structure, used for asynchronous computations
Definition: tensor.h:383