From 1e9c7b89f6ba3fb2f712c7088d03921b963fc1ed Mon Sep 17 00:00:00 2001 From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu> Date: Wed, 30 Jun 2021 23:10:28 -0500 Subject: [PATCH] Compiling AlexNet with INT8 -- pushing calib values shared by Shubham --- .../alexnet_cifar10/alexnet_cifar10.cpp | 28 +++++++++---------- .../benchmarks/alexnet_cifar10/calib.txt | 22 +++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/calib.txt diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp index 962fbd2e62..8ed9252e43 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp @@ -392,8 +392,8 @@ int main(int argc, char *argv[]) { } std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_cifar10/"; - std::string input_path = dir_prefix + std::string("test_input.bin"); - std::string labels_path = dir_prefix + std::string("test_labels.bin"); + std::string input_path = dir_prefix + std::string("test_input_fp16.bin"); + std::string labels_path = dir_prefix + std::string("test_labels_fp16.bin"); uint8_t *labels = readLabels(labels_path.c_str(), 5000); //--std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); @@ -401,40 +401,40 @@ int main(int argc, char *argv[]) { //-- readTrainedWeights(conv2d_1_w_path.c_str(), 0, 64, 3, 11, 11); void *conv2d_1_w = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_1_w.bin", 0, 64, 3, 11, 11); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_1_w_fp16.bin", 0, 64, 3, 11, 11); //---std::string conv2d_1_b_path = dir_prefix + std::string("conv2d_1_b.bin"); void *conv2d_1_b = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_1_b.bin", 0, 1, 64, 1, 1); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_1_b_fp16.bin", 0, 1, 64, 1, 1); //std::string conv2d_2_w_path = dir_prefix + std::string("conv2d_2_w.bin"); void *conv2d_2_w = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_2_w.bin", 0, 192, 64, 5, 5); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_2_w_fp16.bin", 0, 192, 64, 5, 5); //std::string conv2d_2_b_path = dir_prefix + std::string("conv2d_2_b.bin"); void *conv2d_2_b = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_2_b.bin", 0, 1, 192, 1, 1); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_2_b_fp16.bin", 0, 1, 192, 1, 1); //std::string conv2d_3_w_path = dir_prefix + std::string("conv2d_3_w.bin"); void *conv2d_3_w = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_3_w.bin", 0, 384, 192, 3, 3); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_3_w_fp16.bin", 0, 384, 192, 3, 3); //std::string conv2d_3_b_path = dir_prefix + std::string("conv2d_3_b.bin"); void *conv2d_3_b = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_3_b.bin", 0, 1, 384, 1, 1); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_3_b_fp16.bin", 0, 1, 384, 1, 1); //std::string conv2d_4_w_path = dir_prefix + std::string("conv2d_4_w.bin"); void *conv2d_4_w = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_4_w.bin", 0, 256, 384, 3, 3); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_4_w_fp16.bin", 0, 256, 384, 3, 3); //std::string conv2d_4_b_path = dir_prefix + std::string("conv2d_4_b.bin"); void *conv2d_4_b = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_4_b.bin", 0, 1, 256, 1, 1); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_4_b_fp16.bin", 0, 1, 256, 1, 1); ///std::string conv2d_5_w_path = dir_prefix + std::string("conv2d_5_w.bin"); void *conv2d_5_w = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_5_w.bin", 0, 256, 256, 3, 3); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_5_w_fp16.bin", 0, 256, 256, 3, 3); ///std::string conv2d_5_b_path = dir_prefix + std::string("conv2d_5_b.bin"); void *conv2d_5_b = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_5_b.bin", 0, 1, 256, 1, 1); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/conv2d_5_b_fp16.bin", 0, 1, 256, 1, 1); //std::string dense_1_w_path = dir_prefix + std::string("dense_1_w.bin"); void *dense_1_w = - readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/dense_1_w.bin", 0, 1, 1, 4096, 10); + readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/dense_1_w_fp16.bin", 0, 1, 1, 4096, 10); ///std::string dense_1_b_path = dir_prefix + std::string("dense_1_b.bin"); - void *dense_1_b = readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/dense_1_b.bin", 0, 1, 10, 1, 1); + void *dense_1_b = readTrainedWeights(MODEL_PARAMS_DIR_STR "/alexnet_cifar10/dense_1_b_fp16.bin", 0, 1, 10, 1, 1); RootIn *args = static_cast<RootIn *>(malloc(sizeof(RootIn))); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/calib.txt b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/calib.txt new file mode 100644 index 0000000000..1037d0fe8b --- /dev/null +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/calib.txt @@ -0,0 +1,22 @@ +input: 0.021688217297196388 +conv1: 0.1280621439218521 +add1: 0.1280621439218521 +tanh1: 0.007875937968492508 +pool1: 0.007875937968492508 +conv2: 0.15858858823776245 +add2: 0.15858858823776245 +tanh2: 0.007875937968492508 +pool2: 0.007875937968492508 +conv3: 0.12322093546390533 +add3: 0.12322093546390533 +tanh3: 0.007875937968492508 +conv4: 0.166531503200531 +add4: 0.166531503200531 +tanh4: 0.007875937968492508 +conv5: 0.1268610805273056 +add5: 0.1268610805273056 +tanh5: 0.007875937968492508 +pool3: 0.007875937968492508 +gemm1: 0.30668970942497253 +add6: 0.30668970942497253 +softmax1: 0.30668970942497253 -- GitLab