Skip to main content

PyTorch extension package for Bessel functions with arbitrary real order and complex inputs

Project description

About

PyTorch extension package for modified Bessel functions of the second kind with complex inputs

Install

Currently only supports Linux (with CUDA 12.4) or MacOS (Apple silicon, cpu only) with python >= 3.9, <= 3.12.

pip install torch-bessel

Example

import torch_bessel

real, imag = torch.randn(2, 5, device="cuda")
z = torch.complex(real.abs(), imag)  # correctness for inputs in the left-half complex plane is not gauranteed.
torch_bessel.ops.modified_bessel_k0(z)

Implemented functions

  • modified_bessel_k0: Same as torch.special.modified_bessel_k0, but also handles backpropagation and complex inputs on cpu and cuda. Correctness is guaranteed on the right-half complex plane for double types, and almost guaranteed for float types, though it appears there are a very small handful of inputs which result in NaNs which needs to be fixed. On cuda, torch.chalf inputs are also supported, though the underlying cuda kernel just upcasts chalf to cfloat (note that this uses no extra GPU memory, as opposed to manually casting torch.chalf to torch.cfloat before calling modified_bessel_k0 which doubles the GPU memory used). On the left-half complex plane, function output appears mostly correct, but with small numerical errors for certain inputs. On the negative real line, output is NaN.
  • modified_bessel_k1: Same as torch.special.modified_bessel_k1, but also handles complex inputs on cpu and cuda. Backpropagation not implemented, but this can be easily manually implemented yourself by writing a torch.autograd.Function using the recurrence properties of bessel functions. Same caveats as modified_bessel_k0 apply.

WIP

  • modified_bessel_kv: Analogue of scipy.special.kv.

Benchmarks

Benchmarking performed with the asv package. Results can be viewed at https://hchau630.github.io/torch-bessel.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

torch_bessel-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (33.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.7-cp312-cp312-macosx_11_0_arm64.whl (82.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

torch_bessel-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (33.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.7-cp311-cp311-macosx_11_0_arm64.whl (83.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

torch_bessel-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (33.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.7-cp310-cp310-macosx_11_0_arm64.whl (82.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

torch_bessel-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (33.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.7-cp39-cp39-macosx_11_0_arm64.whl (82.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file torch_bessel-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a3bbd41fe75453738efcd889544c98284a8931840a8264d12868dc5da6d922a
MD5 7718e77feab3df6901b467509a681eab
BLAKE2b-256 4c3ab2f146490fc67aba7b827c8b8f168b676c98170c5c43994ea788a52f1b57

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ca5f04d8483a97a923c3733ec3e1a12a9b54dc6542c77e95961d1a76e2a7264
MD5 e612bc3662d2928bb3c58dc04646fd9e
BLAKE2b-256 a2ace5712b1940da2f927a665d07b0fe1215fa3146fdffc267b22aa4b173f9ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 53a99bb2d89f7ba3eaef67454d3b89af2c277beac853fa67b95f8ef1d01b0fed
MD5 f7306e0fa80ba743d7a3a9c502f6f14c
BLAKE2b-256 890df643324b6c2c4a6b8d516233d2917e05040a852094a2764bd9efa5867e8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aea122965d0593674526cf55075a0f2871cabf447449395a150a2adf4ef95d76
MD5 a21dbd4d8860c2060de53586734942eb
BLAKE2b-256 b37b50807178512645cead688b19bb4451a5662a6d2af6455f0fe8a31ea1acdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 689399eb1bf10c104f2b76ea1fc519bacb5d2056975d1af416506587f41b747d
MD5 94a2e16f49f2ff85c2894586efae8296
BLAKE2b-256 4398f512c64d1e50d0dfeeb7350aa08999f1b29e53d7547a0b79262e1fa074eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77e003881a623b0e72c70d2c8e5b22fcd43722d404892aeda4ee9594ba707029
MD5 775cabd6c4f9ec7d54066d1b67881ab1
BLAKE2b-256 0f7a0724e0dc95c1c09b12bb48f3b54f2c22413306157c5d38812866793a14ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c45693e3a7c707c78c8d9540962c8f26b7fff1d105a26c3995aeac0fa88a83f3
MD5 4b1c28dc2bac5c6e0fb659899d1edf20
BLAKE2b-256 86037cdef0947829151ea26415ba22cea09551a504b8a167412757cc709b3675

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_bessel-0.0.7-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7c4963a10af4f0692bd292af6bcd35fa0641c6352da8306a500c137414946b6
MD5 4ad07abeee45f296bf379ec0685adecd
BLAKE2b-256 5bd0cc68bfb45946c2b3e4e5fd7728ee6a041ff90491efdde42d0ae8a789c23b

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.7-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: build_and_deploy.yml on hchau630/torch-bessel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page