karthik-0306 opened a new issue, #41386: URL: https://github.com/apache/beam/issues/41386
### What happened? `get_num_bytes` in `onnx_inference.py` and `tensorrt_inference.py` returns `sum(np_array.itemsize for np_array in batch)`. `itemsize` is the size of a single element, so each example counts as 4 or 8 bytes whatever its shape, and the `inference_request_batch_byte_size` metric is wrong. For a batch of two `float32` arrays of shape `(3, 224, 224)`, `OnnxModelHandlerNumpy.get_num_bytes` returns `8` instead of `1204224`. The `test_num_bytes` tests in `onnx_inference_test.py` and `tensorrt_inference_test.py` assert the current value (`itemsize * len(batch)`). #41058 fixes the same undercount for the PyTorch and HuggingFace handlers. For numpy arrays the equivalent fix is `ndarray.nbytes`. Expected: `get_num_bytes` returns the total size of the batch. I plan to use `ndarray.nbytes` in both handlers and fix the tests. Version: master at b791929763 (2.79.0.dev). ### Issue Priority Priority: 3 (minor) ### Issue Components - [x] Component: Python SDK - [ ] Component: Java SDK - [ ] Component: Go SDK - [ ] Component: Typescript SDK - [ ] Component: IO connector - [ ] Component: Beam YAML - [ ] Component: Beam examples - [ ] Component: Beam playground - [ ] Component: Beam katas - [ ] Component: Website - [ ] Component: Infrastructure - [ ] Component: Spark Runner - [ ] Component: Flink Runner - [ ] Component: Prism Runner - [ ] Component: Hazelcast Jet Runner - [ ] Component: Google Cloud Dataflow Runner -- 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]
