Skip to content

Latest commit

 

History

History
54 lines (35 loc) · 1.55 KB

README.markdown

File metadata and controls

54 lines (35 loc) · 1.55 KB

petalisp-einsum

This packages tries to implement the functionality of Numpy's einsum function for Petalisp.

Usage

The only exported function of this package is einsum and its variant einsum*. It tries to emulate the behavior of Numpy's/PyTorch's einsum function.

E. g. the following expression will calculate the matrix product of two arrays. We calculate the product over the different axis indices and sum over non-unique indices.

(ql:quickload :array-operations)
(defparameter *mat-a* (aops:rand '(4 3)))
(defparameter *mat-b* (aops:rand '(3 5)))

(petalisp:compute (einsum "ij jk" *mat-a* *mat-b*))

When you specify one or multiple results it will sum over axis specifiers not present in the result. So the following will calculate the matrix product and its transpose (commas are not obligatory).

(multiple-value-call #'compute (einsum "ij, jk -> ik ki" *mat-a* *mat-b*))

The stared version allows to set alternatives for the elementwise operation and reduction.

(petalisp:compute (einsum "ij jk" (list *mat-a* *mat-b*) #'max #'min))

Installation

With quicklisp installed, clone this repository to your local projects folder and then load it via quicklisp.

(ql:quickload :petalisp-einsum)

Author

Copyright

Copyright (c) 2020 Stephan Seitz (stephan.seitz@fau.de)

License

Licensed under the GPL License.