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

A memory descriptor. More...

#include <dnnl.hpp>

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

Public Member Functions

 desc ()
 Constructs a zero (empty) memory descriptor. More...
 
 desc (const memory::dims &dims, data_type data_type, format_tag format_tag)
 Constructs a memory descriptor. More...
 
 desc (const memory::dims &dims, data_type data_type, const memory::dims &strides)
 Constructs a memory descriptor by strides. More...
 
 desc (const dnnl_memory_desc_t &data)
 Constructs a memory descriptor from a C API data structure. More...
 
desc submemory_desc (const memory::dims &dims, const memory::dims &offsets) const
 Constructs a memory descriptor for a region inside an area described by this memory descriptor. More...
 
desc reshape (const memory::dims &dims) const
 Constructs a memory descriptor by reshaping existing one. More...
 
memory::dims dims () const
 Returns dimensions of the memory descriptor. More...
 
memory::data_type data_type () const
 Returns the data type of the memory descriptor. More...
 
size_t get_size () const
 Returns size of the memory descriptor in bytes. More...
 
bool is_zero () const
 Checks whether the memory descriptor is zero (empty). More...
 
bool operator== (const desc &other) const
 An equality operator. More...
 
bool operator!= (const desc &other) const
 An inequality operator. More...
 

Public Attributes

dnnl_memory_desc_t data
 The underlying C API data structure.
 

Detailed Description

A memory descriptor.

Examples
cnn_inference_f32.cpp, cnn_inference_int8.cpp, cnn_training_f32.cpp, cpu_cnn_training_bf16.cpp, cpu_matmul_quantization.cpp, cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, cpu_sgemm_and_matmul.cpp, getting_started.cpp, gpu_opencl_interop.cpp, inference_int8_matmul.cpp, memory_format_propagation.cpp, performance_profiling.cpp, rnn_training_f32.cpp, and sycl_interop.cpp.

Constructor & Destructor Documentation

◆ desc() [1/4]

dnnl::memory::desc::desc ( )
inline

Constructs a zero (empty) memory descriptor.

Such a memory descriptor can be used to indicate absence of an argument.

◆ desc() [2/4]

dnnl::memory::desc::desc ( const memory::dims dims,
data_type  data_type,
format_tag  format_tag 
)
inline

Constructs a memory descriptor.

Note
As always, the logical order of dimensions corresponds to the abc... format tag, and the physical meaning of the dimensions depends on both the primitive that consumes the memory and the context of that consumption.
Parameters
dimsTensor dimensions.
data_typeData precision/type.
format_tagMemory format tag.

◆ desc() [3/4]

dnnl::memory::desc::desc ( const memory::dims dims,
data_type  data_type,
const memory::dims strides 
)
inline

Constructs a memory descriptor by strides.

Note
As always, the logical order of dimensions corresponds to the abc... format tag, and the physical meaning of the dimensions depends on both the primitive that consumes the memory and the context of that consumption.
Parameters
dimsTensor dimensions.
data_typeData precision/type.
stridesThe strides for each dimension.

◆ desc() [4/4]

dnnl::memory::desc::desc ( const dnnl_memory_desc_t data)
inline

Constructs a memory descriptor from a C API data structure.

Parameters
dataA C API dnnl_memory_desc_t structure.

Member Function Documentation

◆ submemory_desc()

desc dnnl::memory::desc::submemory_desc ( const memory::dims dims,
const memory::dims offsets 
) const
inline

Constructs a memory descriptor for a region inside an area described by this memory descriptor.

Parameters
dimsSizes of the region.
offsetsOffsets to the region from the encompassing memory object in each dimension.
Returns
A memory descriptor for the region.
Examples
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and rnn_training_f32.cpp.

◆ reshape()

desc dnnl::memory::desc::reshape ( const memory::dims dims) const
inline

Constructs a memory descriptor by reshaping existing one.

Parameters
dimsNew dimensions. The product of dimensions must remain constant.
Returns
A new memory descriptor with new dimensions.

◆ dims()

memory::dims dnnl::memory::desc::dims ( ) const
inline

Returns dimensions of the memory descriptor.

Potentially expensive due to the data copy involved.

Returns
A copy of the dimensions vector.
Examples
inference_int8_matmul.cpp.

◆ data_type()

memory::data_type dnnl::memory::desc::data_type ( ) const
inline

Returns the data type of the memory descriptor.

Returns
The data type.

◆ get_size()

size_t dnnl::memory::desc::get_size ( ) const
inline

Returns size of the memory descriptor in bytes.

Returns
The number of bytes required to allocate a memory buffer for the memory object described by this memory descriptor including the padding area.
Examples
cpu_rnn_inference_f32.cpp, cpu_rnn_inference_int8.cpp, and performance_profiling.cpp.

◆ is_zero()

bool dnnl::memory::desc::is_zero ( ) const
inline

Checks whether the memory descriptor is zero (empty).

Returns
true if the memory descriptor describes an empty memory and false otherwise.

◆ operator==()

bool dnnl::memory::desc::operator== ( const desc other) const
inline

An equality operator.

Parameters
otherAnother memory descriptor.
Returns
Whether this and the other memory descriptors have the same format tag, dimensions, strides, blocking, etc.

◆ operator!=()

bool dnnl::memory::desc::operator!= ( const desc other) const
inline

An inequality operator.

Parameters
otherAnother memory descriptor.
Returns
Whether this and the other memory descriptors describe different memory.

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