Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal functions #29

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Universal functions #29

merged 1 commit into from
Jan 22, 2025

Conversation

seanmcl
Copy link
Collaborator

@seanmcl seanmcl commented Jan 21, 2025

NumPy uses an abstraction of functions called Ufunc. It has a lot of widgets in NumPy, but for now we just support lifting element-wise operations and broadcasting.

TensorLib/Ufunc.lean Show resolved Hide resolved
return Element.arrayScalar acc

-- Sum with a single axis.
def sum1 (a : Type) [Add a] [Zero a] [Element a] (arr : Tensor) (axis : Nat) : Err Tensor := do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came out pretty nice. Seems like the design is holding up well.

TensorLib/Ufunc.lean Show resolved Hide resolved
TensorLib/Ufunc.lean Show resolved Hide resolved
@seanmcl seanmcl merged commit a30d840 into main Jan 22, 2025
1 check passed
@seanmcl seanmcl deleted the sm/09-ufunc branch January 22, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants