-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import shortfin as sf | ||
|
||
|
||
def get_selected_devices(sb: sf.SystemBuilder, device_ids=None): | ||
available = sb.available_devices | ||
selected = [] | ||
if device_ids is not None: | ||
if len(device_ids) > len(available): | ||
raise ValueError( | ||
f"Requested more device ids ({device_ids}) than available ({available})." | ||
) | ||
for did in device_ids: | ||
if isinstance(did, str): | ||
try: | ||
did = int(did) | ||
except ValueError: | ||
did = did | ||
if did in available: | ||
selected.append(did) | ||
elif isinstance(did, int): | ||
selected.append(available[did]) | ||
else: | ||
raise ValueError(f"Device id {did} could not be parsed.") | ||
else: | ||
selected = available | ||
return selected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters