torchinterp1d
CUDA 1-D interpolation for Pytorch
Requires PyTorch >= 1.6 (due to torch.searchsorted).
Presentation
This repository implements an interp1d function that overrides torch.autograd.Function, enabling
linear 1D interpolation on the GPU for Pytorch.
def interp1d(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
-
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 byx. The length ofyalong its last dimension must be the same as that ofx -
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 whicheverxandyis 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
Type pip install -e . in the root folder of this repo.
Usage
Basically simply calle torchinterp1d.interp1d.
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%.
Metadata
Release files for torchinterp1d 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchinterp1d-1.1.tar.gz | 4.5 kB | Without provenance | Details for torchinterp1d-1.1.tar.gz |
Release files / torchinterp1d-1.1.tar.gz
| Download URL | torchinterp1d-1.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
905f69f90e5c95662623a9659e7b15bec27734b9bf501200385cafcf96cd805f
|
|
BLAKE2b-256 checksum How to use checksums |
690cda695d93b0ab0c06aef78a62d5e74303c452c03769bb82af950420bd1677
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.8
|
Security for torchinterp1d 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.