From 8e074b45362737787e5ad1d467f0286976490e4f Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Thu, 3 Oct 2024 12:11:12 -0700 Subject: [PATCH] [shortfin] Fix mobilenet_server example by filling mapped storage. (#241) I saw this error trying to run this example: ``` RuntimeError: Async exception on ): '_shortfin_default.lib.array.storage' object has no attribute 'data' ``` I looked around for and API that would allow for copying from `array.array` (https://docs.python.org/3/library/array.html) into shortfin's `array.storage` (https://shortfin.readthedocs.io/en/latest/reference.html#shortfin_default.lib.array.storage) and only found `map()`. Quite possible that I'm missing something, or there is an easier interface that isn't fully plumbed through to Python and the documentation yet. Logs of this running: https://gist.github.com/ScottTodd/da8c1d6805584490c46e4d2086404a6b --- shortfin/examples/python/mobilenet_server/inference_system.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shortfin/examples/python/mobilenet_server/inference_system.py b/shortfin/examples/python/mobilenet_server/inference_system.py index e42f4cef7..4ba0aba4f 100644 --- a/shortfin/examples/python/mobilenet_server/inference_system.py +++ b/shortfin/examples/python/mobilenet_server/inference_system.py @@ -40,7 +40,9 @@ async def run(self): # just writing to the backing storage is the best we have API # support for. Generally, APIs on storage should be mirrored onto # the array. - self.host_staging.storage.data = request.raw_image_data + # TODO: Easier to use API for writing into the storage + with self.host_staging.storage.map(write=True, discard=True) as m: + m.fill(request.raw_image_data) print("host_staging =", self.host_staging) self.device_input.copy_from(self.host_staging)