this post was submitted on 22 May 2025
11 points (100.0% liked)

dynomight internet forum

74 readers
2 users here now

dynomight internet forum

founded 11 months ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] ferflo@lemmy.world 1 points 1 week ago

I did at some point consider adding a new symbol (like ":") that would act as a new axis with a unique name, but have been hesitant so far, since it adds to the complexity of the notation. There are a bunch of ideas for improving quality-of-life in einx, but so far I've tried erring on the side of less complexity (and there's probably some cases where I should've adhered to this more); to keep a low barrier of entry and also not end up with a mess of many different rules that classical tensor notation is in (you made good points about that here...). There are indeed cases where the operation depends on names in the brackets, e.g. einx.dot("a [b], [b c], [c] d", ...), so the ":" would be an additional variant rather than a simplification.

What I like better about using actual names is also that they convey semantics

einx.softmax("b h q [k]", x) # Ok, softmax along key dimension
einx.softmax("b h q [:]", x) # Softmax along... last dimension?

and indicate corresponding axes in consecutive operations (although this is not enforced strictly).

Defining the shapes of a vmapped operation in the decorator sounds like a good idea. It would probably require a kind of pattern matching to align the inner and outer expression (e.g. to also allow for n-dimensional inputs or variadic arguments to the custom, vmapped function).