Class JSPrePostProcessor#
Note
Construct via the Class AniraWeb factory in most cases:
aniraWeb.JSPrePostProcessor(...) rather than new JSPrePostProcessor(...). The
factory threads the WASM instance through for you.
- class JSPrePostProcessor(wasmInstance, inferenceConfig)#
TypeScript wrapper for JSPrePostProcessor. Each instance is identified by its C++ pointer and carries its own pre/post implementation that the inference worker dispatches to.
- Extends:
PrePostProcessor
- Arguments:
wasmInstance (AniraWasmInstance)
inferenceConfig (PossiblePointer<InferenceConfig>)
- afterInference(buffers, backend)#
Called on the inference worker immediately after the backend runs. Override in a subclass to capture the model’s output tensors that must feed the next inference (e.g. recurrent state feedback) — see
anira::PrePostProcessor::after_inference(). The default forwards to the C++ base (a no-op).- Arguments:
buffers (PossiblePointer<VectorBufferF>)
backend (number)
- beforeInference(buffers, backend)#
Called on the inference worker immediately before the backend runs. Override in a subclass to patch the model’s input tensors with data that must reflect the previous inference (e.g. recurrent state feedback) — see
anira::PrePostProcessor::before_inference(). The default forwards to the C++ base (a no-op). Only fires once the subclass is registered on the inference worker viaAniraWeb.registerPrePostProcessor().- Arguments:
buffers (PossiblePointer<VectorBufferF>)
backend (number)
- destroy()#
Free the underlying C++ object. See Lifecycle and Cleanup for when to call this.
- postProcess(buffers, ringBuffers, backend)#
Called by the inference worker when C++ invokes the JS callback. Override in a subclass to implement custom postprocessing.
- Arguments:
buffers (PossiblePointer<VectorBufferF>)
ringBuffers (PossiblePointer<VectorRingBuffer>)
backend (number)
- preProcess(ringBuffers, buffers, backend)#
Called by the inference worker when C++ invokes the JS callback. Override in a subclass to implement custom preprocessing.
- Arguments:
ringBuffers (PossiblePointer<VectorRingBuffer>)
buffers (PossiblePointer<VectorBufferF>)
backend (number)
- setInferenceHooks(enabled)#
Enable or disable the C++
before_inference/after_inferenceJS callbacks for this processor. When disabled (the default) the C++ hooks short-circuit to the base no-op without crossing into JS, soJSPrePostProcessorinstances used only for pre/post-processing pay nothing on the inference thread. The inference worker flips this on when the processor is registered there (AniraWeb.registerPrePostProcessor()).- Arguments:
enabled (boolean)