Skip to content

Commit 3dc48c5

Browse files
committed
Applied new pre-commit-config to all files, non-critical changes only
1 parent 4dca934 commit 3dc48c5

File tree

136 files changed

+900
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+900
-834
lines changed

docs/finn/conf.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,44 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('../../src/'))
15+
16+
sys.path.insert(0, os.path.abspath("../../src/"))
1617

1718

1819
# -- Project information -----------------------------------------------------
1920

20-
project = 'FINN'
21-
copyright = '2020, Xilinx'
22-
author = 'Y. Umuroglu and J. Petri-Koenig'
21+
project = "FINN"
22+
copyright = "2020, Xilinx"
23+
author = "Y. Umuroglu and J. Petri-Koenig"
2324

2425

2526
# -- General configuration ---------------------------------------------------
2627

2728
# Add any Sphinx extension module names here, as strings. They can be
2829
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2930
# ones.
30-
extensions = [
31-
]
32-
extensions.append('sphinx.ext.autodoc')
31+
extensions = []
32+
extensions.append("sphinx.ext.autodoc")
3333

3434
# Add any paths that contain templates here, relative to this directory.
35-
templates_path = ['_templates']
35+
templates_path = ["_templates"]
3636

3737
# List of patterns, relative to source directory, that match files and
3838
# directories to ignore when looking for source files.
3939
# This pattern also affects html_static_path and html_extra_path.
40-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
40+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4141

4242

4343
# -- Options for HTML output -------------------------------------------------
4444

4545
# The theme to use for HTML and HTML Help pages. See the documentation for
4646
# a list of builtin themes.
4747
#
48-
html_theme = 'sphinx_rtd_theme'
48+
html_theme = "sphinx_rtd_theme"
4949

5050
# Add any paths that contain custom static files (such as style sheets) here,
5151
# relative to this directory. They are copied after the builtin static files,
5252
# so a file named "default.css" will overwrite the builtin "default.css".
53-
html_static_path = ['_static']
53+
html_static_path = ["_static"]
5454

55-
master_doc = 'index'
55+
master_doc = "index"

docs/finn/faq.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@ Frequently Asked Questions
99
Can I install FINN out of the Docker container?
1010
===============================================
1111

12-
We do not support out of the Docker implementations at the moment. This is due
12+
We do not support out of the Docker implementations at the moment. This is due
1313
to the high complexity of the FINN project dependencies.
1414

1515
Since FINN uses ONNX, can I compile any model from the ONNX Model Zoo to an FPGA accelerator?
1616
=============================================================================================
1717

18-
The short answer is no. FINN uses ONNX in a specific (non-standard) way, including custom layer
18+
The short answer is no. FINN uses ONNX in a specific (non-standard) way, including custom layer
1919
types and quantization annotations. Networks must be first quantized using Brevitas and exported
2020
to FINN-ONNX to be converted to FPGA accelerators.
2121

2222

23-
Can I deploy custom NNs with arbitrary precisions and layers using FINN?
23+
Can I deploy custom NNs with arbitrary precisions and layers using FINN?
2424
=========================================================================
2525

2626
Yes, though the effort required and quality of results will vary.
27-
Although we do support arbitrary
28-
precision, the way we create the hardware isn't typically practical for more than
29-
4 bits, or very large networks for a single FPGA.
30-
In terms of layers, only a subset of quantized layers covered by the various FINN examples
27+
Although we do support arbitrary
28+
precision, the way we create the hardware isn't typically practical for more than
29+
4 bits, or very large networks for a single FPGA.
30+
In terms of layers, only a subset of quantized layers covered by the various FINN examples
3131
are currently supported.
3232
It is possible to add support for new layers, though we don't have tutorials for this in place
3333
just yet.
3434

3535
Does FINN only work with the example networks?
3636
==============================================
3737

38-
FINN isn't restricted to the example networks;
39-
rather, it's restricted to certain patterns (e.g. certain layer types and their combinations).
40-
The current best practice for custom networks is to take a working network and gradually modify it.
38+
FINN isn't restricted to the example networks;
39+
rather, it's restricted to certain patterns (e.g. certain layer types and their combinations).
40+
The current best practice for custom networks is to take a working network and gradually modify it.
4141

4242
What is the expected background for using FINN?
4343
===============================================
4444

4545
Some general knowledge of Python, Docker, machine learning with neural networks and Jupyter notebooks
4646
is expected.
47-
Our goal is to make the tool in a shape and form so that no hardware/FPGA background
47+
Our goal is to make the tool in a shape and form so that no hardware/FPGA background
4848
should be necessary, although having some knowledge would give better results.
4949

5050
What operating systems are supported by FINN?
@@ -66,6 +66,6 @@ What board do you recommend to start working with FINN?
6666
Our preferred target platforms are those supported by `PYNQ <http://www.pynq.io/board.html>`_.
6767
For those boards we can offer end-to-end (DNN-to-bitstream) deployment,
6868
see the `finn-examples <https://github.com/Xilinx/finn-examples>`_ repository for some examples.
69-
However, FINN also supports Vivado IP Integrator designs. The IPs connect using AXI stream (FIFO)
69+
However, FINN also supports Vivado IP Integrator designs. The IPs connect using AXI stream (FIFO)
7070
in-and-out interfaces. This means that it can be integrated onto any Xilinx FPGA board,
7171
though you will have to do the system integration manually.

finn-rtllib/memstream/sim/gen_memblocks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ for (( i=0; i<$NBLOCKS; i++ ))
3636
do
3737
START=$(( 1 + $i * 1024 ))
3838
tail -n +$START $1 | head -n 1024 >> memblock_$i.dat
39-
done
39+
done

notebooks/end2end_example/cybersecurity/dataloader_quantized.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
import torch
30-
import pandas as pd
29+
import math
3130
import numpy as np
31+
import pandas as pd
32+
import torch
3233
from sklearn import preprocessing
3334
from sklearn.preprocessing import OneHotEncoder
34-
import math
3535

3636
# quantize the UNSW_NB15 dataset and convert it to binary vectors
3737
# reimplementation
@@ -112,7 +112,7 @@ def my_binary_repr(number, nbits):
112112

113113
def round_like_matlab_number(self, n: np.float64) -> int:
114114
"""Round the input "n" like matlab uint32(n) cast (which also rounds) e.g.
115-
0.5->1; 1.5->2; 2.3->2; 2.45->2 """
115+
0.5->1; 1.5->2; 2.3->2; 2.45->2"""
116116
if n - math.floor(n) < 0.5:
117117
return math.floor(n)
118118
return math.ceil(n)

notebooks/end2end_example/cybersecurity/validate-unsw-nb15.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

2929
import argparse
30+
import numpy as np
3031
from driver import io_shape_dict
3132
from driver_base import FINNExampleOverlay
32-
import numpy as np
3333

3434

3535
def make_unsw_nb15_test_batches(bsize, dataset_root):

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@
3535
PyScaffold helps you to put up the scaffold of your new Python project.
3636
Learn more under: https://pyscaffold.org/
3737
"""
38-
import sys
3938
from pkg_resources import VersionConflict, require
4039
from setuptools import setup
4140

41+
import sys
42+
4243
try:
4344
require("setuptools>=38.3")
4445
except VersionConflict:

src/finn/analysis/fpgadataflow/floorplan_params.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
from finn.util.fpgadataflow import is_fpgadataflow_node
3029
from finn.custom_op.registry import getCustomOp
30+
from finn.util.fpgadataflow import is_fpgadataflow_node
3131

3232

3333
def floorplan_params(model):

src/finn/analysis/fpgadataflow/hls_synth_res_estimation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
import warnings
2928
import os
29+
import warnings
3030
import xml.etree.ElementTree as ET
3131

3232
import finn.custom_op.registry as registry

src/finn/analysis/fpgadataflow/post_synth_res.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import os
3030
import xml.etree.ElementTree as ET
3131

32-
from finn.transformation.move_reshape import _is_fpgadataflow_node
3332
from finn.core.modelwrapper import ModelWrapper
3433
from finn.custom_op.registry import getCustomOp
34+
from finn.transformation.move_reshape import _is_fpgadataflow_node
3535

