Skip to content
Snippets Groups Projects
Commit ab7f11cd authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Adding confidence dumping to AlexNet2

parent 5ea062d8
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "../../../tensor_runtime/include/tensor_runtime.h"
#include "../../include/utils.h"
#include "tensor_runtime.h"
#include "utils.h"
int total_runs = 1;
......@@ -40,6 +40,15 @@ int main(int argc, char* argv[]){
offset = atoi(argv[5]);
}
bool shouldDumpClassConf = false;
float* classConfs;
int* predictedLabels;
if(argc > 6){
shouldDumpClassConf = true;
classConfs = (float*) malloc(sizeof(float) * test_input_size);
predictedLabels = (int*) malloc(sizeof(int) * test_input_size);
}
llvm_hpvm_initTensorRt(1);
......@@ -56,11 +65,15 @@ int main(int argc, char* argv[]){
int batch_count = test_input_size / batch_size;
float final_accuracy = 0.0;
std::string dir_prefix = std::string("../model_params/alexnet2_cifar10_test/");
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");
for(int i = 0; i < batch_count; i++){
std::string dir_prefix = std::string("../model_params/alexnet2_cifar10_test/");
std::string input_path = dir_prefix + std::string("input.bin");
std::string labels_path = dir_prefix + std::string("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);
std::string conv2d_1_b_path = dir_prefix + std::string("conv2d_1_b.bin");
......@@ -110,7 +123,15 @@ int main(int argc, char* argv[]){
uint8_t* labels = readLabelsBatch(labels_path.c_str(),start,end);
float accuracy = computeAccuracy2(labels, batch_size, var_7);
final_accuracy += accuracy;
final_accuracy += accuracy;
if(shouldDumpClassConf){
int relative_start = start - offset;
int relative_end = end - offset;
copyClassConfsAndLabels(var_6, classConfs, predictedLabels, relative_start, relative_end);
}
freeBatchMemory();
}
......@@ -120,6 +141,15 @@ int main(int argc, char* argv[]){
if (final_accuracy < bench_acc)
missed += 1;
if(shouldDumpClassConf){
int labels_start = offset;
int labels_end = offset + test_input_size;
uint32_t* goldLabels = readLabelsBatch3(labels32_path.c_str(), labels_start, labels_end);
dumpClassConfsAndLabels(classConfs, predictedLabels, goldLabels, test_input_size);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment