clDNN
Memory Management
Collaboration diagram for Memory Management:

Classes

struct  cldnn_tensor
 N-dimensional vector. Mostly used to represent memory size. More...
 
struct  cldnn_padding
 Padding information. More...
 
struct  cldnn_layout
 Memory layout description. More...
 

Macros

#define CLDNN_FLOAT_TYPE_MASK   0x80
 
#define CLDNN_UINT_TYPE_MASK   0x40
 
#define CLDNN_TENSOR_BATCH_DIM_MAX   1
 
#define CLDNN_TENSOR_FEATURE_DIM_MAX   1
 
#define CLDNN_TENSOR_SPATIAL_DIM_MAX   2
 
#define CLDNN_TENSOR_DIM_MAX   8
 

Typedefs

typedef struct cldnn_memory_impl * cldnn_memory
 Memory object.
 

Enumerations

enum  cldnn_format_type {
  cldnn_format_yxfb, cldnn_format_byxf, cldnn_format_bfyx, cldnn_format_fyxb,
  cldnn_format_os_iyx_osv16, cldnn_format_bs_xs_xsv8_bsv8, cldnn_format_bs_xs_xsv8_bsv16, cldnn_format_bs_x_bsv16,
  cldnn_format_bf8_xy16, cldnn_format_image_2d_weights_c4_fyx_b, cldnn_format_image_2d_weights_c1_b_fyx, cldnn_format_format_num,
  cldnn_format_any = -1
}
 Represents memory formats (orders).
In CNN most of data is describe as 4 dimensional blocks. In Intel(R) clDNN library we describe memory with 4 letters. More...
 
enum  cldnn_data_type { cldnn_i8 = sizeof(int8_t), cldnn_f16 = sizeof(int16_t) | CLDNN_FLOAT_TYPE_MASK, cldnn_f32 = sizeof(float) | CLDNN_FLOAT_TYPE_MASK, cldnn_u8 = sizeof(uint8_t) | CLDNN_UINT_TYPE_MASK }
 Data type stored in memory.
 

Functions

CLDNN_API cldnn_memory cldnn_allocate_memory (cldnn_engine engine, cldnn_layout layout, cldnn_status *status)
 Allocate memory on engine using specified layout.
 
CLDNN_API cldnn_memory cldnn_attach_memory (cldnn_layout layout, void *pointer, size_t size, cldnn_status *status)
 Create memory object attached to the buffer allocated by user. More...
 
CLDNN_API int32_t cldnn_is_the_same_buffer (cldnn_memory mem1, cldnn_memory mem2, cldnn_status *status)
 Checks if two memory objects refer to the same underlaying buffer.
 
CLDNN_API void cldnn_retain_memory (cldnn_memory memory, cldnn_status *status)
 Increment reference counter for the memory object.
 
CLDNN_API void cldnn_release_memory (cldnn_memory memory, cldnn_status *status)
 Decrement reference counter for the memory object. Deletes object when counter becomes zero.
 
CLDNN_API void * cldnn_lock_memory (cldnn_memory memory, cldnn_status *status)
 Locks memory buffer. Provides direct access to memory data. More...
 
CLDNN_API void cldnn_unlock_memory (cldnn_memory memory, cldnn_status *status)
 Unlocks memory locked by cldnn_lock_memory(cldnn_memory memory, cldnn_status* status).
 
CLDNN_API cldnn_layout cldnn_get_memory_layout (cldnn_memory memory, cldnn_status *status)
 Returns memory layout. More...
 
CLDNN_API cldnn_engine cldnn_get_memory_engine (cldnn_memory memory, cldnn_status *status)
 Returns reference to the engine associated with memory object. More...
 
CLDNN_API uint16_t cldnn_float_to_half (float, cldnn_status *)
 converts float(32 bit) to half_t(fp16 bit) More...
 
CLDNN_API float cldnn_half_to_float (uint16_t, cldnn_status *)
 converts half_t(f16 bit) to float(32 bit) More...
 

Detailed Description


Class Documentation

◆ cldnn_tensor

struct cldnn_tensor

N-dimensional vector. Mostly used to represent memory size.

Definition at line 266 of file cldnn.h.

Class Members
size_t batch_num
size_t feature_num
int32_t sizes[CLDNN_TENSOR_DIM_MAX]
size_t spatial_num

◆ cldnn_padding

struct cldnn_padding

Padding information.

Definition at line 275 of file cldnn.h.

Collaboration diagram for cldnn_padding:
Class Members
float filling_value

Filling value for an element of padding. If data type of elements is different than float it is converted to it using round-towards-nearest-even (for floating-point data types) or round-towards-zero (for integral data types).

