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

Adding dumpOutput routine in utils

parent f5958412
No related branches found
No related tags found
No related merge requests found
......@@ -569,21 +569,33 @@ float computePSNRViolation(void* gold_ptr, void* approx_ptr, float PSNR_threshol
}
}
printf ("max_val = %f \n", max_val);
mse_sum = mse_sum / image_size;
float psnr = 20 * log10(max_val / sqrt(mse_sum));
if (psnr < PSNR_threshold)
num_errors += 1;
printf("PSNR value = %f \n", psnr);
}
return 0.0;
float violation_rate = (num_errors * 1.0) / batch_dim * 100.0;
printf("*** violation_rate= %f \n\n", violation_rate);
return violation_rate;
}
void dumpOutput(void* output){
void dumpOutput(void* output_ptr){
struct Tensor* out_tensor = (struct Tensor*) output_ptr;
size_t size_in_bytes = out_tensor->size_in_bytes;
printf ("** Output size = %lu \n", size_in_bytes);
float* host_data = (float*) out_tensor->host_data;
FILE* fd = fopen("output.bin", "w+");
fwrite(host_data, 1, size_in_bytes, fd);
fclose(fd);
}
......
......@@ -86,8 +86,6 @@ void testLenetTanh(){
readOpenTunerFlags("opentuner_flags"); // Resets the OpenTuner counters
// Start power and performnce profiling
startProfiling();
int conv_mode = 1; // NOTE: using CROSS_CORRELATION
int conv_precision = 0; // NOTE: using Float as compute precision. FIXIT: use enum
......@@ -107,10 +105,13 @@ void testLenetTanh(){
void* result = tensorAdd(emboss_out, emboss_bias);
// End profiling and dump output to profile.txt
stopProfiling();
// NOTE-IMP: Important to include this call always before doing dumpOutput and computePSNViolation
hpvm_request_tensor(result, 0);
dumpOutput(result);
computePSNRViolation(golden_output, result, 30);
dumpAccuracyNorms();
freeOutputTensors();
......
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