Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix liquid parsing issues in pytorch ndarray cheatsheet #2690

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions docs/pytorch/pytorch-djl-ndarray-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tensor.tensor(a)
```

```
float[][] array = {{1, 2, 3}, {4, 5, 6}};
float[][] array = { {1, 2, 3}, {4, 5, 6} };
NDArray nd = manager.create(array);
```

Expand Down Expand Up @@ -107,7 +107,7 @@ torch.zeros_like(a)
NDArray ones = manager.ones(new Shape(1, 2, 3));
NDarray zeros = manager.zeros(new Shape(1, 2, 3));

NDArray a = manager.create(new float[][] {{1, 2, 3}, {4, 5, 6}});
NDArray a = manager.create(new float[][] { {1, 2, 3}, {4, 5, 6} });
ones = a.onesLike();
zeros= a.zerosLike();
```
Expand All @@ -125,7 +125,7 @@ torch.tensor(a, requires_grad=True, dtype=float)
```

```
NDArray a = manager.create(new float[][] {{1, 2, 3}, {4, 5, 6}});
NDArray a = manager.create(new float[][] { {1, 2, 3}, {4, 5, 6} });
a.setRequiresGradient(true);
a
```
Expand Down Expand Up @@ -587,7 +587,7 @@ a.T
Java

```
var a = manager.create(new float[][] {{1, 2}, {3, 4}});
var a = manager.create(new float[][] { {1, 2}, {3, 4} });
a.transpose();
```

Expand Down Expand Up @@ -683,7 +683,7 @@ ND: (3) cpu() int32
</details>

```
var indices = manager.create(new int[][] {{2, 4}, {6, 8}});
var indices = manager.create(new int[][] { {2, 4}, {6, 8} });
a.get(indices);
```

Expand All @@ -705,7 +705,7 @@ ND: (2, 2) cpu() int32
### multi-dimension ndarray slice

```
var a = manager.create(new int[][] {{5, 10, 20}, {30, 40, 50}, {60, 70, 80}});
var a = manager.create(new int[][] { {5, 10, 20}, {30, 40, 50}, {60, 70, 80} });
```

---
Expand Down Expand Up @@ -1028,8 +1028,8 @@ ND: (2, 6) cpu() float32
#### stack

```
var images0 = manager.create(new int[][] {{128, 0, 0}, {0, 128, 0}});
var images1 = manager.create(new int[][] {{0, 0, 128}, {127, 127, 127}});
var images0 = manager.create(new int[][] { {128, 0, 0}, {0, 128, 0} });
var images1 = manager.create(new int[][] { {0, 0, 128}, {127, 127, 127} });
```

```
Expand Down Expand Up @@ -1198,7 +1198,7 @@ torch.abs(tensor)
```

```
var ndarray = manager.create(new int[][] {{1, 2}, {-1, -2}});
var ndarray = manager.create(new int[][] { {1, 2}, {-1, -2} });
ndarray.abs();
```

Expand Down Expand Up @@ -1226,7 +1226,7 @@ torch.ceil(tensor)
```

```
var ndarray = manager.create(new double[][] {{1.0,1.1,1.2,1.3,1.4}, {1.5,1.6,1.7,1.8,1.9});
var ndarray = manager.create(new double[][] { {1.0,1.1,1.2,1.3,1.4}, {1.5,1.6,1.7,1.8,1.9} });
ndarray.ceil();
```

Expand Down Expand Up @@ -1254,7 +1254,7 @@ torch.floor(tensor)
```

```
var ndarray = manager.create(new double[][] {{1.0,1.1,1.2,1.3,1.4}, {1.5,1.6,1.7,1.8,1.9});
var ndarray = manager.create(new double[][] { {1.0,1.1,1.2,1.3,1.4}, {1.5,1.6,1.7,1.8,1.9} });
ndarray.floor();
```

Expand Down Expand Up @@ -1282,7 +1282,7 @@ torch.round(tensor)
```

```
var ndarray = manager.create(new double[][] {{1.0,1.1,1.2,1.3,1.4}, {1.5,1.6,1.7,1.8,1.9}});
var ndarray = manager.create(new double[][] { {1.0,1.1,1.2,1.3,1.4}, {1.5,1.6,1.7,1.8,1.9} });
ndarray.round();
```

Expand Down Expand Up @@ -1310,7 +1310,7 @@ torch.sign(tensor)
```

```
var ndarray = manager.create(new double[][] {{-0.1, -0.0}, {0.0, 0.1});
var ndarray = manager.create(new double[][] { {-0.1, -0.0}, {0.0, 0.1} });
ndarray.sign();
```

Expand Down Expand Up @@ -1440,7 +1440,7 @@ torch.nonzero()
```

```
var a = manager.create(new long[][] {{0.0,0.1}, {0.2,0.3}});
var a = manager.create(new long[][] { {0.0,0.1}, {0.2,0.3} });
a.nonzero();
```

Expand Down Expand Up @@ -1482,8 +1482,8 @@ torch.masked_select(t, mask)
```

```
var ndarray = manager.create(new double[][] {{0.1, 0.2}, {0.3, 0.4}});
var mask = manager.create(new boolean[][] {false, true}, {true,false}});
var ndarray = manager.create(new double[][] { {0.1, 0.2}, {0.3, 0.4} });
var mask = manager.create(new boolean[][] { {false, true}, {true,false} });
ndarray.booleanMask(mask);
```

Expand Down