-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Feature request - einsum #10840
Comments
@sandeep-krishnamurthy could you help to add label Feature Request? Thanks |
I am interested in implementing this. Has anyone already started working on this? |
@jasonyu1996 - Thanks for looking into this issue, as far as I know, nobody is working on this feature. Contributions are welcome. Let us know, if you need any help. |
@sandeep-krishnamurthy It seems that it is somewhat complicated to implement einsum in the backend. But I would like to have a try first. Thanks! |
@sandeep-krishnamurthy I am not sure whether this should be implemented in the backend. It needs to be based on several other operators, as it would be complicated and inefficient to directly forward and backward as a whole (especially backward). The
Could you point to me where I should work if I need to use other operators? Or, alternatively, is there a way of storing temporary data in forward for use in backward? Thanks! |
Operators are stateless, but, I remember there is a optimization switch, that enables saving data from forward pass to be used in backward pass to make the computation faster. |
Would it be good then to implement it as a |
I have almost finished the implementation, save some polishing and testing. The current solution is not in the backend, but alongside I think this is probably a decision on the design, as it means a new interface for developing new operators which are relatively complex and high-level and should be implemented based on existing ones. |
May I follow up what is the current state of einsum? It is convenient at times and most useful, perhaps, for its autograd computation. |
@yifeim I have actually implemented one based on the high-level interfaces. However, it supports only the Gluon interface. I guess to add support for Symbol I have to move onto a lower abstraction layer, or rely on some missing high-level interfaces (#12484 for example). @altosaar @roywei @sandeep-krishnamurthy I would be grateful if you can help. |
@jasonyu1996 Could you actually point me to the Gluon interface. A hacky way to get a symbol is to |
See #13244 for an example about how to export gluon models. |
We now have einsum in the numpy interface of MXNet. Thus, close this issue. You may try import mxnet as mx
import numpy as np
mx.npx.set_np()
lhs = mx.np.array(np.random.normal(0, 1, (64, 8, 128, 512)), dtype=np.float32, ctx=mx.gpu())
rhs = mx.np.array(np.random.normal(0, 1, (64, 8, 128, 512)), dtype=np.float32, ctx=mx.gpu())
mx.npx.waitall()
gt = mx.np.einsum('abiz,abjz->abij', lhs, rhs)
gt_np = gt.asnumpy() |
Useful for writing models: https://rockt.github.io/2018/04/30/einsum
The text was updated successfully, but these errors were encountered: