Assign to diagonal #291
Closed
AllanYangZhou
started this conversation in
Ideas
Replies: 2 comments
-
In eindex you can do something like this:
But eindex supports only numpy, as torch/tf/jax still do not support array api. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks, eindex looks really promising! Though yeah the torch/jax incompatibility for now might be a bit limiting. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Suppose
X
is a rank-5 tensor andy
a matrix. The operation I want to accomplish is:X[i,i,i,j,k] += y[j,k]
for all values of indices
i,j,k
. That is, I want to broadcast the matrixy
along the "diagonal" of the first 3 dimensions ofX
.More generally, I want to assign arbitrary-rank
y
to the diagonal along an arbitrary subset of dimensions ofX
, as long as the shapes are all compatible. Is this possible with any einops-like functions? I could not figure out any way.Is there some small modification of existing einops implementations that could accomplish this?
Beta Was this translation helpful? Give feedback.
All reactions