|
28 | 28 | __all__ = [
|
29 | 29 | "_calc_memory_bytes_remove_stripe_ti",
|
30 | 30 | "_calc_memory_bytes_remove_all_stripe",
|
| 31 | + "_calc_memory_bytes_raven_filter", |
31 | 32 | ]
|
32 | 33 |
|
33 | 34 |
|
@@ -66,3 +67,53 @@ def _calc_memory_bytes_remove_all_stripe(
|
66 | 67 | tot_memory_bytes = int(input_size + output_size)
|
67 | 68 |
|
68 | 69 | return (tot_memory_bytes, methods_memory_allocations)
|
| 70 | + |
| 71 | + |
| 72 | +def _calc_memory_bytes_raven_filter( |
| 73 | + non_slice_dims_shape: Tuple[int, int], |
| 74 | + dtype: np.dtype, |
| 75 | + **kwargs, |
| 76 | +) -> Tuple[int, int]: |
| 77 | + |
| 78 | + pad_x = kwargs["pad_x"] |
| 79 | + pad_y = kwargs["pad_y"] |
| 80 | + |
| 81 | + input_size = np.prod(non_slice_dims_shape) * dtype.itemsize |
| 82 | + output_size = np.prod(non_slice_dims_shape) * dtype.itemsize |
| 83 | + |
| 84 | + # Padded input |
| 85 | + padded_non_slice_dims_shape = ( |
| 86 | + non_slice_dims_shape[0] + 2 * pad_y, |
| 87 | + non_slice_dims_shape[1] + 2 * pad_x, |
| 88 | + ) |
| 89 | + |
| 90 | + in_slice_size_pad = ( |
| 91 | + (padded_non_slice_dims_shape[0]) |
| 92 | + * (padded_non_slice_dims_shape[1]) |
| 93 | + * dtype.itemsize |
| 94 | + ) |
| 95 | + out_slice_size_pad = in_slice_size_pad |
| 96 | + |
| 97 | + complex_slice_fft_data = in_slice_size_pad / dtype.itemsize * np.complex64().nbytes |
| 98 | + complex_slice_fft_data_shifted = complex_slice_fft_data |
| 99 | + data_out_ifft_complex = complex_slice_fft_data |
| 100 | + |
| 101 | + # Plan size for 2D FFT |
| 102 | + fftplan_slice = cufft_estimate_2d( |
| 103 | + nx=padded_non_slice_dims_shape[1], |
| 104 | + ny=padded_non_slice_dims_shape[0], |
| 105 | + fft_type=CufftType.CUFFT_C2C, |
| 106 | + ) |
| 107 | + |
| 108 | + tot_memory_bytes = int( |
| 109 | + input_size |
| 110 | + + output_size |
| 111 | + + in_slice_size_pad |
| 112 | + + out_slice_size_pad |
| 113 | + + complex_slice_fft_data |
| 114 | + + complex_slice_fft_data_shifted |
| 115 | + + data_out_ifft_complex |
| 116 | + + 2 * fftplan_slice |
| 117 | + ) |
| 118 | + |
| 119 | + return (tot_memory_bytes, 0) |
0 commit comments