-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Aside from the @einops_str
macro for Python syntax, an @einops
macro could be used to reduce colons and commas in the input expression—although without commas, (a b)
won't work, so [a b]
could be used instead.
@einops a b c d -> [a b] c d
This is parsed as:
julia> :(@einops a b c d -> [a b] c d)
:(#= REPL[5]:1 =# @einops a b c (d->begin
#= REPL[5]:1 =#
[a b]
end) c d)
so anything adjacent to ->
would require special parsing.
Alternatively (or additionally), the @einops
macro could act on calls, e.g. @einops rearrange(x, "a b c d -> (a b) c d")
but this isn't really better than rearrange(x, einops"a b c d -> (a b) c d")
.
Another option is @rearrange(x, "a b c d -> (a b) c d")
for near perfect parity with Python implementation (just an extra @
).
I don't want this becoming full of macros though, with 5 different ways of calling the same thing.
I would potentially consider just shortening einops"..."
to ein"..."
like they do in OMEinsum.jl, but there's the risk of clashing.