diff --git a/.flake8 b/.flake8
index c3d2f4b8..61d90815 100644
--- a/.flake8
+++ b/.flake8
@@ -1,4 +1,2 @@
[flake8]
max-line-length = 99
-per-file-ignores =
- range_linear_ai84.py:E501,E128
diff --git a/.gitignore b/.gitignore
index ca71c500..ce04887a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,5 +13,4 @@
/super-linter.log
/super-linter.report/
/.version-check
-/venv*/
/sdk/
diff --git a/.isort.cfg b/.isort.cfg
deleted file mode 100644
index 99b46845..00000000
--- a/.isort.cfg
+++ /dev/null
@@ -1,6 +0,0 @@
-[settings]
-profile=
-line_length=99
-known_third_party=distiller
-known_math=numpy,torch,torchvision,torchaudio,tensorboard,tensorflow
-sections=FUTURE,STDLIB,MATH,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
diff --git a/.pylintrc b/.pylintrc
deleted file mode 100644
index 504816c1..00000000
--- a/.pylintrc
+++ /dev/null
@@ -1,21 +0,0 @@
-[MESSAGES CONTROL]
-disable=invalid-name, consider-using-with, duplicate-code, not-callable
-[TYPECHECK]
-ignored-modules = numpy, matplotlib.cm, torch
-ignored-classes = ModelProto
-[FORMAT]
-max-line-length = 99
-[DESIGN]
-max-locals=100
-max-statements=2000
-min-public-methods=0
-max-branches=180
-max-module-lines=5000
-max-nested-blocks=10
-max-args=55
-max-attributes=60
-max-public-methods=35
-max-bool-expr=12
-max-parents=15
-[MASTER]
-ignore=CMSIS_5,sdk
diff --git a/.python-version b/.python-version
index 73bb444b..b6d8b761 100644
--- a/.python-version
+++ b/.python-version
@@ -1 +1 @@
-3.8.11
+3.11.8
diff --git a/KNOWN_ISSUES.txt b/KNOWN_ISSUES.txt
new file mode 100644
index 00000000..cf64d940
--- /dev/null
+++ b/KNOWN_ISSUES.txt
@@ -0,0 +1,4 @@
+KNOWN ISSUES for ai8x-synthesis with PyToch 2.3.0
+=================================================
+
+N/A
diff --git a/README.md b/README.md
index 504b4cf5..e0edfcca 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# ADI MAX78000/MAX78002 Model Training and Synthesis
-April 19, 2024
+May 6, 2024
+
+**Note: The pytorch-2 branch is in development. Please see [KNOWN_ISSUES](KNOWN_ISSUES.txt).**
ADI’s MAX78000/MAX78002 project is comprised of five repositories:
@@ -62,8 +64,8 @@ PyTorch operating system and hardware support are constantly evolving. This docu
Full support and documentation are provided for the following platform:
* CPU: 64-bit amd64/x86_64 “PC” with [Ubuntu Linux 20.04 LTS or 22.04 LTS](https://ubuntu.com/download/server)
-* GPU for hardware acceleration (optional but highly recommended): Nvidia with [CUDA 11](https://developer.nvidia.com/cuda-toolkit-archive)
-* [PyTorch 1.8.1 (LTS)](https://pytorch.org/get-started/locally/) on Python 3.8.x
+* GPU for hardware acceleration (optional but highly recommended): Nvidia with [CUDA 12.1](https://developer.nvidia.com/cuda-toolkit-archive) or later
+* [PyTorch 2.3.0](https://pytorch.org/get-started/locally/) on Python 3.11.x
Limited support and advice for using other hardware and software combinations is available as follows.
@@ -85,7 +87,7 @@ If WSL2 is not available, it is also possible (but not recommended due to inhere
##### macOS
-The software works on macOS, but model training suffers from the lack of hardware acceleration.
+The software works on macOS and uses MPS acceleration on Apple Silicon. On Intel CPUs, model training suffers from the lack of hardware acceleration.
##### Virtual Machines (Unsupported)
@@ -97,20 +99,18 @@ This software also works inside Docker containers. However, CUDA support inside
#### PyTorch and Python
-The officially supported version of [PyTorch is 1.8.1 (LTS)](https://pytorch.org/get-started/locally/) running on Python 3.8.x. Newer versions will typically work, but are not covered by support, documentation, and installation scripts.
+The officially supported version of [PyTorch is 2.3.0](https://pytorch.org/get-started/locally/) running on Python 3.11.x. Newer versions will typically work, but are not covered by support, documentation, and installation scripts.
#### Hardware Acceleration
-When going beyond simple models, model training does not work well without CUDA hardware acceleration. The network loader (“izer”) does not require CUDA, and very simple models can also be trained on systems without CUDA.
-
-* CUDA requires Nvidia GPUs.
-
-* There is a PyTorch pre-release with ROCm acceleration for certain AMD GPUs on Linux ([see blog entry](https://pytorch.org/blog/pytorch-for-amd-rocm-platform-now-available-as-python-package/)), but this is not currently covered by the installation instructions in this document, and it is not supported.
-
-* At this time, there is neither CUDA nor ROCm nor Neural Engine support on macOS, and therefore no hardware acceleration (there is a pre-release version of PyTorch with M1 acceleration on macOS 12.3 or later, and M1 acceleration will be supported in a future release of these tools).
+When going beyond simple models, model training does not work well without hardware acceleration – Nvidia CUDA, AMD ROCm, or Apple Silicon MPS. The network loader (“izer”) does not require hardware acceleration, and very simple models can also be trained on systems without hardware acceleration.
+* CUDA requires modern Nvidia GPUs. This is the most compatible, and best supported hardware accelerator.
+* ROCm requires certain AMD GPUs, see [blog entry](https://pytorch.org/blog/pytorch-for-amd-rocm-platform-now-available-as-python-package/).
+* MPS requires Apple Silicon (M1 or newer) and macOS 12.3 or newer.
* PyTorch does not include CUDA support for aarch64/arm64 systems. *Rebuilding PyTorch from source is not covered by this document.*
+
##### Using Multiple GPUs
When using multiple GPUs (graphics cards), the software will automatically use all available GPUs and distribute the workload. To prevent this (for example, when the GPUs are not balanced), set the `CUDA_VISIBLE_DEVICES` environment variable. Use the `--gpus` command line argument to set the default GPU.
@@ -171,19 +171,19 @@ Some additional system packages are required, and installation of these addition
##### macOS
-On macOS (no CUDA support available) use:
+On macOS use:
```shell
-$ brew install libomp libsndfile tcl-tk
+$ brew install libomp libsndfile tcl-tk sox
```
-##### Linux (Ubuntu), including WSL2
+##### Linux (Ubuntu), including WSL2)
```shell
$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev \
- libsndfile-dev portaudio19-dev
+ libsndfile-dev portaudio19-dev libsox-dev
```
###### RedHat Enterprise Linux / CentOS 8
@@ -207,11 +207,11 @@ $ sudo dnf install openssl-devel zlib-devel \
libsndfile libsndfile-devel portaudio-devel
```
-#### Python 3.8
+#### Python 3.11
-*The software in this project uses Python 3.8.11 or a later 3.8.x version.*
+*The software in this project uses Python 3.11.8 or a later 3.11.x version.*
-First, check whether there is a default Python interpreter and whether it is version 3.8.x:
+First, check whether there is a default Python interpreter and whether it is version 3.11.x:
```shell
$ python --version
@@ -225,17 +225,17 @@ Python 2.7.18
# wrong version, pyenv required
```
-Python 2 **will not function correctly** with the MAX78000/MAX78002 tools. If the result is Python **3.8**.x, skip ahead to [git Environment](#git-environment). For *any* other version (for example, 2.7, 3.7, 3.9, 3.10), or no version, continue here.
+Python 2 **will not function correctly** with the MAX78000/MAX78002 tools. If the result is Python **3.11**.x, skip ahead to [git Environment](#git-environment). For *any* other version (for example, 2.7, 3.7, 3.8, 3.9, 3.10), or no version, continue here.
-*Note: For the purposes of the MAX78000/MAX78002 tools, “python3” is not a substitute for “python”. Please install pyenv when `python --version` does not return version 3.8.x, even if “python3” is available.*
+*Note: For the purposes of the MAX78000/MAX78002 tools, “python3” is not a substitute for “python”. Please install pyenv when `python --version` does not return version 3.11.x, even if “python3” is available.*
-*Note for advanced users: `sudo apt-get install python-is-python3` on Ubuntu 20.04 will install Python 3 as the default Python version; however, it may not be version 3.8.x.*
+*Note for advanced users: `sudo apt-get install python-is-python3` on Ubuntu 20.04 will install Python 3 as the default Python version; however, it may not be version 3.11.x.*
##### pyenv
-It is not necessary to install Python 3.8 system-wide, or to rely on the system-provided Python. To manage Python versions, instead use `pyenv` (). This allows multiple Python versions to co-exist on the same system without interfering with the system or with one another.
+It is not necessary to install Python 3.11 system-wide, or to rely on the system-provided Python. To manage Python versions, instead use `pyenv` (). This allows multiple Python versions to co-exist on the same system without interfering with the system or with one another.
-On macOS (no CUDA support available):
+On macOS:
```shell
$ brew install pyenv pyenv-virtualenv
@@ -277,7 +277,7 @@ $ ~/.pyenv/bin/pyenv init
*Note: Installing both conda and pyenv in parallel may cause issues. Ensure that the pyenv initialization tasks are executed before any conda related tasks.*
-Next, close the Terminal, open a new Terminal and install Python 3.8.11.
+Next, close the Terminal, open a new Terminal and install Python 3.11.8.
On macOS:
@@ -289,13 +289,13 @@ $ env \
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
CFLAGS="-I$(brew --prefix tcl-tk)/include" \
PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \
- pyenv install 3.8.11
+ pyenv install 3.11.8
```
On Linux, including WSL2:
```shell
-$ pyenv install 3.8.11
+$ pyenv install 3.11.8
```
#### git Environment
@@ -331,39 +331,40 @@ $ cd ai8x-training
The default branch is “develop” which is updated most frequently. If you want to use the “main” branch instead, switch to “main” using `git checkout main`.
-If using pyenv, set the local directory to use Python 3.8.11.
+If using pyenv, set the local directory to use Python 3.11.8.
```shell
-$ pyenv local 3.8.11
+$ pyenv local 3.11.8
```
-In all cases, verify that a 3.8.x version of Python is used:
+In all cases, verify that a 3.11.x version of Python is used:
```shell
$ python --version
-Python 3.8.11
+Python 3.11.8
```
-If this does *not* return version 3.8.x, please install and initialize [pyenv](#python-38).
+If this does *not* return version 3.11.x, please install and initialize [pyenv](#python-311).
Then continue with the following:
```shell
-$ python -m venv venv --prompt ai8x-training
+$ python -m venv .venv --prompt ai8x-training
+$ echo "*" > .venv/.gitignore
```
-If this command returns an error message similar to *“The virtual environment was not created successfully because ensurepip is not available,”* please install and initialize [pyenv](#python-38).
+If this command returns an error message similar to *“The virtual environment was not created successfully because ensurepip is not available,”* please install and initialize [pyenv](#python-311).
On macOS and Linux, including WSL2, activate the environment using
```shell
-$ source venv/bin/activate
+$ source .venv/bin/activate
```
On native Windows, instead use:
```shell
-$ source venv/Scripts/activate
+$ source .venv/Scripts/activate
```
Then continue with
@@ -372,21 +373,21 @@ Then continue with
(ai8x-training) $ pip3 install -U pip wheel setuptools
```
-The next step differs depending on whether the system uses CUDA 11.x, or not.
+The next step differs depending on whether the system uses CUDA 12.1+, or not.
-For CUDA 11.x on Linux, including WSL2:
+For CUDA 12:
```shell
-(ai8x-training) $ pip3 install -r requirements-cu11.txt
+(ai8x-training) $ pip3 install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121
```
-For CUDA 11.x on native Windows:
+For ROCm 5.7:
```shell
-(ai8x-training) $ pip3 install -r requirements-win-cu11.txt
+(ai8x-training) $ pip3 install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/rocm5.7
```
-For all other systems, including macOS, and CUDA 10.2 on Linux:
+For all other systems, including macOS:
```shell
(ai8x-training) $ pip3 install -r requirements.txt
@@ -410,7 +411,7 @@ After a small delay of typically a day, a “Release” tag is created on GitHub
In addition to code updated in the repository itself, **submodules and Python libraries may have been updated as well**.
-Major upgrades (such as updating from PyTorch 1.7 to PyTorch 1.8) are best done by removing all installed wheels. This can be achieved most easily by creating a new folder and starting from scratch at [Upstream Code](#upstream-code). Starting from scratch is also recommended when upgrading the Python version.
+Major upgrades (such as updating from PyTorch 1.8 to PyTorch 2.0) are best done by removing all installed wheels. This can be achieved most easily by creating a new folder and starting from scratch at [Upstream Code](#upstream-code). Starting from scratch is also recommended when upgrading the Python version.
For minor updates, pull the latest code and install the updated wheels:
@@ -427,11 +428,11 @@ Please *also* update the MSDK or use the Maintenance Tool as documented in the [
##### Python Version Updates
-Updating Python may require updating `pyenv` first. Should `pyenv install 3.8.11` fail,
+Updating Python may require updating `pyenv` first. Should `pyenv install 3.11.8` fail,
```shell
-$ pyenv install 3.8.11
-python-build: definition not found: 3.8.11
+$ pyenv install 3.11.8
+python-build: definition not found: 3.11.8
```
then `pyenv` must be updated. On macOS, use:
@@ -454,19 +455,19 @@ $
The update should now succeed:
```shell
-$ pyenv install 3.8.11
-Downloading Python-3.8.11.tar.xz...
--> https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tar.xz
-Installing Python-3.8.11...
+$ pyenv install 3.11.8
+Downloading Python-3.11.8.tar.xz...
+-> https://www.python.org/ftp/python/3.11.8/Python-3.11.8.tar.xz
+Installing Python-3.11.8...
...
-$ pyenv local 3.8.11
+$ pyenv local 3.11.8
```
#### Synthesis Project
-The `ai8x-synthesis` project does not require CUDA.
+The `ai8x-synthesis` project does not require hardware acceleration.
Start by deactivating the `ai8x-training` environment if it is active.
@@ -486,34 +487,35 @@ If you want to use the main branch, switch to “main” using the optional comm
If using pyenv, run:
```shell
-$ pyenv local 3.8.11
+$ pyenv local 3.11.8
```
-In all cases, make sure Python 3.8.x is the active version:
+In all cases, make sure Python 3.11.x is the active version:
```shell
$ python --version
-Python 3.8.11
+Python 3.11.8
```
-If this does *not* return version 3.8.x, please install and initialize [pyenv](#python-38).
+If this does *not* return version 3.11.x, please install and initialize [pyenv](#python-311).
Then continue:
```shell
-$ python -m venv venv --prompt ai8x-synthesis
+$ python -m venv .venv --prompt ai8x-synthesis
+$ echo "*" > .venv/.gitignore
```
Activate the virtual environment. On macOS and Linux (including WSL2), use
```shell
-$ source venv/bin/activate
+$ source .venv/bin/activate
```
On native Windows, instead use
```shell
-$ source venv/Scripts/activate
+$ source .venv/Scripts/activate
```
For all systems, continue with:
@@ -1224,30 +1226,31 @@ The example shows a fractionally-strided convolution with a stride of 2, a pad o
If hardware acceleration is not available, skip the following two steps and continue with [Training Script](#training-script).
-1. Before the first training session, check that CUDA hardware acceleration is available using `nvidia-smi -q`:
+Before the first training session, check that hardware acceleration is available and recognized by PyTorch:
- ```shell
- (ai8x-training) $ nvidia-smi -q
- ...
- Driver Version : 470.57.02
- CUDA Version : 11.4
+ ```shell
+ (ai8x-training) $ python check_cuda.py
+ System: linux
+ Python version: 3.11.8 (main, Mar 4 2024, 15:29:36) [GCC 11.4.0]
+ PyTorch version: 2.3.0+cu121
+ CUDA/ROCm acceleration: available in PyTorch
+ MPS acceleration: NOT available in PyTorch
+ ```
- Attached GPUs : 1
- GPU 00000000:01:00.0
- Product Name : NVIDIA TITAN RTX
- Product Brand : Titan
- ...
- ```
+CUDA can be diagnosed using `nvidia-smi -q`:
-2. Verify that PyTorch recognizes CUDA:
+```shell
+(ai8x-training) $ nvidia-smi -q
+...
+Driver Version : 545.23.06
+CUDA Version : 12.3
- ```shell
- (ai8x-training) $ python check_cuda.py
- System: linux
- Python version: 3.8.11 (default, Jul 14 2021, 12:46:05) [GCC 9.3.0]
- PyTorch version: 1.8.1+cu111
- CUDA acceleration: available in PyTorch
- ```
+Attached GPUs : 2
+GPU 00000000:01:00.0
+ Product Name : NVIDIA TITAN RTX
+ Product Brand : Titan
+...
+```
### Training Script
@@ -1257,11 +1260,15 @@ The `models/` folder contains models that fit into the MAX78000 or MAX78002’s
To train the FP32 model for MNIST on MAX78000 or MAX78002, run `scripts/train_mnist.sh` from the `ai8x-training` project. This script will place checkpoint files into the log directory. Training makes use of the Distiller framework, but the `train.py` software has been modified slightly to improve it and add some MAX78000/MAX78002 specifics.
+#### Distributed Training
+
+On systems with multiple GPUs, the training script supports `DistributedDataParallel`. To use distributed training, prefix the training script with `scripts/distributed.sh`. For example, run `scripts/distributed.sh scripts/train_mnist.sh`. Note that (at this time) distributed training is only supported locally.
+
Since training can take a significant amount of time, the training script does not overwrite any weights previously produced. Results are placed in sub-directories under `logs/` named with the date and time when training began. The latest results are always soft-linked to by `latest-log_dir` and `latest_log_file`.
#### Troubleshooting
-1. If the training script returns `ModuleNotFoundError: No module named 'numpy'`, please activate the virtual environment using `source venv/bin/activate`, or on native Windows without WSL2, `source venv/scripts/activate`.
+1. If the training script returns `ModuleNotFoundError: No module named 'numpy'`, please activate the virtual environment using `source .venv/bin/activate`, or on native Windows without WSL2, `source .venv/scripts/activate`.
2. If the training script crashes, or if it returns an internal error (such as `CUDNN_STATUS_INTERNAL_ERROR`), it may be necessary to limit the number of PyTorch workers to 1 (this has been observed running on native Windows). Add `--workers=1` when running any training script, for example;
@@ -1312,7 +1319,9 @@ Since training can take a significant amount of time, the training script does n
Training might succeed after reducing the batch size, reducing image dimensions, or pruning the dataset. Unfortunately, the only real fix for this issue is more system RAM. In the example, `kinetics_get_datasets()` from `datasets/kinetics.py` states “The current implementation of using 2000 training and 150 test examples per class at 240×240 resolution and 5 frames per second requires around 50 GB of RAM.”
-
+6. On CUDA-capable machines, the training script by default uses PyTorch 2.0’s [`torch.compile()` feature](https://pytorch.org/docs/stable/generated/torch.compile.html) which improves execution speed. However, some models may not support this feature. It can be disabled using the command line option
+ `--compiler-mode none`
+ Disabling `torch.compile()` may also be necessary when using AMD ROCm acceleration.
### Example Training Session
@@ -1456,6 +1465,7 @@ The following table describes the most important command line arguments for `tra
| `--nas` | Enable network architecture search | |
| `--nas-policy` | Define NAS policy in YAML file | `--nas-policy nas/nas_policy.yaml` |
| `--regression` | Select regression instead of classification (changes Loss function, and log output) | |
+| `--compiler-mode` | Select [TorchDynamo optimization mode](https://pytorch.org/docs/stable/generated/torch.compile.html) (default: enabled on CUDA capable machines) | `--compiler-mode none` |
| `--dr` | Set target embedding dimensionality for dimensionality reduction |`--dr 64` |
| `--scaf-lr` | Initial learning rate for sub-center ArcFace loss optimizer | |
| `--scaf-scale` |Scale hyperparameter for sub-center ArcFace loss | |
@@ -1616,7 +1626,7 @@ Quantization-aware training (QAT) is enabled by default. QAT is controlled by a
* `weight_bits` describes the number of bits available for weights.
* `overrides` allows specifying the `weight_bits` on a per-layer basis.
-By default, weights are quantized to 8-bits after 10 epochs as specified in `policies/qat_policy.yaml`. A more refined example that specifies weight sizes for individual layers can be seen in `policies/qat_policy_cifar100.yaml`.
+By default, weights are quantized to 8-bits after 30 epochs as specified in `policies/qat_policy.yaml`. A more refined example that specifies weight sizes for individual layers can be seen in `policies/qat_policy_cifar100.yaml`.
Quantization-aware training can be disabled by specifying `--qat-policy None`.
@@ -1688,20 +1698,6 @@ When using PuTTY, port forwarding is achieved as follows:
-#### SHAP — SHapely Additive exPlanations
-
-The training software integrates code to generate SHAP plots (see ). This can help with feature attribution for input images.
-
-The `train.py` program can create plots using the `--shap` command line argument in combination with `--evaluate`:
-
-```shell
-$ python train.py --model ai85net5 --dataset CIFAR10 --confusion --evaluate --device MAX78000 --exp-load-weights-from logs/CIFAR-new/best.pth.tar --shap 3
-```
-
-This will create a plot with a random selection of 3 test images. The plot shows ten outputs (the ten classes) for the three different input images on the left. Red pixels increase the model’s output while blue pixels decrease the output. The sum of the SHAP values equals the difference between the expected model output (averaged over the background dataset) and the current model output.
-
-
-
### BatchNorm Fusing
Batchnorm fusing (see [Batch Normalization](#batch-normalization)) is needed as a separate step only when both the following are true:
@@ -2933,7 +2929,7 @@ For RGB image inputs, there are three channels. For example, a 3×80×60 (C×H×
```shell
(ai8x-synthesis) $ deactivate
$ cd ../ai8x-training
- $ source venv/bin/activate
+ $ source .venv/bin/activate
```
2. Create an evaluation script and run it:
diff --git a/README.pdf b/README.pdf
index 0216a1d1..a99f5559 100644
Binary files a/README.pdf and b/README.pdf differ
diff --git a/ai8x-synthesis.code-workspace b/ai8x-synthesis.code-workspace
index ab28e7f3..d7f50438 100644
--- a/ai8x-synthesis.code-workspace
+++ b/ai8x-synthesis.code-workspace
@@ -6,7 +6,6 @@
],
"settings": {
"markdown.extension.toc.levels": "2..6",
- "python.pythonPath": "venv/bin/python",
"git.ignoreLimitWarning": true,
"pylint.args": ["--rcfile=.pylintrc"]
},
diff --git a/docs/shap.png b/docs/shap.png
deleted file mode 100644
index 6a4197c6..00000000
Binary files a/docs/shap.png and /dev/null differ
diff --git a/izer/latency.py b/izer/latency.py
index 11b3dbd0..db199ace 100644
--- a/izer/latency.py
+++ b/izer/latency.py
@@ -35,13 +35,13 @@ def calculate(
Calculate the latency in cycles for a single layer with the arguments given.
"""
# Input
- img_rows, img_cols = input_dim # type: Tuple[int, int]
- pool_rows, pool_cols = pool # type: Tuple[int, int]
- pool_row_stride, pool_col_stride = pool_stride # type: Tuple[int, int]
- img_pooled_rows, img_pooled_cols = pooled_dim # type: Tuple[int, int]
- row_pad, col_pad = padding # type: Tuple[int, int]
- kern_rows, kern_cols = kernel_size # type: Tuple[int, int]
- output_rows, output_cols = output_dim # type: Tuple[int, int]
+ img_rows, img_cols = input_dim
+ pool_rows, pool_cols = pool
+ pool_row_stride, pool_col_stride = pool_stride
+ img_pooled_rows, img_pooled_cols = pooled_dim
+ row_pad, col_pad = padding
+ kern_rows, kern_cols = kernel_size
+ output_rows, output_cols = output_dim
s: str = ' Channels C Rows H Columns W\n' \
f'Input dimensions{input_chan:11}{img_rows:11}{img_cols:11}\n' \
diff --git a/izer/sampleweight.py b/izer/sampleweight.py
index 5a762924..4773d350 100644
--- a/izer/sampleweight.py
+++ b/izer/sampleweight.py
@@ -1,5 +1,5 @@
###################################################################################################
-# Copyright (C) 2019-2022 Maxim Integrated Products, Inc. All Rights Reserved.
+# Copyright (C) 2019-2023 Maxim Integrated Products, Inc. All Rights Reserved.
#
# Maxim Integrated Products, Inc. Default Copyright Notice:
# https://www.maximintegrated.com/en/aboutus/legal/copyrights.html
@@ -54,7 +54,7 @@ def load(
try:
while True:
w.append(np.load(file))
- except ValueError:
+ except (ValueError, EOFError):
pass
if len(w) == 1: # If the weights file wasn't a list
@@ -143,7 +143,7 @@ def load_bias(
_ = np.load(file)
seq += 1
ll += 1
- except ValueError:
+ except (ValueError, EOFError):
pass
return bias
diff --git a/mypy.ini b/mypy.ini
deleted file mode 100644
index 732a65c9..00000000
--- a/mypy.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[mypy]
-ignore_missing_imports=true
-follow_imports=silent
-show_column_numbers=true
diff --git a/pyproject.toml b/pyproject.toml
index 81397eea..e3ee9813 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,10 +1,98 @@
+[build-system]
+requires = ["pip", "setuptools", "wheel"]
+
+[project]
+name = "ai8x-synthesis"
+description = "Quantization and Synthesis (Device Specific Code Generation) for ADI's MAX78000 and MAX78002 Edge AI Devices"
+authors = [
+ {name = "Analog Devices Inc."},
+]
+requires-python = ">=3.11.8,<3.12"
+readme = "README.md"
+license = {file = "LICENSE.txt"}
+keywords = ["machine-learning", "ai", "deep-learning", "artificial-intelligence", "analog-devices", "maxim", "maxim-integrated", "max78000", "max78002"]
+dynamic = ["version"]
+
+[project.urls]
+Homepage = "https://github.com/MaximIntegratedAI"
+Documentation = "https://github.com/MaximIntegratedAI/ai8x-synthesis/blob/develop/README.md"
+Repository = "https://github.com/MaximIntegratedAI/ai8x-synthesis.git"
+Issues = "https://github.com/MaximIntegratedAI/ai8x-synthesis/issues"
+
+[project.scripts]
+izer = "izer.izer:main"
+
[tool.black]
line-length = 99
-target-version = ['py36']
[tool.codespell]
-count = ''
-ignore-words-list = 'nervana,cconfiguration'
+count = ""
+ignore-words-list = "nervana,cconfiguration,anormal"
quiet-level = 3
-skip = '*.dasm,*.map,./rtldev,./.mypy_cache,./sdk,./venv,./.git,./super-linter.log'
+skip = "*.dasm,*.map,./rtldev,./.mypy_cache,./sdk,./.venv,./.git,./super-linter.log"
ignore-regex = '^\s+"image/png".*$'
+
+[tool.pytest.ini_options]
+norecursedirs = [
+ ".git",
+ ".venv",
+ "assets",
+ "attic",
+ "bin",
+ "etc",
+ "docs",
+ "lib",
+ "networks",
+ "rtldev",
+ "sdk",
+ "share",
+ "trained",
+]
+
+[tool.isort]
+profile = ""
+line_length = 99
+known_math = [
+ "numpy",
+ "torch",
+ "torchvision",
+ "torchaudio",
+ "tensorboard",
+ "tensorflow",
+]
+sections = [
+ "FUTURE",
+ "STDLIB",
+ "MATH",
+ "THIRDPARTY",
+ "FIRSTPARTY",
+ "LOCALFOLDER",
+]
+
+[tool.mypy]
+ignore_missing_imports = true
+follow_imports = "silent"
+show_column_numbers = true
+
+[tool.pylint."MESSAGES CONTROL"]
+disable = "invalid-name,consider-using-with,duplicate-code,not-callable"
+[tool.pylint.TYPECHECK]
+ignored-modules = "numpy,matplotlib.cm,torch"
+ignored-classes = "ModelProto"
+[tool.pylint.FORMAT]
+max-line-length = 99
+[tool.pylint.DESIGN]
+max-locals = 100
+max-statements = 2000
+min-public-methods = 0
+max-branches = 180
+max-module-lines = 5000
+max-nested-blocks = 10
+max-args = 55
+max-attributes = 60
+max-public-methods = 35
+max-bool-expr = 12
+max-parents = 15
+[tool.pylint.MASTER]
+ignore = "CMSIS_5,sdk"
+
diff --git a/pytest.ini b/pytest.ini
deleted file mode 100644
index ef227d5d..00000000
--- a/pytest.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[pytest]
-norecursedirs = .git assets attic bin etc distiller docs lib networks rtldev sdk share trained
diff --git a/requirements.txt b/requirements.txt
index 33d53beb..73624edf 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,13 +1,11 @@
-numpy>=1.22,<1.23
-PyYAML>=5.1.1
-six>=1.12.0
-scipy>=1.3.0
-torch==1.8.1
-pytest~=4.6.4
-onnx>=1.9.0
-GitPython>=3.1.18
-PyGithub>=1.55
-rich>=11.2.0
-protobuf>=3.20.1,<4.0
-xxhash>=3.0.0
-matplotlib>=3.6.0
+pip>=24.0
+GitPython==3.1.43
+PyGithub==2.3.0
+PyYAML==6.0.1
+matplotlib==3.8.4
+numpy==1.26.4
+onnx==1.16.0
+pytest==8.2.0
+rich==13.7.1
+torch~=2.3.0
+xxhash==3.4.1