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.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.8-cp312-cp312-macosx_11_0_arm64.whl (81.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

torch_bessel-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.8-cp311-cp311-macosx_11_0_arm64.whl (82.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

torch_bessel-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.8-cp310-cp310-macosx_11_0_arm64.whl (81.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

torch_bessel-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

torch_bessel-0.0.8-cp39-cp39-macosx_11_0_arm64.whl (81.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99032a81436cf35f9c9000e03614142430ed2fc7d64426a4a3c1b9f21b53fa0a
MD5 bb5d6652f1a02b9e377d28296f9723e7
BLAKE2b-256 39b86ff78949bcb6fb3fb0c80441dc67ec7f2141ec8074a6734775eb3932e8ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 159b5f9c46d91cb79bf1176520bb082a3f4954368a98391797415cead9711b78
MD5 ca9e770dbad7508d3e53c59e3f324aac
BLAKE2b-256 903b0e2f152f795013d3b40523cada3d7fb5449db478a960450113fbd989e016

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2037b5f6ed9efcbbd38a37dc5709af8ddcc7946f2eb1826df4a5b7c2815d92bb
MD5 28c2008ce5e8ea00c3ea65bc78041893
BLAKE2b-256 023147473bb54858881d2fe4adb9647cc6c9f702f63dcdd3216cda30d1c15e23

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f39bbc675d5349bf21ab54aa0801fe6b6acb7cca98a58bb862f38013d43a0c30
MD5 a1e5f8e8c9d769848bc9bcf3a292b7d5
BLAKE2b-256 aac88af9b4c6821dab74bb211699299847d41be849b5792e18114e010361a48b

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72707d47c7a67aaf9b74a04b957af1692af44ffbc13d12c32d54e9521437cc9a
MD5 2f24e54895adeac53edfdd89ea7a6d51
BLAKE2b-256 da2fa1102426d56966717633928339e175ea32f0b30ad1d2888f0fd3404d6d54

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44180b39f343d42de677fec202422e1fed5a5130c821d495188a9f0bc72f1f25
MD5 6d9a78be8b707102f37f959a735043d5
BLAKE2b-256 8845e7f13fdedc8ec18464d03a227a467ab2f0dba8e4f459249d94674300dedb

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b70714c8610d9a4e543018631fed63656a1d3193931a4d257275ee114938315
MD5 168ea887106ae86fb8f277af9b951959
BLAKE2b-256 f5166efdce5ea4951c275c5c5ececc36ef8b74e5f9363b0bd2c84cbef0a5959a

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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.8-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for torch_bessel-0.0.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a412bcafec247574e99a4161180db298f904e3d5dfe96508541d9eb019c7259
MD5 f3d639fda8211711c498a1c4ebb66fa2
BLAKE2b-256 f87753eb642f1b2ff9def3b53d034d37b46c29d73ea48d988712c6ccdb4cc610

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_bessel-0.0.8-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