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

Removing unused *_promise tensorRT sources

parent 896e0a8a
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 570 deletions
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "../../../tensor_runtime/include/tensor_runtime.h"
#include "../../include/utils.h"
int main(){
llvm_hpvm_initTensorRt(0);
int total_runs = 1;
for (int i = 0 ; i < total_runs; i++){
startMemTracking();
int test_input_size = 10000;
int batch_size = 10000;
int batch_count = test_input_size / batch_size;
float final_accuracy = 0.0;
for(int i = 0; i < batch_count; i++){
std::string dir_prefix = std::string("../model_params/depthwise_batchnorm2/");
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,1,5,5);
std::string conv2d_1_b_path = dir_prefix + std::string("conv2d_1_b.bin");
void* conv2d_1_b = readTrainedWeights(conv2d_1_b_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_1_gamma_path = dir_prefix + std::string("batch_normalization_1_gamma.bin");
void* batch_normalization_1_gamma = readTrainedWeights(batch_normalization_1_gamma_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_1_beta_path = dir_prefix + std::string("batch_normalization_1_beta.bin");
void* batch_normalization_1_beta = readTrainedWeights(batch_normalization_1_beta_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_1_mean_path = dir_prefix + std::string("batch_normalization_1_mean.bin");
void* batch_normalization_1_mean = readTrainedWeights(batch_normalization_1_mean_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_1_variance_path = dir_prefix + std::string("batch_normalization_1_variance.bin");
void* batch_normalization_1_variance = readTrainedWeights(batch_normalization_1_variance_path.c_str(), 0,1,32,1,1);
std::string depthwise_conv2d_1_w_path = dir_prefix + std::string("depthwise_conv2d_1_w.bin");
void* depthwise_conv2d_1_w = readTrainedWeights(depthwise_conv2d_1_w_path.c_str(), 0,32,1,3,3);
std::string depthwise_conv2d_1_b_path = dir_prefix + std::string("depthwise_conv2d_1_b.bin");
void* depthwise_conv2d_1_b = readTrainedWeights(depthwise_conv2d_1_b_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_2_gamma_path = dir_prefix + std::string("batch_normalization_2_gamma.bin");
void* batch_normalization_2_gamma = readTrainedWeights(batch_normalization_2_gamma_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_2_beta_path = dir_prefix + std::string("batch_normalization_2_beta.bin");
void* batch_normalization_2_beta = readTrainedWeights(batch_normalization_2_beta_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_2_mean_path = dir_prefix + std::string("batch_normalization_2_mean.bin");
void* batch_normalization_2_mean = readTrainedWeights(batch_normalization_2_mean_path.c_str(), 0,1,32,1,1);
std::string batch_normalization_2_variance_path = dir_prefix + std::string("batch_normalization_2_variance.bin");
void* batch_normalization_2_variance = readTrainedWeights(batch_normalization_2_variance_path.c_str(), 0,1,32,1,1);
std::string dense_1_w_path = dir_prefix + std::string("dense_1_w.bin");
void* dense_1_w = readTrainedWeights(dense_1_w_path.c_str(), 0,1,1,6272,1024);
std::string dense_1_b_path = dir_prefix + std::string("dense_1_b.bin");
void* dense_1_b = readTrainedWeights(dense_1_b_path.c_str(), 0,1,1024,1,1);
std::string dense_2_w_path = dir_prefix + std::string("dense_2_w.bin");
void* dense_2_w = readTrainedWeights(dense_2_w_path.c_str(), 0,1,1,1024,10);
std::string dense_2_b_path = dir_prefix + std::string("dense_2_b.bin");
void* dense_2_b = readTrainedWeights(dense_2_b_path.c_str(), 0,1,10,1,1);
int start = i * batch_size;
int end = (i + 1) * batch_size;
void* input = readInputBatch(input_path.c_str(),0,start,end,1,28,28);
void* var_0 = ConvLayer_PROMISE(input, 0.0, 1.0, conv2d_1_w, -0.21894497, 0.20240873, conv2d_1_b, -0.2508162, 0.031047817, 2, 2, 1, 1, -1, 0, 1, 0.0, 0.3616602423787114, 9);
void* var_1 = tensorBatchNorm(var_0, batch_normalization_1_gamma, batch_normalization_1_beta, batch_normalization_1_mean, batch_normalization_1_variance, 0.001);
void* var_2 = tensorPooling(var_1,0,2,2,0,0,2,2);
void* var_3 = tensorConvolution(var_2, depthwise_conv2d_1_w, 1, 1, 1, 1, 1, 32);
void* var_4 = tensorAdd(var_3, depthwise_conv2d_1_b);
void* var_5 = tensorRelu(var_4);
void* var_6 = tensorBatchNorm(var_5, batch_normalization_2_gamma, batch_normalization_2_beta, batch_normalization_2_mean, batch_normalization_2_variance, 0.001);
void* var_7 = FCLayer_PROMISE(var_6, -1.0247770547866821, 5.120966439247134, dense_1_w, -0.04442959, 0.04483322, dense_1_b, -0.001500695, 0.002055318, 1, 0.0, 4.769639563560498, 9);
void* var_8 = FCLayer_PROMISE(var_7, 0.0, 4.769639563560498, dense_2_w, -0.123055816, 0.12699054, dense_2_b, -0.00430397, 0.004860983, 1, 0.0, 21.660391826629642, 9);
void* var_9 = tensorSoftmax(var_8);
uint8_t* labels = readLabelsBatch(labels_path.c_str(),start,end);
float accuracy = computeAccuracy2(labels, batch_size, var_9);
final_accuracy += accuracy;
freeBatchMemory();
}
final_accuracy = final_accuracy / batch_count;
dumpFinalAccuracy(final_accuracy);
}
dumpExecutionAccuracies();
llvm_hpvm_cleanupTensorRt();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "../../../tensor_runtime/include/tensor_runtime.h"
#include "../../include/utils.h"
int main(){
llvm_hpvm_initTensorRt(1);
int total_runs = 1;
for (int i = 0 ; i < total_runs; i++){
startMemTracking();
int test_input_size = 10000;
int batch_size = 10000;
int batch_count = test_input_size / batch_size;
float final_accuracy = 0.0;
for(int i = 0; i < batch_count; i++){
std::string dir_prefix = std::string("../model_params/depthwise_test_8/");
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,1,5,5);
std::string conv2d_1_b_path = dir_prefix + std::string("conv2d_1_b.bin");
void* conv2d_1_b = readTrainedWeights(conv2d_1_b_path.c_str(), 0,1,32,1,1);
std::string depthwise_conv2d_1_w_path = dir_prefix + std::string("depthwise_conv2d_1_w.bin");
void* depthwise_conv2d_1_w = readTrainedWeights(depthwise_conv2d_1_w_path.c_str(), 0,32,1,3,3);
std::string depthwise_conv2d_1_b_path = dir_prefix + std::string("depthwise_conv2d_1_b.bin");
void* depthwise_conv2d_1_b = readTrainedWeights(depthwise_conv2d_1_b_path.c_str(), 0,1,32,1,1);
std::string dense_1_w_path = dir_prefix + std::string("dense_1_w.bin");
void* dense_1_w = readTrainedWeights(dense_1_w_path.c_str(), 0,1,1,6272,1024);
std::string dense_1_b_path = dir_prefix + std::string("dense_1_b.bin");
void* dense_1_b = readTrainedWeights(dense_1_b_path.c_str(), 0,1,1024,1,1);
std::string dense_2_w_path = dir_prefix + std::string("dense_2_w.bin");
void* dense_2_w = readTrainedWeights(dense_2_w_path.c_str(), 0,1,1,1024,10);
std::string dense_2_b_path = dir_prefix + std::string("dense_2_b.bin");
void* dense_2_b = readTrainedWeights(dense_2_b_path.c_str(), 0,1,10,1,1);
int start = i * batch_size;
int end = (i + 1) * batch_size;
void* input = readInputBatch(input_path.c_str(),0,start,end,1,28,28);
void* var_0 = ConvLayer_PROMISE(input, 0.0, 1.0, conv2d_1_w, -0.45243406, 0.4331673, conv2d_1_b, -0.2225991, 0.05682303, 2, 2, 1, 1, 0, 2, 1, 0.0, 2.593297730684286, 9);
void* var_1 = tensorConvolution(var_0, depthwise_conv2d_1_w, 1, 1, 1, 1, 1, 32);
void* var_2 = tensorAdd(var_1, depthwise_conv2d_1_b);
void* var_3 = tensorRelu(var_2);
void* var_4 = FCLayer_PROMISE(var_3, 0.0, 1.4831079334020663, dense_1_w, -0.1172131, 0.105426796, dense_1_b, -0.027105594, 0.04015947, 1, 0.0, 2.723612790107728, 9);
void* var_5 = FCLayer_PROMISE(var_4, 0.0, 2.723612790107728, dense_2_w, -0.23769215, 0.20409682, dense_2_b, -0.004073992, 0.049675815, 1, 0.0, 24.92628944396973, 9);
void* var_6 = tensorSoftmax(var_5);
uint8_t* labels = readLabelsBatch(labels_path.c_str(),start,end);
float accuracy = computeAccuracy2(labels, batch_size, var_6);
final_accuracy += accuracy;
freeBatchMemory();
}
final_accuracy = final_accuracy / batch_count;
dumpFinalAccuracy(final_accuracy);
}
dumpExecutionAccuracies();
llvm_hpvm_cleanupTensorRt();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "../../../tensor_runtime/include/tensor_runtime.h"
#include "../../include/utils.h"
#include "../../include/types.h"
bool Opentuner_run = false;
void test_4_Layer_clipped_FC(){
int total_runs = 100000;
if(Opentuner_run){
total_runs = 100000;
}
printf("********* 3-Layer FC with clipped activations and weights ********* \n");
int test_batch_size = 5000;
uint8_t* labels = readLabels("../model_params/lenet_params/datasets/t10k-labels-idx1-ubyte", test_batch_size);
clearTensorMap();
for(int i = 0; i < total_runs; i++){
void* input = readTrainedWeights("../model_params/FC_network2/mnist_float_input.bin",
float_type, test_batch_size, 1, 28, 28);
void* fc1_weights = readTrainedWeights("../model_params/fc2_clipped/fc1.bin",
float_type, 1, 1, 784, 128);
void* fc1_bias = readTrainedWeights("../model_params/fc2_clipped/fc1_bias.bin",
float_type, 1, 128, 1, 1);
void* fc2_weights = readTrainedWeights("../model_params/fc2_clipped/fc2.bin",
float_type, 1, 1, 128, 10);
void* fc2_bias = readTrainedWeights("../model_params/fc2_clipped/fc2_bias.bin",
float_type, 1, 10, 1, 1);
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);
}
readOpenTunerFlags("opentuner_flags"); // Resets the OpenTuner counters
void* fc1_out = FCLayer_PROMISE(input, 0,1, fc1_weights, -1,1, fc1_bias, -1,1,
2, 0,2, 8);
void* fc2_out = FCLayer_PROMISE(fc1_out, 0,2, fc2_weights, -1,1, fc2_bias, -1,1,
2, 0,2, 8);
void* result = tensorSoftmax(fc2_out);
computeAccuracy2(labels, test_batch_size, result);
freeOutputTensors();
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);
}
}
printf("**** ALL RUNS COMPLETTED **** \n\n");
}
int main(int argc, char* argv[]){
if(argc > 1)
Opentuner_run = true;
// This initializes the runtime - must be called before anything
llvm_hpvm_initTensorRt(0);
test_4_Layer_clipped_FC();
llvm_hpvm_cleanupTensorRt();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "../../../tensor_runtime/include/tensor_runtime.h"
#include "../../include/utils.h"
#include "../../include/types.h"
bool Opentuner_run = false;
void test_4_Layer_clipped_FC(){
int total_runs = 100000;
if(Opentuner_run){
total_runs = 100000;
}
printf("********* 3-Layer FC with clipped activations and weights ********* \n");
int test_batch_size = 5000;
uint8_t* labels = readLabels("../model_params/lenet_params/datasets/t10k-labels-idx1-ubyte", test_batch_size);
clearTensorMap();
for(int i = 0; i < total_runs; i++){
void* input = readTrainedWeights("../model_params/FC_network2/mnist_float_input.bin",
float_type, test_batch_size, 1, 28, 28);
void* fc1_weights = readTrainedWeights("../model_params/fc3_clipped/fc1.bin",
float_type, 1, 1, 784, 256);
void* fc1_bias = readTrainedWeights("../model_params/fc3_clipped/fc1_bias.bin",
float_type, 1, 256, 1, 1);
void* fc2_weights = readTrainedWeights("../model_params/fc3_clipped/fc2.bin",
float_type, 1, 1, 256, 128);
void* fc2_bias = readTrainedWeights("../model_params/fc3_clipped/fc2_bias.bin",
float_type, 1, 128, 1, 1);
void* fc3_weights = readTrainedWeights("../model_params/fc3_clipped/fc3.bin",
float_type, 1, 1, 128, 10);
void* fc3_bias = readTrainedWeights("../model_params/fc3_clipped/fc3_bias.bin",
float_type, 1, 10, 1, 1);
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);
}
readOpenTunerFlags("opentuner_flags"); // Resets the OpenTuner counters
void* fc1_out = FCLayer_PROMISE(input, 0,1, fc1_weights, -1,1, fc1_bias, -1,1,
2, 0,2, 8);
void* fc2_out = FCLayer_PROMISE(fc1_out, 0,2, fc2_weights, -1,1, fc2_bias, -1,1,
2, 0,2, 8);
void* fc3_out = FCLayer_PROMISE(fc2_out, 0,2, fc3_weights, -1,1, fc3_bias, -1,1,
2, 0,2, 8);
void* result = tensorSoftmax(fc3_out);
computeAccuracy2(labels, test_batch_size, result);
freeOutputTensors();
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);
}
}
printf("**** ALL RUNS COMPLETTED **** \n\n");
}
int main(int argc, char* argv[]){
if(argc > 1)
Opentuner_run = true;
// This initializes the runtime - must be called before anything
llvm_hpvm_initTensorRt(0);
test_4_Layer_clipped_FC();
llvm_hpvm_cleanupTensorRt();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "../../../tensor_runtime/include/tensor_runtime.h"
#include "../../include/utils.h"
#include "../../include/types.h"
bool Opentuner_run = false;
void test_4_Layer_clipped_FC(){
int total_runs = 1000;
if(Opentuner_run){
total_runs = 1000000;
}
printf("********* 3-Layer FC with clipped activations and weights ********* \n");
int test_batch_size = 5000;
uint8_t* labels = readLabels("../model_params/lenet_params/datasets/t10k-labels-idx1-ubyte", test_batch_size);
clearTensorMap();
for(int i = 0; i < total_runs; i++){
void* input = readTrainedWeights("../model_params/FC_network2/mnist_float_input.bin",
float_type, test_batch_size, 1, 28, 28);
void* fc1_weights = readTrainedWeights("../model_params/fc4_clipped/fc1.bin",
float_type, 1, 1, 784, 512);
void* fc1_bias = readTrainedWeights("../model_params/fc4_clipped/fc1_bias.bin",
float_type, 1, 512, 1, 1);
void* fc2_weights = readTrainedWeights("../model_params/fc4_clipped/fc2.bin",
float_type, 1, 1, 512, 256);
void* fc2_bias = readTrainedWeights("../model_params/fc4_clipped/fc2_bias.bin",
float_type, 1, 256, 1, 1);
void* fc3_weights = readTrainedWeights("../model_params/fc4_clipped/fc3.bin",
float_type, 1, 1, 256, 128);
void* fc3_bias = readTrainedWeights("../model_params/fc4_clipped/fc3_bias.bin",
float_type, 1, 128, 1, 1);
void* fc4_weights = readTrainedWeights("../model_params/fc4_clipped/fc4.bin",
float_type, 1, 1, 128, 10);
void* fc4_bias = readTrainedWeights("../model_params/fc4_clipped/fc4_bias.bin",
float_type, 1, 10, 1, 1);
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);
}
readOpenTunerFlags("opentuner_flags"); // Resets the OpenTuner counters
void* fc1_out = FCLayer_PROMISE(input, 0,1, fc1_weights, -1,1, fc1_bias, -1,1,
2, 0,2, 9);
void* fc2_out = FCLayer_PROMISE(fc1_out, 0,2, fc2_weights, -1,1, fc2_bias, -1,1,
2, 0,2, 9);
void* fc3_out = FCLayer_PROMISE(fc2_out, 0,2, fc3_weights, -1,1, fc3_bias, -1,1,
2, 0,2, 9);
void* fc4_out = FCLayer_PROMISE(fc3_out, 0,2, fc4_weights, -1,1, fc4_bias, -1,1,
2, 0,2, 9);
void* result = tensorSoftmax(fc4_out);
computeAccuracy2(labels, test_batch_size, result);
freeOutputTensors();
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);
}
}
}
int main(int argc, char* argv[]){
if(argc > 1)
Opentuner_run = true;
// This initializes the runtime - must be called before anything
llvm_hpvm_initTensorRt(0);
test_4_Layer_clipped_FC();
llvm_hpvm_cleanupTensorRt();
return 0;
}
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