NumPy einsum equivalent for XTensor (C++)

749 views Asked by At

At the beginning, it's my very first question here, I'll really try my best to describe,
please note if I did it wrong.

Recently, I have been rewriting some numpy stuff to C++.
Circumstances required to do so, sadly. I really can't do anything about it.
(I can call some python commands from C++, but not everything.)

Naturally, I have started with XTensor, as it claims to be C++ equivalent of numpy.
Sadly, I've got stuck on numpy.einsum
I searched through the internet and found some related stuff, how it works (at least a bit).

Then comes my problem here. First of all, I need to implement the version without ->.
Numpy docs are telling me that it's somewhat of 'implicit mode' (also with ellipsis then).
(Described later) I've found implementations / equivalents to some einsum configurations,
like 'i,ij' and else.
I would like to stick with XTensor, since I've done quite much stuff already.
Here is the part of code I need to re-implement in XTensor with C++:

# a is ndarray with shape (1, 28), 2dim
# e is ndarray with shape (1, 28, 3, 17), 4dim

numpy.einsum('...i,...ijk', a, e)

I hope that someone could explain me, what does it refer to.
And it would be best if you could give me some idea how could I implement it.
I can use anything, I thinkā€¦ what actually will end up as xt::xarray at the end.
I was thinking about calling python code from C++ or even using Google protobuf, in worst case.

If you have any ideas or useful links, please share!
(related to code i posted and not to numpy.einsum in general)

0

There are 0 answers