Skip to content

Commit

Permalink
8 KERNEL PROC Changes
Browse files Browse the repository at this point in the history
Changes:
Eltwise Add Software layer
8 Kernel Proc functionality fixes
  • Loading branch information
Anitha Barri committed Aug 16, 2018
1 parent 84318fb commit 2ac2f2f
Show file tree
Hide file tree
Showing 39 changed files with 1,135 additions and 107 deletions.
Binary file modified SD_Card/zcu102/alexnet.elf
Binary file not shown.
Binary file modified SD_Card/zcu102/alexnetfcn.elf
Binary file not shown.
Binary file added SD_Card/zcu102/eval.elf
Binary file not shown.
Binary file modified SD_Card/zcu102/googlenet.elf
Binary file not shown.
Binary file modified SD_Card/zcu102/lib/libparser_arm.so
Binary file not shown.
Binary file modified SD_Card/zcu102/lib/libxstack.so
Binary file not shown.
Binary file modified SD_Card/zcu102/resnet50.elf
Binary file not shown.
Binary file modified SD_Card/zcu102/ssd.elf
Binary file not shown.
Binary file modified SD_Card/zcu102/vgg.elf
Binary file not shown.
Binary file modified SD_Card/zcu104/alexnet.elf
Binary file not shown.
Binary file modified SD_Card/zcu104/alexnetfcn.elf
Binary file not shown.
Binary file added SD_Card/zcu104/eval.elf
Binary file not shown.
Binary file modified SD_Card/zcu104/googlenet.elf
Binary file not shown.
Binary file modified SD_Card/zcu104/lib/libparser_arm.so
Binary file not shown.
Binary file modified SD_Card/zcu104/lib/libxstack.so
Binary file not shown.
Binary file modified SD_Card/zcu104/resnet50.elf
Binary file not shown.
Binary file modified SD_Card/zcu104/ssd.elf
Binary file not shown.
Binary file modified SD_Card/zcu104/vgg.elf
Binary file not shown.
6 changes: 4 additions & 2 deletions software/bufmgmt/xi_buf_mgmt_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,14 @@ int convWeightsSize(int out_depth, int in_depth, int kernel_h, int kernel_w, int
int size_of_weights;
int no_kernals,no_planes;

remainder=no_kernals_1%KER_PROC;
//remainder=no_kernals_1%KER_PROC;
remainder=no_kernals_1%CONV_IO_PACK_ELEMS;

if(remainder==0)
no_kernals=no_kernals_1;
else
no_kernals=no_kernals_1+KER_PROC-remainder;
//no_kernals=no_kernals_1+KER_PROC-remainder;
no_kernals=no_kernals_1+CONV_IO_PACK_ELEMS-remainder;

if(no_kernals<4)
no_kernals=4; //TODO: make it as a argument minimum number of kernels are processing
Expand Down
2 changes: 1 addition & 1 deletion software/checkers/checkers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int errorCheck(
return -1;
}

if(inLayer.kernType == CONV)
if((inLayer.kernType == CONV) || (inLayer.kernType == ELTWISEADD))
{
#if PACKED_INOUT
status = cpCheck_packed(inLayer);
Expand Down
22 changes: 20 additions & 2 deletions software/checkers/checkers_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ limitations under the License.

#include "ap_int.h"
#include "../common/kernelinfo_class.h"
#include "../swkernels/xi_format_converter.hpp"

//# Checks Convolution/Pool funtionality
int cpCheck(
Expand Down Expand Up @@ -191,6 +190,12 @@ int cpCheck(

relu = params[10];
en_batch_size_one = params[126];//58];

int pool_split_cnt = params[110];
if(pool_split_cnt>1)
{
indepth = params[109];
}
}
else if(inLayer.kernType == NORM)
{
Expand All @@ -200,6 +205,14 @@ int cpCheck(
en_batch_size_one = params[8];
offline_quant_mode = params[9];
}
else if(inLayer.kernType == ELTWISEADD)
{
height = params[4];
width = params[5];
indepth = params[3];
en_batch_size_one = 0;//params[8];
offline_quant_mode = 1;//params[9];
}
else //POOL
{
height = params[2];
Expand Down Expand Up @@ -690,7 +703,7 @@ int cpCheck(
return -1;
else
return 0;
#endif
#endif //if LAYERWISE_OUTPUT_WRITE

}
// cpCheck
Expand Down Expand Up @@ -3019,6 +3032,11 @@ void LoadInputData(xChangeLayer inLayer, char *lay_path)
planes = params[5];
height = params[0];
width = params[1];
int pool_split_cnt = params[110];
if(pool_split_cnt>1)
{
planes = params[109];
}
}

if(inLayer.kernType == POOL)
Expand Down
172 changes: 169 additions & 3 deletions software/common/kernelinfo_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,14 @@ void update_conv_module_opcode_table(Opcode_info & obj_module_opcode,map<opcode_
/****** OPCODE_CRELU ***********/
obj_module_opcode.op_code = OPCODE_CRELU;
opcode_info_map[obj_module_opcode.op_code]=obj_module_opcode;
/****** OPCODE_BN ***********/
/****** OPCODE_BN + SCALE***********/
obj_module_opcode.op_code = OPCODE_BN;
opcode_info_map[obj_module_opcode.op_code]=obj_module_opcode;
/****** OPCODE_ELTWISE ***********/
#if XI_DIET_CHAI_Z==0
obj_module_opcode.op_code = OPCODE_ELTWISE;
opcode_info_map[obj_module_opcode.op_code]=obj_module_opcode;
#endif
/****** OPCODE_FUSE_BN_CONV ***********/
obj_module_opcode.op_code = OPCODE_FUSE_BN_CONV;
opcode_info_map[obj_module_opcode.op_code]=obj_module_opcode;
Expand Down Expand Up @@ -1283,6 +1285,163 @@ void update_permute_xunpack_module_opcode_table(Opcode_info & obj_module_opcode,
opcode_info_map[obj_module_opcode.op_code]=obj_module_opcode;

}
void update_opcde_sw_eltwise_module_opcode_table(Opcode_info & obj_module_opcode,map<opcode_num_e, Opcode_info> & opcode_info_map,int batch_size){

Module_info module_default;
module_default.module_target_info = CPU;
module_default.module_type = SW_ELTWISE_ADD;
module_default.module_name = "Eltwise"; /// TODO abid needs to update the layer information based on the enum instead of layer name
module_default.num_total_ports=11; // TODO need to check with buffer management & init module
obj_module_opcode.mega_module = module_default;

/*** xcustom mega module ports & these port order should be same as deploy file*********/

Port_info port_defualt;
port_defualt.port_width=XI_128BIT_WIDTH;
port_defualt.data_type = XI_INT8;
port_defualt.size_datatype = XI_INT8_S;
port_defualt.memory_align_required=32; // TODO need to check with buffer management & init module
port_defualt.memory_map_info = __MALLOC_TYPE;
port_defualt.port_enum=XI_INPUT;
port_defualt.qant_scheme_type = g_quant_value;


packinfo input_pack;

input_pack.dim = XI_CHANNEL;
input_pack.mem_contiguous = true;
input_pack.mod_div_factor = (port_defualt.port_width/port_defualt.size_datatype)/batch_size;
input_pack.sep=XI_DIVISION;

port_defualt.pack_info_vec.push_back(input_pack);

input_pack.dim = XI_HEIGHT;
input_pack.mem_contiguous = true;
input_pack.mod_div_factor = 0;
input_pack.sep=XI_NONE;

port_defualt.pack_info_vec.push_back(input_pack);

input_pack.dim = XI_WIDTH;
input_pack.mem_contiguous = true;
input_pack.mod_div_factor = 0;
input_pack.sep=XI_NONE;

port_defualt.pack_info_vec.push_back(input_pack);

input_pack.dim = XI_INTERLEAVED;
input_pack.mem_contiguous = true;
input_pack.mod_div_factor = (port_defualt.port_width/port_defualt.size_datatype)/batch_size;
input_pack.sep=XI_MODULO;
port_defualt.pack_info_vec.push_back(input_pack);

input_pack.dim = XI_BATCH;
input_pack.mem_contiguous = true;
input_pack.mod_div_factor = 0;
input_pack.sep=XI_NONE;

port_defualt.pack_info_vec.push_back(input_pack);

obj_module_opcode.port_vec.push_back(port_defualt);


packinfo input_pack1;
Port_info port_defualt2;
port_defualt2.port_width=XI_128BIT_WIDTH;
port_defualt2.data_type = XI_INT8;
port_defualt2.size_datatype = XI_INT8_S;
port_defualt2.memory_align_required=32; // TODO need to check with buffer management & init module
port_defualt2.memory_map_info = __MALLOC_TYPE;
port_defualt2.port_enum=XI_INPUT;
port_defualt2.qant_scheme_type = g_quant_value;

input_pack1.dim = XI_CHANNEL;
input_pack1.mem_contiguous = true;
input_pack1.mod_div_factor = (port_defualt2.port_width/port_defualt2.size_datatype)/batch_size;
input_pack1.sep=XI_DIVISION;

port_defualt2.pack_info_vec.push_back(input_pack1);

input_pack1.dim = XI_HEIGHT;
input_pack1.mem_contiguous = true;
input_pack1.mod_div_factor = 0;
input_pack1.sep=XI_NONE;

port_defualt2.pack_info_vec.push_back(input_pack1);

input_pack1.dim = XI_WIDTH;
input_pack1.mem_contiguous = true;
input_pack1.mod_div_factor = 0;
input_pack1.sep=XI_NONE;

port_defualt2.pack_info_vec.push_back(input_pack1);

input_pack1.dim = XI_INTERLEAVED;
input_pack1.mem_contiguous = true;
input_pack1.mod_div_factor = (port_defualt2.port_width/port_defualt2.size_datatype)/batch_size;
input_pack1.sep=XI_MODULO;
port_defualt2.pack_info_vec.push_back(input_pack1);

input_pack1.dim = XI_BATCH;
input_pack1.mem_contiguous = true;
input_pack1.mod_div_factor = 0;
input_pack1.sep=XI_NONE;

port_defualt2.pack_info_vec.push_back(input_pack1);
obj_module_opcode.port_vec.push_back(port_defualt2);

Port_info port_defualt1;
port_defualt1.port_width=XI_128BIT_WIDTH;
port_defualt1.data_type = XI_INT8;
port_defualt1.size_datatype = XI_INT8_S;
port_defualt1.memory_align_required=32; // TODO need to check with buffer management & init module
port_defualt1.memory_map_info = __MALLOC_TYPE;
port_defualt1.port_enum=XI_OUTPUT;
port_defualt1.qant_scheme_type = g_quant_value;

packinfo output_pack0;

output_pack0.dim = XI_CHANNEL;
output_pack0.mem_contiguous = true;
output_pack0.mod_div_factor = (port_defualt1.port_width/port_defualt1.size_datatype)/batch_size;
output_pack0.sep=XI_DIVISION;

port_defualt1.pack_info_vec.push_back(output_pack0);

output_pack0.dim = XI_HEIGHT;
output_pack0.mem_contiguous = true;
output_pack0.mod_div_factor = 0;
output_pack0.sep=XI_NONE;

port_defualt1.pack_info_vec.push_back(output_pack0);

output_pack0.dim = XI_WIDTH;
output_pack0.mem_contiguous = true;
output_pack0.mod_div_factor = 0;
output_pack0.sep=XI_NONE;

port_defualt1.pack_info_vec.push_back(output_pack0);

output_pack0.dim = XI_INTERLEAVED;
output_pack0.mem_contiguous = true;
output_pack0.mod_div_factor = (port_defualt1.port_width/port_defualt1.size_datatype)/batch_size;
output_pack0.sep=XI_MODULO;

port_defualt1.pack_info_vec.push_back(output_pack0);

output_pack0.dim = XI_BATCH;
output_pack0.mem_contiguous = true;
output_pack0.mod_div_factor = 0;
output_pack0.sep=XI_NONE;

port_defualt1.pack_info_vec.push_back(output_pack0);
obj_module_opcode.port_vec.push_back(port_defualt1);


/****** OPCODE_SW_ELTWISE_ADD *******/
obj_module_opcode.op_code = OPCODE_SW_ELTWISE_ADD;
opcode_info_map[obj_module_opcode.op_code]=obj_module_opcode;
}
void update_sf_xpack_module_opcode_table(Opcode_info & obj_module_opcode,map<opcode_num_e, Opcode_info> & opcode_info_map,int batch_size){

Module_info module_default;
Expand Down Expand Up @@ -1823,12 +1982,16 @@ kernelInfo::kernelInfo()
update_l2normalize_module_opcode_table(opcde_l2normalize,opcode_info_map,batch_size);



Opcode_info opcde_sf_xpack;
update_sf_xpack_module_opcode_table(opcde_sf_xpack,opcode_info_map,batch_size);

Opcode_info permute_xunpack;
update_permute_xunpack_module_opcode_table(permute_xunpack,opcode_info_map,batch_size);

#if XI_DIET_CHAI_Z
Opcode_info opcde_sw_eltwise;
update_opcde_sw_eltwise_module_opcode_table(opcde_sw_eltwise,opcode_info_map,batch_size);
#endif
// opcode_info_info.insert()
//
// kernelinfo_func_keys.insert(pair<int, kernelfunction>(int(HW_CONV), &kernelInfo::kernelinfo_function));
Expand Down Expand Up @@ -1913,7 +2076,10 @@ kernelInfo::kernelInfo(string &quant_schem)

Opcode_info permute_xunpack;
update_permute_xunpack_module_opcode_table(permute_xunpack,opcode_info_map,batch_size);

#if XI_DIET_CHAI_Z
Opcode_info opcde_sw_eltwise;
update_opcde_sw_eltwise_module_opcode_table(opcde_sw_eltwise,opcode_info_map,batch_size);
#endif
// opcode_info_info.insert()
//
// kernelinfo_func_keys.insert(pair<int, kernelfunction>(int(HW_CONV), &kernelInfo::kernelinfo_function));
Expand Down
3 changes: 2 additions & 1 deletion software/common/kernelinfo_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ enum moudle_type {
SW_XPACK=104,
SW_XUNPACK=105,
SW_PERMUTE=106,
SW_L2NORMALIZE=107
SW_L2NORMALIZE=107,
SW_ELTWISE_ADD=108
};
typedef enum moudle_type _moudle_type_e;

Expand Down
12 changes: 10 additions & 2 deletions software/common/xi_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void ConvolutionForward(
istg_out1 = istg_out1 + scalar_conv_args[112];
#if !SINGLE_IO_PORT
input_other2 = input_other2 + scalar_conv_args[111];
istg_out2 = output2 + scalar_conv_args[112];
istg_out2 = istg_out2+ scalar_conv_args[112];
#endif
/*
if(loop_iter==(pool_split_cnt-2))
Expand All @@ -173,11 +173,12 @@ void ConvolutionForward(
scalar_conv_args[14] = scalar_conv_args[117];
scalar_conv_args[15] = scalar_conv_args[118];
}*/

/*
if(loop_iter==(pool_split_cnt-1))
{
scalar_conv_args[4] = scalar_conv_args[109];
}
*/
}

#ifdef __SDSOC
Expand Down Expand Up @@ -506,5 +507,12 @@ void XpackForward(void *input1, void *input2, void *output1, void *output2, stri
XpackWrapper(input1, input2, output1, output2, quant, params, float_params);
}

void EltwiseaddWrapper(IO_DATA_TYPE *input1, IO_DATA_TYPE *input2, IO_DATA_TYPE *input3, IO_DATA_TYPE *input4, IO_DATA_TYPE *output1, IO_DATA_TYPE *output2, int *params);

void EltwiseaddForward(void *input1, void *input2, void *input3, void *input4, void *output1, void *output2, int *params)
{
EltwiseaddWrapper((IO_DATA_TYPE *)input1, (IO_DATA_TYPE *)input2, (IO_DATA_TYPE *)input3, (IO_DATA_TYPE *)input4, (IO_DATA_TYPE *)output1, (IO_DATA_TYPE *)output2, params);
}


#endif//_XI_KERNELS_HPP_
1 change: 1 addition & 0 deletions software/common/xi_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ void CropForward(int *input, int *output, int *scalars);

void XpackForward(void *input1, void *input2, void *output1, void *output2, string quant, int *params, float *float_params);

void EltwiseaddForward(void *input1, void *input2, void *input3, void *input4, void *output1, void *output2, int *params);

#endif//_XI_KERNELS_H_
Loading

0 comments on commit 2ac2f2f

Please sign in to comment.