You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Maxim Integrated AI project is comprised of four repositories:
6
6
@@ -301,7 +301,7 @@ By default, the main branch is checked out. This branch has been tested more rig
301
301
302
302
Support for TensorFlow / Keras is currently in the `develop-tf` branch.
303
303
304
-
##### Updates
304
+
####Updating to the Latest Version
305
305
306
306
After additional testing, `develop` is merged into the main branch at regular intervals.
307
307
@@ -311,7 +311,7 @@ After a small delay of typically a day, a “Release” tag is created on GitHub
311
311
312
312
In addition to code updated in the repository itself, submodules and Python libraries may have been updated as well.
313
313
314
-
Major upgrades (such as updating from PyTorch 1.5 to PyTorch 1.7) 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.
314
+
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.
315
315
316
316
For minor updates, pull the latest code and install the updated wheels:
317
317
@@ -322,7 +322,44 @@ For minor updates, pull the latest code and install the updated wheels:
322
322
(ai8x-training) $ pip3 install -U -r requirements.txt # or requirements-cu11.txt with CUDA 11.x
@@ -964,7 +1001,7 @@ There are two supported cases for `view()` or `reshape()`.
964
1001
`x = x.view(x.size(0), x.size(1), -1) # 2D to 1D`
965
1002
`x = x.view(x.shape[0], x.shape[1], 16, -1) # 1D to 2D`
966
1003
*Note: `x.size()` and `x.shape[]` are equivalent.*
967
-
When reshaping data, `in_dim:` must be specified in the model description file.
1004
+
When reshaping data, `in_dim:` must be specified in the model description file.
968
1005
2. Conversion from 1D and 2D to Fully Connected (“flattening”): The batch dimension (first dimension) must stay the same, and the other dimensions are combined (i.e., M = C×H×W or M = C×L).
969
1006
Example:
970
1007
`x = x.view(x.size(0), -1) # Flatten`
@@ -989,6 +1026,8 @@ By default, weights are quantized to 8-bits after 10 epochs as specified in `qat
989
1026
990
1027
Quantization-aware training can be <u>disabled</u> by specifying `--qat-policy None`.
991
1028
1029
+
For more information, please also see [Quantization](#Quantization).
1030
+
992
1031
#### Batch Normalization
993
1032
994
1033
Batch normalization after `Conv1d` and `Conv2d` layers is supported using “fusing”. The fusing operation merges the effect of batch normalization layers into the parameters of the preceding convolutional layer. For detailed information about batch normalization fusing/folding, see Section 3.2 of the following paper: https://arxiv.org/pdf/1712.05877.pdf.
@@ -1085,7 +1124,6 @@ The following table describes the command line arguments for `batchnormfuser.py`
1085
1124
|`-o`, `--out_path`| Set output checkpoint path for saving fused model |`-o best_without_bn.pth.tar`|
1086
1125
|`-oa`, `--out_arch`| Set output architecture name (architecture without batchnorm layers) |`-oa ai85simplenet`|
1087
1126
1088
-
1089
1127
### Quantization
1090
1128
1091
1129
There are two main approaches to quantization — quantization-aware training and post-training quantization. The MAX78000/MAX78002 support both approaches.
@@ -1186,9 +1224,9 @@ The training/verification data is located (by default) in `data/DataSetName`, fo
1186
1224
1187
1225
Train the new network/new dataset. See `scripts/train_mnist.sh` for a command line example.
1188
1226
1189
-
#### Netron - Network Visualization
1227
+
#### Netron — Network Visualization
1190
1228
1191
-
The Netron tool(https://github.com/lutzroeder/Netron) can visualize networks, similar to what is available within Tensorboard. To use Netron, use `train.py` to export the trained network to ONNX, and upload the ONNX file.
1229
+
The [Netron tool](https://github.com/lutzroeder/Netron) can visualize networks, similar to what is available within Tensorboard. To use Netron, use `train.py` to export the trained network to ONNX, and upload the ONNX file.
Network descriptions are written in YAML (see https://en.wikipedia.org/wiki/YAML). There are two sections in each file — global statements and a sequence of layer descriptions.
@@ -1826,7 +1868,7 @@ np.save(os.path.join('tests', 'sample_mnist'), a, allow_pickle=False, fix_import
@@ -1840,7 +1882,7 @@ np.save(os.path.join('tests', 'sample_mnist'), a, allow_pickle=False, fix_import
1840
1882
| optimizer_type | type | SGD |
1841
1883
| state_dict | OrderedDict | |
1842
1884
+----------------------+-------------+----------+
1843
-
1885
+
1844
1886
=> Checkpoint['extras'] contents:
1845
1887
+-----------------+--------+-------------------+
1846
1888
| Key | Type | Value |
@@ -1851,7 +1893,7 @@ np.save(os.path.join('tests', 'sample_mnist'), a, allow_pickle=False, fix_import
1851
1893
| clipping_scale | float | 0.85 |
1852
1894
| current_top1 | float | 99.46666666666667 |
1853
1895
+-----------------+--------+-------------------+
1854
-
1896
+
1855
1897
Loaded compression schedule from checkpoint (epoch 165)
1856
1898
=> loaded 'state_dict' from checkpoint '../ai8x-synthesis/trained/new.pth.tar'
1857
1899
Optimizer Type: <class 'torch.optim.sgd.SGD'>
@@ -1867,7 +1909,7 @@ np.save(os.path.join('tests', 'sample_mnist'), a, allow_pickle=False, fix_import
1867
1909
Test: [ 30/ 40] Loss 51.816276 Top1 99.518229 Top5 99.986979
1868
1910
Test: [ 40/ 40] Loss 53.596094 Top1 99.500000 Top5 99.990000
1869
1911
==> Top1: 99.500 Top5: 99.990 Loss: 53.596
1870
-
1912
+
1871
1913
==> Confusion:
1872
1914
[[ 979 0 0 0 0 0 0 0 1 0]
1873
1915
[ 0 1132 1 0 0 0 0 2 0 0]
@@ -1896,50 +1938,19 @@ The MAX78000/MAX78002 accelerator can generate an interrupt on completion, and i
1896
1938
1897
1939
To run another inference, ensure all groups are disabled (stopping the state machine, as shown in `cnn_init()`). Next, load the new input data and start processing.
1898
1940
1899
-
#### Softmax, and Data Unload in C
1900
-
1901
-
`ai8xize.py` can generate a call to a software Softmax function using the command line switch `--softmax`. That function is provided in the `assets/device-all` folder. To use the provided software Softmax on MAX78000/MAX78002, the last layer output should be 32-bit wide (`output_width: 32`).
1902
-
1903
-
The software Softmax function is optimized for processing time and it quantizes the input. When the last layer uses weights that are not 8-bits, the software function used will shift the input values first.
1904
-
1905
-

1906
-
1907
-
1908
-
1909
-
#### Generated Files and Upgrading the CNN Model
1910
-
1911
-
The generated C code comprises the following files. Some of the files are customized based in the project name, and some are custom for a combination of project name and weight/sample data inputs:
| model.launch | template in assets/eclipse | Yes | No |
1924
-
| .cproject | template in assets/eclipse | Yes | No |
1925
-
| .project | template in assets/eclipse | Yes | No |
1926
-
1927
-
In order to upgrade an embedded project after retraining the model, point the network generator to a new empty directory and regenerate. Then, copy the four files that will have changed to your original project — `cnn.c`, `cnn.h`, `weights.h`, and `log.txt`. This allows for persistent customization of the I/O code and project (for example, in `main.c` and additional files) while allowing easy model upgrades.
1928
1941
1929
-
The generator also adds all files from the `assets/eclipse`, `assets/device-all`, and `assets/embedded-ai87` folders. These files (when starting with `template` in their name) will be automatically customized to include project specific information as shown in the following table:
| `##__PROJ_NAME__##` | Project name (works on file names as well as the file contents) |
1934
-
| `##__ELF_FILE__##` | Output elf (binary) file name |
1935
-
| `##__BOARD__##` | Board name (e.g., `EvKit_V1`) |
1936
-
| `##__FILE_INSERT__##` | Network statistics and timer |
1944
+
The generated code is split between API code (in `cnn.c`) and data dependent code in `main.c` or `main_riscv.c`. The data dependent code is based on a known-answer test. The `main()` function shows the proper sequence of steps to load and configure the CNN accelerator, run it, unload it, and verify the result.
1937
1945
1938
-
##### Contents of the device-all Folder
1946
+
`void load_input(void);`
1947
+
Load the example input. This function can serve as a template for loading data into the CNN accelerator. Note that the clocks and power to the accelerator must be enabled first. If this is skipped, the device may hang and the [recovery procedure](https://github.com/MaximIntegratedAI/MaximAI_Documentation/tree/master/MAX78000_Feather#how-to-unlock-a-max78000-that-can-no-longer-be-programmed) may have to be used.
1939
1948
1940
-
* For MAX78000/MAX78002, the software Softmax is implemented in `softmax.c`.
1941
-
* A template for the `cnn.h` header file in `templatecnn.h`. The template is customized during code generation using model statistics and timer, but uses common function signatures for all projects.
1949
+
`int check_output(void);`
1950
+
This function verifies that the known-answer test works correctly in hardware (using the example input). This function is typically not needed in the final application.
1942
1951
1952
+
`int main(void);`
1953
+
This is the main function and can serve as a template for the user application. It shows the correct sequence of operations to initialize, load, run, and unload the CNN accelerator.
1943
1954
1944
1955
1945
1956
#### Overview of the Generated API Functions
@@ -1988,6 +1999,50 @@ Turn on the boost circuit on `port`.`pin`. This is only needed for very energy i
1988
1999
Turn off the boost circuit connected to `port`.`pin`.
1989
2000
1990
2001
2002
+
#### Softmax, and Data Unload in C
2003
+
2004
+
`ai8xize.py` can generate a call to a software Softmax function using the command line switch `--softmax`. That function is provided in the `assets/device-all` folder. To use the provided software Softmax on MAX78000/MAX78002, the last layer output should be 32-bit wide (`output_width: 32`).
2005
+
2006
+
The software Softmax function is optimized for processing time and it quantizes the input. When the last layer uses weights that are not 8-bits, the software function used will shift the input values first.
2007
+
2008
+

2009
+
2010
+
2011
+
#### Generated Files and Upgrading the CNN Model
2012
+
2013
+
The generated C code comprises the following files. Some of the files are customized based in the project name, and some are custom for a combination of project name and weight/sample data inputs:
| model.launch | template in assets/eclipse | Yes | No |
2026
+
| .cproject | template in assets/eclipse | Yes | No |
2027
+
| .project | template in assets/eclipse | Yes | No |
2028
+
2029
+
In order to upgrade an embedded project after retraining the model, point the network generator to a new empty directory and regenerate. Then, copy the four files that will have changed to your original project — `cnn.c`, `cnn.h`, `weights.h`, and `log.txt`. This allows for persistent customization of the I/O code and project (for example, in `main.c` and additional files) while allowing easy model upgrades.
2030
+
2031
+
The generator also adds all files from the `assets/eclipse`, `assets/device-all`, and `assets/embedded-ai87` folders. These files (when starting with `template` in their name) will be automatically customized to include project specific information as shown in the following table:
| `##__PROJ_NAME__##` | Project name (works on file names as well as the file contents) |
2036
+
| `##__ELF_FILE__##` | Output elf (binary) file name |
2037
+
| `##__BOARD__##` | Board name (e.g., `EvKit_V1`) |
2038
+
| `##__FILE_INSERT__##` | Network statistics and timer |
2039
+
2040
+
##### Contents of the device-all Folder
2041
+
2042
+
* For MAX78000/MAX78002, the software Softmax is implemented in `softmax.c`.
2043
+
* A template for the `cnn.h` header file in `templatecnn.h`. The template is customized during code generation using model statistics and timer, but uses common function signatures for all projects.
2044
+
2045
+
1991
2046
1992
2047
#### Energy Measurement
1993
2048
@@ -1997,14 +2052,21 @@ When running C code generated with `--energy`, the power display on the EVKit wi
1997
2052
1998
2053
*Note: MAX78000 uses LED1 and LED2 to trigger power measurement via MAX32625 and MAX34417.*
1999
2054
2000
-
See https://github.com/MaximIntegratedAI/MaximAI_Documentation/blob/master/MAX78000_Evaluation_Kit/MAX78000%20Power%20Monitor%20and%20Energy%20Benchmarking%20Guide.pdf for more information about benchmarking.
2055
+
See the [benchmarking guide](https://github.com/MaximIntegratedAI/MaximAI_Documentation/blob/master/MAX78000_Evaluation_Kit/MAX78000%20Power%20Monitor%20and%20Energy%20Benchmarking%20Guide.pdf) for more information about benchmarking.
2056
+
2057
+
2001
2058
2002
2059
## Further Information
2003
2060
2004
-
Additional information about the evaluation kits, and the software development kit (SDK) is available on the web at https://github.com/MaximIntegratedAI/aximAI_Documentation
2061
+
Additional information about the evaluation kits, and the software development kit (SDK) is available on the web at https://github.com/MaximIntegratedAI/MaximAI_Documentation
2062
+
2063
+
2064
+
2005
2065
2006
2066
---
2007
2067
2068
+
2069
+
2008
2070
## AHB Memory Addresses
2009
2071
2010
2072
The following tables show the AHB memory addresses for the MAX78000 accelerator:
@@ -2221,6 +2283,4 @@ Do not try to push any changes into the master branch. Instead, create a fork an
0 commit comments