@@ -52,7 +52,7 @@ def calculate_section_output_chunk_shape(
5252 for method in section .methods :
5353 if method .memory_gpu is None :
5454 continue
55- output_non_slice_dims = method .calculate_output_dims (input_non_slice_dims )
55+ output_non_slice_dims = method .calculate_output_dims (output_non_slice_dims )
5656
5757 output_chunk_shape = list (output_non_slice_dims )
5858 output_chunk_shape .insert (slicing_dim , chunk_shape [slicing_dim ])
@@ -74,7 +74,7 @@ def estimate_section_memory(
7474 sections : List [Section ],
7575 section_idx : int ,
7676 consider_pinned_memory_pool : bool = False ,
77- ) -> int :
77+ ) -> tuple [ int , tuple [ int , int , int ]] :
7878 # Get chunk shape created by reader of section `n` (the current section) that will account
7979 # for padding. This chunk shape is based on the chunk shape written by the writer of
8080 # section `n - 1` (the previous section)
@@ -150,12 +150,26 @@ def estimate_section_memory(
150150 # See https://github.com/cupy/cupy/issues/9813
151151 cupy_transfer_overhead = total_mem
152152
153+ # Calculate the shape of the global data of the output of the section to pass back to the
154+ # caller.
155+ #
156+ # NOTE: The caller will only use this if performing CPU memory estimation of the entire
157+ # pipeline not at runtime of htttomo (ie, the `memory-check` CLI command). If performing
158+ # CPU memory estimation of a section during runtime of httomo, the caller won't use this
159+ # value.
160+ current_section_slicing_dim = _get_slicing_dim (sections [section_idx ].pattern ) - 1
161+ output_global_shape = list (output_chunk_shape )
162+ output_global_shape [current_section_slicing_dim ] = (
163+ output_global_shape [current_section_slicing_dim ] * nprocs
164+ )
165+
153166 return (
154167 padded_input_chunk_bytes
155168 + output_chunk_bytes
156169 + reslice_bytes
157170 + cupy_pinned_cpu_pool_memory
158- + cupy_transfer_overhead
171+ + cupy_transfer_overhead ,
172+ output_global_shape ,
159173 )
160174
161175
@@ -167,7 +181,7 @@ def determine_store_backing(
167181 global_shape : Tuple [int , int , int ],
168182 section_idx : int ,
169183) -> DataSetStoreBacking :
170- section_memory = estimate_section_memory (
184+ section_memory , _ = estimate_section_memory (
171185 comm .size ,
172186 comm .rank ,
173187 comm .allgather ,
0 commit comments