give first top split blob same name as bottom blob
authorJeff Donahue <jeff.donahue@gmail.com>
Sun, 16 Feb 2014 00:00:44 +0000 (16:00 -0800)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Wed, 26 Feb 2014 22:41:27 +0000 (14:41 -0800)
src/caffe/test/test_split_layer.cpp
src/caffe/util/insert_splits.cpp

index 5d5a184..a3252b2 100644 (file)
@@ -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: { "
index 2638f8c..afbaf7f 100644 (file)
@@ -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