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

element-wise each? #205

Open
tcolgate opened this issue Jan 10, 2025 · 1 comment
Open

element-wise each? #205

tcolgate opened this issue Jan 10, 2025 · 1 comment

Comments

@tcolgate
Copy link
Contributor

tcolgate commented Jan 10, 2025

Ivy's @ cannot (I think) currently do element-wise each.
e.g.
In TryAPL:

(⍳ 4 4) ,¨ (⍳ 4 4)
┌───────┬───────┬───────┬───────┐
│1 1 1 1│1 2 1 2│1 3 1 3│1 4 1 4│
├───────┼───────┼───────┼───────┤
│2 1 2 1│2 2 2 2│2 3 2 3│2 4 2 4│
├───────┼───────┼───────┼───────┤
│3 1 3 1│3 2 3 2│3 3 3 3│3 4 3 4│
├───────┼───────┼───────┼───────┤
│4 1 4 1│4 2 4 2│4 3 4 3│4 4 4 4│
└───────┴───────┴───────┴───────┘

So A f¨ B implies pairwise (A[1 1] f B[1 1]) (B[1 2] f B[2 2]).....
In ivy A f@ B does (A f B[1]) A f B[2]. @f@ does a full 'cross product' of all elements.

Most of the built in ops will operate elementwise anyway, but for those that don't (like ,), or for user defined ops, I've had to resort to reshaping as a flat vector, pairing them up, applying a unary function that takes the pairs, and then reshaping the result.

Is an elementwise version of @ achievable?

@rsc
Copy link
Contributor

rsc commented Jan 10, 2025

Indeed, this is what I meant by #69 (comment). I'd like to think more about this before suggesting anything.

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

No branches or pull requests

2 participants