Skip to main content

FftExecutor

Struct FftExecutor 

Source
pub struct FftExecutor { /* private fields */ }
Expand description

Reusable concrete FFT executor with an explicitly owned backend-neutral cache.

Use this executor for repeated concrete FFT calls that should reuse backend plans (exception E02). The FftOps methods stay one-shot and do not retain hidden process-global, thread-local, or backend-owned plan state between calls.

Implementations§

Source§

impl FftExecutor

Source

pub fn new(plans: FftPlanCache) -> Self

Create an executor from a caller-configured FFT execution cache.

Source

pub const fn plan_cache(&self) -> &FftPlanCache

Inspect the owned backend-neutral FFT cache.

Source

pub fn plan_cache_mut(&mut self) -> &mut FftPlanCache

Mutably inspect or configure the owned backend-neutral FFT cache.

Source

pub fn cache_stats(&self) -> CacheStats

Snapshot aggregate statistics for every backend cache namespace.

Source

pub fn clear_cache(&mut self)

Remove every retained backend plan or workspace from this executor.

Source

pub fn fft_with( &mut self, input: &Tensor, opts: &FftOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::fft (complex, or full spectrum of a real input) reusing this executor’s plans. Bit-identical to FftOps::fft_with on the same input.

§Errors

As FftOps::fft: Validation for an invalid axis/n, Unsupported for an unsupported dtype or an engine without an FFT capability, or the backend’s typed error.

§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(vec![4], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = executor.fft_with(&x, &FftOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.as_slice::<Complex64>()?[0], Complex64::new(10.0, 0.0));
assert!(executor.cache_stats().entries > 0);
Source

pub fn ifft_with( &mut self, input: &Tensor, opts: &FftOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::ifft reusing this executor’s plans.

§Errors

As FftOps::ifft: Validation for an invalid axis/n, Unsupported for an unsupported dtype or an engine without an FFT capability, or the backend’s typed error.

§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(
    vec![2],
    vec![Complex64::new(3.0, 0.0), Complex64::new(-1.0, 0.0)],
)?;
let y = executor.ifft_with(&x, &FftOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.as_slice::<Complex64>()?[1], Complex64::new(2.0, 0.0));
Source

pub fn rfft_with( &mut self, input: &Tensor, opts: &FftOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::rfft reusing this executor’s plans.

§Errors

As FftOps::rfft: Validation for an invalid axis/n or a non-real input, Unsupported for an unsupported dtype or an engine without an FFT capability, or the backend’s typed error.

§Examples
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(vec![4], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = executor.rfft_with(&x, &FftOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.shape(), &[3]);
Source

pub fn irfft_with( &mut self, input: &Tensor, opts: &FftOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::irfft reusing this executor’s plans.

§Errors

As FftOps::irfft: Validation for an invalid axis/n or a complex input, Unsupported for an unsupported dtype or an engine without an FFT capability, or the backend’s typed error.

§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(
    vec![3],
    vec![Complex64::new(10.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(-2.0, 0.0)],
)?;
let y = executor.irfft_with(&x, &FftOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.shape(), &[4]);
Source

pub fn fftn_with( &mut self, input: &Tensor, opts: &FftnOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::fftn reusing this executor’s plans.

§Errors

As FftOps::fftn: Validation for an invalid axes/shape/n, Unsupported for an unsupported dtype or an engine without an N-d FFT capability, or the backend’s typed error.

§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftnOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = executor.fftn_with(&x, &FftnOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.as_slice::<Complex64>()?[0], Complex64::new(10.0, 0.0));
Source

pub fn ifftn_with( &mut self, input: &Tensor, opts: &FftnOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::ifftn reusing this executor’s plans.

§Errors

As FftOps::ifftn: Validation for an invalid axes/shape/n, Unsupported for an unsupported dtype or an engine without an N-d FFT capability, or the backend’s typed error.

§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftnOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(vec![1, 2], vec![Complex64::new(3.0, 0.0), Complex64::new(-1.0, 0.0)])?;
let y = executor.ifftn_with(&x, &FftnOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.as_slice::<Complex64>()?[1], Complex64::new(2.0, 0.0));
Source

pub fn rfftn_with( &mut self, input: &Tensor, opts: &FftnOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::rfftn reusing this executor’s plans.

§Errors

As FftOps::rfftn: Validation for an invalid axes/shape/n or a non-real input, Unsupported for an unsupported dtype or an engine without an N-d FFT capability, or the backend’s typed error.

§Examples
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftnOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let x = Tensor::from_vec_col_major(vec![2, 4], vec![1.0_f64; 8])?;
let y = executor.rfftn_with(&x, &FftnOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.shape(), &[2, 3]);
Source

pub fn irfftn_with( &mut self, input: &Tensor, opts: &FftnOptions, exec: &mut dyn Engine, ) -> Result<Tensor>

FftOps::irfftn reusing this executor’s plans.

§Errors

As FftOps::irfftn: Validation for an invalid axes/shape/n or a complex input, Unsupported for an unsupported dtype or an engine without an N-d FFT capability, or the backend’s typed error.

§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{FftExecutor, FftnOptions};
use tenferro_tensor::Tensor;

let mut executor = FftExecutor::default();
let mut spectrum = vec![Complex64::new(0.0, 0.0); 6];
spectrum[0] = Complex64::new(8.0, 0.0);
let x = Tensor::from_vec_col_major(vec![2, 3], spectrum)?;
let y = executor.irfftn_with(&x, &FftnOptions::default(), &mut CpuEngine::serial())?;
assert_eq!(y.as_slice::<f64>()?, &[1.0; 8]);

Trait Implementations§

Source§

impl Default for FftExecutor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.