diff --git a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/lenet_mnist_half.cc b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/lenet_mnist_half.cc index 0fb39cbe84af998ad42c9c14915e272aa3dab88d..54cbbed01475ab0f13c3ff9b131bf174ba8e8e12 100644 --- a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/lenet_mnist_half.cc +++ b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/lenet_mnist_half.cc @@ -11,33 +11,40 @@ void testLenetTanh() { int test_batch_size = 5000; - std::string dir_prefix = model_params_path + std::string("/lenet_mnist/"); - - std::string input_path = dir_prefix + std::string("input.bin"); - std::string labels_path = dir_prefix + std::string("labels.bin"); - std::string labels32_path = dir_prefix + std::string("labels32.bin"); + std::string dir_prefix = + model_params_path + std::string("/lenet_mnist/"); + + std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string labels_path = dir_prefix + std::string("test_labels.bin"); // Loading Input Batch void *input = readInputBatch(input_path.c_str(), 0, 0, test_batch_size, 1, 28, 28); - uint8_t *labels = readLabelsBatch(labels_path.c_str(), 0, test_batch_size); - - void *conv1_filter = readTrainedWeights( - "../model_params/lenet_mnist/conv1.bin", float_type, 32, 1, 5, 5); - void *conv1_bias = readTrainedWeights( - "../model_params/lenet_mnist/conv1_bias.bin", float_type, 1, 32, 1, 1); - void *conv2_filter = readTrainedWeights( - "../model_params/lenet_mnist/conv2.bin", float_type, 64, 32, 5, 5); - void *conv2_bias = readTrainedWeights( - "../model_params/lenet_mnist/conv2_bias.bin", float_type, 1, 64, 1, 1); - void *fc1_weights = readTrainedWeights("../model_params/lenet_mnist/fc1.bin", + + uint32_t *labels = readLabelsBatch3(labels_path.c_str(), 0, test_batch_size); + + void *conv1_filter = readTrainedWeights((dir_prefix + std::string("/conv2d_1_w.bin")).c_str(), + float_type, 32, 1, 5, 5); + void *conv1_bias = readTrainedWeights((dir_prefix + std::string("/conv2d_1_b.bin")).c_str(), + float_type, 1, 32, 1, 1); + void *conv2_filter = readTrainedWeights((dir_prefix + std::string("/conv2d_2_w.bin")).c_str(), + float_type, 64, 32, 5, 5); + + void *conv2_bias = readTrainedWeights((dir_prefix + std::string("/conv2d_2_b.bin")).c_str(), + float_type, 1, 64, 1, 1); + + void *fc1_weights = readTrainedWeights((dir_prefix + std::string("/dense_1_w.bin")).c_str(), float_type, 1, 1, 7 * 7 * 64, 1024); - void *fc1_bias = readTrainedWeights( - "../model_params/lenet_mnist/fc1_bias.bin", float_type, 1, 1024, 1, 1); - void *fc2_weights = readTrainedWeights("../model_params/lenet_mnist/fc2.bin", + + void *fc1_bias = readTrainedWeights((dir_prefix + std::string("/dense_1_b.bin")).c_str(), + float_type, 1, 1024, 1, 1); + + void *fc2_weights = readTrainedWeights((dir_prefix + std::string("/dense_2_w.bin")).c_str(), float_type, 1, 1, 1024, 10); - void *fc2_bias = readTrainedWeights( - "../model_params/lenet_mnist/fc2_bias.bin", float_type, 1, 10, 1, 1); + + void *fc2_bias = readTrainedWeights((dir_prefix + std::string("/dense_2_b.bin")).c_str(), + float_type, 1, 10, 1, 1); + clearTensorMap(); @@ -88,7 +95,7 @@ void testLenetTanh() { // End profiling and dump output to profile.txt stopProfiling(); - computeAccuracy2(labels, test_batch_size, result); + computeAccuracy3(labels, result); dumpAccuracyNorms(); freeOutputTensors(); diff --git a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/mobilenet_half.cc b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/mobilenet_half.cc index 7722447047aaac6dc679fb02c16e6b2c20c2c049..7340e52c8d60453a1fb6f68f718c1c08c478c058 100644 --- a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/mobilenet_half.cc +++ b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/mobilenet_half.cc @@ -7,9 +7,11 @@ int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = model_params_path + std::string("/mobilenet/"); - std::string input_path = dir_prefix + std::string("input.bin"); - std::string labels_path = dir_prefix + std::string("labels.bin"); + std::string dir_prefix = model_params_path + std::string("/mobilenet_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 conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); void *conv2d_1_w = readTrainedWeights(conv2d_1_w_path.c_str(), 0, 32, 3, 3, 3); @@ -710,9 +712,9 @@ int main() { void *var_102 = tensorHalfAdd(var_101, dense_1_b); void *var_103 = tensorSoftmax(var_102); - uint8_t *labels = readLabelsBatch(labels_path.c_str(), start, end); + uint32_t *labels = readLabelsBatch3(labels_path.c_str(), start, end); - float accuracy = computeAccuracy2(labels, batch_size, var_103); + float accuracy = computeAccuracy3(labels, var_103); final_accuracy += accuracy; freeBatchMemory(); } diff --git a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar100_half.cc b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar100_half.cc index 1bd79c7fb71400edd900bceb42413cf4320005fe..a5b703ab6e2461f67c2d05b077ca2bdade86a5f9 100644 --- a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar100_half.cc +++ b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar100_half.cc @@ -8,8 +8,10 @@ int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = model_params_path + std::string("/vgg16_cifar100/"); - std::string input_path = dir_prefix + std::string("input.bin"); - std::string labels_path = dir_prefix + std::string("labels.bin"); + + std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string labels_path = dir_prefix + std::string("test_labels.bin"); + std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); void *conv2d_1_w = readTrainedWeights(conv2d_1_w_path.c_str(), 0, 64, 3, 3, 3); @@ -164,9 +166,9 @@ int main() { void *var_59 = tensorHalfAdd(var_58, dense_2_b); void *var_60 = tensorSoftmax(var_59); - uint8_t *labels = readLabelsBatch(labels_path.c_str(), start, end); + uint32_t *labels = readLabelsBatch3(labels_path.c_str(), start, end); - float accuracy = computeAccuracy2(labels, batch_size, var_60, 100); + float accuracy = computeAccuracy3(labels, var_60); final_accuracy += accuracy; freeBatchMemory(); } diff --git a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar10_half.cc b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar10_half.cc index 22d2a3614cb668a668f60c7a3941e06d92ebf4de..2a4b5a6a914698f621284e0f5b19843b817068df 100644 --- a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar10_half.cc +++ b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp16/vgg16_cifar10_half.cc @@ -8,9 +8,10 @@ int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = model_params_path + std::string("/vgg16_cifar10/"); - std::string input_path = dir_prefix + std::string("input.bin"); - std::string labels_path = dir_prefix + std::string("labels.bin"); + std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); + void *conv2d_1_w = readTrainedWeights(conv2d_1_w_path.c_str(), 0, 64, 3, 3, 3); std::string conv2d_1_b_path = dir_prefix + std::string("conv2d_1_b.bin"); @@ -167,9 +168,9 @@ int main() { void *var_59 = tensorHalfAdd(var_58, dense_2_b); void *var_60 = tensorSoftmax(var_59); - uint8_t *labels = readLabelsBatch(labels_path.c_str(), start, end); + uint32_t *labels = readLabelsBatch3(labels_path.c_str(), start, end); - float accuracy = computeAccuracy2(labels, batch_size, var_60); + float accuracy = computeAccuracy3(labels, var_60); final_accuracy += accuracy; freeBatchMemory(); diff --git a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp32/lenet_mnist.cc b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp32/lenet_mnist.cc index cb6593f7d5cac872159c909c99fbde478729df29..e1550c715cb36dca8eec1fd24e82e038014039a0 100644 --- a/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp32/lenet_mnist.cc +++ b/hpvm/projects/hpvm-tensor-rt/dnn_sources/src/fp32/lenet_mnist.cc @@ -1,50 +1,54 @@ #include "tensor_runtime.h" -#include "utils.h" +#include "../include/utils.h" int total_runs = 1; -/* NOTE: Reference Architecture to use for profiling */ + void testLenetTanh() { printf("********* Lenet-2 Architecture ********** \n"); - // FIXIT: Extend this to batch of images - currently 5 images int test_batch_size = 5000; - std::string dir_prefix = model_params_path + std::string("/lenet_mnist/"); - - std::string input_path = dir_prefix + std::string("input.bin"); - std::string labels_path = dir_prefix + std::string("labels.bin"); - std::string labels32_path = dir_prefix + std::string("labels32.bin"); + std::string dir_prefix = + model_params_path + std::string("/lenet_mnist/"); + + std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string labels_path = dir_prefix + std::string("test_labels.bin"); // Loading Input Batch void *input = readInputBatch(input_path.c_str(), 0, 0, test_batch_size, 1, 28, 28); - uint8_t *labels = readLabelsBatch(labels_path.c_str(), 0, test_batch_size); - - void *conv1_filter = readTrainedWeights( - "../model_params/lenet_mnist/conv1.bin", float_type, 32, 1, 5, 5); - void *conv1_bias = readTrainedWeights( - "../model_params/lenet_mnist/conv1_bias.bin", float_type, 1, 32, 1, 1); - void *conv2_filter = readTrainedWeights( - "../model_params/lenet_mnist/conv2.bin", float_type, 64, 32, 5, 5); - void *conv2_bias = readTrainedWeights( - "../model_params/lenet_mnist/conv2_bias.bin", float_type, 1, 64, 1, 1); - void *fc1_weights = readTrainedWeights("../model_params/lenet_mnist/fc1.bin", + + uint32_t *labels = readLabelsBatch3(labels_path.c_str(), 0, test_batch_size); + + void *conv1_filter = readTrainedWeights((dir_prefix + std::string("/conv2d_1_w.bin")).c_str(), + float_type, 32, 1, 5, 5); + void *conv1_bias = readTrainedWeights((dir_prefix + std::string("/conv2d_1_b.bin")).c_str(), + float_type, 1, 32, 1, 1); + void *conv2_filter = readTrainedWeights((dir_prefix + std::string("/conv2d_2_w.bin")).c_str(), + float_type, 64, 32, 5, 5); + + void *conv2_bias = readTrainedWeights((dir_prefix + std::string("/conv2d_2_b.bin")).c_str(), + float_type, 1, 64, 1, 1); + + void *fc1_weights = readTrainedWeights((dir_prefix + std::string("/dense_1_w.bin")).c_str(), float_type, 1, 1, 7 * 7 * 64, 1024); - void *fc1_bias = readTrainedWeights( - "../model_params/lenet_mnist/fc1_bias.bin", float_type, 1, 1024, 1, 1); - void *fc2_weights = readTrainedWeights("../model_params/lenet_mnist/fc2.bin", + + void *fc1_bias = readTrainedWeights((dir_prefix + std::string("/dense_1_b.bin")).c_str(), + float_type, 1, 1024, 1, 1); + + void *fc2_weights = readTrainedWeights((dir_prefix + std::string("/dense_2_w.bin")).c_str(), float_type, 1, 1, 1024, 10); - void *fc2_bias = readTrainedWeights( - "../model_params/lenet_mnist/fc2_bias.bin", float_type, 1, 10, 1, 1); + + void *fc2_bias = readTrainedWeights((dir_prefix + std::string("/dense_2_b.bin")).c_str(), + float_type, 1, 10, 1, 1); clearTensorMap(); for (int i = 0; i < total_runs; i++) { - readOpenTunerFlags("opentuner_flags"); // Resets the OpenTuner counters - + // Start power and performnce profiling startProfiling(); @@ -89,7 +93,7 @@ void testLenetTanh() { // End profiling and dump output to profile.txt stopProfiling(); - float accuracy = computeAccuracy2(labels, test_batch_size, result); + float accuracy = computeAccuracy3(labels, result); dumpFinalAccuracy(accuracy); // FIXME: remove the comment below to use piped autotuner