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
{{ message }}
This repository was archived by the owner on Oct 21, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+79-25
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ docs/C API.md.
21
21
22
22
[**Examples**](examples/): Example code and Deep Learning tutorial.
23
23
24
+
[**Pytorch-torchscript**](torch_mdla/README.md): Tutorial on how to add Micro DLA into pytorch using torchscript.
24
25
25
26
## Table of Contents:
26
27
@@ -45,17 +46,18 @@ docs/C API.md.
45
46
-[6. Tutorial - PutInput and GetResult](#6-tutorial---putinput-and-getresult) : tutorial for using PutInput and GetOutput
46
47
-[7. Tutorial - Writing tests](#7-tutorial---writing-tests) : Tutorial on running tests
47
48
-[8. Tutorial - Debugging](#8-tutorial---debugging) : Tutorial on debugging and printing
48
-
-[9. Running a model from your favorite deep learning framework](#9-running-a-model-from-your-favorite-deep-learning-framework) : Tutorial on converting models to ONNX
49
+
-[9. Variable Fix Point Quantization](#9-variable-fix-point-quantization) : Tutorial on using variable fix-point
50
+
-[10. Running a model from your favorite deep learning framework](#10-running-a-model-from-your-favorite-deep-learning-framework) : Tutorial on converting models to ONNX
49
51
*[Tensorflow](#tensorflow)
50
52
*[Caffe1](#caffe1)
51
53
*[Keras](#keras)
52
-
-[10. Supported models and layers](#10-supported-models-and-layers) : List of supported layers and models tested on the DLA
54
+
-[11. Supported models and layers](#11-supported-models-and-layers) : List of supported layers and models tested on the DLA
53
55
*[Tested models](#tested-models)
54
56
*[TF-Slim models tested on Micron DLA inference engine](#tf-slim-models-tested-on-microndla-inference-engine)
55
57
*[ONNX model zoo](#onnx-model-zoo)
56
58
*[Keras](#keras)
57
59
*[CNTK](#cntk)
58
-
-[11. Troubleshooting and Q&A](#11-troubleshooting-and-qa) : Troubleshooting common issues and answering common questions
60
+
-[12. Troubleshooting and Q&A](#12-troubleshooting-and-qa) : Troubleshooting common issues and answering common questions
59
61
60
62
61
63
# 1. Installation
@@ -282,6 +284,22 @@ For more information about onnx please visit [https://onnx.ai/](https://onnx.ai/
282
284
283
285
To convert tensorflow models into ONNX files please reference the section [6. Using with Tensorflow](#6-using-with-tensorflow)
284
286
287
+
**Loading hardware into FPGA**
288
+
289
+
When you turn on the system, it will have the FPGA programmed with a default hardware definition. You need to load the MDLA bitfile only once after turning on the system.
290
+
291
+
You can load a MDLA bitfile of choice using:
292
+
293
+
`python3 loadbitfile.py <bitfile path>`
294
+
295
+
You can find the MDLA bitfiles in the pico-computing folder:
296
+
297
+
`/usr/src/picocomputing`
298
+
299
+
Loading the FPGA will take at max 5 min.
300
+
Loading the FPGA only fails when there are no FPGA cards available. If you find issues in loading FPGA check out [Troubleshooting](#11-troubleshooting-and-qa).
301
+
Micron DLA hardware will be loaded in the FPGA card. The following MDLA runs will not need to load the hardware anymore.
302
+
285
303
**Running inference on Micron DLA hardware for one image**
286
304
287
305
In the SDK folder, there is simpledemo.py, which is a python demo application.
@@ -296,16 +314,7 @@ Its main parts are:
296
314
The user may modify steps 1 and 5 according to users needs.
297
315
Check out other possible application programs using Micron DLA hardware [here](http://fwdnxt.com/).
298
316
The example program is located in examples/python/
`-l` option will load the hardware into a FPGA card.
304
317
305
-
306
-
Loading the FPGA and bringing up the HMC will take at max 5 min.
307
-
Loading the FPGA only fails when there are no FPGA cards available. If you find issues in loading FPGA check out [Troubleshooting](#11-troubleshooting-and-qa).
308
-
After the first run, Micron DLA hardware will be loaded in the FPGA card. The following runs will not need to load the hardware anymore.
309
318
You can run the network on hardware with this command, which will find the FPGA card that was loaded with Micron DLA hardware:
`-b` option will load the specified DLA bitfile into a FPGA card.
362
-
Loading the FPGA and bringing up the HMC will take a maximum of five minutes.
363
-
Loading the FPGA only fails when there are no FPGA cards available. If you find issues in loading FPGA check out [Troubleshooting](#11-troubleshooting-and-qa).
364
-
After the first run, the DLA will be loaded in the FPGA card. The following runs will not need to load the DLA bitfile anymore.
365
-
You can run the network on the DLA with this command, which will find the FPGA card that was loaded with the DLA:
369
+
After creating the `instructions.bin`, you can run the network on the DLA with this command, which will find the FPGA card that was loaded with the DLA:
The code also have a profile option, which will execute each layer of the model and print the time measurements into a `.csv` file.
754
758
755
-
# 9. Running a model from your favorite deep learning framework
759
+
# 9. Variable Fix Point Quantization
760
+
761
+
Micro DLA uses 16-bit fix point to represent numbers. The `Compile` function will convert the numbers in the onnx model from float 32-bit into 16-bit fix-point [Q8.8](https://en.wikipedia.org/wiki/Q_(number_format)). The default Micron DLA bitfile will run the model using Q8.8.
762
+
763
+
A Micron DLA bitfile with variable fix-point support is provided in order to reduce the discrepancy between the float 32-bit and the Q8.8 representation.
764
+
765
+
This bitfile allows the software to choose different QX.Y representations that is the best fit for different parts of the neural network model.
766
+
767
+
The SDK provides 2 options for variable fix-point quantization. **Before you try** these options, make sure to load the bitfile that supports variable fix-point into the FPGA.
768
+
769
+
**Option 1**: For each layer of the model, their weights and biases are converted into different QX.Y representations.
770
+
771
+
In this case, you can set 'V' in the options using `SetFlag` function before `Compile`:
**Option 2**: Variable fix-point can be determined for input and output of each layer if one or more sample inputs are provided.
781
+
782
+
You will need to provide a set of sample inputs (calibration data) to `Quantize` funtion. In addition to compiling the model, `Quantize` will run the model with the calibration inputs using float32 and save the variable fix-point configuration for each input/output of each layer in the model. `Quantize` will also convert the static data (weights and biases) to the appropriate fix-point representation, so no need for `ie.SetFlag('options', 'V')` in this case.
783
+
784
+
Instead of using ie.Compile, you use `Quantize` and give an array of input data:
785
+
786
+
```python
787
+
#Load image into a numpy array
788
+
img = LoadImage(args.image, args)
789
+
imgs = []
790
+
for fn in os.listdir(args.imagesdir):
791
+
x = LoadImage(args.imagesdir +'/'+ fn, args)
792
+
imgs.append(x)
793
+
794
+
#Create and initialize the Inference Engine object
After that, `Init` and `Run` runs as usual using the saved variable fix-point configuration.
801
+
802
+
Checkout the example [quantize.py](examples/python/quantize.py) which takes same arguments as `simpledemo.py`. The only addition is a folder with the calibration input images for calibration data.
803
+
804
+
# 10. Running a model from your favorite deep learning framework
756
805
757
806
Micron DLA supports different deep learning frameworks by running models in ONNX format. In order to convert a model from your favorite deep learning framework to ONNX format you should follow the instructions [here](https://github.com/onnx/tutorials). However there are some extra steps you should take with certain frameworks for the best compatibility with Micron DLA and we describe them below.
0 commit comments