Skip to content

Commit 73f3526

Browse files
authored
Merge pull request #15 from DiamondLightSource/ravenfilter
raven filter library and memory estimator
2 parents 68daa95 + 81cf6a4 commit 73f3526

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

httomo_backends/methods_database/backends/httomolibgpu/httomolibgpu.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ prep:
127127
- datasets: [tomo]
128128
- multipliers: [None]
129129
- methods: [module]
130+
raven_filter:
131+
pattern: sinogram
132+
output_dims_change: False
133+
implementation: gpu_cupy
134+
save_result_default: False
135+
padding: False
136+
memory_gpu:
137+
- datasets: [tomo]
138+
- multipliers: [None]
139+
- methods: [module]
130140
recon:
131141
algorithm:
132142
FBP:

httomo_backends/methods_database/backends/httomolibgpu/supporting_funcs/prep/stripe.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
__all__ = [
2929
"_calc_memory_bytes_remove_stripe_ti",
3030
"_calc_memory_bytes_remove_all_stripe",
31+
"_calc_memory_bytes_raven_filter",
3132
]
3233

3334

@@ -66,3 +67,53 @@ def _calc_memory_bytes_remove_all_stripe(
6667
tot_memory_bytes = int(input_size + output_size)
6768

6869
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

Comments
 (0)