Go to the documentation of this file.
24 #ifndef MXNET_RESOURCE_H_
25 #define MXNET_RESOURCE_H_
27 #include <dmlc/logging.h>
47 #if MXNET_USE_CUDNN == 1
51 #endif // MXNET_USE_CUDNN == 1
67 inline std::string __extract_fname(
const std::string& path) {
68 std::size_t last_dir_pos = path.find_last_of(
"/\\");
69 if (last_dir_pos == std::string::npos) {
72 return path.substr(last_dir_pos + 1);
76 #if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__)
77 #define MXNET_RESOURCE_DEFAULT_NAME_FARG(tag) \
78 std::string(tag) + " (" + __extract_fname(__builtin_FILE()) + " +" + \
79 std::to_string(__builtin_LINE()) + ")"
80 #else // !__GNUC__ || __clang__
81 #define MXNET_RESOURCE_DEFAULT_NAME_FARG(tag) \
82 std::string(tag) + " (" + __extract_fname(__FILE__) + " +" + std::to_string(__LINE__) + ")"
83 #endif // __GNUC__ && !__clang__
110 template <
typename xpu,
typename DType>
114 ret->set_stream(stream);
124 template <
typename xpu,
typename DType>
147 template <
typename xpu,
int ndim>
152 return get_space_typed<xpu, ndim, real_t>(shape, stream, name);
164 return get_host_space_typed<cpu, ndim, real_t>(shape);
177 template <
typename xpu,
int ndim,
typename DType>
189 #if MXNET_USE_CUDNN == 1
199 void get_cudnn_dropout_desc(
200 cudnnDropoutDescriptor_t* dropout_desc,
204 #endif // MXNET_USE_CUDNN == 1
215 template <
int ndim,
typename DType>
268 #endif // MXNET_RESOURCE_H_
namespace of mxnet
Definition: api_registry.h:33
MSHADOW_XINLINE index_t Size(void) const
Definition: tensor.h:158
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:163
Type
Resource type, indicating what the pointer type is.
Definition: resource.h:40
The resources that can be requested by Operator.
Definition: resource.h:38
computaion stream structure, used for asynchronous computations
Definition: tensor.h:488
common::random::RandGenerator< xpu, DType > * get_parallel_random() const
Get parallel random number generator.
Definition: resource.h:125
Resource()
default constructor
Definition: resource.h:103
void * get_host_space_internal(size_t size) const
internal function to get cpu space from resources.
int32_t id
identifier of id information, used for debug purpose
Definition: resource.h:96
engine::VarHandle var
engine variable
Definition: resource.h:94
ResourceRequest()
default constructor
Definition: resource.h:56
random number generator
Definition: random.h:45
Definition: random_generator.h:41
@ kRandom
mshadow::Random<xpu> object
Definition: resource.h:42
mshadow::Tensor< xpu, ndim, DType > get_space_typed(mshadow::Shape< ndim > shape, mshadow::Stream< xpu > *stream, const std::string &name=MXNET_RESOURCE_DEFAULT_NAME_FARG("temp_space")) const
Get space requested as mshadow Tensor in specified type. The caller can request arbitrary size.
Definition: resource.h:178
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:216
general tensor
Definition: tensor.h:525
ResourceRequest req
The original request.
Definition: resource.h:92
void * ptr_
pointer to the resource, do not use directly, access using member functions
Definition: resource.h:101
Global resource manager.
Definition: resource.h:239
static ResourceManager * Get()
void * get_space_internal(size_t size, const std::string &name) const
internal function to get space from resources.
Definition: stream_gpu-inl.h:37
#define MXNET_RESOURCE_DEFAULT_NAME_FARG(tag)
Definition: resource.h:81
virtual void SeedRandom(uint32_t seed)=0
Seed all the allocated random number generators.
Type type
type of resources
Definition: resource.h:54
mshadow::Random< xpu, DType > * get_random(mshadow::Stream< xpu > *stream) const
Get random number generator.
Definition: resource.h:111
Context information about the execution environment.
Definition: base.h:90
base class of engine variables.
Definition: engine.h:111
Resources used by mxnet operations. A resource is something special other than NDArray,...
Definition: resource.h:90
shape of a tensor
Definition: tensor.h:64
@ kTempSpace
A dynamic temp space that can be arbitrary size.
Definition: resource.h:44
mshadow::Tensor< xpu, ndim, real_t > get_space(mshadow::Shape< ndim > shape, mshadow::Stream< xpu > *stream, const std::string &name=MXNET_RESOURCE_DEFAULT_NAME_FARG("temp_space")) const
Get space requested as mshadow Tensor. The caller can request arbitrary size.
Definition: resource.h:148
virtual ~ResourceManager() DMLC_THROW_EXCEPTION
virtual destructor
Definition: resource.h:261
Engine that schedules all the operations according to dependency.
@ kParallelRandom
common::RandGenerator<xpu> object, which can be used in GPU kernel functions
Definition: resource.h:46
#define DMLC_THROW_EXCEPTION
Definition: base.h:233
virtual Resource Request(Context ctx, const ResourceRequest &req)=0
Get resource of requested type.
ResourceRequest(Type type)
constructor, allow implicit conversion
Definition: resource.h:61
configuration of MXNet as well as basic data structure.
Parallel random number generator.