Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scipy.interpolate.griddata equivalent in CUDA

I'm trying to perform Fitted Value Iteration (FVI) in python (involving approximating a 5 dimensional function using piecewise linear interpolation).

scipy.interpolate.griddata works perfectly for this. However, I need to call the interpolation routine several thousand times (since FVI is a MC based algorithm).

So basically, the set of points where the function is known is static (and large - say 32k), but the points i need to approximate (which are small perturbations of the original set) is very large (32k x 5000 say).

Is there an implementation of what scipy.interpolate.griddata does that's been ported to CUDA? alternatively, is there a way to speed up the calculation somehow?

Thanks.

like image 363
user1726633 Avatar asked Dec 23 '12 22:12

user1726633


People also ask

What does Scipy interpolate Griddata do?

interpolate. griddata() method is used to interpolate on a 2-Dimension grid.

What is interpolate interp1d?

The interp1d() function of scipy. interpolate package is used to interpolate a 1-D function. It takes arrays of values such as x and y to approximate some function y = f(x) and then uses interpolation to find the value of new points.

What is a spline in Scipy?

Spline interpolation is a type of piecewise polynomial interpolation method. The SciPy API provides several functions to implement the interpolation method for a given dataset. In this tutorial, you'll learn how to apply interpolation for a given dataset by using SciPy API functions in Python.


1 Answers

For piece-wise linear interpolation, the docs say that scipy.interpolate.griddata uses the methods of scipy.interpolate.LinearNDInterpolator, which in turn uses qhull to do a Delaunay tesellation of the input points, then performs standard barycentric interpolation, where for each point you have to determine inside which hypertetrahedron each point is, then use its barycentric coordinates as the interpolation weights for the hypertetrahedron node values.

The tesellation is probably hard to parallelize, but you can access the CPU version with scipy.spatial.Delaunay. The other two steps are easily parallelized, although I don't know of any freely available implementation.

If your known-function points are on a regular grid, the method described here is specially easy to implement in CUDA, and I have worked with actual implementations of it, albeit none publicly available.

So I am afraid you are going to have to do most of the work yourself...

like image 67
Jaime Avatar answered Sep 28 '22 08:09

Jaime