From 9b72c9472187d0978f83642a6770e35b09376337 Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Sat, 15 Feb 2014 16:00:44 -0800 Subject: [PATCH] give first top split blob same name as bottom blob --- src/caffe/test/test_split_layer.cpp | 14 ++++++++------ src/caffe/util/insert_splits.cpp | 16 ++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/caffe/test/test_split_layer.cpp b/src/caffe/test/test_split_layer.cpp index 5d5a184..a3252b2 100644 --- a/src/caffe/test/test_split_layer.cpp +++ b/src/caffe/test/test_split_layer.cpp @@ -123,6 +123,8 @@ class SplitLayerInsertionTest : public ::testing::Test { output_param_string, &expected_output_param)); NetParameter actual_output_param; insert_splits(input_param, &actual_output_param); + CHECK_EQ(expected_output_param.DebugString(), + actual_output_param.DebugString()); EXPECT_EQ(expected_output_param.DebugString(), actual_output_param.DebugString()); } @@ -275,7 +277,7 @@ TYPED_TEST(SplitLayerInsertionTest, TestInsertion) { " type: \"split\" " " } " " bottom: \"data\" " - " top: \"data_split_0\" " + " top: \"data\" " " top: \"data_split_1\" " " top: \"data_split_2\" " "} " @@ -284,7 +286,7 @@ TYPED_TEST(SplitLayerInsertionTest, TestInsertion) { " name: \"innerprod1\" " " type: \"inner_product\" " " } " - " bottom: \"data_split_0\" " + " bottom: \"data\" " " top: \"innerprod1\" " "} " "layers: { " @@ -301,7 +303,7 @@ TYPED_TEST(SplitLayerInsertionTest, TestInsertion) { " type: \"split\" " " } " " bottom: \"innerprod2\" " - " top: \"innerprod2_split_0\" " + " top: \"innerprod2\" " " top: \"innerprod2_split_1\" " "} " "layers: { " @@ -318,7 +320,7 @@ TYPED_TEST(SplitLayerInsertionTest, TestInsertion) { " type: \"euclidean_loss\" " " } " " bottom: \"innerprod1\" " - " bottom: \"innerprod2_split_0\" " + " bottom: \"innerprod2\" " "} " "layers: { " " layer { " @@ -376,7 +378,7 @@ TYPED_TEST(SplitLayerInsertionTest, TestInputInsertion) { " type: \"split\" " " } " " bottom: \"data\" " - " top: \"data_split_0\" " + " top: \"data\" " " top: \"data_split_1\" " "} " "layers: { " @@ -384,7 +386,7 @@ TYPED_TEST(SplitLayerInsertionTest, TestInputInsertion) { " name: \"innerprod1\" " " type: \"inner_product\" " " } " - " bottom: \"data_split_0\" " + " bottom: \"data\" " " top: \"innerprod1\" " "} " "layers: { " diff --git a/src/caffe/util/insert_splits.cpp b/src/caffe/util/insert_splits.cpp index 2638f8c..afbaf7f 100644 --- a/src/caffe/util/insert_splits.cpp +++ b/src/caffe/util/insert_splits.cpp @@ -91,12 +91,16 @@ void configure_split_layer(const string& blob_name, void get_split_blob_name(const string& blob_name, const int split_index, string* split_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; + if (split_index == 0) { + *split_blob_name = blob_name; + } else { + 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; + } } } // namespace caffe -- 2.7.4