opeltre / topos

Statistics and Topology
MIT License
9 stars 0 forks source link

Field multiplication on CPU #20

Closed opeltre closed 3 years ago

opeltre commented 3 years ago

Computing the product of two fields, e.g.

pV = p * V
# or
V -= K.sums(p * V)

is right now very slow on CPU. Much slower than matrix-vector product, Gibbs state computation, etc. This is what's holding tangent diffusion far behind BP in performance.

This is quite strange as in the 2nd example, p * V should be understood as rvalue. Even if we allocate a tensor pV for this intermediate result in the loop as in 1st example, it stays slow, although there shouldn't be any new memory allocation.

opeltre commented 3 years ago

Replace 1st example by:

pV.data = p.data * V.data 

and it's lightning fast :zap:

How can we transfer this behaviour to Field.__mul__ ???

edit: it was string computations...