Skip to main content

FFT Conv PyTorch

Python package Upload Python Package PyPI version

This is a fork of fft-conv-pytorch. I made some modifications to support dilated, strided, and transposed convolution, so it can be a drop-in-replacement of original PyTorch Conv*d modules and conv*d functions, with the same behaviour and interface.

Install

pip install torch-fftconv

Example Usage

import torch
from torch_fftconv import fft_conv1d, FFTConv1d

signal = torch.randn(3, 3, 1024 * 1024)
kernel = torch.randn(2, 3, 128)
bias = torch.randn(2)

# Functional execution.  (Easiest for generic use cases.)
out = fft_conv1d(signal, kernel, bias=bias)

# Object-oriented execution.
fft_conv = FFTConv1d(3, 2, 128, bias=True)
out = fft_conv(signal)

# Suppose you want to replace all the existing convolution layers in a neural network with FFTConv, you can do it like this:
m: torch.nn.Module = ...  # some existing model
from torch_fftconv.utils import convert_fft_conv
m = convert_fft_conv(m)  # this will replace all Conv/TransposedConv layers in m with FFTConv layers, and copy the weights and bias.

Benchmarks

The best situation to use FFTConv is when using large size kernel. The following image shows that when the size of input is fixed, the fft method remains an almost constant cost among all size of kernel, regardless.

For details and benchmarks on other parameters, check this notebook.

Features

  • [ ] Jittability.
  • Dilated Convolution.
  • Transposed Convolution.
  • Support complex input and kernel.

Metadata

Release files for torch-fftconv 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-fftconv 1.0.0
File Size Uploaded Provenance
torch_fftconv-1.0.0.tar.gz 8.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for torch-fftconv 1.0.0
File Interpreter ABI Platform
torch_fftconv-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / torch_fftconv-1.0.0.tar.gz

Download URL torch_fftconv-1.0.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
14a7d47c4a2e9aaec6e6beeab2c5d56c45b60fff924a610c014a3d0fa1224bff
BLAKE2b-256 checksum
How to use checksums
b3491ce497065fea30bea4675888b51621511bc12f4be29a8d878186fe0d0d9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / torch_fftconv-1.0.0-py3-none-any.whl

Download URL torch_fftconv-1.0.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e64edd2c36847c820c9f61b6b0de94652d6017c261e00c59d55f18e32809c145
BLAKE2b-256 checksum
How to use checksums
4879fb06c196086cccab5da8e1c7b8f385c435084144634fac02c89a97c66560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for torch-fftconv 1.0.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page