get_split_blob_name returns a string to remove some verbosity

This commit is contained in:
Jeff Donahue 2014-02-16 03:18:39 -08:00 коммит произвёл Evan Shelhamer
Родитель 90c581dfc1
Коммит 00aca7ad98
2 изменённых файлов: 11 добавлений и 19 удалений

Просмотреть файл

@ -16,8 +16,7 @@ void insert_splits(const NetParameter& param, NetParameter* param_split);
void configure_split_layer(const string& blob_name,
const int split_count, LayerConnection* split_layer_connection);
void get_split_blob_name(const string& blob_name, const int split_index,
string* split_blob_name);
string get_split_blob_name(const string& blob_name, const int split_index);
} // namespace caffe

Просмотреть файл

@ -54,10 +54,8 @@ void insert_splits(const NetParameter& param, NetParameter* param_split) {
const string& blob_name = layer_connection->bottom(j);
const int split_count = blob_name_to_bottom_count[blob_name];
if (split_count > 1) {
string split_blob_name;
get_split_blob_name(blob_name,
blob_name_to_bottom_split_idx[blob_name]++, &split_blob_name);
layer_connection->set_bottom(j, split_blob_name);
layer_connection->set_bottom(j, get_split_blob_name(blob_name,
blob_name_to_bottom_split_idx[blob_name]++));
}
}
// Create split layer for any top blobs used by other layers as bottom
@ -82,24 +80,19 @@ void configure_split_layer(const string& blob_name,
split_layer_param->set_name(blob_name + "_split");
split_layer_param->set_type("split");
for (int k = 0; k < split_count; ++k) {
string split_blob_name;
get_split_blob_name(blob_name, k, &split_blob_name);
split_layer_connection->add_top(split_blob_name);
split_layer_connection->add_top(get_split_blob_name(blob_name, k));
}
}
void get_split_blob_name(const string& blob_name, const int split_index,
string* split_blob_name) {
string get_split_blob_name(const string& blob_name, const int split_index) {
if (split_index == 0) {
*split_blob_name = blob_name;
} else {
return blob_name;
}
const int suffix_max_length = 16;
char split_suffix[suffix_max_length];
const int suffix_length = snprintf(split_suffix, suffix_max_length,
"_split_%d", split_index);
CHECK_LT(suffix_length, suffix_max_length);
*split_blob_name = blob_name + split_suffix;
}
CHECK_LT(snprintf(split_suffix, suffix_max_length, "_split_%d", split_index),
suffix_max_length);
return blob_name + split_suffix;
}
} // namespace caffe