Merge branch 'ceccocats:master' into master
This commit is contained in:
@@ -166,6 +166,11 @@ Conv2d::Conv2d( Network *net, int out_ch, int kernelH, int kernelW,
|
||||
}
|
||||
initCUDNN(deConv);
|
||||
|
||||
if(this->groups != 1)
|
||||
MACC = kernelH*kernelW*output_dim.c*output_dim.w*output_dim.h;
|
||||
else
|
||||
MACC = input_dim.c*kernelH*kernelW*output_dim.c*output_dim.w*output_dim.h;
|
||||
|
||||
// allocate warkspace
|
||||
if (ws_sizeInBytes!=0) {
|
||||
checkCuda( cudaMalloc(&workSpace, ws_sizeInBytes) );
|
||||
|
||||
@@ -73,6 +73,12 @@ DeformConv2d::DeformConv2d( Network *net, int out_ch, int deformable_group, int
|
||||
|
||||
output_dim.c = out_ch;
|
||||
initCUDNN();
|
||||
|
||||
if(this->deformableGroup != 1)
|
||||
MACC = kernelH*kernelW*output_dim.c*output_dim.w*output_dim.h;
|
||||
else
|
||||
MACC = input_dim.c*kernelH*kernelW*output_dim.c*output_dim.w*output_dim.h;
|
||||
|
||||
//allocate data for infer result
|
||||
checkCuda( cudaMalloc(&dstData, output_dim.tot()*sizeof(dnnType)) );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ Layer::Layer(Network *net) {
|
||||
if(!net->addLayer(this))
|
||||
FatalError("Net reached max number of layers");
|
||||
}
|
||||
|
||||
feature_map_size = input_dim.tot() + output_dim.tot();
|
||||
}
|
||||
|
||||
Layer::~Layer() {
|
||||
|
||||
@@ -19,6 +19,8 @@ LayerWgs::LayerWgs(Network *net, int inputs, int outputs,
|
||||
int seek = 0;
|
||||
readBinaryFile(weights_path.c_str(), inputs*outputs*kh*kw*kl, &data_h, &data_d, seek);
|
||||
seek += inputs*outputs*kh*kw*kl;
|
||||
n_params = seek;
|
||||
|
||||
this->additional_bias = additional_bias;
|
||||
if(additional_bias) {
|
||||
readBinaryFile(weights_path.c_str(), outputs, &bias2_h, &bias2_d, seek);
|
||||
@@ -36,6 +38,7 @@ LayerWgs::LayerWgs(Network *net, int inputs, int outputs,
|
||||
readBinaryFile(weights_path.c_str(), outputs, &mean_h, &mean_d, seek);
|
||||
seek += outputs;
|
||||
readBinaryFile(weights_path.c_str(), outputs, &variance_h, &variance_d, seek);
|
||||
seek += outputs;
|
||||
|
||||
float eps = TKDNN_BN_MIN_EPSILON;
|
||||
|
||||
|
||||
@@ -96,6 +96,28 @@ dataDim_t Network::getOutputDim() {
|
||||
return layers[num_layers-1]->output_dim;
|
||||
}
|
||||
|
||||
void Network::adjustFeatureMapSizeWithShortcuts(){
|
||||
layerType_t layer_type;
|
||||
int shortcutted_idx;
|
||||
|
||||
for(int i=0; i<num_layers; i++) {
|
||||
layer_type = layers[i]->getLayerType();
|
||||
if(layer_type == LAYER_SHORTCUT){
|
||||
shortcutted_idx = -1;
|
||||
for(int j=0; j<num_layers; j++) {
|
||||
if(static_cast<tk::dnn::Shortcut*>(layers[i])->backLayer == layers[j]){
|
||||
shortcutted_idx = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(shortcutted_idx == -1)
|
||||
FatalError("Problem when computing featuer_map_size with shortcuts");
|
||||
for(int j=shortcutted_idx+1; j<i; ++j)
|
||||
layers[j]->feature_map_size += layers[shortcutted_idx]->output_dim.tot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Network::print() {
|
||||
|
||||
printCenteredTitle(" NETWORK MODEL ", '=', 60);
|
||||
@@ -106,10 +128,21 @@ void Network::print() {
|
||||
std::cout.width(16); std::cout<<std::left<<"output (H*W,CH)";
|
||||
std::cout<<"\n";
|
||||
|
||||
adjustFeatureMapSizeWithShortcuts();
|
||||
|
||||
long long unsigned int tot_params = 0;
|
||||
long long unsigned int max_feature_map_size = 0;
|
||||
long long unsigned int tot_MACC = 0;
|
||||
|
||||
for(int i=0; i<num_layers; i++) {
|
||||
dataDim_t in = layers[i]->input_dim;
|
||||
dataDim_t out = layers[i]->output_dim;
|
||||
|
||||
tot_params += layers[i]->n_params;
|
||||
tot_MACC += layers[i]->MACC;
|
||||
if(layers[i]->feature_map_size> max_feature_map_size)
|
||||
max_feature_map_size = layers[i]->feature_map_size;
|
||||
|
||||
std::cout.width(3); std::cout<<std::right<<i;
|
||||
std::cout<<" ";
|
||||
std::cout.width(16); std::cout<<std::left<<layers[i]->getLayerName();
|
||||
@@ -128,6 +161,9 @@ void Network::print() {
|
||||
}
|
||||
printCenteredTitle("", '=', 60);
|
||||
std::cout<<"\n";
|
||||
std::cout<<"N params: "<<tot_params<<std::endl;
|
||||
std::cout<<"Max feature map size: "<<max_feature_map_size<<std::endl;
|
||||
std::cout<<"N MACC: "<<tot_MACC<<std::endl<<std::endl;
|
||||
printCudaMemUsage();
|
||||
}
|
||||
const char *Network::getNetworkRTName(const char *network_name){
|
||||
|
||||
@@ -88,7 +88,6 @@ dnnType* Yolo::infer(dataDim_t &dim, dnnType* srcData) {
|
||||
for (int b = 0; b < dim.n; ++b){
|
||||
for(int n = 0; n < n_masks; ++n){
|
||||
int index = entry_index(b, n*dim.w*dim.h, 0, classes, input_dim, output_dim);
|
||||
std::cout<<"new_coords"<<new_coords<<std::endl;
|
||||
if (new_coords == 1){
|
||||
if (this->scaleXY != 1) scalAdd(dstData + index, 2 * dim.w*dim.h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
|
||||
}
|
||||
|
||||
+9
-7
@@ -92,7 +92,7 @@ void printDeviceVector(int size, dnnType* vec_d, bool device){
|
||||
delete [] vec;
|
||||
}
|
||||
|
||||
int checkResult(int size, dnnType *data_d, dnnType *correct_d, bool device, int limit) {
|
||||
int checkResult(int size, dnnType *data_d, dnnType *correct_d, bool device, int limit, bool verbose) {
|
||||
|
||||
dnnType *data_h, *correct_h;
|
||||
const float eps = 0.02f;
|
||||
@@ -127,13 +127,15 @@ int checkResult(int size, dnnType *data_d, dnnType *correct_d, bool device, int
|
||||
delete [] correct_h;
|
||||
}
|
||||
|
||||
std::cout<<" | ";
|
||||
if(diffs == 0)
|
||||
std::cout<<COL_GREENB<<"OK";
|
||||
else
|
||||
std::cout<<COL_REDB<<"Wrongs: "<<diffs;
|
||||
if(verbose){
|
||||
std::cout<<" | ";
|
||||
if(diffs == 0)
|
||||
std::cout<<COL_GREENB<<"OK";
|
||||
else
|
||||
std::cout<<COL_REDB<<"Wrongs: "<<diffs;
|
||||
|
||||
std::cout<<COL_END<<" ~"<<eps<<"\n";
|
||||
std::cout<<COL_END<<" ~"<<eps<<"\n";
|
||||
}
|
||||
return diffs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user