Intel(R) Math Kernel Library for Deep Neural Networks (Intel(R) MKL-DNN)  1.0.4
Performance library for Deep Learning
Classes | Public Types | Public Member Functions | List of all members
mkldnn::memory Struct Reference

Memory that describes the data. More...

#include <mkldnn.hpp>

Inheritance diagram for mkldnn::memory:
Inheritance graph
[legend]
Collaboration diagram for mkldnn::memory:
Collaboration graph
[legend]

Classes

struct  desc
 A memory descriptor. More...
 

Public Types

enum  data_type {
  data_type::undef = mkldnn_data_type_undef, data_type::f16 = mkldnn_f16, data_type::bf16 = mkldnn_bf16, data_type::f32 = mkldnn_f32,
  data_type::s32 = mkldnn_s32, data_type::s8 = mkldnn_s8, data_type::u8 = mkldnn_u8
}
 Data type specification. More...
 
enum  format_kind {
  format_kind::undef = mkldnn_format_kind_undef, format_kind::any = mkldnn_format_kind_any, format_kind::blocked = mkldnn_blocked, format_kind::wino = mkldnn_format_kind_wino,
  format_kind::packed = mkldnn_format_kind_rnn_packed
}
 Memory format kind. More...
 
enum  format_tag {
  format_tag::undef = mkldnn_format_tag_undef, format_tag::any = mkldnn_format_tag_any, format_tag::a = mkldnn_a, format_tag::ab = mkldnn_ab,
  format_tag::abc = mkldnn_abc, format_tag::abcd = mkldnn_abcd, format_tag::abcde = mkldnn_abcde, format_tag::abcdef = mkldnn_abcdef,
  format_tag::abdec = mkldnn_abdec, format_tag::acb = mkldnn_acb, format_tag::acbde = mkldnn_acbde, format_tag::acdb = mkldnn_acdb,
  format_tag::acdeb = mkldnn_acdeb, format_tag::ba = mkldnn_ba, format_tag::bac = mkldnn_bac, format_tag::bacd = mkldnn_bacd,
  format_tag::bcda = mkldnn_bcda, format_tag::cba = mkldnn_cba, format_tag::cdba = mkldnn_cdba, format_tag::cdeba = mkldnn_cdeba,
  format_tag::decab = mkldnn_decab , format_tag::aBcd8b = mkldnn_aBcd8b , format_tag::ABcd8b8a = mkldnn_ABcd8b8a , format_tag::nc = mkldnn_nc ,
  format_tag::nchw = mkldnn_nchw, format_tag::nhwc = mkldnn_nhwc, format_tag::chwn = mkldnn_chwn
}
 Memory format tag specification. More...
 

Public Member Functions

 memory (const desc &md, const engine &aengine, void *ahandle)
 Constructs a memory. More...
 
 memory (const desc &md, const engine &aengine)
 Constructs a memory. More...
 
desc get_desc () const
 Returns the descriptor of the memory.
 
engine get_engine () const
 Returns the engine of the memory.
 
void * get_data_handle () const
 Returns a handle of the data contained in the memory. More...
 
template<typename T = void>
T * map_data () const
 Maps the data of the memory. More...
 
void unmap_data (void *mapped_ptr) const
 Unmaps the previously mapped data for the memory. More...
 
- Public Member Functions inherited from mkldnn::handle< mkldnn_memory_t >
 handle (mkldnn_memory_t t, bool weak=false)
 Constructs a C handle wrapper. More...
 
 handle ()
 Empty constructor. More...
 
void reset (mkldnn_memory_t t, bool weak=false)
 Resets the value of a C handle. More...
 
mkldnn_memory_t get (bool allow_emtpy=false) const
 Returns the value of the underlying C handle.
 

Detailed Description

Memory that describes the data.

Examples:
cpu_cnn_inference_f32.cpp, cpu_cnn_inference_int8.cpp, cpu_cnn_training_bf16.cpp, cpu_cnn_training_f32.cpp, cpu_getting_started.cpp, cpu_memory_format_propagation.cpp, cpu_performance_profiling.cpp, cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, cpu_rnn_training_f32.cpp, gpu_getting_started.cpp, and gpu_opencl_interop.cpp.

Member Enumeration Documentation

◆ data_type

Data type specification.

Enumerator
undef 

Undefined data type, used for empty memory descriptors.

