Skip to main content

Denoiser

Struct Denoiser 

Source
pub struct Denoiser { /* private fields */ }

Implementations§

Source§

impl Denoiser

Source

pub fn create( accelerators: &[Accelerator], device: &Device, width: u32, height: u32, options: DenoiserOptions, ) -> Result<Self, DenoiserError>

Probe each accelerator in accelerators in order and build a denoiser on the first one that’s available. device lets the caller pick a non-default device for the chosen runtime.

§Thread stack size

cubecl spawns an internal per-device worker thread (named DS{U,D}-…) on which GPU kernel codegen runs. It uses Rust’s default thread stack (RUST_MIN_STACK, or 2 MiB if unset). The windowed NLM kernels here contain (2·search_radius + 1)²-times #[unroll]ed bodies, so large search_radius (≳ 5) values can overflow that 2 MiB default and abort the process.

Callers planning to use search_radius > 4 should set RUST_MIN_STACK to at least 16 MiB before any cubecl thread spawns (typically at the very top of main), e.g.:

if std::env::var_os("RUST_MIN_STACK").is_none() {
    // SAFETY: single-threaded at startup.
    unsafe { std::env::set_var("RUST_MIN_STACK", "16777216") };
}
Source

pub fn selected_accelerator(&self) -> Accelerator

The accelerator picked by sniff_best_accelerator.

Source

pub fn width(&self) -> u32

Width passed at construction.

Source

pub fn height(&self) -> u32

Height passed at construction.

Source

pub fn push_frame(&mut self, frame: &[f32]) -> Result<(), DenoiserError>

Upload one frame into the temporal window. frame must contain width * height * channels f32 values in [0, 1]. Once the window is full and the in-flight pipeline has room, this also kicks off the kernels for the next denoised frame.

Up to MAX_PENDING outputs may be in flight simultaneously: the GPU runs frame N+1’s kernels while frame N’s readback is in flight. Returns DenoiserError::QueueFull once that ceiling is reached; the caller must drain via Self::recv_frame before pushing more.

Source

pub fn recv_frame(&mut self) -> Result<Option<Vec<f32>>, DenoiserError>

Block until the in-flight denoise completes and return the denoised frame. Returns Ok(None) if nothing is in flight (e.g. the temporal window isn’t full yet).

Source

pub fn try_recv_frame(&mut self) -> Result<Option<Vec<f32>>, DenoiserError>

Drain the in-flight denoise if one is ready. May block briefly while the runtime confirms the readback has landed; on workloads where kernels are already complete, the wait is effectively immediate.

Source

pub fn flush(&mut self, sink: impl FnMut(Vec<f32>)) -> Result<(), DenoiserError>

Drain in-flight frames and the trailing temporal tail (padded by duplicating the last pushed frame), handing each produced frame to sink.

On success the denoiser is left ready to accept a fresh, independent stream of the same dimensions and parameters. Pushing more frames after flush starts a new temporal window from scratch. May be called multiple times.

If flush returns Err, the denoiser is left in an undefined state and should be dropped rather than reused.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more