Synchronous Buffer Port With Margin Configuration - 2024.1 English

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
UG1603
Release Date
2024-06-06
Version
2024.1 English
Option 1
Configure with dimensions() API in graph.
k = kernel::create(simple);
connect netN(in.out[0], k.in[0]);
dimensions(k.in[0]) = {INPUT_SAMPLE_SIZE};
dimensions(k.out[0]) = {OUTPUT_SAMPLE_SIZE};
Kernel k's function prototype specifies margin size.
Note: The margin cannot be specified in the graph. The margin must be set in the kernel signature within the template parameters of the buffer.
simple(input_buffer<int32, adf::extents<adf::inherited_extent>, adf::margin<MARGIN_SIZE>> & in0,
        output_buffer<int32> & out0);
Option 2
Configure with kernel function prototype.
k = kernel::create(simple);
connect netN(in.out[0], k.in[0]);

Kernel k’s function prototype specifies input buffer size plus margin size and output buffer size.

simple(input_buffer<int32, adf::extents<INPUT_SAMPLE_SIZE>, adf::margin<MARGIN_SIZE>> & in0,
        output_buffer<int32, adf::extents<OUTPUT_SAMPLE_SIZE>> & out0);

The buffer ports are designed to be accessed sequentially. The kernel program reads the buffer port and starts from the first position of samples. Therefore, a useful model is that of a current position, which can be advanced or rolled back on reads or writes. On starting a kernel, the current position is always in the correct position. For example, the current position for an input buffer port for a filter is on the first sample to restore the delay line. It could be an older sample in the case of filters requiring overlap of incoming data samples, in which case the connection needs to be declared using the overlap or margin as described above. Similarly, the current position for an output buffer is on the first sample to send to the next block, irrespective of whether that block requires a duplication of older samples. The kernel is free to manipulate this current position and it is not necessary that this position is at the end of the block when the kernel completes. Buffer ports are implemented as linear buffers. Circular buffer port types are also supported. For more information, see Linear and Circular Addressing of Buffer Ports.