Skip to content

Commit b3950b0

Browse files
committed
Added examples for getting started page
1 parent 9e17d5c commit b3950b0

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

docs/getting-started.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,16 @@ pip install dyson
1414

1515

1616
```python
17-
from dyson import router
17+
import dyson
1818
import torch
19+
import time
20+
from dyson import router
21+
22+
# Define a function
23+
def mat(a, b):
24+
return torch.matmul(a,b)
1925

20-
class ComplexOperations:
21-
def add(self):
22-
a, b = 1, 3
23-
return a + b
2426

25-
def func(self):
26-
x = torch.tensor([1, 2])
27-
y = torch.tensor([3, 4])
28-
z = torch.add(x, y)
29-
return z
3027
```
3128

3229
### Routing Your Workload
@@ -37,12 +34,10 @@ Add the `key.cgl` path in your code like so,
3734
key_path = "path/to/your/key.cgl"
3835
```
3936

40-
Add your function with [`paramter`](https://crossgl.github.io/crossgl-docs/dyson/#advanced-routing-parameters) values.
37+
Add your function with [`parameter`](https://crossgl.github.io/crossgl-docs/dyson/#advanced-routing-parameters) values.
4138

4239
```python
43-
physics_function = ComplexOperations()
44-
45-
result = router.route_hardware(
40+
hardware = router.route_hardware(
4641
key_path,
4742
physics_function,
4843
mode="energy-efficient",
@@ -52,4 +47,19 @@ result = router.route_hardware(
5247
precision="normal",
5348
multi_device=True
5449
)
55-
```
50+
```
51+
52+
We now have the hardware name required for routing. This can be passed as a parameter to the dyson.run() function, enabling it to route to the specified hardware.
53+
54+
```python
55+
# Compile the function for CUDA (or CPU)
56+
func = dyson.run(mat, target_device=hardware)
57+
58+
# Execute the function with arguments
59+
a = torch.randn(1000, 1000)
60+
b = torch.randn(1000, 1000)
61+
result = func(a, b)
62+
63+
print(result)
64+
```
65+

0 commit comments

Comments
 (0)