mxnet
|
A primitive to describe and store data.
The library supports various data types and formats. Memory hierarchy consists of three levels of abstraction:
void
.) The data handle can be queried using mkldnn_memory_get_data_handle() and set using mkldnn_memory_set_data_handle(). The latter function always sets the memory in the padding region to zero, which is the invariant maintained by all the primitives in Intel MKL-DNN. See understanding_memory_formats for more details. A memory primitive can be created using mkldnn_primitive_create() with empty inputs and outputs. In this case, the memory primitive's data handle must be set manually using mkldnn_memory_set_data_handle().Along with ordinary memory with all dimensions being positive, Intel MKL-DNN supports zero-volume memory with one or more dimensions set to zero. This is to support the NumPy* convention. If a zero-volume memory is passed to a primitive, the primitive does not perform any computations on this memory. For example:
(0 batch, 3 input channels, 13 height, 13 width)
source and (16 output channels, 3 inputs, channel, 3 height, 3 width)
weights would produce (0 batch, 16 ouput channels, 11 height, 11 width)
destination (assuming strides are 1
and paddings are zero) and perform zero multiply-add operations.(3, 4, 13, 13)
, (3, 0, 13, 13)
, and (3, 1, 13, 13)
along the second axis would produce the output of the shape (3, 5, 13, 13)
, effectively ignoring the second input (however, if the user created a concatenation primitive descriptor with three inputs they should also provide all three memories to the concatenation primitive, including the one with zero second dimension).Data handle of zero-volume memory is never accessed and hence can be unset (NULL in case of CPU engine).
mkldnn_status_t MKLDNN_API mkldnn_memory_desc_init | ( | mkldnn_memory_desc_t * | memory_desc, |
int | ndims, | ||
const mkldnn_dims_t | dims, | ||
mkldnn_data_type_t | data_type, | ||
mkldnn_memory_format_t | format | ||
) |
Initializes a memory_desc
memory descriptor using ndims
, dims
, data_type
, and data format
. format
can be mkldnn_any, which means that specific data layouts are not permitted.
mkldnn_status_t MKLDNN_API mkldnn_memory_get_data_handle | ( | const_mkldnn_primitive_t | memory, |
void ** | handle | ||
) |
For a memory
primitive, returns the data handle
. For the CPU engine, the data handle is a pointer to the actual data.
mkldnn_status_t MKLDNN_API mkldnn_memory_primitive_desc_create | ( | mkldnn_primitive_desc_t * | memory_primitive_desc, |
const mkldnn_memory_desc_t * | memory_desc, | ||
mkldnn_engine_t | engine | ||
) |
Creates a memory_primitive_desc
memory primitive descriptor using memory_desc
and engine
. memory_desc
cannot be uncertain; that is, it cannot be initialized with mkldnn_any.
int MKLDNN_API mkldnn_memory_primitive_desc_equal | ( | const_mkldnn_primitive_desc_t | lhs, |
const_mkldnn_primitive_desc_t | rhs | ||
) |
Compares two descriptors of memory primitives.
Use this function to identify whether a reorder is required for the memory primitives. lhs
and rhs
must be either memory or view primitive descriptors.
size_t MKLDNN_API mkldnn_memory_primitive_desc_get_size | ( | const_mkldnn_primitive_desc_t | memory_primitive_desc | ) |
Returns the size (in bytes) that is required for given memory_primitive_desc
mkldnn_status_t MKLDNN_API mkldnn_memory_set_data_handle | ( | mkldnn_primitive_t | memory, |
void * | handle | ||
) |
For a memory
primitive, sets the data handle
.
mkldnn_status_t MKLDNN_API mkldnn_view_primitive_desc_create | ( | mkldnn_primitive_desc_t * | view_primitive_desc, |
const_mkldnn_primitive_desc_t | memory_primitive_desc, | ||
const mkldnn_dims_t | dims, | ||
const mkldnn_dims_t | offsets | ||
) |
Creates a view_primitive_desc
for a given memory_primitive_desc
, with dims
sizes and offsets
offsets. May fail if the format used does not allow obtaining the desired view. In this case, consider using the extract primitive.