-
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.
[shortfin] Add simple example to enumerate devices and test options.
- Loading branch information
1 parent
92170e1
commit 1ea095a
Showing
1 changed file
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2024 Advanced Micro Devices, Inc. | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
r"""Simple test program that enumerates devices available. | ||
Run with SystemBuilder keyword args on the command line like:: | ||
python examples/python/enumerate_devices.py \ | ||
system_type=amdgpu amdgpu_logical_devices_per_physical_device=4 | ||
""" | ||
|
||
import sys | ||
|
||
import shortfin as sf | ||
|
||
|
||
def main(): | ||
args = [arg.split("=", maxsplit=1) for arg in sys.argv[1:]] | ||
arg_dict = {k: v for k, v in args} | ||
print(f"Creating system with args: {arg_dict}") | ||
builder = sf.SystemBuilder(**arg_dict) | ||
with builder.create_system() as ls: | ||
for device in ls.devices: | ||
print(device) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |