(data, batch_size, layout)
| 50 | |
| 51 | |
| 52 | def _check_data_batch(data, batch_size, layout): |
| 53 | shape, uniform = _get_batch_shape(data) |
| 54 | if len(shape) > batch_size: |
| 55 | raise RuntimeError( |
| 56 | f"The external source callback returned an unexpected batch " |
| 57 | f"size. Expected batch_size <= {batch_size}, actual: {len(shape)}" |
| 58 | ) |
| 59 | |
| 60 | if len(shape) > 0: |
| 61 | dim = len(shape[0]) |
| 62 | if not uniform: |
| 63 | for ts in shape: |
| 64 | if len(ts) != dim: |
| 65 | raise RuntimeError( |
| 66 | "All tensors in a batch must have the same number of dimensions" |
| 67 | ) |
| 68 | if layout is not None and layout != "" and dim != len(layout): |
| 69 | raise RuntimeError(f"The layout '{layout}' cannot describe {dim}-dimensional data") |
| 70 | |
| 71 | |
| 72 | def _prep_data_for_feed_input(data, batch_size, layout, device_id=None): |
no test coverage detected