getkeops / keops

KErnel OPerationS, on CPUs and GPUs, with autodiff and without memory overflows
https://www.kernel-operations.io
MIT License
1.04k stars 64 forks source link

Dot product between two LazyTensor #212

Closed vishalsharbidar closed 2 years ago

vishalsharbidar commented 2 years ago

Hello, First of all, I would like to thank you for creating KeOps. Its a great library.

Coming to the issue, I have two matrices, A=[M,128] and B=[N,128] and I want to calculate the score matrix between A and B. Its a dot product of A and B to get [M,N] matrix. M and N are around 20000 and 15000. I created a LazyTensor of (M, 1, 128) and (1, N, 128), but I am unable to transform these tensor to do the dot product using KeOps.

I would appreciate the help! Thanks!

jeanfeydy commented 2 years ago

Hi @vishalsharbidar ,

Thanks for your kind words! The trick is that with the current LazyTensor syntax, the dot product operation is given by the binary or | operator. This is a convention that made sense for us in 2017, coming from applied mathematics, but we now understand that this is super confusing in Python. @bcharlier and @joanglaunes are currently working on re-vamping our compilation engine to release KeOps v2.0. Once this is out, we will definitely work to include a 100% NumPy-compatible SymbolicTensor API in KeOps v2.1 :-)

Best regards, Jean

vishalsharbidar commented 2 years ago

Hello @jeanfeydy

Thanks for the quick response. The provided solution is working. Thank you again and have a great day ahead.

Regards, Vishal