Class anira::v2::PrePostProcessor#

class PrePostProcessor#

Collaboration diagram for anira::v2::PrePostProcessor:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="anira::v2::InferenceConfig" tooltip="anira::v2::InferenceConfig"]
    "1" [label="anira::v2::PrePostProcessor" tooltip="anira::v2::PrePostProcessor" fillcolor="#BFBFBF"]
    "3" [label="anira::v2::ProcessingSpec" tooltip="anira::v2::ProcessingSpec"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "1" -> "2" [dir=forward tooltip="usage"]
}

The 2.x PrePostProcessor over the views: the four virtuals with their 2.x signatures and default bodies, the values of the non-streamable tensors as per-element atomics any thread may set and read, and the five 2.x helpers with their 2.x rules (a plain pop lands ring channel c at [c * n, (c + 1) * n) of the buffer; the window, offset and batched pops write every ring channel to the same position, mono windows). It runs inside a LegacyProcessor: the phases of the processor call the virtuals, pre_process and post_process on the thread that drives the handler, before_inference and after_inference on an inference thread, with the backend of the plan the chunk runs on. A virtual that throws fails its chunk (the chunk delivers zeros and the status lands in anira_handler_rt_error: an anira::Error’s status, else ANIRA_ERROR_ENGINE); in 2.x the throw reached the host. A Static input a custom pre_process leaves alone reads zeros, where 2.x left what the buffer last held.

Public Functions

PrePostProcessor() = delete#
inline explicit PrePostProcessor(InferenceConfig &inference_config)#

Sizes the atomics from the configuration: one per element of every non-streamable tensor, zero until set (inputs) or until an inference is collected (outputs). The configuration outlives the processor.

virtual ~PrePostProcessor() = default#
PrePostProcessor(const PrePostProcessor&) = delete#
PrePostProcessor &operator=(const PrePostProcessor&) = delete#
PrePostProcessor(PrePostProcessor&&) = delete#
PrePostProcessor &operator=(PrePostProcessor&&) = delete#
inline virtual void pre_process(std::vector<RingBuffer> &input, std::vector<BufferF> &output, InferenceBackend current_inference_backend)#

The model input of every slot from its host end: a streamable tensor pops its hop from the ring (with the window’s history ahead of it when the tensor holds more than one hop per channel), a non-streamable one takes its atomics.

inline virtual void post_process(std::vector<BufferF> &input, std::vector<RingBuffer> &output, InferenceBackend current_inference_backend)#

The host end of every output slot from the model output: a streamable tensor pushes its hop into the ring, a non-streamable one sets its atomics.

inline virtual void before_inference(std::vector<BufferF> &input, InferenceBackend current_inference_backend)#

On an inference thread, before the model runs, over the model inputs. Does nothing.

inline virtual void after_inference(std::vector<BufferF> &output, InferenceBackend current_inference_backend)#

On an inference thread, after the model ran, over the model outputs. Does nothing.

inline void set_input(const float &input, size_t i, size_t j) noexcept#

Element j of non-streamable input i, any thread; captured when an inference is submitted. An index out of range, or a streamable tensor’s, is ignored (2.x asserted).

inline void set_output(const float &output, size_t i, size_t j) noexcept#
inline float get_input(size_t i, size_t j) const noexcept#

Element j of non-streamable input i; 0 out of range.

inline float get_output(size_t i, size_t j) const noexcept#

Element j of non-streamable output i as the last collected inference left it, any thread; 0 out of range.

inline void pop_samples_from_buffer(RingBuffer &input, BufferF &output, size_t num_samples) noexcept#

num_samples of every ring channel c into [c * num_samples, (c + 1) * num_samples).

inline void pop_samples_from_buffer(RingBuffer &input, BufferF &output, size_t num_new_samples, size_t num_old_samples) noexcept#

A window of num_old samples of history and num_new popped ones at the buffer’s start.

inline void pop_samples_from_buffer(RingBuffer &input, BufferF &output, size_t num_new_samples, size_t num_old_samples, size_t offset) noexcept#

The window at an offset; every ring channel writes the same position (mono windows).

inline void pop_samples_from_buffer(RingBuffer &input, BufferF &output, size_t num_new_samples, size_t num_old_samples, size_t offset, size_t num_batches) noexcept#

num_batches windows (RingBuffer::pop_windows); every ring channel writes the same windows.

inline void push_samples_to_buffer(const BufferF &input, RingBuffer &output, size_t num_samples) noexcept#

num_samples of every ring channel c from [c * num_samples, (c + 1) * num_samples).

inline const InferenceConfig &config() const noexcept#

The configuration the processor was built with: the slot roles its processor reads.