Deep Neural Network Library (DNNL)  1.1.3
Performance library for Deep Learning
Classes | Public Types | Public Member Functions | List of all members
dnnl::memory Struct Reference

Memory that describes the data. More...

#include <dnnl.hpp>

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

Classes

struct  desc
 A memory descriptor. More...
 

Public Types

enum  data_type {
  data_type::undef = dnnl_data_type_undef, data_type::f16 = dnnl_f16, data_type::bf16 = dnnl_bf16, data_type::f32 = dnnl_f32,
  data_type::s32 = dnnl_s32, data_type::s8 = dnnl_s8, data_type::u8 = dnnl_u8
}
 Data type specification. More...
 
enum  format_kind {
  format_kind::undef = dnnl_format_kind_undef, format_kind::any = dnnl_format_kind_any, format_kind::blocked = dnnl_blocked, format_kind::wino = dnnl_format_kind_wino,
  format_kind::packed = dnnl_format_kind_rnn_packed
}
 Memory format kind. More...
 
enum  format_tag {
  format_tag::undef = dnnl_format_tag_undef, format_tag::any = dnnl_format_tag_any, format_tag::a = dnnl_a, format_tag::ab = dnnl_ab,
  format_tag::abc = dnnl_abc, format_tag::abcd = dnnl_abcd, format_tag::abcde = dnnl_abcde, format_tag::abcdef = dnnl_abcdef,
  format_tag::abdec = dnnl_abdec, format_tag::acb = dnnl_acb, format_tag::acbde = dnnl_acbde, format_tag::acdb = dnnl_acdb,
  format_tag::acdeb = dnnl_acdeb, format_tag::ba = dnnl_ba, format_tag::bac = dnnl_bac, format_tag::bacd = dnnl_bacd,
  format_tag::bcda = dnnl_bcda, format_tag::cba = dnnl_cba, format_tag::cdba = dnnl_cdba, format_tag::cdeba = dnnl_cdeba,
  format_tag::decab = dnnl_decab , format_tag::aBcd8b = dnnl_aBcd8b , format_tag::ABcd8b8a = dnnl_ABcd8b8a , format_tag::nc = dnnl_nc ,
  format_tag::nchw = dnnl_nchw, format_tag::nhwc = dnnl_nhwc, format_tag::chwn = dnnl_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...
 
cl_mem get_ocl_mem_object () const
 Returns the OpenCL memory object associated with the memory.
 
void set_ocl_mem_object (cl_mem mem_object)
 Sets the OpenCL memory object mem_object associated with the memory.
 
- Public Member Functions inherited from dnnl::handle< dnnl_memory_t >
 handle ()=default
 Empty constructor. More...
 
 handle (dnnl_memory_t t, bool weak=false)
 Constructs a C handle wrapper from a C handle. More...
 
void reset (dnnl_memory_t t, bool weak=false)
 Resets the value of a C handle. More...
 
dnnl_memory_t get (bool allow_emtpy=false) const
 Returns the value of the underlying C handle.
 

Detailed Description

Memory that describes the data.

Examples:
cnn_inference_f32.cpp, cnn_inference_int8.cpp, cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, cross_engine_reorder.cpp, getting_started.cpp, gpu_opencl_interop.cpp, memory_format_propagation.cpp, performance_profiling.cpp, and rnn_training_f32.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:
cnn_inference_f32.cpp, cnn_inference_int8.cpp, cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, and 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 dnnl_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 dnnl_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 dnnl::memory::format_tag::ab

nchw 

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

nhwc 

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

chwn 

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

Examples:
cnn_inference_f32.cpp, cnn_inference_int8.cpp, cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, and rnn_training_f32.cpp.

Constructor & Destructor Documentation

◆ memory() [1/2]

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

Constructs a memory.

Parameters
mdMemory descriptor.
aengineEngine.
ahandlehandle.

◆ memory() [2/2]

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

Constructs a memory.

Parameters
mdMemory descriptor.
aengineEngine.

Member Function Documentation

◆ get_data_handle()

void* dnnl::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_rnn_inference_f32.cpp, and cpu_rnn_inference_int8.cpp.

◆ map_data()

template<typename T = void>
T* dnnl::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:
cross_engine_reorder.cpp.

◆ unmap_data()

void dnnl::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:
cross_engine_reorder.cpp.

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