torchinterp1d


Nametorchinterp1d JSON
Version 1.1 PyPI version JSON
download
home_pagehttps://github.com/aliutkus/torchinterp1d
SummaryAn interp1d implementation for pytorch
upload_time2024-05-25 00:50:55
maintainerNone
docs_urlNone
authorAntoine Liutkus
requires_pythonNone
licenseNone
keywords interp1d torch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # torchinterp1d
## CUDA 1-D interpolation for Pytorch

Requires PyTorch >= 1.6 (due to [torch.searchsorted](https://pytorch.org/docs/master/generated/torch.searchsorted.html)).

## 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 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

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%.
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aliutkus/torchinterp1d",
    "name": "torchinterp1d",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "interp1d torch",
    "author": "Antoine Liutkus",
    "author_email": "antoine.liutkus@inria.fr",
    "download_url": "https://files.pythonhosted.org/packages/69/0c/da695d93b0ab0c06aef78a62d5e74303c452c03769bb82af950420bd1677/torchinterp1d-1.1.tar.gz",
    "platform": null,
    "description": "# torchinterp1d\n## CUDA 1-D interpolation for Pytorch\n\nRequires PyTorch >= 1.6 (due to [torch.searchsorted](https://pytorch.org/docs/master/generated/torch.searchsorted.html)).\n\n## Presentation\n\nThis repository implements an `interp1d` function that overrides torch.autograd.Function, enabling\nlinear 1D interpolation on the GPU for Pytorch.\n\n```\ndef interp1d(x, y, xnew, out=None)\n```\n\nThis function returns interpolated values of a set of 1-D functions at the desired query points `xnew`.\n\nIt works similarly to Matlab\u2122 or scipy functions with\nthe `linear` interpolation mode on, except that it parallelises over any number of desired interpolation problems and exploits CUDA on the GPU\n\n### Parameters for `interp1d`\n\n* `x` : a (N, ) or (D, N) Pytorch Tensor:\nEither 1-D or 2-D. It contains the coordinates of the observed samples.\n\n* `y` : (N,) or (D, N) Pytorch Tensor.\nEither 1-D or 2-D. It contains the actual values that correspond to the coordinates given by `x`.\nThe length of `y` along its last dimension must be the same as that of `x`\n\n* `xnew` : (P,) or (D, P) Pytorch Tensor.\nEither 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.\n\n* `out` : (D, P) Pytorch Tensor`\n        Tensor for the output. If None: allocated automatically.\n\n### Results\n\na Pytorch tensor of shape (D, P), containing the interpolated values.\n\n## Installation\n\nType `pip install -e .` in the root folder of this repo.\n\n## Usage\n\nBasically simply calle `torchinterp1d.interp1d`.\n\nTry out `python test.py` in the `examples` folder.\n```\nSolving 100000 interpolation problems: each with 100 observations and 30 desired values\nCPU: 8060.260ms, GPU: 70.735ms, error: 0.000000%.\n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "An interp1d implementation for pytorch",
    "version": "1.1",
    "project_urls": {
        "Download": "https://github.com/aliutkus/torchinterp1d/archive/refs/tags/v1.tar.gz",
        "Homepage": "https://github.com/aliutkus/torchinterp1d"
    },
    "split_keywords": [
        "interp1d",
        "torch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "690cda695d93b0ab0c06aef78a62d5e74303c452c03769bb82af950420bd1677",
                "md5": "ab9c9f26935304625f9b1fb5ed3a902f",
                "sha256": "905f69f90e5c95662623a9659e7b15bec27734b9bf501200385cafcf96cd805f"
            },
            "downloads": -1,
            "filename": "torchinterp1d-1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ab9c9f26935304625f9b1fb5ed3a902f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4490,
            "upload_time": "2024-05-25T00:50:55",
            "upload_time_iso_8601": "2024-05-25T00:50:55.899610Z",
            "url": "https://files.pythonhosted.org/packages/69/0c/da695d93b0ab0c06aef78a62d5e74303c452c03769bb82af950420bd1677/torchinterp1d-1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-25 00:50:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aliutkus",
    "github_project": "torchinterp1d",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "torchinterp1d"
}
        
Elapsed time: 0.24490s