cldnn_tensor lower_size Lower padding sizes. For spatials, it means size of left (X) and top (Y) padding.
cldnn_tensor upper_size Upper padding sizes. For spatials, it means size of right (X) and bottom (Y) padding.

◆ cldnn_layout

struct cldnn_layout

Memory layout description.

Definition at line 295 of file cldnn.h.

Collaboration diagram for cldnn_layout:
Class Members
size_t data_type data type (cldnn_data_type) stored in memory.
int32_t format Memor format (cldnn_format_type)
cldnn_padding padding Explicitly added padding to memory buffer.
cldnn_tensor size N-dimensional vector describes size (in elements) of memory (excluding padding).

Enumeration Type Documentation

◆ cldnn_format_type

Represents memory formats (orders).
In CNN most of data is describe as 4 dimensional blocks. In Intel(R) clDNN library we describe memory with 4 letters.

  • b - number of blocks in batch. For weights formats: output features - conv, neurons - inner product
  • f - number of feature maps, features or channels. For weights formats: input features - conv, inputs, inner product
  • x - spatial, width
  • y - spatial, height /n For explanation how each format type is implemented in memory we will use naming shown bellow (b=2,f=3,y=3,x=3):
    layout_memory_representation.jpg
Enumerator
cldnn_format_yxfb 

batch first, feature and than spatials

yxfb.jpg
cldnn_format_byxf 

used in bitmaps, input from user i.e b images of RGB format

byxf.jpg
cldnn_format_bfyx 

the most common format for activations in clDNN.

bfyx.jpg
cldnn_format_fyxb 

format not used inside clDNN, but supported in reorder as extension for user provided formats.

cldnn_format_os_iyx_osv16 

format used only for convolution weights: os - output feature maps slice, i - input feature maps, yx - spatials, sv16 - 16 values of single slice.

os_iyx_osv16.jpg
cldnn_format_bs_xs_xsv8_bsv8 

format used only for fully connected weights: bs - batch slice, xs - x slice, bsv8 - 8 values of single slice.

bs_xs_xsv8_bsv8.jpg
cldnn_format_bs_xs_xsv8_bsv16 

format used only for fully connected weights: bs - batch slice, xs - x slice, bsv16 - 16 values of single slice.

bs_xs_xsv8_bsv16.jpg
cldnn_format_bs_x_bsv16 

format used only for fully connected weights fp16 batch=1 : bs - batch slice (responses slice), bsv16 - 16 values of single batch slice, x - flattened plane of (fyx).

bs_x_bsv16.jpg
cldnn_format_bf8_xy16 

format used only for convolution 1x1 input, xy aligned to 16, f aligned to 8

bf8_xy16.jpg
cldnn_format_image_2d_weights_c4_fyx_b 


image format for weights, image 2d, 4-channel, width size is f*y*x/4 (4-channels filled with fyx data), height is b

image_2d_weights_c4_fyx_b.jpg
cldnn_format_image_2d_weights_c1_b_fyx 


image format for weights, image 2d, single channel, width size is b, height is f*y*x

image_2d_weights_c1_b_fyx.jpg
cldnn_format_format_num 

number of format types

Definition at line 233 of file cldnn.h.

Function Documentation

◆ cldnn_attach_memory()

CLDNN_API cldnn_memory cldnn_attach_memory ( cldnn_layout  layout,
void *  pointer,
size_t  size,
cldnn_status status 
)

Create memory object attached to the buffer allocated by user.

Note
User is responsible for buffer deallocation. Buffer lifetime should be bigger than lifetime of the memory object.

◆ cldnn_float_to_half()

CLDNN_API uint16_t cldnn_float_to_half ( float  ,
cldnn_status  
)

converts float(32 bit) to half_t(fp16 bit)

Returns
16bit half_t

◆ cldnn_get_memory_engine()

CLDNN_API cldnn_engine cldnn_get_memory_engine ( cldnn_memory  memory,
cldnn_status status 
)

Returns reference to the engine associated with memory object.

Returns
The engine associated with memory object. Or NULL if memory was attached to user-allocated buffer.

◆ cldnn_get_memory_layout()

CLDNN_API cldnn_layout cldnn_get_memory_layout ( cldnn_memory  memory,
cldnn_status status 
)

Returns memory layout.

Returns
cldnn_layout which describes memory.

◆ cldnn_half_to_float()

CLDNN_API float cldnn_half_to_float ( uint16_t  ,
cldnn_status  
)

converts half_t(f16 bit) to float(32 bit)

Returns
32bit float

◆ cldnn_lock_memory()

CLDNN_API void* cldnn_lock_memory ( cldnn_memory  memory,
cldnn_status status 
)

Locks memory buffer. Provides direct access to memory data.

Returns
Direct pointer to the memory data.