f16 

16-bit/half-precision floating point.

bf16 

non-standard 16-bit (bfloat16 w/ 7 bit mantissa) floating point.

f32 

32-bit/single-precision floating point.

s32 

32-bit signed integer.

s8 

8-bit signed integer.

u8 

8-bit unsigned integer.

Examples:
cpu_cnn_inference_f32.cpp, cpu_cnn_inference_int8.cpp, cpu_cnn_training_bf16.cpp, cpu_cnn_training_f32.cpp, and cpu_rnn_training_f32.cpp.

◆ format_kind

Memory format kind.

Enumerator
undef 

Undefined memory format kind, used for empty memory descriptors.

any 

Unspecified format kind.

The primitive selects a format automatically.

blocked 

A tensor in a generic format described by the stride and blocking values in each dimension.

See mkldnn_blocking_desc_t for more information.

wino 

Weights format used in 8bit Winograd convolution.

packed 

Packed weights format used in RNN.

◆ format_tag

Memory format tag specification.

See mkldnn_format_tag_t for a detailed description.

Enumerator
undef 

Undefined memory format tag.

any 

Placeholder memory format tag.

The primitive selects a format automatically.

plain 1D tensor

ab 

plain 2D tensor

abc 

plain 3D tensor

abcd 

plain 4D tensor

abcde 

plain 5D tensor

abcdef 

plain 6D tensor

abdec 

permuted 5D tensor

acb 

permuted 3D tensor

acbde 

permuted 5D tensor

acdb 

permuted 4D tensor

acdeb 

permuted 5D tensor

ba 

permuted 2D tensor

bac 

permuted 3D tensor

bacd 

permuted 4D tensor

bcda 

permuted 4D tensor

cba 

permuted 3D tensor

cdba 

permuted 4D tensor

cdeba 

permuted 5D tensor

decab 

permuted 5D tensor

aBcd8b 

4D tensor blocked by 2nd dimension with block size 8

ABcd8b8a 

4D tensor blocked by 1st and 2nd dimension with block size 8

nc 

2D CNN activations tensor, an alias to mkldnn::memory::format_tag::ab

nchw 

4D CNN activations tensor, an alias to mkldnn::memory::format_tag::abcd

nhwc 

4D CNN activations tensor, an alias to mkldnn::memory::format_tag::acdb

chwn 

4D CNN activations tensor, an alias to mkldnn::memory::format_tag::bcda

Examples:
cpu_cnn_inference_f32.cpp, cpu_cnn_inference_int8.cpp, cpu_cnn_training_bf16.cpp, cpu_cnn_training_f32.cpp, and cpu_rnn_training_f32.cpp.

Constructor & Destructor Documentation

◆ memory() [1/2]

mkldnn::memory::memory ( const desc md,
const engine aengine,
void *  ahandle 
)
inline

Constructs a memory.

Parameters
mdMemory descriptor.
aengineEngine.
ahandlehandle.

◆ memory() [2/2]

mkldnn::memory::memory ( const desc md,
const engine aengine 
)
inline

Constructs a memory.

Parameters
mdMemory descriptor.
aengineEngine.

Member Function Documentation

◆ get_data_handle()

void* mkldnn::memory::get_data_handle ( ) const
inline

Returns a handle of the data contained in the memory.

On the CPU engine, this is a pointer to the allocated memory.

Examples:
cpu_getting_started.cpp, cpu_performance_profiling.cpp, cpu_rnn_inference_f32.cpp, and cpu_rnn_inference_int8.cpp.

◆ map_data()

template<typename T = void>
T* mkldnn::memory::map_data ( ) const
inline

Maps the data of the memory.

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.

Template Parameters
TType of the pointer to be mapped.
Note
Any primitives working with the memory should be completed before mapping. Use stream::wait() to synchronize the corresponding execution stream.
Map/unmap API is provided mainly for debug/testing purposes and its performance may be suboptimal.
Examples:
gpu_getting_started.cpp.

◆ unmap_data()

void mkldnn::memory::unmap_data ( void *  mapped_ptr) const
inline

Unmaps the previously mapped data for 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 map_data() call.

Note
Map/unmap API is provided mainly for debug/testing purposes and its performance may be suboptimal.
Examples:
gpu_getting_started.cpp.

The documentation for this struct was generated from the following file: