You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,21 +34,7 @@ The macro also tries to provide a gradient for use with [Tracker](https://github
34
34
35
35
* The option `grad=Dual` uses instead [ForwardDiff](https://github.com/JuliaDiff/ForwardDiff.jl) to differentiate the right hand side (only for reductions over `+`). This allows for more complicated expressions.
36
36
37
-
The expression need not be just one line, for example:
38
-
39
-
```julia
40
-
@tullio out[x, y] :=@inbounds(begin# sum over k
41
-
a,b = off[k]
42
-
mat[mod(x+a), mod(y+b)]
43
-
end) (x inaxes(mat,1), y inaxes(mat,2)) grad=Dual nograd=off
44
-
```
45
-
46
-
Here the macro cannot infer the range of the output's indices `x,y`, so they must be provided explicitly.
47
-
(If writing into an existing array, with `out[x,y] = begin ...` or `+=`, then ranges would be taken from there.)
48
-
Because it sees assignment being made, it does not attempt to sum over `a,b`, and it assumes that indices could go out of bounds so does not add `@inbounds` for you.
49
-
(Although in fact `mod(x+a) == mod(x+a, axes(mat,1))` is safe.)
50
-
It will also not be able to take a symbolic derivative, but dual numbers will work fine.
51
-
37
+
The entire right hand side is summed over the full possible range of any indices not appearing on the left.
52
38
Pipe operators `|>` or `<|` indicate functions to be performed *outside* the sum, for example:
The expression need not be just one line, for example:
257
+
258
+
```julia
259
+
@tullio out[x, y] :=@inbounds(begin# sum over k
260
+
a,b = off[k]
261
+
mat[mod(x+a), mod(y+b)]
262
+
end) (x inaxes(mat,1), y inaxes(mat,2)) grad=Dual nograd=off
263
+
```
264
+
Here the macro cannot infer the range of the output's indices `x,y`, so they must be provided explicitly.
265
+
(If writing into an existing array, with `out[x,y] = begin ...` or `+=`, then ranges would be taken from there.)
266
+
Because it sees assignment being made, it does not attempt to sum over `a,b`, and it assumes that indices could go out of bounds so does not add `@inbounds` for you.
267
+
(Although in fact `mod(x+a) == mod(x+a, axes(mat,1))` is safe.)
268
+
It will also not be able to take a symbolic derivative, but dual numbers will work fine.
0 commit comments