Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["fft", "dft", "discrete", "fourier", "no_std"]
categories = ["algorithms", "science"]

[dependencies]
monarch-derive = "=0.4.0"
monarch-derive = { path = "crates/monarch-derive" }
num-complex = "0.4"
num-traits = { version = "0.2", default-features = false }

Expand Down
Binary file modified assets/linear_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/log_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions crates/benches/generate_benchmark_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@
plt.xlabel('FFT Size')
# plt.yscale('log')
plt.legend(loc='upper left')
plt.gcf().set_size_inches(10, 5)
# plt.savefig('../../linear_comparison.png')
plt.show()
18 changes: 9 additions & 9 deletions crates/monarch-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn generate_switch(_input: TokenStream) -> TokenStream {
/// let input: Vec<_> = (0..8).map(|i| Complex::new(i as f32, 0.0)).collect();
/// let output = fft::<8, _, _>(input);
/// ```
#[inline]
#[inline(always)]
pub fn fft<const N: usize, T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; N] {
let x_in = input.as_ref();
assert_eq!(x_in.len(), N);
Expand All @@ -135,7 +135,7 @@ pub fn generate_switch(_input: TokenStream) -> TokenStream {
/// let input: Vec<_> = (0..8).map(|i| Complex::new(i as f32, 0.0)).collect();
/// let output = ifft::<8, _, _>(input);
/// ```
#[inline]
#[inline(always)]
pub fn ifft<const N: usize, T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; N] {
let x_in = input.as_ref();
assert_eq!(x_in.len(), N);
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn generate_powers_of_two(_input: TokenStream) -> TokenStream {

quote! {
#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn #func<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; #s] {
let n = #s;
let x = input.as_ref();
Expand All @@ -214,7 +214,7 @@ pub fn generate_powers_of_two(_input: TokenStream) -> TokenStream {

let expanded = quote! {

#[inline]
#[inline(always)]
pub fn fft1<T: Float, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 1] {
let n = 1;
let x = input.as_ref();
Expand Down Expand Up @@ -281,7 +281,7 @@ pub fn generate_coprimes(_input: TokenStream) -> TokenStream {

quote! {
#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn #func<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; #s] {
let n = #s;
let x = input.as_ref();
Expand Down Expand Up @@ -366,7 +366,7 @@ pub fn generate_mixed_radix(_input: TokenStream) -> TokenStream {

quote! {
#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn #func<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; #s] {
let n = #s;
let x = input.as_ref();
Expand Down Expand Up @@ -548,7 +548,7 @@ pub fn generate_primes(_input: TokenStream) -> TokenStream {

quote! {
#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn #func<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; #s] {
let n = #s;
let x = input.as_ref();
Expand Down Expand Up @@ -603,7 +603,7 @@ pub fn generate_iffts(_input: TokenStream) -> TokenStream {

quote! {
#[doc = concat!("Inner iFFT")]
#[inline]
#[inline(always)]
pub fn #func<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; #n] {
let x = input.as_ref();
assert_eq!(x.len(), #n);
Expand All @@ -621,7 +621,7 @@ pub fn generate_iffts(_input: TokenStream) -> TokenStream {

let expanded = quote! {
#[doc = concat!("Inner iFFT")]
#[inline]
#[inline(always)]
pub fn ifft1<T: Float, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 1] {
let n = 1;
let x = input.as_ref();
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn _compute_twiddle<T: Float + FloatConst>(index: usize, fft_len: usize) -> Comp
}

#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn fft3<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 3] {
let n = 3;
let x = input.as_ref();
Expand All @@ -99,7 +99,7 @@ pub fn fft3<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex
}

#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn fft9<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 9] {
let n = 9;
let x = input.as_ref();
Expand Down Expand Up @@ -132,7 +132,7 @@ pub fn fft9<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex
}

#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn fft18<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 18] {
let n = 18;
let x = input.as_ref();
Expand Down Expand Up @@ -202,7 +202,7 @@ pub fn fft18<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Comple
}

#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn fft27<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 27] {
let n = 27;
let x = input.as_ref();
Expand Down Expand Up @@ -279,7 +279,7 @@ pub fn fft27<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Comple
}

#[doc = concat!("Inner FFT")]
#[inline]
#[inline(always)]
pub fn fft125<T: Float + FloatConst, A: AsRef<[Complex<T>]>>(input: A) -> [Complex<T>; 125] {
let n = 125;
let x = input.as_ref();
Expand Down