|
1 | 1 | # MAX78000 Model Training and Synthesis
|
2 | 2 |
|
3 |
| -_March 18, 2021_ |
| 3 | +_March 31, 2021_ |
4 | 4 |
|
5 | 5 | The Maxim Integrated AI project is comprised of four repositories:
|
6 | 6 |
|
@@ -1845,15 +1845,53 @@ The MAX78000/MAX78002 accelerator can generate an interrupt on completion, and i
|
1845 | 1845 |
|
1846 | 1846 | 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.
|
1847 | 1847 |
|
1848 |
| -#### Softmax, and Data unload in C |
| 1848 | +#### Softmax, and Data Unload in C |
1849 | 1849 |
|
1850 | 1850 | `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`).
|
1851 | 1851 |
|
1852 | 1852 | 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.
|
1853 | 1853 |
|
1854 | 1854 | 
|
1855 | 1855 |
|
1856 |
| -#### Overview of the Generated API functions |
| 1856 | + |
| 1857 | + |
| 1858 | +#### Generated Files and Upgrading the CNN Model |
| 1859 | + |
| 1860 | +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: |
| 1861 | + |
| 1862 | +| File name | Source | Project specific? | Model/weights change? | |
| 1863 | +| ------------ | -------------------------------- | ----------------- | --------------------- | |
| 1864 | +| Makefile | template in assets/embedded-ai87 | Yes | No | |
| 1865 | +| cnn.c | generated | Yes | **Yes** | |
| 1866 | +| cnn.h | template in assets/device-all | Yes | **Yes** | |
| 1867 | +| weights.h | generated | Yes | **Yes** | |
| 1868 | +| log.txt | generated | Yes | **Yes** | |
| 1869 | +| main.c | generated | Yes | No | |
| 1870 | +| sampledata.h | generated | Yes | No | |
| 1871 | +| softmax.c | assets/device-all | No | No | |
| 1872 | +| model.launch | template in assets/eclipse | Yes | No | |
| 1873 | +| .cproject | template in assets/eclipse | Yes | No | |
| 1874 | +| .project | template in assets/eclipse | Yes | No | |
| 1875 | + |
| 1876 | +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. |
| 1877 | + |
| 1878 | +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: |
| 1879 | + |
| 1880 | +| Key | Replaced by | |
| 1881 | +| --------------------- | ------------------------------------------------------------ | |
| 1882 | +| `##__PROJ_NAME__##` | Project name (works on file names as well as the file contents) | |
| 1883 | +| `##__ELF_FILE__##` | Output elf (binary) file name | |
| 1884 | +| `##__BOARD__##` | Board name (e.g., `EvKit_V1`) | |
| 1885 | +| `##__FILE_INSERT__##` | Network statistics and timer | |
| 1886 | + |
| 1887 | +##### Contents of the device-all Folder |
| 1888 | + |
| 1889 | +* For MAX78000/MAX78002, the software Softmax is implemented in `softmax.c`. |
| 1890 | +* 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. |
| 1891 | + |
| 1892 | + |
| 1893 | + |
| 1894 | +#### Overview of the Generated API Functions |
1857 | 1895 |
|
1858 | 1896 | The API code (in `cnn.c` by default) is auto-generated. It is data independent, but differs depending on the network. This simplifies replacing the network while keeping the remainder of the code intact.
|
1859 | 1897 |
|
@@ -1898,10 +1936,7 @@ Turn on the boost circuit on `port`.`pin`. This is only needed for very energy i
|
1898 | 1936 | `int cnn_boost_disable(mxc_gpio_regs_t *port, uint32_t pin);`
|
1899 | 1937 | Turn off the boost circuit connected to `port`.`pin`.
|
1900 | 1938 |
|
1901 |
| -#### Contents of the device-all Folder |
1902 | 1939 |
|
1903 |
| -* For MAX78000/MAX78002, the software Softmax is implemented in `softmax.c`. |
1904 |
| -* A template for the `cnn.h` header file in `templatecnn.h`. The template is customized during code generation. |
1905 | 1940 |
|
1906 | 1941 | #### Energy Measurement
|
1907 | 1942 |
|
|
0 commit comments