Skip to main content

FftBackend

Trait FftBackend 

Source
pub trait FftBackend: BackendSession {
    // Required method
    fn execute_fft(
        &mut self,
        input: &Tensor,
        spec: &FftPlanSpec,
        cache: FftExecutionCache<'_>,
    ) -> Result<Tensor>;

    // Provided method
    fn validate_fft_read_input(
        &self,
        _op: &'static str,
        _input: &TensorRead<'_>,
    ) -> Result<()> { ... }
}
Expand description

Explicit backend capability required by concrete and traced FFT execution.

Implementations must execute on the input’s existing placement. Unsupported dtypes, layouts, placements, or operations return an error; they must never transfer the tensor or select a different backend.

§Examples

use tenferro_cpu::{with_cpu_exec_session, CpuBackend};
use tenferro_fft::FftBackend;
use tenferro_tensor::BackendSessionHost;

fn accepts_fft_backend<B: FftBackend>(_backend: &mut B) {}

let mut backend = CpuBackend::new();
backend.with_backend_session(|session| {
    with_cpu_exec_session(session, |exec_session| accepts_fft_backend(exec_session))
        .expect("CpuBackend must expose a CPU execution session");
});

A generic tensor backend without this explicit capability cannot build the FFT extension module:

use tenferro_tensor::{Tensor, TensorBackend};
use tenferro_fft::{FftNorm, TensorFftExt};

fn use_without_fft_capability<B: TensorBackend + 'static>(backend: &mut B, input: &Tensor) {
    let _module =
        tenferro_fft::extension_module::<B>(tenferro_cpu::runtime_engine_id().unwrap()).unwrap();
    let _ = input.fft(None, -1, FftNorm::Backward, backend);
}

Required Methods§

Source

fn execute_fft( &mut self, input: &Tensor, spec: &FftPlanSpec, cache: FftExecutionCache<'_>, ) -> Result<Tensor>

Execute one validated FFT request on input’s existing placement.

§Errors

Returns tenferro_tensor::Error::Unsupported for an unsupported operation, dtype, layout, or placement; tenferro_tensor::Error::Validation for inconsistent input/spec metadata or checked shape arithmetic; and a typed backend or runtime source when plan creation, cache access, or execution fails.

Provided Methods§

Source

fn validate_fft_read_input( &self, _op: &'static str, _input: &TensorRead<'_>, ) -> Result<()>

Validate a borrowed runtime input before the extension read path materializes it into a compact tensor.

Backends that can materialize their own placement may keep the default no-op. CPU overrides this to report device inputs as unsupported FFT placement errors instead of leaking a generic host-materialization error.

§Errors

Returns tenferro_tensor::Error::Unsupported when this backend cannot consume the borrowed input placement without an explicit transfer.

Implementors§