Hmmm🤔
If u are looking for a more efficient way to do this well… , but I mean u can try out what i said in my previous answer coz that’ll also save and update parameters Pi for (xi, yi) and Pi+1 for (xi+1, yi+1) and so on.
What I can suggest u do to make things faster:
Use the garbage collector to empty redundant variables
Share the work amongst different gpus (but u said u have only 1 so u should consider cloud service)
Prototype the implementation in python and do the main implementation in C++ then u can run inference in python