Skip to main content

Crate tenferro_fft

Crate tenferro_fft 

Source
Expand description

FFT extension operations for tenferro.

This crate is an out-of-tree ExtensionOp package. The initial implementation executes on host tensors through rustfft; it does not add FFT to the core tenferro backend trait surface.

§Examples

use num_complex::Complex64;
use tenferro_cpu::CpuBackend;
use tenferro_runtime::{GraphCompiler, GraphExecutor, TracedTensor};
use tenferro_fft::{FftNorm, TracedTensorFftExt};

let x = TracedTensor::from_vec_col_major(
    vec![4],
    vec![
        Complex64::new(1.0, 0.0),
        Complex64::new(2.0, 0.0),
        Complex64::new(3.0, 0.0),
        Complex64::new(4.0, 0.0),
    ],
)
.unwrap();
let y = x.fft(None, -1, FftNorm::Backward).unwrap();

let mut compiler = GraphCompiler::new();
let program = compiler.compile(&y).unwrap();
let mut executor = GraphExecutor::new(CpuBackend::new());
executor.register_extension(tenferro_fft::register_runtime).unwrap();
let out = executor.run(&program).unwrap();
assert_eq!(out.shape(), &[4]);
assert_eq!(out.as_slice::<Complex64>().unwrap()[0], Complex64::new(10.0, 0.0));

Enums§

FftNorm
FFT normalization convention.

Constants§

FFT_EXTENSION_FAMILY_ID
Extension family id used by the tenferro FFT extension.

Traits§

TracedTensorFftExt
FFT extension methods for [TracedTensor].

Functions§

register_runtime