Add computation of #parameters, #MACC, and max feature map size in the tests
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user