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]])
| 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. |