Giter Club home page Giter Club logo

torchinterp1d's Introduction

torchinterp1d

CUDA 1-D interpolation for Pytorch

Presentation

This repository implements an Interp1d class that overrides torch.autograd.Function, enabling linear 1D interpolation on the GPU for Pytorch.

class Interp1d(torch.autograd.Function):
    def forward(ctx, x, y, xnew, out=None)

This function returns interpolated values of a set of 1-D functions at the desired query points xnew.

It works similarly to Matlab™ or scipy functions with the linear interpolation mode on, except that it parallelises over any number of desired interpolation problems and exploits CUDA on the GPU

Parameters for Interp1d.forward

  • x : a (N, ) or (D, N) Pytorch Tensor: Either 1-D or 2-D. It contains the coordinates of the observed samples.

  • y : (N,) or (D, N) Pytorch Tensor. Either 1-D or 2-D. It contains the actual values that correspond to the coordinates given by x. The length of y along its last dimension must be the same as that of x

  • xnew : (P,) or (D, P) Pytorch Tensor. Either 1-D or 2-D. If it is not 1-D, its length along the first dimension must be the same as that of whichever x and y is 2-D. x-coordinates for which we want the interpolated output.

  • out : (D, P) Pytorch Tensor` Tensor for the output. If None: allocated automatically.

Results

a Pytorch tensor of shape (D, P), containing the interpolated values.

Installation

The CUDA interp1d function depends on the torchsearchsorted repository.

If not installed, you must:

  1. Clone that repo through git clone [email protected]:aliutkus/torchsearchsorted.git
  2. Go in the corresponding directory of that repo and launch python setup.py install.

Then, type pip install -e . in the root folder of this repo.

Usage

Try out python test.py in the examples folder.

Solving 100000 interpolation problems: each with 100 observations and 30 desired values
CPU: 8060.260ms, GPU: 70.735ms, error: 0.000000%.

torchinterp1d's People

Contributors

aliutkus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.