From 92aeb02c56a91e6ab63a75978205498a9e00c2a9 Mon Sep 17 00:00:00 2001 From: Yifan Zhao <yifanz16@illinois.edu> Date: Sat, 3 Apr 2021 13:56:08 -0500 Subject: [PATCH] Pass compiler def instead of generated MODEL_PARAM into file (less invasive) --- hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt | 9 ++++----- .../benchmarks/alexnet2_cifar10/alexnet2_cifar10.cpp | 10 +++++++++- .../alexnet2_cifar10/alexnet2_cifar10_cudnn.cpp | 10 +++++++++- .../benchmarks/alexnet_cifar10/alexnet_cifar10.cpp | 10 +++++++++- .../alexnet_cifar10/alexnet_cifar10_cudnn.cpp | 10 +++++++++- .../benchmarks/alexnet_imagenet/alexnet_imagenet.cpp | 10 +++++++++- .../alexnet_imagenet/alexnet_imagenet_cudnn.cpp | 10 +++++++++- .../hpvm-c/benchmarks/lenet_mnist/lenet_mnist.cpp | 10 +++++++++- .../benchmarks/lenet_mnist/lenet_mnist_cudnn.cpp | 10 +++++++++- .../mobilenet_cifar10/mobilenet_cifar10.cpp | 10 +++++++++- .../mobilenet_cifar10/mobilenet_cifar10_cudnn.cpp | 10 +++++++++- .../benchmarks/resnet18_cifar10/resnet18_cifar10.cpp | 10 +++++++++- .../resnet18_cifar10/resnet18_cifar10_cudnn.cpp | 10 +++++++++- .../resnet50_imagenet/resnet50_imagenet.cpp | 10 +++++++++- .../resnet50_imagenet/resnet50_imagenet_cudnn.cpp | 10 +++++++++- .../benchmarks/vgg16_cifar10/vgg16_cifar10.cpp | 10 +++++++++- .../benchmarks/vgg16_cifar10/vgg16_cifar10_cudnn.cpp | 10 +++++++++- .../benchmarks/vgg16_cifar100/vgg16_cifar100.cpp | 10 +++++++++- .../vgg16_cifar100/vgg16_cifar100_cudnn.cpp | 10 +++++++++- .../benchmarks/vgg16_imagenet/vgg16_imagenet.cpp | 10 +++++++++- .../vgg16_imagenet/vgg16_imagenet_cudnn.cpp | 10 +++++++++- .../test/dnn_benchmarks/tensor-rt-src/CMakeLists.txt | 6 +++--- .../tensor-rt-src/fp16/alexnet2_cifar10_half.cc | 11 ++++++++--- .../tensor-rt-src/fp16/alexnet_cifar10_half.cc | 11 ++++++++--- .../tensor-rt-src/fp16/lenet_mnist_half.cc | 11 ++++++++--- .../tensor-rt-src/fp16/mobilenet_cifar10_half.cc | 11 ++++++++--- .../tensor-rt-src/fp16/resnet18_cifar10_half.cc | 11 ++++++++--- .../tensor-rt-src/fp16/vgg16_cifar100_half.cc | 11 ++++++++--- .../tensor-rt-src/fp16/vgg16_cifar10_half.cc | 11 ++++++++--- .../tensor-rt-src/fp32/alexnet2_cifar10.cc | 8 +++++++- .../tensor-rt-src/fp32/alexnet_cifar10.cc | 11 ++++++++--- .../tensor-rt-src/fp32/alexnet_imagenet.cc | 11 ++++++++--- .../dnn_benchmarks/tensor-rt-src/fp32/lenet_mnist.cc | 11 ++++++++--- .../tensor-rt-src/fp32/mobilenet_cifar10.cc | 12 +++++++++--- .../tensor-rt-src/fp32/resnet18_cifar10.cc | 11 ++++++++--- .../tensor-rt-src/fp32/resnet50_imagenet.cc | 11 ++++++++--- .../tensor-rt-src/fp32/vgg16_cifar10.cc | 12 +++++++++--- .../tensor-rt-src/fp32/vgg16_cifar100.cc | 11 ++++++++--- .../tensor-rt-src/fp32/vgg16_imagenet.cc | 11 ++++++++--- 39 files changed, 324 insertions(+), 77 deletions(-) diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt b/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt index f56312e9c3..aedf064002 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt +++ b/hpvm/test/dnn_benchmarks/hpvm-c/CMakeLists.txt @@ -1,17 +1,16 @@ -# Each source file contains a @MODEL_PARAMS_DIR@ waiting to be filled in. +# MODEL_PARAMS_DIR is given as -DMODEL_PARAMS_DIR=<value> to compiler. set(MODEL_PARAMS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../model_params/") set(test_compile_targets "") function(compile_hpvm_c target_name src_filepath codegen_target) - set(generated_file_path "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.cpp") set(output_bin_path "${CMAKE_CURRENT_BINARY_DIR}/hpvm_${target_name}") - configure_file(${src_filepath} ${generated_file_path}) # Add an "hpvm_" prefix here because Ninja generator doesn't like # the name of output file and custom target to clash. add_custom_command( OUTPUT ${output_bin_path} - DEPENDS ${generated_file_path} hpvm-clang + DEPENDS ${src_filepath} hpvm-clang COMMAND hpvm-clang - ${generated_file_path} ${output_bin_path} -O3 -fno-exceptions + ${src_filepath} ${output_bin_path} -O3 -fno-exceptions + "-DMODEL_PARAMS_DIR=${MODEL_PARAMS_DIR}" -t ${codegen_target} ${ARGN} ) add_custom_target(${target_name} DEPENDS ${output_bin_path}) diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10.cpp index 2faf1413bc..8a043d3644 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -428,7 +436,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet2_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet2_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10_cudnn.cpp index bca6ca47cd..b0a8fe8102 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet2_cifar10/alexnet2_cifar10_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -433,7 +441,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet2_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet2_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp index d274d52ec1..1ff20c28a6 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -379,7 +387,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); uint8_t *labels = readLabels(labels_path.c_str(), 5000); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10_cudnn.cpp index e82985d04f..48ce086417 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_cifar10/alexnet_cifar10_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -385,7 +393,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); uint32_t *labels = readLabels3(labels_path.c_str(), 5000); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet.cpp index c058e913c9..b20aab8720 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet.cpp @@ -1,4 +1,12 @@ #include <config.h> + +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) #include <hpvm.h> #include <string> #include <tensorUtils.h> @@ -477,7 +485,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet_imagenet/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet_cudnn.cpp index 26e717fd73..239d4ea579 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/alexnet_imagenet/alexnet_imagenet_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -482,7 +490,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet_imagenet/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist.cpp index 8185d9dc69..f9d8bc3e43 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -281,7 +289,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/lenet_mnist/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/lenet_mnist/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist_cudnn.cpp index a0cd32151e..b607e9e653 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/lenet_mnist/lenet_mnist_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -286,7 +294,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/lenet_mnist/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/lenet_mnist/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10.cpp index 77b448d81d..d309cd5b5e 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -1983,7 +1991,7 @@ int main(int argc, char *argv[]) { } std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/mobilenet_cifar10/"; + std::string(MODEL_PARAMS_DIR_STR) + "/mobilenet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10_cudnn.cpp index adb140bd69..7cfeca0041 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/mobilenet_cifar10/mobilenet_cifar10_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -1988,7 +1996,7 @@ int main(int argc, char *argv[]) { } std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/mobilenet_cifar10/"; + std::string(MODEL_PARAMS_DIR_STR) + "/mobilenet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10.cpp index ef94b055bd..54e93e0ff5 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10.cpp @@ -4,6 +4,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -1317,7 +1325,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/resnet18_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/resnet18_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10_cudnn.cpp index ecfa229573..7eb4acc44a 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet18_cifar10/resnet18_cifar10_cudnn.cpp @@ -4,6 +4,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -1248,7 +1256,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/resnet18_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/resnet18_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); uint32_t *labels = readLabels3(labels_path.c_str(), 5000); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet.cpp index 37a4111411..54d0089326 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -5150,7 +5158,7 @@ int main(int argc, char *argv[]) { } std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/resnet50_imagenet/"; + std::string(MODEL_PARAMS_DIR_STR) + "/resnet50_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet_cudnn.cpp index 1ac5141bca..fa1e616156 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/resnet50_imagenet/resnet50_imagenet_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -4926,7 +4934,7 @@ int main(int argc, char *argv[]) { } std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/resnet50_imagenet/"; + std::string(MODEL_PARAMS_DIR_STR) + "/resnet50_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10.cpp index c1de0703df..bf1c007ff3 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -844,7 +852,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10_cudnn.cpp index 7bda121335..79970b6395 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar10/vgg16_cifar10_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -849,7 +857,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100.cpp index bee78428df..c45e115fb3 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -844,7 +852,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar100/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar100/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100_cudnn.cpp index c12855437b..7c6fd3ff40 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_cifar100/vgg16_cifar100_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -849,7 +857,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar100/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar100/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet.cpp index b046f42551..dcf237bd78 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::TENSOR_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -892,7 +900,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_imagenet/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet_cudnn.cpp b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet_cudnn.cpp index b06c992f3c..e516b9117b 100644 --- a/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet_cudnn.cpp +++ b/hpvm/test/dnn_benchmarks/hpvm-c/benchmarks/vgg16_imagenet/vgg16_imagenet_cudnn.cpp @@ -3,6 +3,14 @@ #include <tensorUtils.h> #include <config.h> +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + void var_0_node(void *t1, size_t bytes_t1, void *t2, size_t bytes_t2) { __hpvm__hint(hpvm::CUDNN_TARGET); __hpvm__attributes(2, t1, t2, 0); @@ -897,7 +905,7 @@ int main(int argc, char *argv[]) { } } - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_imagenet/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/CMakeLists.txt b/hpvm/test/dnn_benchmarks/tensor-rt-src/CMakeLists.txt index 6e22eba674..1cadb68b80 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/CMakeLists.txt +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/CMakeLists.txt @@ -2,13 +2,13 @@ # Don't put binaries in build/bin. This doesn't affect global setting. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +# MODEL_PARAMS_DIR is given as -DMODEL_PARAMS_DIR=<value> to compiler. set(MODEL_PARAMS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../model_params/") set(test_compile_targets "") function(add_trt_source target_name filepath) - set(generated_file_path "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.cpp") - configure_file(${filepath} ${generated_file_path}) - add_executable(${target_name} ${generated_file_path}) + add_executable(${target_name} ${filepath}) target_link_libraries(${target_name} tensor_runtime_online) + target_compile_definitions(${target_name} PRIVATE "-DMODEL_PARAMS_DIR=${MODEL_PARAMS_DIR}") set(test_compile_targets ${test_compile_targets} ${target_name} PARENT_SCOPE) endfunction(add_trt_source) diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet2_cifar10_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet2_cifar10_half.cc index ab80718fd3..5bc3ea6428 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet2_cifar10_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet2_cifar10_half.cc @@ -1,8 +1,13 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) /* NOTE: Reference Architecture to use for profiling */ void testCifarNet() { @@ -10,7 +15,7 @@ void testCifarNet() { printf("********* Alexnet2 CIFAR-10 DNN ********** \n"); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/alexnet2_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string(MODEL_PARAMS_DIR_STR) + "/alexnet2_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet_cifar10_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet_cifar10_half.cc index b3b69d6b69..bf01835c2e 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet_cifar10_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/alexnet_cifar10_half.cc @@ -1,14 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/lenet_mnist_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/lenet_mnist_half.cc index 44b78b9169..2e80dd98f9 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/lenet_mnist_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/lenet_mnist_half.cc @@ -1,8 +1,13 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) /* NOTE: Reference Architecture to use for profiling */ void testLenetTanh() { @@ -12,7 +17,7 @@ void testLenetTanh() { int test_batch_size = 5000; - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/lenet_mnist/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/lenet_mnist/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/mobilenet_cifar10_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/mobilenet_cifar10_half.cc index d4423bf434..5ecb8618f8 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/mobilenet_cifar10_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/mobilenet_cifar10_half.cc @@ -1,15 +1,20 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/mobilenet_cifar10/"; + std::string(MODEL_PARAMS_DIR_STR) + "/mobilenet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/resnet18_cifar10_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/resnet18_cifar10_half.cc index 76dea5ef08..1e1bc36f79 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/resnet18_cifar10_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/resnet18_cifar10_half.cc @@ -1,15 +1,20 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/resnet18_cifar10/"; + std::string(MODEL_PARAMS_DIR_STR) + "/resnet18_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar100_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar100_half.cc index 2772fd3da4..73b057c097 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar100_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar100_half.cc @@ -1,14 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar100/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar100/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar10_half.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar10_half.cc index 954f6778b8..1928398c43 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar10_half.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp16/vgg16_cifar10_half.cc @@ -1,14 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet2_cifar10.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet2_cifar10.cc index e7431234d7..8f08e80d1f 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet2_cifar10.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet2_cifar10.cc @@ -2,7 +2,13 @@ #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) /* NOTE: Reference Architecture to use for profiling */ void testCifarNet() { @@ -10,7 +16,7 @@ void testCifarNet() { printf("********* Alexnet2 CIFAR-10 DNN ********** \n"); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/alexnet2_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string(MODEL_PARAMS_DIR_STR) + "/alexnet2_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_cifar10.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_cifar10.cc index 12c304c9b4..9f23cc6566 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_cifar10.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_cifar10.cc @@ -1,14 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/alexnet_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); // std::string labels_path = dir_prefix + std::string("labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_imagenet.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_imagenet.cc index b57e60c0fe..74de9507e5 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_imagenet.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/alexnet_imagenet.cc @@ -1,15 +1,20 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/alexnet_imagenet/"; + std::string(MODEL_PARAMS_DIR_STR) + "/alexnet_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/lenet_mnist.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/lenet_mnist.cc index 9777670722..e973f712c9 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/lenet_mnist.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/lenet_mnist.cc @@ -1,8 +1,13 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int total_runs = 1; @@ -11,7 +16,7 @@ void testLenetTanh() { int test_batch_size = 5000; - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/lenet_mnist/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/lenet_mnist/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/mobilenet_cifar10.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/mobilenet_cifar10.cc index 3e37bf7feb..36f90e4954 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/mobilenet_cifar10.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/mobilenet_cifar10.cc @@ -1,14 +1,20 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/mobilenet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); + std::string(MODEL_PARAMS_DIR_STR) + "/mobilenet_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); void *conv2d_1_w = diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet18_cifar10.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet18_cifar10.cc index c8a99419a8..6cfcfbfbe1 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet18_cifar10.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet18_cifar10.cc @@ -1,15 +1,20 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/resnet18_cifar10/"; + std::string(MODEL_PARAMS_DIR_STR) + "/resnet18_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet50_imagenet.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet50_imagenet.cc index 3aeabc2273..56e02cc4aa 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet50_imagenet.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/resnet50_imagenet.cc @@ -1,15 +1,20 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); std::string dir_prefix = - std::string("@MODEL_PARAMS_DIR@") + "/resnet50_imagenet/"; + std::string(MODEL_PARAMS_DIR_STR) + "/resnet50_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar10.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar10.cc index f7fffadfc3..a7b05ee731 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar10.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar10.cc @@ -1,13 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) + int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar10/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar10/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); std::string conv2d_1_w_path = dir_prefix + std::string("conv2d_1_w.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar100.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar100.cc index d3949c7cc5..b908f4201b 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar100.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_cifar100.cc @@ -1,14 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_cifar100/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_cifar100/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); diff --git a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_imagenet.cc b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_imagenet.cc index 2bb1be2821..a881e7905f 100644 --- a/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_imagenet.cc +++ b/hpvm/test/dnn_benchmarks/tensor-rt-src/fp32/vgg16_imagenet.cc @@ -1,14 +1,19 @@ - - #include "tensor_runtime.h" #include "tensorUtils.h" +#ifndef MODEL_PARAMS_DIR +#error MODEL_PARAMS_DIR is not defined +#endif + +#define STR_VALUE(X) #X +#define STRINGIFY(X) STR_VALUE(X) +#define MODEL_PARAMS_DIR_STR STRINGIFY(MODEL_PARAMS_DIR) int main() { llvm_hpvm_initTensorRt(0); - std::string dir_prefix = std::string("@MODEL_PARAMS_DIR@") + "/vgg16_imagenet/"; + std::string dir_prefix = std::string(MODEL_PARAMS_DIR_STR) + "/vgg16_imagenet/"; std::string input_path = dir_prefix + std::string("test_input.bin"); std::string labels_path = dir_prefix + std::string("test_labels.bin"); -- GitLab