diff --git a/llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/lenet_promise.cc b/llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/lenet_promise.cc index 37a30c55002bd2fea2ac4054649869e5cf4b5c6f..cbc5fbee8a3bd79c5d3cc6812c5bdc351913b3dd 100644 --- a/llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/lenet_promise.cc +++ b/llvm/projects/hpvm-tensor-rt/dnn_sources/src/promise/lenet_promise.cc @@ -11,8 +11,6 @@ #include "../../include/utils.h" -// Piped OpenTuner usage is now deprecated -bool Opentuner_run = false; int total_runs = 1; float bench_acc = 0; int to_skip = 5; @@ -22,13 +20,16 @@ int to_skip = 5; void testLenetTanh(){ - printf("********* Lenet-2 Architecture ********** \n"); - // FIXIT: Extend this to batch of images - currently 5 images - - int test_batch_size = 1000; - - uint8_t* labels = readLabels("../model_params/lenet_params/datasets/t10k-labels-idx1-ubyte", test_batch_size); + printf("********* Lenet-5 Architecture ********** \n"); + + int batch_size = 2000; + int offset = 5000; + + std::string dir_prefix = std::string("../model_params/lenet_params/"); + std::string input_path = dir_prefix + std::string("input.bin"); + std::string labels_path = dir_prefix + std::string("labels.bin"); + clearTensorMap(); int missed = 0; @@ -38,10 +39,13 @@ void testLenetTanh(){ break; } - void* input = readInputTensor("../model_params/lenet_params/datasets/t10k-images-idx3-ubyte", - CUDNN_DATA_FLOAT, - test_batch_size, 1, 28, 28); + int start = i * batch_size + offset; + int end = (i + 1) * batch_size + offset; + + // Loading Input Batch + void* input = readInputBatch(input_path.c_str(),0,start,end,1,28,28); + // Loading Weights void* conv1_filter = readTrainedWeights("../model_params/lenet_keras/conv1.bin", float_type, 32, 1, 5, 5); void* conv1_bias = readTrainedWeights("../model_params/lenet_keras/conv1_bias.bin", @@ -60,27 +64,25 @@ void testLenetTanh(){ float_type, 1, 10, 1, 1); - - - readOpenTunerFlags("promise_flags"); // Resets the OpenTuner counters - - + // DNN Operations void* conv1_out = ConvLayer_PROMISE(input, 0,1, conv1_filter, -1,1, conv1_bias, -1,1, 2, 2, 1, 1, 0, 2, 0, -1,1, 9); - void* conv2_out = ConvLayer_PROMISE(conv1_out, -1,1, conv2_filter, -1,1, conv2_bias, -1,1, 2, 2, 1, 1, 0, 2, 0, -1,1, 9); void* fc1_out = FCLayer_PROMISE(conv2_out, -1,1, fc1_weights, -1,1, fc1_bias, -1,1, - 0, -1,1, 9); - + 0, -1,1, 9); void* fc2_out = FCLayer_PROMISE(fc1_out, -1,1, fc2_weights, -1,1, fc2_bias, -1,1, 0, -1,1, 9); void* result = tensorSoftmax(fc2_out); - float accuracy = computeAccuracy2(labels, test_batch_size, result); + + uint8_t* labels = readLabelsBatch(labels_path.c_str(),start,end); + + float accuracy = computeAccuracy2(labels, batch_size, result); + freeOutputTensors(); @@ -124,43 +126,3 @@ int main(int argc, char* argv[]){ - - - -/* if(Opentuner_run){ - - char* myfifo = "/tmp/myfifo"; - int fd = open(myfifo, O_RDONLY); - - int ret_val = fcntl(fd, F_GETFD); - if(ret_val == -1){ - printf("Invalid descriptor \n"); - abort(); - } - - char str[100]; - read(fd, str, 80); - if(strcmp(str, "stop_run") == 0){ - abort(); - } - - close(fd); - } -*/ - - -/* if(Opentuner_run){ - - char* myfifo = "/tmp/myfifo"; - int fd_out = open(myfifo, O_WRONLY); - int ret_val = fcntl(fd_out, F_GETFD); - if(ret_val == -1){ - printf("Invalid descriptor \n"); - abort(); - } - - const char* str = "completed***!\n\0"; - write(fd_out, str, 80); - close(fd_out); - } -*/ diff --git a/llvm/projects/hpvm-tensor-rt/model_params/lenet_params/input.bin b/llvm/projects/hpvm-tensor-rt/model_params/lenet_params/input.bin new file mode 100644 index 0000000000000000000000000000000000000000..4d2423f74188cfe0364185ccb66837785ccf4c4e Binary files /dev/null and b/llvm/projects/hpvm-tensor-rt/model_params/lenet_params/input.bin differ diff --git a/llvm/projects/hpvm-tensor-rt/model_params/lenet_params/labels.bin b/llvm/projects/hpvm-tensor-rt/model_params/lenet_params/labels.bin new file mode 100644 index 0000000000000000000000000000000000000000..5e1f3881897f4729d6d90ff208a08ccdabb8fe7c Binary files /dev/null and b/llvm/projects/hpvm-tensor-rt/model_params/lenet_params/labels.bin differ