diff options
| author | Yong He <yonghe@outlook.com> | 2024-01-08 09:58:03 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-08 09:58:03 -0800 |
| commit | b570ad4b90fc9eb01d9b11f1c21314f3521c0bdf (patch) | |
| tree | 0a89234a8c2af0410531e8a33e00bd79d0999902 /docs | |
| parent | 1abc67c4404f0db10f5f6ff4150c574b2664cb1e (diff) | |
Update a1-02-slangpy.md
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/user-guide/a1-02-slangpy.md | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/docs/user-guide/a1-02-slangpy.md b/docs/user-guide/a1-02-slangpy.md index b704e215a..bebdb06f4 100644 --- a/docs/user-guide/a1-02-slangpy.md +++ b/docs/user-guide/a1-02-slangpy.md @@ -201,7 +201,7 @@ class MySquareFunc(torch.autograd.Function): Now we can use the autograd function `MySquareFunc` in our python script: ```python -x = torch.tensor([[3.0, 4.0],[0.0, 1.0]], requires_grad=True, device='cuda') +x = torch.tensor((3.0, 4.0), requires_grad=True, device='cuda') print(f"X = {x}") y_pred = MySquareFunc.apply(x) loss = y_pred.sum() @@ -211,10 +211,9 @@ print(f"dX = {x.grad.cpu()}") Output: ``` -X = tensor([[3., 4.], - [0., 1.]], device='cuda:0', requires_grad=True) -dX = tensor([[6., 8.], - [0., 2.]]) +X = tensor([3., 4.], + device='cuda:0', requires_grad=True) +dX = tensor([6., 8.]) ``` And that's it! `slangpy.loadModule` uses JIT compilation to compile your Slang source into CUDA binary. |
