diff --git a/hpvm/projects/keras/README.md b/hpvm/projects/keras/README.md index 4d1085595b9ec1bda23ec13fbf94d390470c3b40..bfdae5b0926865e65fe306b765157395ff8e6bc2 100644 --- a/hpvm/projects/keras/README.md +++ b/hpvm/projects/keras/README.md @@ -25,7 +25,7 @@ conda activate keras_python36 At the root of this project (`/projects/keras/`) install the Keras frontend pip package as: ``` -pip install -e ./ +pip3 install -e ./ ``` **NOTE:** If you are using the conda environment, activate it prior to this step. diff --git a/hpvm/test/dnn_benchmarks/keras/README.md b/hpvm/test/dnn_benchmarks/keras/README.md index 34b7a7804d43f40295cbbe968a0fd4ef9e0682f7..f80ac8a387ecd3a537473a9797eaec190f3c9964 100644 --- a/hpvm/test/dnn_benchmarks/keras/README.md +++ b/hpvm/test/dnn_benchmarks/keras/README.md @@ -1,21 +1,60 @@ -# Keras Benchmarks +# Keras Frontend + +Install Keras Frontend after moving to directory `/hpvm/hpvm/projects/keras` + +## Requirements + +* python == 3.6.x +* pip >= 18 + +If your system uses a different Python version, we recommend using the conda environment `keras_python36.yml`. Install this using: + +``` +conda env create -f keras_python36.yml --name keras_python36 +``` + +Activate the conda environment before installing the pip package (below) using: + +``` +conda activate keras_python36 +``` + +**NOTE:** This step must be performed each time (for each shell process) the frontend is to be used. ## Installing the Keras Frontend Package -Instructions for Installing the Keras Frontend are [here](https://gitlab.engr.illinois.edu/llvm/hpvm/-/blob/approx_hpvm_reorg_keras/hpvm/projects/keras/README.md) +At the root of this project (`/projects/keras/`) install the Keras frontend pip package as: + +``` +pip3 install -e ./ +``` + +**NOTE:** If you are using the conda environment, activate it prior to this step. + +## Suppported Operations + +List of supported operations and limitations detailed in https://gitlab.engr.illinois.edu/llvm/hpvm/-/blob/approx_hpvm_reorg_keras/hpvm/projects/keras/docs/Support.md + + + +# Keras Benchmarks + +Run the Keras benchmarks under `hpvm/hpvm/test/dnn_benchmarks/keras` + ## Download CNN Model Files -The weight (model) and data files to use with the CNN benchmarks are hosted on Git LFS and need to separately downloaded. This can be done using: +Prior to running the benchmarks, ensure you download the CNN model data (inputs and weights) if not done in automatic build script. ``` -git lfs fetch -git lfs checkout +wget https://databank.illinois.edu/datafiles/o3izd/download -O model_params.tar.gz +tar -xf model_params.tar.gz ``` -**NOTE:** Data donwload is necesary before running benchmarks +Move extracted `model_params` directory to `/test/dnn_benchmarks/model_params` (Benchmarks expect data at this location) + ## Running Benchmaks @@ -23,22 +62,22 @@ List of benchmarks and the expected accuracies: | Benchmark | Accuracy | | ----------- | ----------- | -| AlexNet-CIFAR10 | 79.28 | -| AlexNet2-CIFAR10 | 84.98 | -| AlexNet-ImageNet | 56.30 | -| LeNet-MNIST | 98.70 | -| MobileNet-CIFAR10 | 84.42 | -| ResNet18-CIFAR10 | 89.56 | -| ResNet50-ImageNet | 75.10 | -| VGG16-CIFAR10 | 89.96 | -| VGG16-CIFAR100 | 66.50 | -| VGG16-ImageNet | 69.46 | +| alexnet.py | 79.28 | +| alexnet2.py | 84.98 | +| alexnet_imagenet.py | 56.30 | +| lenet.py | 98.70 | +| mobilenet_cifar10.py | 84.42 | +| resnet18_cifar10.py | 89.56 | +| resnet50_imagenet.py | 75.10 | +| vgg16_cifar10.py | 89.96 | +| vgg16_cifar100.py | 66.50 | +| vgg16_imagenet.py | 69.46 | ### Synopsis ``` -python ${BENCH_NAME}.py [hpvm_reload|keras_reload] [frontend] [compile] +python3 ${BENCH_NAME}.py [hpvm_reload|keras_reload] [frontend] [compile] ``` @@ -111,6 +150,32 @@ These are described here: Trains the Keras model constructed in `buildModel` and is expected to return the trained keras model - training parameters should be tuned here. +### Directly using Keras Frontend API + +Alternate to extending the `Benchmark` class, users may directly invoke the Keras Frontend API. This can be done as: + +```python + +from keras_frontend.approxhpvm_translator import translate_to_approxhpvm + +# Construct and train your Keras Model (or load pre-trained weights) + +translate_to_approxhpvm(model, data_dir, src_dir, test_data, test_labels, tune_data, tune_labels, batch_size, num_classes) + +``` + +## Running HPVM Binary + +Run the `HPVM_binary` generated under the directory specified by `src_dir` (described above). Usage: + +``` +./HPVM_binary -t {test|tune} -c ${config_file_path} +``` + +`test|tune`: Runs with either tune (autotuning data) or test set (for evaluation) + +`config_file_path`: Path to an HPVM tensor configuration file (includes approximation settings) + ## Automated Tests @@ -121,9 +186,6 @@ python test_benchmarks.py ``` -## Suppported Operations - -List of supported operations and limitations detailed in https://gitlab.engr.illinois.edu/llvm/hpvm/-/blob/approx_hpvm_reorg_keras/hpvm/projects/keras/docs/Support.md