Metadata-Version: 2.1
Name: fmot
Version: 1.5.6
Summary: Femtosense Model Optimization Toolkit
Home-page: https://github.com/femtosense/fmot
Author: Femtosense
Author-email: info@femtosense.ai
Project-URL: Source, https://github.com/femtosense/fmot
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Cython
Requires-Dist: torch (>=1.12.1)
Requires-Dist: numpy (>=1.18.0)
Requires-Dist: scipy
Requires-Dist: python-speech-features
Requires-Dist: tqdm
Requires-Dist: networkx
Requires-Dist: deprecation
Requires-Dist: tabulate
Requires-Dist: datashader (>=0.14.4)
Requires-Dist: colorcet
Requires-Dist: matplotlib

![Build Status](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiRGpDOFpEOXF1M0prSy9OOVNkZ3F2NkRKM0NNMG8xbmpZU0hZdUp1ejhHOEswdDRhOEZOakMrdWZyaHp1WGVtQ1lVTStzRUpXaFlYeFZPSEJFd21NdjF3PSIsIml2UGFyYW1ldGVyU3BlYyI6InJZYzhuZ3d3a1FUUzBzM0kiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)

# fmot
The Femtosense Model Optimization Toolkit (fmot) quantizes neural network models for deployment on Femtosense hardware.

## Installation
```
git clone https://github.com/femtosense/fmot.git
cd fmot
pip install -e .
```

## Quantizing Models
You get to define your pytorch models however you want. Once your model has been trained, it can be converted to the `fmot.qat` format by calling `fmot.convert.convert_torch_to_qat`. This resulting `qat` model will initially not be quantized. To quantize it, provide your model, along with an iteratable of sample inputs, to `fmot.qat.control.quantize`. These test inputs will help the `qat` model to find an optimal quantization configuration. The resulting quantized model will now simulate the fixed-point integer arithmetic, exactly how it will be performed on Femtosense hardware.
```python
import torch
import fmot

class MyModel(torch.nn.Module):
    def __init__(self, din, dout):
        super().__init__()
        weights = torch.rand(din, dout)
        self.weight = torch.nn.Parameter(weights)
        self.linear = torch.nn.Linear(dout, dout)

    def forward(self, x):
        x = torch.matmul(x, self.weight)
        x = x.relu()
        x = self.linear(x)
        x = torch.sigmoid(x)
        return x

model = MyModel(128, 256)

### TRAINING GOES HERE

# Convert the trained model to qat format
quant_model = fmot.convert.convert_torch_to_qat(model)
# Provide a set of sample inputs to choose an optimal quantization scheme
quant_model = fmot.qat.control.quantize(quant_model, [torch.randn(16, 128) for __ in range(20)])
```
**NOTE: THE ABOVE API NEEDS A TOP-LEVEL SHORTCUT**

## Fine-Tuning Quantized Models

## Setting Custom Bitwidths

## Emitting FQIR
Once your model has been quantized, 

## Building and Viewing Sphinx Documentation
First, let's install sphinx. On macOs:
```
brew install sphinx-doc
```
On [other platforms](https://www.sphinx-doc.org/en/1.8/usage/installation.html).

Now, let's install some dependencies with pip:
```
cd docs
pip install -r requirements.txt
```

You can now build the documentation by running
```
make html
```

This documentation can be viewed in your browser with `Open File` (⌘O). Navigate to
```
{fmot_base}/docs/_build/html/index.html
```

## Running Tests

## Pruning Weight Matrices

## Sparsifying Activations

## Using Custom Layers