3636

3737
def post_synth_res(model, override_synth_report_filename=None):

src/finn/builder/build_dataflow_config.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
from typing import List, Optional, Any
30-
from finn.util.basic import pynq_part_map, alveo_part_map
31-
from finn.transformation.fpgadataflow.vitis_build import VitisOptStrategy
32-
from enum import Enum
29+
import numpy as np
30+
import os
3331
from dataclasses import dataclass
3432
from dataclasses_json import dataclass_json
35-
import os
36-
import numpy as np
33+
from enum import Enum
34+
from typing import Any, List, Optional
35+
36+
from finn.transformation.fpgadataflow.vitis_build import VitisOptStrategy
37+
from finn.util.basic import alveo_part_map, pynq_part_map
3738

3839

3940
class ShellFlowType(str, Enum):

src/finn/builder/build_dataflow_steps.py

+55-55
Original file line numberDiff line numberDiff line change
@@ -26,78 +26,78 @@
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
from finn.core.modelwrapper import ModelWrapper
30-
import os
3129
import json
30+
import numpy as np
31+
import os
32+
from copy import deepcopy
33+
from shutil import copy, copytree
34+
3235
import finn.transformation.fpgadataflow.convert_to_hls_layers as to_hls
3336
import finn.transformation.streamline.absorb as absorb
34-
from finn.transformation.bipolar_to_xnor import ConvertBipolarMatMulToXnorPopcount
35-
from finn.transformation.fold_constants import FoldConstants
36-
from finn.transformation.general import (
37-
ApplyConfig,
38-
GiveReadableTensorNames,
39-
GiveUniqueNodeNames,
40-
RemoveUnusedTensors,
41-
RemoveStaticGraphInputs,
42-
)
43-
from finn.transformation.infer_datatypes import InferDataTypes
44-
from finn.transformation.infer_shapes import InferShapes
45-
from finn.transformation.streamline import Streamline
46-
from finn.transformation.infer_data_layouts import InferDataLayouts
47-
from finn.transformation.move_reshape import RemoveCNVtoFCFlatten
48-
from finn.transformation.lower_convs_to_matmul import LowerConvsToMatMul
49-
from finn.transformation.streamline.reorder import MakeMaxPoolNHWC
50-
51-
from shutil import copy, copytree
52-
from finn.transformation.fpgadataflow.insert_dwc import InsertDWC
53-
from finn.transformation.fpgadataflow.insert_fifo import InsertFIFO
54-
from finn.transformation.fpgadataflow.prepare_ip import PrepareIP
55-
from finn.transformation.fpgadataflow.hlssynth_ip import HLSSynthIP
56-
from finn.transformation.fpgadataflow.create_stitched_ip import CreateStitchedIP
57-
from finn.transformation.fpgadataflow.set_fifo_depths import (
58-
InsertAndSetFIFODepths,
59-
RemoveShallowFIFOs,
60-
)
61-
from finn.transformation.fpgadataflow.make_zynq_proj import ZynqBuild
62-
from finn.transformation.fpgadataflow.vitis_build import VitisBuild
63-
from finn.transformation.fpgadataflow.make_pynq_driver import MakePYNQDriver
64-
from finn.transformation.fpgadataflow.set_folding import SetFolding
65-
from finn.transformation.fpgadataflow.create_dataflow_partition import (
66-
CreateDataflowPartition,
67-
)
68-
from finn.transformation.fpgadataflow.replace_verilog_relpaths import (
69-
ReplaceVerilogRelPaths,
70-
)
71-
from finn.custom_op.registry import getCustomOp
37+
from finn.analysis.fpgadataflow.dataflow_performance import dataflow_performance
7238
from finn.analysis.fpgadataflow.exp_cycles_per_layer import exp_cycles_per_layer
73-
from finn.analysis.fpgadataflow.res_estimation import (
74-
res_estimation,
75-
res_estimation_complete,
76-
)
39+
from finn.analysis.fpgadataflow.hls_synth_res_estimation import hls_synth_res_estimation
7740
from finn.analysis.fpgadataflow.op_and_param_counts import (
7841
aggregate_dict_keys,
7942
op_and_param_counts,
8043
)
81-
from finn.analysis.fpgadataflow.dataflow_performance import dataflow_performance
82-
from finn.analysis.fpgadataflow.hls_synth_res_estimation import hls_synth_res_estimation
83-
from finn.util.config import extract_model_config_to_json
84-
from finn.transformation.fpgadataflow.synth_ooc import SynthOutOfContext
44+
from finn.analysis.fpgadataflow.res_estimation import (
45+
res_estimation,
46+
res_estimation_complete,
47+
)
8548
from finn.builder.build_dataflow_config import (
8649
DataflowBuildConfig,
8750
DataflowOutputType,
8851
ShellFlowType,
8952
VerificationStepType,
9053
)
91-
from finn.transformation.fpgadataflow.annotate_cycles import AnnotateCycles
54+
from finn.core.modelwrapper import ModelWrapper
9255
from finn.core.onnx_exec import execute_onnx
93-
import numpy as np
94-
from finn.util.test import execute_parent
95-
from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim
56+
from finn.core.throughput_test import throughput_test_rtlsim
57+
from finn.custom_op.registry import getCustomOp
58+
from finn.transformation.bipolar_to_xnor import ConvertBipolarMatMulToXnorPopcount
59+
from finn.transformation.fold_constants import FoldConstants
60+
from finn.transformation.fpgadataflow.annotate_cycles import AnnotateCycles
9661
from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim
97-
from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode
62+
from finn.transformation.fpgadataflow.create_dataflow_partition import (
63+
CreateDataflowPartition,
64+
)
65+
from finn.transformation.fpgadataflow.create_stitched_ip import CreateStitchedIP
66+
from finn.transformation.fpgadataflow.hlssynth_ip import HLSSynthIP
67+
from finn.transformation.fpgadataflow.insert_dwc import InsertDWC
68+
from finn.transformation.fpgadataflow.insert_fifo import InsertFIFO
69+
from finn.transformation.fpgadataflow.make_pynq_driver import MakePYNQDriver
70+
from finn.transformation.fpgadataflow.make_zynq_proj import ZynqBuild
71+
from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim
72+
from finn.transformation.fpgadataflow.prepare_ip import PrepareIP
9873
from finn.transformation.fpgadataflow.prepare_rtlsim import PrepareRTLSim
99-
from finn.core.throughput_test import throughput_test_rtlsim
100-
from copy import deepcopy
74+
from finn.transformation.fpgadataflow.replace_verilog_relpaths import (
75+
ReplaceVerilogRelPaths,
76+
)
77+
from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode
78+
from finn.transformation.fpgadataflow.set_fifo_depths import (
79+
InsertAndSetFIFODepths,
80+
RemoveShallowFIFOs,
81+
)
82+
from finn.transformation.fpgadataflow.set_folding import SetFolding
83+
from finn.transformation.fpgadataflow.synth_ooc import SynthOutOfContext
84+
from finn.transformation.fpgadataflow.vitis_build import VitisBuild
85+
from finn.transformation.general import (
86+
ApplyConfig,
87+
GiveReadableTensorNames,
88+
GiveUniqueNodeNames,
89+
RemoveStaticGraphInputs,
90+
RemoveUnusedTensors,
91+
)
92+
from finn.transformation.infer_data_layouts import InferDataLayouts
93+
from finn.transformation.infer_datatypes import InferDataTypes
94+
from finn.transformation.infer_shapes import InferShapes
95+
from finn.transformation.lower_convs_to_matmul import LowerConvsToMatMul
96+
from finn.transformation.move_reshape import RemoveCNVtoFCFlatten
97+
from finn.transformation.streamline import Streamline
98+
from finn.transformation.streamline.reorder import MakeMaxPoolNHWC
99+
from finn.util.config import extract_model_config_to_json
100+
from finn.util.test import execute_parent
101101

102102

103103
def verify_step(

0 commit comments

Comments
 (0)