4 ms·
No need for .ein source files. We just need a programming language that allows the definition of embedded DSLs without shoving them into one-line strings. A lan
by reikonomusha 2y ago
No need for .ein source files. We just need a programming language that allows the definition of embedded DSLs without shoving them into one-line strings. A language like Common Lisp.
Here's einsum in 200 lines of Common Lisp. All einsum expressions are statically analyzed, checked for errors, and AOT compiled to machine code: https://github.com/quil-lang/magicl/blob/master/src/high-level/einsum.lisp#L16 https://github.com/quil-lang/magicl/blob/master/src/high-lev...
- mcabbott 2y agoThis is also how it works in Julia, where macros digest notation for einsum-like operations before compile-time. In fact the linked file's explanatory comment: (einsum (A i j) (B i k) (C k j)) results in the the updates A[i,j] = \\sum_k B[i,k]C[k,j], which is equivalent to matrix multiplication. very nearly contains the syntax used by all the Julia packages (where @ marks a macro), which is @tensor A[i,j] = B[i,k] * C[k,j] (using https://github.com/Jutho/TensorOperations.jl https://github.com/Jutho/TensorOperations.jl, but see also OMEinsum, Finch, and my Tullio, TensorCast.)