Skip to content

Commit

Permalink
Add install instruction for new interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tridao committed Aug 3, 2020
1 parent 61ed6e0 commit e735ed4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
Code to accompany the paper <a href="https://arxiv.org/abs/1903.05895">Learning Fast Algorithms for Linear Transforms Using Butterfly Factorizations.

## Requirements
Python 3.6+
PyTorch >=1.2
Numpy
python>=3.6
pytorch>=1.6
numpy
scipy

## Usage

2020-08-03: The new interface to butterfly C++/CUDA code is in `csrc` and
`torch_butterfly`.
It is tested in `tests/test_torch_butterfly.py` (which also shows example
usage).

To install:
```
python setup.py install
```
That is, use the `setup.py` file in this root directory.

The file `torch_butterfly/special.py` shows how to construct butterfly matrices
that performs FFT, inverse FFT, circulant matrix multiplication,
Hadamard transform, and torch.nn.Conv1d with circular padding. The tests in
`tests/test_special.py` show that these butterfly matrices exactly perform
those operations.

## Old interface

Note: this interface is being rewritten. Only use this if you need some feature
that's not supported in the new interface.

* The module `Butterfly` in `butterfly/butterfly.py` can be used as a drop-in
replacement for a `nn.Linear` layer. The files in `butterfly` directory are all
that are needed for this use.
Expand Down
6 changes: 3 additions & 3 deletions torch_butterfly/butterfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class Butterfly(nn.Module):
bias: If set to False, the layer will not learn an additive bias.
Default: ``True``
complex: whether complex or real
increasing_stride: whether to multiply with increasing stride (e.g. 1, 2, ..., n/2) or
decreasing stride (e.g., n/2, n/4, ..., 1).
increasing_stride: whether the first butterfly block will multiply with increasing stride
(e.g. 1, 2, ..., n/2) or decreasing stride (e.g., n/2, n/4, ..., 1).
ortho_init: whether the weight matrix should be initialized to be orthogonal/unitary.
nblocks: number of (BB^T) blocks.
nblocks: number of B or B^T blocks. The B and B^T will alternate.
"""

def __init__(self, in_size, out_size, bias=True, complex=False,
Expand Down

0 comments on commit e735ed4

Please sign in to comment.