diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/approxhpvm_src.cc b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/approxhpvm_src.cc new file mode 100644 index 0000000000000000000000000000000000000000..96b24a0409ae15f708bd7b6897edca08e52d82bb --- /dev/null +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/approxhpvm_src.cc @@ -0,0 +1,373 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <cstring> +#include <visc.h> +#include <tensorTypes.h> +#include <tensorUtils.h> + +void var_0_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_convolution(t1, t2, 2, 2, 1, 1); + __visc__return(2, r, (size_t) 0); +} + +void var_1_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_add(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_2_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_relu(t1); + __visc__return(2, r, (size_t) 0); +} + +void var_3_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_pool_max(t1, 2, 2, 0, 0, 2, 2); + __visc__return(2, r, (size_t) 0); +} + +void var_4_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_convolution(t1, t2, 2, 2, 1, 1); + __visc__return(2, r, (size_t) 0); +} + +void var_5_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_add(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_6_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_relu(t1); + __visc__return(2, r, (size_t) 0); +} + +void var_7_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_convolution(t1, t2, 1, 1, 2, 2); + __visc__return(2, r, (size_t) 0); +} + +void var_8_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_add(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_9_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_relu(t1); + __visc__return(2, r, (size_t) 0); +} + +void var_10_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_mul(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_11_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_add(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_12_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_relu(t1); + __visc__return(2, r, (size_t) 0); +} + +void var_13_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_mul(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_14_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(2, t1, t2, 0); + + void *r = __visc__tensor_add(t1, t2); + __visc__return(2, r, (size_t) 0); +} + +void var_15_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_relu(t1); + __visc__return(2, r, (size_t) 0); +} + +void var_16_node(void* t1, size_t bytes_t1) { + __visc__hint(visc::CUDNN_TARGET); + __visc__attributes(1, t1, 0); + + void* r = __visc__tensor_softmax(t1); + __visc__return(2, r, (size_t) 0); +} + +void root(void* input, size_t input_bytes, + void* conv2d_1_w, size_t conv2d_1_w_bytes, + void* conv2d_1_b, size_t conv2d_1_b_bytes, + void* conv2d_2_w, size_t conv2d_2_w_bytes, + void* conv2d_2_b, size_t conv2d_2_b_bytes, + void* conv2d_3_w, size_t conv2d_3_w_bytes, + void* conv2d_3_b, size_t conv2d_3_b_bytes, + void* dense_1_w, size_t dense_1_w_bytes, + void* dense_1_b, size_t dense_1_b_bytes, + void* dense_2_w, size_t dense_2_w_bytes, + void* dense_2_b, size_t dense_2_b_bytes){ + + + __visc__hint(visc::CPU_TARGET); + __visc__attributes(11, input, conv2d_1_w, conv2d_1_b, conv2d_2_w, conv2d_2_b, conv2d_3_w, conv2d_3_b, dense_1_w, dense_1_b, dense_2_w, dense_2_b, 0); + + + void* var_0 = __visc__createNodeND(0, var_0_node); + + __visc__bindIn(var_0, 0, 0, 0); + __visc__bindIn(var_0, 1, 1, 0); + __visc__bindIn(var_0, 2, 2, 0); + __visc__bindIn(var_0, 3, 3, 0); + + void* var_1 = __visc__createNodeND(0, var_1_node); + + __visc__edge(var_0, var_1, 1, 0, 0, 0); + __visc__edge(var_0, var_1, 1, 1, 1, 0); + __visc__bindIn(var_1, 4, 2, 0); + __visc__bindIn(var_1, 5, 3, 0); + + void* var_2 = __visc__createNodeND(0, var_2_node); + + __visc__edge(var_1, var_2, 1, 0, 0, 0); + __visc__edge(var_1, var_2, 1, 1, 1, 0); + + void* var_3 = __visc__createNodeND(0, var_3_node); + + __visc__edge(var_2, var_3, 1, 0, 0, 0); + __visc__edge(var_2, var_3, 1, 1, 1, 0); + + void* var_4 = __visc__createNodeND(0, var_4_node); + + __visc__edge(var_3, var_4, 1, 0, 0, 0); + __visc__edge(var_3, var_4, 1, 1, 1, 0); + __visc__bindIn(var_4, 6, 2, 0); + __visc__bindIn(var_4, 7, 3, 0); + + void* var_5 = __visc__createNodeND(0, var_5_node); + + __visc__edge(var_4, var_5, 1, 0, 0, 0); + __visc__edge(var_4, var_5, 1, 1, 1, 0); + __visc__bindIn(var_5, 8, 2, 0); + __visc__bindIn(var_5, 9, 3, 0); + + void* var_6 = __visc__createNodeND(0, var_6_node); + + __visc__edge(var_5, var_6, 1, 0, 0, 0); + __visc__edge(var_5, var_6, 1, 1, 1, 0); + + void* var_7 = __visc__createNodeND(0, var_7_node); + + __visc__edge(var_6, var_7, 1, 0, 0, 0); + __visc__edge(var_6, var_7, 1, 1, 1, 0); + __visc__bindIn(var_7, 10, 2, 0); + __visc__bindIn(var_7, 11, 3, 0); + + void* var_8 = __visc__createNodeND(0, var_8_node); + + __visc__edge(var_7, var_8, 1, 0, 0, 0); + __visc__edge(var_7, var_8, 1, 1, 1, 0); + __visc__bindIn(var_8, 12, 2, 0); + __visc__bindIn(var_8, 13, 3, 0); + + void* var_9 = __visc__createNodeND(0, var_9_node); + + __visc__edge(var_8, var_9, 1, 0, 0, 0); + __visc__edge(var_8, var_9, 1, 1, 1, 0); + + void* var_10 = __visc__createNodeND(0, var_10_node); + + __visc__edge(var_9, var_10, 1, 0, 0, 0); + __visc__edge(var_9, var_10, 1, 1, 1, 0); + __visc__bindIn(var_10, 14, 2, 0); + __visc__bindIn(var_10, 15, 3, 0); + + void* var_11 = __visc__createNodeND(0, var_11_node); + + __visc__edge(var_10, var_11, 1, 0, 0, 0); + __visc__edge(var_10, var_11, 1, 1, 1, 0); + __visc__bindIn(var_11, 16, 2, 0); + __visc__bindIn(var_11, 17, 3, 0); + + void* var_12 = __visc__createNodeND(0, var_12_node); + + __visc__edge(var_11, var_12, 1, 0, 0, 0); + __visc__edge(var_11, var_12, 1, 1, 1, 0); + + void* var_13 = __visc__createNodeND(0, var_13_node); + + __visc__edge(var_12, var_13, 1, 0, 0, 0); + __visc__edge(var_12, var_13, 1, 1, 1, 0); + __visc__bindIn(var_13, 18, 2, 0); + __visc__bindIn(var_13, 19, 3, 0); + + void* var_14 = __visc__createNodeND(0, var_14_node); + + __visc__edge(var_13, var_14, 1, 0, 0, 0); + __visc__edge(var_13, var_14, 1, 1, 1, 0); + __visc__bindIn(var_14, 20, 2, 0); + __visc__bindIn(var_14, 21, 3, 0); + + void* var_15 = __visc__createNodeND(0, var_15_node); + + __visc__edge(var_14, var_15, 1, 0, 0, 0); + __visc__edge(var_14, var_15, 1, 1, 1, 0); + + void* var_16 = __visc__createNodeND(0, var_16_node); + + __visc__edge(var_15, var_16, 1, 0, 0, 0); + __visc__edge(var_15, var_16, 1, 1, 1, 0); + + __visc__bindOut(var_16, 0, 0, 0); + __visc__bindOut(var_16, 1, 1, 0); + +} + +struct ret_t { + void* tensor; + size_t bytes; +}; + +typedef struct __attribute__((__packed__)) { + void* input; + size_t input_bytes; + void* conv2d_1_w; + size_t conv2d_1_w_bytes; + void* conv2d_1_b; + size_t conv2d_1_b_bytes; + void* conv2d_2_w; + size_t conv2d_2_w_bytes; + void* conv2d_2_b; + size_t conv2d_2_b_bytes; + void* conv2d_3_w; + size_t conv2d_3_w_bytes; + void* conv2d_3_b; + size_t conv2d_3_b_bytes; + void* dense_1_w; + size_t dense_1_w_bytes; + void* dense_1_b; + size_t dense_1_b_bytes; + void* dense_2_w; + size_t dense_2_w_bytes; + void* dense_2_b; + size_t dense_2_b_bytes; + + struct ret_t r; +} +RootIn; + +int main(){ + +std::string dir_prefix = std::string("lenet_hpvm/"); +std::string input_path = dir_prefix + std::string("input.bin"); +void* input = readTrainedWeights(input_path.c_str(), 0,10000,1,28,28); +std::string labels_path = dir_prefix + std::string("labels.bin"); +uint8_t* labels = readLabels(labels_path.c_str(),10000); +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 conv2d_2_w_path = dir_prefix + std::string("conv2d_2_w.bin"); +void* conv2d_2_w = readTrainedWeights(conv2d_2_w_path.c_str(), 0,64,32,5,5); +std::string conv2d_2_b_path = dir_prefix + std::string("conv2d_2_b.bin"); +void* conv2d_2_b = readTrainedWeights(conv2d_2_b_path.c_str(), 0,1,64,1,1); +std::string conv2d_3_w_path = dir_prefix + std::string("conv2d_3_w.bin"); +void* conv2d_3_w = readTrainedWeights(conv2d_3_w_path.c_str(), 0,64,64,3,3); +std::string conv2d_3_b_path = dir_prefix + std::string("conv2d_3_b.bin"); +void* conv2d_3_b = readTrainedWeights(conv2d_3_b_path.c_str(), 0,1,64,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,3136,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); + +__visc__init(); +RootIn* args = static_cast<RootIn*>(malloc(sizeof(RootIn))); + +args->input = input; +args->input_bytes = 0; +args->conv2d_1_w = conv2d_1_w; +args->conv2d_1_w_bytes = 0; +args->conv2d_1_b = conv2d_1_b; +args->conv2d_1_b_bytes = 0; +args->conv2d_2_w = conv2d_2_w; +args->conv2d_2_w_bytes = 0; +args->conv2d_2_b = conv2d_2_b; +args->conv2d_2_b_bytes = 0; +args->conv2d_3_w = conv2d_3_w; +args->conv2d_3_w_bytes = 0; +args->conv2d_3_b = conv2d_3_b; +args->conv2d_3_b_bytes = 0; +args->dense_1_w = dense_1_w; +args->dense_1_w_bytes = 0; +args->dense_1_b = dense_1_b; +args->dense_1_b_bytes = 0; +args->dense_2_w = dense_2_w; +args->dense_2_w_bytes = 0; +args->dense_2_b = dense_2_b; +args->dense_2_b_bytes = 0; + +void* dfg = __visc__launch(0, root, (void*) args); + +__visc__wait(dfg); + +void *result = static_cast<RootIn*>(args)->input; +hpvm_request_tensor(result, 0); + +__visc__cleanup(); + computeAccuracy2(labels, 10000, result); +return 0; + +} diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_1_b.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_1_b.bin new file mode 100644 index 0000000000000000000000000000000000000000..ebffd37c1a573c2397290e60eca569d75dd06d59 Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_1_b.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_1_w.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_1_w.bin new file mode 100644 index 0000000000000000000000000000000000000000..f1cabdb56c1275f03b226c9636b546382a3accc3 Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_1_w.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_2_b.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_2_b.bin new file mode 100644 index 0000000000000000000000000000000000000000..2232a48e41b564a7583ef74acfdc0637856a45f7 --- /dev/null +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_2_b.bin @@ -0,0 +1,2 @@ +7Dà<Þå<–^=À©Š=p =˜<Y-¼ Rž=é<¦:ï; +cƒ<-=&= "=áx´;Ñu<¼ö·F=t_;9=ûSO¼²vŸ;G¨»éM8=+¦x½`žŒ<RªŒ:ßPP;/®™<Ûè¼ø®ä;^Ð<'´9¼43û:ÙË;eø<AÖ#½Ò»‹±e<••<ó¯==Ÿ¨<À´b<»0à<4È<Óö;\§<#t <}¨½ƒp¼¬=:s"½p#¨¼v'™¼ð^;@Ç<ë8\¼É‡à<ëþ¾¼`ýa»Î€^¼`‚û;sjÉ<w”L=üÙ«¼ \ No newline at end of file diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_2_w.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_2_w.bin new file mode 100644 index 0000000000000000000000000000000000000000..10879c3d7acd13ff2f7a099a6cc05b30587c6b97 Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_2_w.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_3_b.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_3_b.bin new file mode 100644 index 0000000000000000000000000000000000000000..b01794dc350196cde2d8e0464acac426d9b4ce44 Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_3_b.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_3_w.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_3_w.bin new file mode 100644 index 0000000000000000000000000000000000000000..8ad6df7aed7ac63695348393951f1084d810941e Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/conv2d_3_w.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_1_b.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_1_b.bin new file mode 100644 index 0000000000000000000000000000000000000000..707c577fc74e6b898c7018860419f0796f77226c Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_1_b.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_1_w.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_1_w.bin new file mode 100644 index 0000000000000000000000000000000000000000..7c98d38c299bf9383cbb945f999b86e33f7910bf Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_1_w.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_2_b.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_2_b.bin new file mode 100644 index 0000000000000000000000000000000000000000..882297c405c5c5ba06f39f388281f18629981f72 Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_2_b.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_2_w.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_2_w.bin new file mode 100644 index 0000000000000000000000000000000000000000..5492117eb22bdaa319de30e4c5247bdcc09cff3d Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/dense_2_w.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/input.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/input.bin new file mode 100644 index 0000000000000000000000000000000000000000..4d2423f74188cfe0364185ccb66837785ccf4c4e Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/input.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/labels.bin b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/labels.bin new file mode 100644 index 0000000000000000000000000000000000000000..5e1f3881897f4729d6d90ff208a08ccdabb8fe7c Binary files /dev/null and b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/labels.bin differ diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/promise_src.cc b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/promise_src.cc new file mode 100644 index 0000000000000000000000000000000000000000..46f4637460485f6d1686901c099d77929099b823 --- /dev/null +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/promise_src.cc @@ -0,0 +1,58 @@ + +#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); + + + +std::string dir_prefix = std::string("lenet_hpvm/"); +std::string input_path = dir_prefix + std::string("input.bin"); +void* input = readTrainedWeights(input_path.c_str(), 0,10000,1,28,28); +std::string labels_path = dir_prefix + std::string("labels.bin"); +uint8_t* labels = readLabels(labels_path.c_str(),10000); +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 conv2d_2_w_path = dir_prefix + std::string("conv2d_2_w.bin"); +void* conv2d_2_w = readTrainedWeights(conv2d_2_w_path.c_str(), 0,64,32,5,5); +std::string conv2d_2_b_path = dir_prefix + std::string("conv2d_2_b.bin"); +void* conv2d_2_b = readTrainedWeights(conv2d_2_b_path.c_str(), 0,1,64,1,1); +std::string conv2d_3_w_path = dir_prefix + std::string("conv2d_3_w.bin"); +void* conv2d_3_w = readTrainedWeights(conv2d_3_w_path.c_str(), 0,64,64,3,3); +std::string conv2d_3_b_path = dir_prefix + std::string("conv2d_3_b.bin"); +void* conv2d_3_b = readTrainedWeights(conv2d_3_b_path.c_str(), 0,1,64,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,3136,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); + + +void* var_0 = ConvLayer_PROMISE(input, 0.0, 1.0, conv2d_1_w, -0.23503187, 0.22027442, conv2d_1_b, -0.059452552, 0.05141998, 2, 2, 1, 1, 0, 2, 1, 0.0, 1.4499073, 9); +void* var_1 = ConvLayer_PROMISE(var_0, 0.0, 1.4499073, conv2d_2_w, -0.16616209, 0.1624253, conv2d_2_b, -0.060705345, 0.07730491, 2, 2, 1, 1, -1, 0, 1, 0.0, 4.394469, 9); +void* var_2 = ConvLayer_PROMISE(var_1, 0.0, 4.394469, conv2d_3_w, -0.17305803, 0.16375193, conv2d_3_b, -0.01982658, 0.05104504, 1, 1, 2, 2, -1, 0, 1, 0.0, 8.275149, 9); +void* var_3 = FCLayer_PROMISE(var_2, 0.0, 8.275149, dense_1_w, -0.10478318, 0.10765447, dense_1_b, -0.0300005, 0.03506347, 1, 0.0, 9.308638, 9); +void* var_4 = FCLayer_PROMISE(var_3, 0.0, 9.308638, dense_2_w, -0.1958274, 0.14691855, dense_2_b, -0.007710449, 0.039741356, 1, 0.0, 36.96972, 9); +void* var_5 = tensorSoftmax(var_4); + +computeAccuracy2(labels,10000,var_5); + +llvm_hpvm_cleanupTensorRt(); + +return 0; + +} diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/src.cc b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/src.cc new file mode 100644 index 0000000000000000000000000000000000000000..c26e11316b648481518ee3b41d029e03d6860e91 --- /dev/null +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/data/lenet_hpvm/src.cc @@ -0,0 +1,68 @@ + +#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); + + +std::string dir_prefix = std::string("lenet_hpvm/"); +std::string input_path = dir_prefix + std::string("input.bin"); +void* input = readTrainedWeights(input_path.c_str(), 0,10000,1,28,28); +std::string labels_path = dir_prefix + std::string("labels.bin"); +uint8_t* labels = readLabels(labels_path.c_str(),10000); +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 conv2d_2_w_path = dir_prefix + std::string("conv2d_2_w.bin"); +void* conv2d_2_w = readTrainedWeights(conv2d_2_w_path.c_str(), 0,64,32,5,5); +std::string conv2d_2_b_path = dir_prefix + std::string("conv2d_2_b.bin"); +void* conv2d_2_b = readTrainedWeights(conv2d_2_b_path.c_str(), 0,1,64,1,1); +std::string conv2d_3_w_path = dir_prefix + std::string("conv2d_3_w.bin"); +void* conv2d_3_w = readTrainedWeights(conv2d_3_w_path.c_str(), 0,64,64,3,3); +std::string conv2d_3_b_path = dir_prefix + std::string("conv2d_3_b.bin"); +void* conv2d_3_b = readTrainedWeights(conv2d_3_b_path.c_str(), 0,1,64,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,3136,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); + + +void* var_0 = tensorConvolution(input, conv2d_1_w, 2, 2, 1, 1, 1, 0); +void* var_1 = tensorAdd(var_0, conv2d_1_b); +void* var_2 = tensorRelu(var_1); +void* var_3 = tensorPooling(var_2,0,2,2,0,0,2,2); +void* var_4 = tensorConvolution(var_3, conv2d_2_w, 2, 2, 1, 1, 1, 0); +void* var_5 = tensorAdd(var_4, conv2d_2_b); +void* var_6 = tensorRelu(var_5); +void* var_8 = tensorConvolution(var_6, conv2d_3_w, 1, 1, 2, 2, 1, 0); +void* var_9 = tensorAdd(var_8, conv2d_3_b); +void* var_10 = tensorRelu(var_9); +void* var_12 = tensorGemmGPU(var_10, dense_1_w); +void* var_13 = tensorAdd(var_12, dense_1_b); +void* var_14 = tensorRelu(var_13); +void* var_15 = tensorGemmGPU(var_14, dense_2_w); +void* var_16 = tensorAdd(var_15, dense_2_b); +void* var_17 = tensorRelu(var_16); +void* var_18 = tensorSoftmax(var_17); + +computeAccuracy2(labels,10000,var_18); + +llvm_hpvm_cleanupTensorRt(); + +return 0; + +} diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/src/lenet.cpp b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/src/lenet.cpp index b6a5f0082170bf5bb806bc63b659cc34f3c5cbe4..eb74dc53feeb887e7a3c0fe02cbd23c851d5a6ec 100644 --- a/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/src/lenet.cpp +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/lenet_dsoc/src/lenet.cpp @@ -4,7 +4,7 @@ #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> -#include <cstring> +#include <string.h> #include <visc.h> //#include <tensorTypes.h> @@ -313,9 +313,10 @@ RootIn; int main(){ - std::string dir_prefix = std::string("../../../../../../projects/hpvm-tensor-rt/model_params/lenet_hpvm/"); + std::string dir_prefix = std::string("../data/lenet_hpvm/"); + std::string input_path = dir_prefix + std::string("input.bin"); - void* input = readTrainedWeights(input_path.c_str(), 0,100,1,28,28); + void* input = readTrainedWeights(input_path.c_str(), 0,500,1,28,28); std::string labels_path = dir_prefix + std::string("labels.bin"); uint8_t* labels = readLabels(labels_path.c_str(),100); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin");