A primitive to describe and store data. More...
Functions | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_desc_init_by_strides (mkldnn_memory_desc_t *memory_desc, int ndims, const mkldnn_dims_t dims, mkldnn_data_type_t data_type, const mkldnn_dims_t strides) |
Initializes a memory_desc memory descriptor using ndims , dims , data_type , and strides . More... | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_desc_init_by_tag (mkldnn_memory_desc_t *memory_desc, int ndims, const mkldnn_dims_t dims, mkldnn_data_type_t data_type, mkldnn_format_tag_t tag) |
Initializes a memory_desc memory descriptor using ndims , dims , data_type , and format tag . More... | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_desc_init_submemory (mkldnn_memory_desc_t *memory_desc, const mkldnn_memory_desc_t *parent_memory_desc, const mkldnn_dims_t dims, const mkldnn_dims_t offsets) |
Initializes a memory_desc for a given parent_memory_desc , with dims sizes and offsets . More... | |
int MKLDNN_API | mkldnn_memory_desc_equal (const mkldnn_memory_desc_t *lhs, const mkldnn_memory_desc_t *rhs) |
Compares two memory descriptors. More... | |
size_t MKLDNN_API | mkldnn_memory_desc_get_size (const mkldnn_memory_desc_t *memory_desc) |
Returns the size (in bytes) that is required for given memory_desc . | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_create (mkldnn_memory_t *memory, const mkldnn_memory_desc_t *memory_desc, mkldnn_engine_t engine, void *handle) |
Creates a memory for given memory_desc and engine . More... | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_get_memory_desc (const_mkldnn_memory_t memory, const mkldnn_memory_desc_t **memory_desc) |
Returns a memory_desc associated with memory . | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_get_engine (const_mkldnn_memory_t memory, mkldnn_engine_t *engine) |
Returns an engine associated with memory . | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_map_data (const_mkldnn_memory_t memory, void **mapped_ptr) |
For a memory , maps the data of the memory to mapped_ptr . More... | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_unmap_data (const_mkldnn_memory_t memory, void *mapped_ptr) |
For a memory , unmaps a mapped pointer to the data of the memory. More... | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_get_data_handle (const_mkldnn_memory_t memory, void **handle) |
For a memory , returns the data handle . More... | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_set_data_handle (mkldnn_memory_t memory, void *handle) |
For a memory , sets the data handle . | |
mkldnn_status_t MKLDNN_API | mkldnn_memory_destroy (mkldnn_memory_t memory) |
Deletes a memory . | |
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 can be created using mkldnn_memory_create() function. A memory can also be queried for the underlying memory descriptor and engine using mkldnn_memory_get_memory_desc() and mkldnn_memory_get_engine() functions.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 output 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_by_strides | ( | mkldnn_memory_desc_t * | memory_desc, |
int | ndims, | ||
const mkldnn_dims_t | dims, | ||
mkldnn_data_type_t | data_type, | ||
const mkldnn_dims_t | strides | ||
) |
Initializes a memory_desc
memory descriptor using ndims
, dims
, data_type
, and strides
.
The strides
might be NULL, which means the order of physical dimensions is the same as the order of logical ones.
mkldnn_status_t MKLDNN_API mkldnn_memory_desc_init_by_tag | ( | mkldnn_memory_desc_t * | memory_desc, |
int | ndims, | ||
const mkldnn_dims_t | dims, | ||
mkldnn_data_type_t | data_type, | ||
mkldnn_format_tag_t | tag | ||
) |
Initializes a memory_desc
memory descriptor using ndims
, dims
, data_type
, and format tag
.
tag
can be mkldnn_format_tag_any, which allows a primitive to define the appropriate memory format. In this case, the format_kind
would be set to mkldnn_format_kind_any
mkldnn_status_t MKLDNN_API mkldnn_memory_desc_init_submemory | ( | mkldnn_memory_desc_t * | memory_desc, |
const mkldnn_memory_desc_t * | parent_memory_desc, | ||
const mkldnn_dims_t | dims, | ||
const mkldnn_dims_t | offsets | ||
) |
Initializes a memory_desc
for a given parent_memory_desc
, with dims
sizes and offsets
.
May fail if layout used does not allow obtain desired submemory. In this case consider using extract
or insert
primitive
int MKLDNN_API mkldnn_memory_desc_equal | ( | const mkldnn_memory_desc_t * | lhs, |
const mkldnn_memory_desc_t * | rhs | ||
) |
Compares two memory descriptors.
Use this function to identify whether a reorder is required between the two memories
mkldnn_status_t MKLDNN_API mkldnn_memory_create | ( | mkldnn_memory_t * | memory, |
const mkldnn_memory_desc_t * | memory_desc, | ||
mkldnn_engine_t | engine, | ||
void * | handle | ||
) |
Creates a memory for given memory_desc
and engine
.
Also sets handle
to one of the following:
mkldnn_status_t MKLDNN_API mkldnn_memory_map_data | ( | const_mkldnn_memory_t | memory, |
void ** | mapped_ptr | ||
) |
For a memory
, maps the data of the memory to mapped_ptr
.
Mapping allows to read/write directly from/to the memory contents for engines that do not support direct memory access.
Mapping is an exclusive operation - a memory object cannot be used in other operations until this memory object is unmapped.
memory
should be completed before mapping the memory. Use mkldnn_stream_wait to synchronize the corresponding execution stream.mkldnn_status_t MKLDNN_API mkldnn_memory_unmap_data | ( | const_mkldnn_memory_t | memory, |
void * | mapped_ptr | ||
) |
For a memory
, unmaps a mapped pointer to the data of the memory.
Any changes of the mapped data are synchronized back to the memory after the call is complete. The mapped pointer must be obtained through a mkldnn_memory_map_data call.
mkldnn_status_t MKLDNN_API mkldnn_memory_get_data_handle | ( | const_mkldnn_memory_t | memory, |
void ** | handle | ||
) |
For a memory
, returns the data handle
.
For the CPU engine, the data handle is a pointer to the actual data.