damccorm commented on code in PR #28182:
URL: https://github.com/apache/beam/pull/28182#discussion_r1307711564
##########
sdks/python/apache_beam/ml/inference/base.py:
##########
@@ -477,11 +477,19 @@ def run_inference(
return predictions
def get_num_bytes(self, batch: Sequence[Tuple[KeyT, ExampleT]]) -> int:
+ keys, unkeyed_batch = zip(*batch)
+ batch_bytes = len(pickle.dumps(keys))
if self._single_model:
- keys, unkeyed_batch = zip(*batch)
- return len(
- pickle.dumps(keys)) + self._unkeyed.get_num_bytes(unkeyed_batch)
- return len(pickle.dumps(batch))
+ return batch_bytes + self._unkeyed.get_num_bytes(unkeyed_batch)
+
+ batch_by_key = defaultdict(list)
+ for pair in batch:
Review Comment:
I updated to use key/examples.
> also there is conflation of batch of keyed prediction inputs vs a batch of
elements for a single key. not sure how to clarify, could use a courtesy
variable like:
I don't think this is right. `batches` means batch of keyed prediction
inputs in all contexts here, `batch_by_key` represents batches of elements per
key.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]