Skip to content

Commit

Permalink
[shortfin] Fix mobilenet_server example by filling mapped storage. (#241
Browse files Browse the repository at this point in the history
)

I saw this error trying to run this example:
```
RuntimeError: Async exception on <Worker 'device-hostcpu:0:0@0'>): '_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
  • Loading branch information
ScottTodd authored Oct 3, 2024
1 parent 04ce113 commit 8e074b4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 8e074b4

Please sign in to comment.