pub trait TracedFftOps {
Show 16 methods
// Required methods
fn fft(&self) -> Result<TracedTensor>;
fn fft_with(&self, options: &FftOptions) -> Result<TracedTensor>;
fn ifft(&self) -> Result<TracedTensor>;
fn ifft_with(&self, options: &FftOptions) -> Result<TracedTensor>;
fn rfft(&self) -> Result<TracedTensor>;
fn rfft_with(&self, options: &FftOptions) -> Result<TracedTensor>;
fn irfft(&self) -> Result<TracedTensor>;
fn irfft_with(&self, options: &FftOptions) -> Result<TracedTensor>;
fn fftn(&self) -> Result<TracedTensor>;
fn fftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>;
fn ifftn(&self) -> Result<TracedTensor>;
fn ifftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>;
fn rfftn(&self) -> Result<TracedTensor>;
fn rfftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>;
fn irfftn(&self) -> Result<TracedTensor>;
fn irfftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>;
}Expand description
FFTs on traced tensors: each call records one FFT node and returns its traced result; execution happens when the graph is prepared and run.
Generated by api_ops! from the fft registry.
Required Methods§
Sourcefn fft(&self) -> Result<TracedTensor>
fn fft(&self) -> Result<TracedTensor>
One-axis discrete Fourier transform along axis (default the last axis).
Uses the default FftOptions; same as fft_with with &FftOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![4], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64])?;
let y = x.fft()?;
let z = x.fft_with(&FftOptions::default().axis(0))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[4]);
assert_eq!(z.shape(), &[4]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(10.0, 0.0)).norm() < 1e-12);Sourcefn fft_with(&self, options: &FftOptions) -> Result<TracedTensor>
fn fft_with(&self, options: &FftOptions) -> Result<TracedTensor>
One-axis discrete Fourier transform along axis (default the last axis).
With explicit FftOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![4], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64])?;
let y = x.fft()?;
let z = x.fft_with(&FftOptions::default().axis(0))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[4]);
assert_eq!(z.shape(), &[4]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(10.0, 0.0)).norm() < 1e-12);Sourcefn ifft(&self) -> Result<TracedTensor>
fn ifft(&self) -> Result<TracedTensor>
One-axis inverse discrete Fourier transform along axis.
Uses the default FftOptions; same as ifft_with with &FftOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.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)])?;
let y = x.ifft()?;
let z = x.ifft_with(&FftOptions::default().axis(0))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[4]);
assert_eq!(z.shape(), &[4]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(2.5, 0.0)).norm() < 1e-12);Sourcefn ifft_with(&self, options: &FftOptions) -> Result<TracedTensor>
fn ifft_with(&self, options: &FftOptions) -> Result<TracedTensor>
One-axis inverse discrete Fourier transform along axis.
With explicit FftOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.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)])?;
let y = x.ifft()?;
let z = x.ifft_with(&FftOptions::default().axis(0))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[4]);
assert_eq!(z.shape(), &[4]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(2.5, 0.0)).norm() < 1e-12);Sourcefn rfft(&self) -> Result<TracedTensor>
fn rfft(&self) -> Result<TracedTensor>
One-axis transform of a real signal, returning the one-sided spectrum.
Uses the default FftOptions; same as rfft_with with &FftOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![4], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64])?;
let y = x.rfft()?;
let z = x.rfft_with(&FftOptions::default().axis(0))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[3]);
assert_eq!(z.shape(), &[3]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(10.0, 0.0)).norm() < 1e-12);Sourcefn rfft_with(&self, options: &FftOptions) -> Result<TracedTensor>
fn rfft_with(&self, options: &FftOptions) -> Result<TracedTensor>
One-axis transform of a real signal, returning the one-sided spectrum.
With explicit FftOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![4], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64])?;
let y = x.rfft()?;
let z = x.rfft_with(&FftOptions::default().axis(0))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[3]);
assert_eq!(z.shape(), &[3]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(10.0, 0.0)).norm() < 1e-12);Sourcefn irfft(&self) -> Result<TracedTensor>
fn irfft(&self) -> Result<TracedTensor>
Inverse of rfft: a one-sided spectrum back to a real signal.
Uses the default FftOptions; same as irfft_with with &FftOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.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 = x.irfft()?;
let z = x.irfft_with(&FftOptions::default().n(Some(4)))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[4]);
assert_eq!(z.shape(), &[4]);
let v = y.as_slice::<f64>()?[0];
assert!((v - 2.0).abs() < 1e-12);Sourcefn irfft_with(&self, options: &FftOptions) -> Result<TracedTensor>
fn irfft_with(&self, options: &FftOptions) -> Result<TracedTensor>
Inverse of rfft: a one-sided spectrum back to a real signal.
With explicit FftOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.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 = x.irfft()?;
let z = x.irfft_with(&FftOptions::default().n(Some(4)))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[4]);
assert_eq!(z.shape(), &[4]);
let v = y.as_slice::<f64>()?[0];
assert!((v - 2.0).abs() < 1e-12);Sourcefn fftn(&self) -> Result<TracedTensor>
fn fftn(&self) -> Result<TracedTensor>
N-dimensional discrete Fourier transform over axes (default every axis).
Uses the default FftnOptions; same as fftn_with with &FftnOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64])?;
let y = x.fftn()?;
let z = x.fftn_with(&FftnOptions::default().axes(vec![0, 1]))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
assert_eq!(z.shape(), &[2, 2]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(10.0, 0.0)).norm() < 1e-12);Sourcefn fftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
fn fftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
N-dimensional discrete Fourier transform over axes (default every axis).
With explicit FftnOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64])?;
let y = x.fftn()?;
let z = x.fftn_with(&FftnOptions::default().axes(vec![0, 1]))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
assert_eq!(z.shape(), &[2, 2]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(10.0, 0.0)).norm() < 1e-12);Sourcefn ifftn(&self) -> Result<TracedTensor>
fn ifftn(&self) -> Result<TracedTensor>
N-dimensional inverse discrete Fourier transform over axes.
Uses the default FftnOptions; same as ifftn_with with &FftnOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 2], 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)])?;
let y = x.ifftn()?;
let z = x.ifftn_with(&FftnOptions::default().axes(vec![0, 1]))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
assert_eq!(z.shape(), &[2, 2]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(2.5, 0.0)).norm() < 1e-12);Sourcefn ifftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
fn ifftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
N-dimensional inverse discrete Fourier transform over axes.
With explicit FftnOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 2], 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)])?;
let y = x.ifftn()?;
let z = x.ifftn_with(&FftnOptions::default().axes(vec![0, 1]))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
assert_eq!(z.shape(), &[2, 2]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(2.5, 0.0)).norm() < 1e-12);Sourcefn rfftn(&self) -> Result<TracedTensor>
fn rfftn(&self) -> Result<TracedTensor>
N-dimensional transform of a real signal; the last transformed axis is one-sided.
Uses the default FftnOptions; same as rfftn_with with &FftnOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 4], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64, 5.0_f64, 6.0_f64, 7.0_f64, 8.0_f64])?;
let y = x.rfftn()?;
let z = x.rfftn_with(&FftnOptions::default().axes(vec![0, 1]))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 3]);
assert_eq!(z.shape(), &[2, 3]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(36.0, 0.0)).norm() < 1e-12);Sourcefn rfftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
fn rfftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
N-dimensional transform of a real signal; the last transformed axis is one-sided.
With explicit FftnOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 4], vec![1.0_f64, 2.0_f64, 3.0_f64, 4.0_f64, 5.0_f64, 6.0_f64, 7.0_f64, 8.0_f64])?;
let y = x.rfftn()?;
let z = x.rfftn_with(&FftnOptions::default().axes(vec![0, 1]))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 3]);
assert_eq!(z.shape(), &[2, 3]);
let v = y.as_slice::<Complex64>()?[0];
assert!((v - Complex64::new(36.0, 0.0)).norm() < 1e-12);Sourcefn irfftn(&self) -> Result<TracedTensor>
fn irfftn(&self) -> Result<TracedTensor>
Inverse of rfftn.
Uses the default FftnOptions; same as irfftn_with with &FftnOptions::default().
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 3], vec![Complex64::new(8.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0)])?;
let y = x.irfftn()?;
let z = x.irfftn_with(&FftnOptions::default().shape(Some(vec![2, 4])))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 4]);
assert_eq!(z.shape(), &[2, 4]);
let v = y.as_slice::<f64>()?[0];
assert!((v - 1.0).abs() < 1e-12);Sourcefn irfftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
fn irfftn_with(&self, options: &FftnOptions) -> Result<TracedTensor>
Inverse of rfftn.
With explicit FftnOptions.
§Layout
On the CPU provider a compact column-major operand is read in place; any other strided view (transposed, sliced, negative strides) is gathered once into a compact buffer of the same placement and dtype before the transform. The CUDA provider canonicalizes on the device. Operands stay on their device; nothing is transferred. The transform runs one one-axis transform per axis; the intermediate spectra stay on the device and the normalization is applied once to the whole transform.
§Errors
Returns an error of kind:
ValidationUnsupported
§Omissions
- lanes (
CpuEngine::with_lanes): an FFT on a lane engine returnsUnsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_fft::{TracedFftOps, FftnOptions};
use tenferro_runtime::{ExecutionEngine, GraphCompiler, Runtime, TraceContext};
let trace = TraceContext::new();
let x = trace.from_vec_col_major(vec![2, 3], vec![Complex64::new(8.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0), Complex64::new(0.0, 0.0)])?;
let y = x.irfftn()?;
let z = x.irfftn_with(&FftnOptions::default().shape(Some(vec![2, 4])))?;
// Build the graph, then run it.
let program = GraphCompiler::new().compile_many(&[&y, &z])?;
let mut engine = CpuEngine::serial();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&engine)?)?;
builder.install_extension_module(tenferro_fft::extension_module::<CpuEngine>(
tenferro_cpu::runtime_engine_id()?,
)?)?;
let runtime = builder.build()?;
let prepared = runtime.prepare(&program, &[], &[engine.target()])?;
let outputs = {
let mut engines: [&mut dyn ExecutionEngine; 1] = [&mut engine];
runtime.run(&mut engines, &prepared, &[])?
};
let mut outputs = outputs.into_iter();
let y = outputs.next().ok_or("missing first output")?.into_tensor(&mut engine)?;
let z = outputs.next().ok_or("missing second output")?.into_tensor(&mut engine)?;
assert_eq!(y.shape(), &[2, 4]);
assert_eq!(z.shape(), &[2, 4]);
let v = y.as_slice::<f64>()?[0];
assert!((v - 1.0).abs() < 1e-12);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".