MCPcopy Create free account
hub / github.com/apple/axlearn / batches

Method batches

axlearn/common/input_base.py:213–225  ·  view source on GitHub ↗

Yields per-feed physical input batches (using `input_dispatcher` if configured). The caller should use `host_to_global_array` to construct a global physical batch from the per-feed physical batches returned from this method. See also `dispatch_global_batch` for constructing

(self, it: Iterator[Nested[Tensor]])

Source from the content-addressed store, hash-verified

211 yield from self.batches(iter(self.dataset()))
212
213 def batches(self, it: Iterator[Nested[Tensor]]) -> Iterator[Nested[Tensor]]:
214 """Yields per-feed physical input batches (using `input_dispatcher` if configured).
215
216 The caller should use `host_to_global_array` to construct a global physical batch from the
217 per-feed physical batches returned from this method.
218
219 See also `dispatch_global_batch` for constructing a global logical batch.
220 """
221 for input_batch in it:
222 input_batch = as_numpy_array(input_batch)
223 if "input_dispatcher" in self.children:
224 input_batch = self.input_dispatcher.logical_to_physical_batch(input_batch)
225 yield input_batch
226
227 def dispatch_global_batch(self, global_physical_batch: Nested[Tensor]) -> Nested[Tensor]:
228 """Converts a global physical batch to a global logical batch.

Callers 7

__iter__Method · 0.95
eval_stepMethod · 0.45
test_input_dispatcherMethod · 0.45
test_batchesMethod · 0.45
runMethod · 0.45

Calls 2

as_numpy_arrayFunction · 0.90

Tested by 4

test_input_dispatcherMethod · 0.36
test_batchesMethod · 0.36