mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
add fftshift and ifftshift fft helpers (#2135)
* add fftshift and ifftshift fft helpers * address comments * axes have to be iterable * fix fp error in roll + add test --------- Co-authored-by: Aashiq Dheeraj <aashiq@aashiq-mbp-m4.local>
This commit is contained in:
@@ -5025,8 +5025,11 @@ array roll(
|
||||
}
|
||||
|
||||
auto sh = shift[i];
|
||||
auto split_index =
|
||||
(sh < 0) ? (-sh) % a.shape(ax) : a.shape(ax) - sh % a.shape(ax);
|
||||
auto size = a.shape(ax);
|
||||
if (size == 0) {
|
||||
continue; // skip rolling this axis if it has size 0
|
||||
}
|
||||
auto split_index = (sh < 0) ? (-sh) % size : size - sh % size;
|
||||
|
||||
auto parts = split(result, Shape{split_index}, ax, s);
|
||||
std::swap(parts[0], parts[1]);
|
||||
|
||||
Reference in New Issue
Block a user