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

Adding AlexNet CUDNN and PROMISE sources + Makefile

parent 0c1b93e0
No related branches found
No related tags found
No related merge requests found
DNN_BENCHMARK_ROOT = $(LLVM_SRC_ROOT)/test/VISC/DNN_Benchmarks DNN_BENCHMARK_ROOT = $(LLVM_SRC_ROOT)/test/VISC/DNN_Benchmarks
# NOTE: can configure build directory # NOTE: can configure build directory
HPVM_BUILD_DIR = $(LLVM_SRC_ROOT)/../build_fresh/ HPVM_BUILD_DIR = $(LLVM_SRC_ROOT)/../build_hpvm/
CC = $(HPVM_BUILD_DIR)/bin/clang++ CC = $(HPVM_BUILD_DIR)/bin/clang++
OPT = $(HPVM_BUILD_DIR)/bin/opt OPT = $(HPVM_BUILD_DIR)/bin/opt
...@@ -8,7 +8,6 @@ LLVM_DIS = $(HPVM_BUILD_DIR)/bin/llvm-dis ...@@ -8,7 +8,6 @@ LLVM_DIS = $(HPVM_BUILD_DIR)/bin/llvm-dis
LLVM_LINK = $(HPVM_BUILD_DIR)/bin/llvm-link LLVM_LINK = $(HPVM_BUILD_DIR)/bin/llvm-link
LLVM_INCLUDE_DIR = $(LLVM_SRC_ROOT)/include LLVM_INCLUDE_DIR = $(LLVM_SRC_ROOT)/include
SRC_DIR = src SRC_DIR = src
BUILD_DIR = build BUILD_DIR = build
APP = alexnet APP = alexnet
...@@ -23,11 +22,17 @@ CCFLAGS += -DDEVICE=CUDNN_TARGET ...@@ -23,11 +22,17 @@ CCFLAGS += -DDEVICE=CUDNN_TARGET
LINKER_FLAGS = -lpthread -lcudart -lcurand -lcudnn -lcublas -lOpenCL LINKER_FLAGS = -lpthread -lcudart -lcurand -lcudnn -lcublas -lOpenCL
HPVM_LIB_DIR = $(HPVM_BUILD_DIR)/lib HPVM_LIB_DIR = $(HPVM_BUILD_DIR)/lib
#HPVM_LIB_DIR = /home/hsharif3/Gitlab/hpvm/build_new/lib
VISC_OPTFLAGS = -load $(HPVM_LIB_DIR)/LLVMBuildDFG.so -load $(HPVM_LIB_DIR)/LLVMInPlaceDFGAnalysis.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_CUDNN.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_X86.so -load $(HPVM_LIB_DIR)/LLVMClearDFG.so -inplace -dfg2llvm-cudnn -dfg2llvm-x86 -clearDFG VISC_OPTFLAGS = -load $(HPVM_LIB_DIR)/LLVMBuildDFG.so -load $(HPVM_LIB_DIR)/LLVMInPlaceDFGAnalysis.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_CUDNN.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_X86.so -load $(HPVM_LIB_DIR)/LLVMClearDFG.so -inplace -dfg2llvm-cudnn -dfg2llvm-x86 -clearDFG
QUANT_FILE_PATH=/home/hsharif3/Gitlab/hpvm/llvm/test/VISC/DNN_Benchmarks/benchmarks/alexnet/data/quant_ranges.txt
VISC_OPTFLAGS2 = -load $(HPVM_LIB_DIR)/LLVMBuildDFG.so -load $(HPVM_LIB_DIR)/LLVMInPlaceDFGAnalysis.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_PROMISE.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_CUDNN.so -load $(HPVM_LIB_DIR)/LLVMDFG2LLVM_X86.so -load $(HPVM_LIB_DIR)/LLVMFuseHPVMTensorNodes.so -load $(HPVM_LIB_DIR)/LLVMClearDFG.so -inplace -hpvm-fuse -dfg2llvm-promise -quantization-levels-filename=$(QUANT_FILE_PATH) -dfg2llvm-cudnn -dfg2llvm-x86 -clearDFG
TARGET = $(BUILD_DIR)/$(APP).opt.bc TARGET = $(BUILD_DIR)/$(APP).opt.bc
SOURCES = $(SRC_DIR)/$(APP).cpp SOURCES = $(SRC_DIR)/$(APP).cpp
VISC_RT_PATH = $(LLVM_SRC_ROOT)/../build/projects/visc-rt/visc-rt.ll VISC_RT_PATH = $(LLVM_SRC_ROOT)/../build/projects/visc-rt/visc-rt.ll
...@@ -38,17 +43,20 @@ default: $(BUILD_DIR) $(TARGET) ...@@ -38,17 +43,20 @@ default: $(BUILD_DIR) $(TARGET)
$(BUILD_DIR)/%.ll: $(SRC_DIR)/%.cpp $(BUILD_DIR)/%.ll: $(SRC_DIR)/%.cpp
$(CC) $(CC_FLAGS) -emit-llvm -S -o $@ $< $(CC) $(CC_FLAGS) -emit-llvm src/$(APP).cpp -S -o $(BUILD_DIR)/$(APP).ll
$(CC) $(CC_FLAGS) -emit-llvm src/$(APP)_promise.cpp -S -o $(BUILD_DIR)/$(APP)_promise.ll
#-visc-timers-gen
$(BUILD_DIR)/%.visc.ll: $(BUILD_DIR)/%.ll
$(OPT) -load LLVMGenVISC.so -genvisc -globaldce $< -S -o $@ $(BUILD_DIR)/%.opt.bc: $(BUILD_DIR)/%.ll
$(OPT) -load LLVMGenVISC.so -genvisc -globaldce $(BUILD_DIR)/$(APP).ll -S -o $(BUILD_DIR)/$(APP).visc.ll
$(BUILD_DIR)/%.opt.bc: $(BUILD_DIR)/%.visc.ll $(OPT) -load LLVMGenVISC.so -genvisc -globaldce $(BUILD_DIR)/$(APP)_promise.ll -S -o $(BUILD_DIR)/$(APP)_promise.visc.ll
$(OPT) $(VISC_OPTFLAGS) $< -o $@ $(OPT) $(VISC_OPTFLAGS) $(BUILD_DIR)/$(APP).visc.ll -o $(BUILD_DIR)/$(APP)_cudnn.bc
$(LLVM_LINK) $@ $(VISC_RT_PATH) -o $(BUILD_DIR)/$(APP)_linked.bc $(OPT) $(VISC_OPTFLAGS2) $(BUILD_DIR)/$(APP)_promise.visc.ll -o $(BUILD_DIR)/$(APP)_promise.bc
$(CC) $(BUILD_DIR)/$(APP)_linked.bc $(TENSOR_LIB_DIR) -o $(BUILD_DIR)/$(APP)_linked $(LINKER_FLAGS) $(LLVM_LINK) $(BUILD_DIR)/$(APP)_cudnn.bc $(VISC_RT_PATH) -o $(BUILD_DIR)/$(APP)_cudnn_linked.bc
$(CC) $(BUILD_DIR)/$(APP)_linked.bc $(TENSOR_AUTOTUNER_DIR) -o $(BUILD_DIR)/$(APP)_tune $(LINKER_FLAGS) $(LLVM_LINK) $(BUILD_DIR)/$(APP)_promise.bc $(VISC_RT_PATH) -o $(BUILD_DIR)/$(APP)_promise_linked.bc
$(CC) $(BUILD_DIR)/$(APP)_cudnn_linked.bc $(TENSOR_LIB_DIR) -o $(BUILD_DIR)/$(APP)_cudnn_linked $(LINKER_FLAGS)
$(CC) $(BUILD_DIR)/$(APP)_promise_linked.bc $(TENSOR_LIB_DIR) -o $(BUILD_DIR)/$(APP)_promise_linked $(LINKER_FLAGS)
#$(CC) $(BUILD_DIR)/$(APP)_cudnn_linked.bc $(TENSOR_AUTOTUNER_DIR) -o $(BUILD_DIR)/lenet_tune $(LINKER_FLAGS)
$(BUILD_DIR): $(BUILD_DIR):
mkdir -p $@ mkdir -p $@
......
-1.88164262419 2.09340954985 -0.33087718 0.3323643 -0.7782218 0.6020472 -0.978641152382 0.998945295811
-0.978641152382 0.998945295811 -0.2095158 0.33543423 -0.45020863 0.30596754 -0.999703943729 0.999930202961
-0.999703943729 0.999930202961 -0.1715614 0.17037082 -0.6519161 0.5939945 -0.999933600426 0.999940037727
-0.999933600426 0.999940037727 -0.15575546 0.14456555 -0.55873865 0.4704539 -0.99999910593 0.999999344349
-0.99999910593 0.999999344349 -0.16108225 0.16864482 -0.22135437 0.10401678 -0.999434411526 0.999634206295
-0.999434411526 0.999634206295 -0.18183032 0.19018902 -0.07189204 0.106005594 -15.0765653801 19.4225852203
...@@ -369,39 +369,39 @@ RootIn; ...@@ -369,39 +369,39 @@ RootIn;
int main(){ int main(){
std::string dir_prefix = std::string("../../../../../../projects/hpvm-tensor-rt/model_params/alexnet_cifar10_front/"); std::string dir_prefix = std::string("../../../../../../projects/hpvm-tensor-rt/model_params/alexnet_cifar10_test/");
//std::string dir_prefix = std::string("../../../../../../projects/hpvm-tensor-rt/model_params/alexnet_cifar10/");
std::string input_path = dir_prefix + std::string("input.bin"); std::string input_path = dir_prefix + std::string("input.bin");
void* input = readTrainedWeights(input_path.c_str(), 0,10000,3,32,32); void* input = readTrainedWeights(input_path.c_str(), 0,10000,3,32,32);
std::string labels_path = dir_prefix + std::string("labels.bin"); std::string labels_path = dir_prefix + std::string("labels.bin");
uint8_t* labels = readLabels(labels_path.c_str(),10000); uint8_t* labels = readLabels(labels_path.c_str(),10000);
std::string conv2d_1_w_path = dir_prefix + std::string("conv0.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,64,3,11,11); void* conv2d_1_w = readTrainedWeights(conv2d_1_w_path.c_str(), 0,64,3,11,11);
std::string conv2d_1_b_path = dir_prefix + std::string("conv_bias0.bin"); 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,64,1,1); void* conv2d_1_b = readTrainedWeights(conv2d_1_b_path.c_str(), 0,1,64,1,1);
std::string conv2d_2_w_path = dir_prefix + std::string("conv3.bin"); 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,192,64,5,5); void* conv2d_2_w = readTrainedWeights(conv2d_2_w_path.c_str(), 0,192,64,5,5);
std::string conv2d_2_b_path = dir_prefix + std::string("conv_bias3.bin"); 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,192,1,1); void* conv2d_2_b = readTrainedWeights(conv2d_2_b_path.c_str(), 0,1,192,1,1);
std::string conv2d_3_w_path = dir_prefix + std::string("conv6.bin"); 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,384,192,3,3); void* conv2d_3_w = readTrainedWeights(conv2d_3_w_path.c_str(), 0,384,192,3,3);
std::string conv2d_3_b_path = dir_prefix + std::string("conv_bias6.bin"); 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,384,1,1); void* conv2d_3_b = readTrainedWeights(conv2d_3_b_path.c_str(), 0,1,384,1,1);
std::string conv2d_4_w_path = dir_prefix + std::string("conv7.bin"); std::string conv2d_4_w_path = dir_prefix + std::string("conv2d_4_w.bin");
void* conv2d_4_w = readTrainedWeights(conv2d_4_w_path.c_str(), 0,256,384,3,3); void* conv2d_4_w = readTrainedWeights(conv2d_4_w_path.c_str(), 0,256,384,3,3);
std::string conv2d_4_b_path = dir_prefix + std::string("conv_bias7.bin"); std::string conv2d_4_b_path = dir_prefix + std::string("conv2d_4_b.bin");
void* conv2d_4_b = readTrainedWeights(conv2d_4_b_path.c_str(), 0,1,256,1,1); void* conv2d_4_b = readTrainedWeights(conv2d_4_b_path.c_str(), 0,1,256,1,1);
std::string conv2d_5_w_path = dir_prefix + std::string("conv8.bin"); std::string conv2d_5_w_path = dir_prefix + std::string("conv2d_5_w.bin");
void* conv2d_5_w = readTrainedWeights(conv2d_5_w_path.c_str(), 0,256,256,3,3); void* conv2d_5_w = readTrainedWeights(conv2d_5_w_path.c_str(), 0,256,256,3,3);
std::string conv2d_5_b_path = dir_prefix + std::string("conv_bias8.bin"); std::string conv2d_5_b_path = dir_prefix + std::string("conv2d_5_b.bin");
void* conv2d_5_b = readTrainedWeights(conv2d_5_b_path.c_str(), 0,1,256,1,1); void* conv2d_5_b = readTrainedWeights(conv2d_5_b_path.c_str(), 0,1,256,1,1);
std::string dense_1_w_path = dir_prefix + std::string("fc12.bin"); 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,4096,10); void* dense_1_w = readTrainedWeights(dense_1_w_path.c_str(), 0,1,1,4096,10);
std::string dense_1_b_path = dir_prefix + std::string("fc_bias12.bin"); 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,10,1,1); void* dense_1_b = readTrainedWeights(dense_1_b_path.c_str(), 0,1,10,1,1);
__visc__init(); __visc__init();
RootIn* args = static_cast<RootIn*>(malloc(sizeof(RootIn))); RootIn* args = static_cast<RootIn*>(malloc(sizeof(RootIn)));
......
#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::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_convolution(t1, t2, 5, 5, 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::PROMISE_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::PROMISE_TARGET);
__visc__attributes(1, t1, 0);
void* r = __visc__tensor_tanh(t1);
__visc__return(2, r, (size_t) 0);
}
void var_3_node(void* t1, size_t bytes_t1) {
__visc__hint(visc::PROMISE_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::PROMISE_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::PROMISE_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::PROMISE_TARGET);
__visc__attributes(1, t1, 0);
void* r = __visc__tensor_tanh(t1);
__visc__return(2, r, (size_t) 0);
}
void var_7_node(void* t1, size_t bytes_t1) {
__visc__hint(visc::PROMISE_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_8_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_convolution(t1, t2, 1, 1, 1, 1);
__visc__return(2, r, (size_t) 0);
}
void var_9_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_add(t1, t2);
__visc__return(2, r, (size_t) 0);
}
void var_10_node(void* t1, size_t bytes_t1) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(1, t1, 0);
void* r = __visc__tensor_tanh(t1);
__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::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_convolution(t1, t2, 1, 1, 1, 1);
__visc__return(2, r, (size_t) 0);
}
void var_12_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_add(t1, t2);
__visc__return(2, r, (size_t) 0);
}
void var_13_node(void* t1, size_t bytes_t1) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(1, t1, 0);
void* r = __visc__tensor_tanh(t1);
__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::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_convolution(t1, t2, 1, 1, 1, 1);
__visc__return(2, r, (size_t) 0);
}
void var_15_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_add(t1, t2);
__visc__return(2, r, (size_t) 0);
}
void var_16_node(void* t1, size_t bytes_t1) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(1, t1, 0);
void* r = __visc__tensor_tanh(t1);
__visc__return(2, r, (size_t) 0);
}
void var_17_node(void* t1, size_t bytes_t1) {
__visc__hint(visc::PROMISE_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_18_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_mul(t1, t2);
__visc__return(2, r, (size_t) 0);
}
void var_19_node(void* t1, size_t bytes_t1, void* t2, size_t bytes_t2) {
__visc__hint(visc::PROMISE_TARGET);
__visc__attributes(2, t1, t2, 0);
void *r = __visc__tensor_add(t1, t2);
__visc__return(2, r, (size_t) 0);
}
void var_20_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* conv2d_4_w, size_t conv2d_4_w_bytes,
void* conv2d_4_b, size_t conv2d_4_b_bytes,
void* conv2d_5_w, size_t conv2d_5_w_bytes,
void* conv2d_5_b, size_t conv2d_5_b_bytes,
void* dense_1_w, size_t dense_1_w_bytes,
void* dense_1_b, size_t dense_1_b_bytes){
__visc__hint(visc::CPU_TARGET);
__visc__attributes(13, input, conv2d_1_w, conv2d_1_b, conv2d_2_w, conv2d_2_b, conv2d_3_w, conv2d_3_b, conv2d_4_w, conv2d_4_b, conv2d_5_w, conv2d_5_b, dense_1_w, dense_1_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);
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, 10, 2, 0);
__visc__bindIn(var_8, 11, 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);
__visc__bindIn(var_9, 12, 2, 0);
__visc__bindIn(var_9, 13, 3, 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);
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, 14, 2, 0);
__visc__bindIn(var_11, 15, 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);
__visc__bindIn(var_12, 16, 2, 0);
__visc__bindIn(var_12, 17, 3, 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);
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, 18, 2, 0);
__visc__bindIn(var_14, 19, 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);
__visc__bindIn(var_15, 20, 2, 0);
__visc__bindIn(var_15, 21, 3, 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);
void* var_17 = __visc__createNodeND(0, var_17_node);
__visc__edge(var_16, var_17, 1, 0, 0, 0);
__visc__edge(var_16, var_17, 1, 1, 1, 0);
void* var_18 = __visc__createNodeND(0, var_18_node);
__visc__edge(var_17, var_18, 1, 0, 0, 0);
__visc__edge(var_17, var_18, 1, 1, 1, 0);
__visc__bindIn(var_18, 22, 2, 0);
__visc__bindIn(var_18, 23, 3, 0);
void* var_19 = __visc__createNodeND(0, var_19_node);
__visc__edge(var_18, var_19, 1, 0, 0, 0);
__visc__edge(var_18, var_19, 1, 1, 1, 0);
__visc__bindIn(var_19, 24, 2, 0);
__visc__bindIn(var_19, 25, 3, 0);
void* var_20 = __visc__createNodeND(0, var_20_node);
__visc__edge(var_19, var_20, 1, 0, 0, 0);
__visc__edge(var_19, var_20, 1, 1, 1, 0);
__visc__bindOut(var_20, 0, 0, 0);
__visc__bindOut(var_20, 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* conv2d_4_w;
size_t conv2d_4_w_bytes;
void* conv2d_4_b;
size_t conv2d_4_b_bytes;
void* conv2d_5_w;
size_t conv2d_5_w_bytes;
void* conv2d_5_b;
size_t conv2d_5_b_bytes;
void* dense_1_w;
size_t dense_1_w_bytes;
void* dense_1_b;
size_t dense_1_b_bytes;
struct ret_t r;
}
RootIn;
int main(){
std::string dir_prefix = std::string("../../../../../../projects/hpvm-tensor-rt/model_params/alexnet_cifar10_test/");
std::string input_path = dir_prefix + std::string("input.bin");
void* input = readTrainedWeights(input_path.c_str(), 0,5000,3,32,32);
std::string labels_path = dir_prefix + std::string("labels.bin");
uint8_t* labels = readLabels(labels_path.c_str(),5000);
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,64,3,11,11);
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,64,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,192,64,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,192,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,384,192,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,384,1,1);
std::string conv2d_4_w_path = dir_prefix + std::string("conv2d_4_w.bin");
void* conv2d_4_w = readTrainedWeights(conv2d_4_w_path.c_str(), 0,256,384,3,3);
std::string conv2d_4_b_path = dir_prefix + std::string("conv2d_4_b.bin");
void* conv2d_4_b = readTrainedWeights(conv2d_4_b_path.c_str(), 0,1,256,1,1);
std::string conv2d_5_w_path = dir_prefix + std::string("conv2d_5_w.bin");
void* conv2d_5_w = readTrainedWeights(conv2d_5_w_path.c_str(), 0,256,256,3,3);
std::string conv2d_5_b_path = dir_prefix + std::string("conv2d_5_b.bin");
void* conv2d_5_b = readTrainedWeights(conv2d_5_b_path.c_str(), 0,1,256,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,4096,10);
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,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->conv2d_4_w = conv2d_4_w;
args->conv2d_4_w_bytes = 0;
args->conv2d_4_b = conv2d_4_b;
args->conv2d_4_b_bytes = 0;
args->conv2d_5_w = conv2d_5_w;
args->conv2d_5_w_bytes = 0;
args->conv2d_5_b = conv2d_5_b;
args->conv2d_5_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;
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, 5000, result);
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