diff --git a/llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h b/llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h index 7eec73c79b37c11a0aad8e9821375c313a4375ee..799b6f45bcca772077afdd028541abc860a455f5 100644 --- a/llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h +++ b/llvm/projects/hpvm-tensor-rt/dnn_sources/include/utils.h @@ -5,10 +5,14 @@ #include <sstream> +#include <vector> #include "../../tensor_runtime/include/tensor.h" #include "types.h" +std::vector<float> run_accuracies; + + void printTensorInfo(void* tensor_ptr){ struct Tensor* tensor = (struct Tensor*) tensor_ptr; @@ -433,6 +437,8 @@ float computeAccuracy2(uint8_t* labels, int num_labels, void* result_ptr, unsign void dumpFinalAccuracy(float accuracy){ + printf("\n\n **** Final Accuracy = %f \n", accuracy); + FILE* fp = fopen("final_accuracy", "w+"); if(fp != NULL){ std::ostringstream ss; @@ -443,6 +449,27 @@ void dumpFinalAccuracy(float accuracy){ } fclose(fp); + + run_accuracies.push_back(accuracy); +} + + +void dumpExecutionAccuracies(){ + + FILE* fp = fopen("run_accuracies.txt", "w+"); + if(fp != NULL){ + for (int i = 0; i < run_accuracies.size(); i++){ + float accuracy = run_accuracies[i]; + std::ostringstream ss; + ss << std::fixed << accuracy; + std::string print_str = ss.str(); + fwrite(print_str.c_str(), 1, print_str.length(), fp); + fwrite("\n", 1, 1, fp); + } + + } + + fclose(fp); }