[moco/tf] tidy FixShapeTransform logging (#4347)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 18 Jul 2019 10:36:10 +0000 (19:36 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 18 Jul 2019 10:36:10 +0000 (19:36 +0900)
This will make FixShapeTransform logging to use stream out of TensorShape, FilterShape and FeatureShape.
Also some tidy to match like other functions.

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/moco-tf/src/Transforms/FixShapeTransform.cpp

index 966ebb7..3d9518c 100644 (file)
@@ -83,6 +83,8 @@ bool copy_shapedata(const loco::Node *src, loco::Node *dst)
 
 bool fix_shape(loco::AvgPool2D *node)
 {
+  LOGGER(l);
+
   auto shapedata = node->annot<ShapeInferenceData>();
   if (shapedata != nullptr)
   {
@@ -143,15 +145,8 @@ bool fix_shape(loco::AvgPool2D *node)
   shape_data->feature_shape(ofm_feature_shape);
   node->annot(std::move(shape_data));
 
-  LOGGER(fixshape_avgpool2d);
-  INFO(fixshape_avgpool2d) << "Fix AvgPool2D shape = ifm(" << ifm_feature_shape.count().value()
-                           << "," << ifm_feature_shape.height().value() << ","
-                           << ifm_feature_shape.width().value() << ","
-                           << ifm_feature_shape.depth().value() << ") --> ofm("
-                           << ofm_feature_shape.count().value() << ","
-                           << ofm_feature_shape.height().value() << ","
-                           << ofm_feature_shape.width().value() << ","
-                           << ofm_feature_shape.depth().value() << ")" << std::endl;
+  INFO(l) << "Fix AvgPool2D shape = ifm" << ifm_feature_shape << " --> ofm" << ofm_feature_shape;
+
   return true;
 }
 
@@ -194,7 +189,7 @@ bool fix_shape(loco::ConstGen *node)
 
 bool fix_shape(loco::Conv2D *node)
 {
-  LOGGER(fixshape_conv2d);
+  LOGGER(l);
 
   auto shapedata = node->annot<ShapeInferenceData>();
   if (shapedata != nullptr)
@@ -264,18 +259,9 @@ bool fix_shape(loco::Conv2D *node)
   shape_data->feature_shape(ofm_feature_shape);
   node->annot(std::move(shape_data));
 
-  INFO(fixshape_conv2d) << "Fix Conv2D shape = ifm(" << ifm_feature_shape.count().value() << ","
-                        << ifm_feature_shape.height().value() << ","
-                        << ifm_feature_shape.width().value() << ","
-                        << ifm_feature_shape.depth().value() << "), "
-                        << "ker(" << ker_filter_shape.height().value() << ","
-                        << ker_filter_shape.width().value() << ","
-                        << ker_filter_shape.depth().value() << ","
-                        << ker_filter_shape.count().value() << ") "
-                        << "--> ofm(" << ofm_feature_shape.count().value() << ","
-                        << ofm_feature_shape.height().value() << ","
-                        << ofm_feature_shape.width().value() << ","
-                        << ofm_feature_shape.depth().value() << ")" << std::endl;
+  INFO(l) << "Fix Conv2D shape = ifm" << ifm_feature_shape << " ker" << ker_filter_shape
+          << " --> ofm" << ofm_feature_shape;
+
   return true;
 }
 
@@ -384,6 +370,8 @@ bool fix_shape(loco::Forward *node)
 
 bool fix_shape(loco::MaxPool2D *node)
 {
+  LOGGER(l);
+
   auto shapedata = node->annot<ShapeInferenceData>();
   if (shapedata != nullptr)
   {
@@ -444,15 +432,8 @@ bool fix_shape(loco::MaxPool2D *node)
   shape_data->feature_shape(ofm_feature_shape);
   node->annot(std::move(shape_data));
 
-  LOGGER(fixshape_maxpool2d);
-  INFO(fixshape_maxpool2d) << "Fix MaxPool2D shape = ifm(" << ifm_feature_shape.count().value()
-                           << "," << ifm_feature_shape.height().value() << ","
-                           << ifm_feature_shape.width().value() << ","
-                           << ifm_feature_shape.depth().value() << ") --> ofm("
-                           << ofm_feature_shape.count().value() << ","
-                           << ofm_feature_shape.height().value() << ","
-                           << ofm_feature_shape.width().value() << ","
-                           << ofm_feature_shape.depth().value() << ")" << std::endl;
+  INFO(l) << "Fix MaxPool2D shape = ifm" << ifm_feature_shape << " --> ofm" << ofm_feature_shape;
+
   return true;
 }
 
@@ -613,7 +594,7 @@ bool fix_shape(moco::tf::TFConst *node)
     LOGGER(l);
     auto shapedata = node->annot<ShapeInferenceData>();
     assert(shapedata != nullptr);
-    INFO(l) << "Fix ConstGen shape = " << shapedata->tensor_shape();
+    INFO(l) << "Fix TFConst shape = " << shapedata->tensor_shape();
   }
 
   return true;
@@ -671,7 +652,8 @@ bool fix_shape(moco::tf::TFConv2D *node)
 
   auto stride_data = node->annot<StrideData>();
   assert(stride_data != nullptr);
-  INFO(l) << "FixShape TFConv2D strides = " << stride_data->stride()->vertical() << ", "
+  // TODO add and use 'stride_data->stride()' stream out
+  INFO(l) << "Fix TFConv2D strides = " << stride_data->stride()->vertical() << ", "
           << stride_data->stride()->horizontal();
 
   auto ifm_tensor_shape = ifm_shapedata->tensor_shape(); // in NHWC
@@ -718,15 +700,9 @@ bool fix_shape(moco::tf::TFConv2D *node)
   shape_data->tensor_shape(ofm_tensor_shape);
   node->annot(std::move(shape_data));
 
-  INFO(l) << "Fix TFConv2D shape = ifm(" << ifm_tensor_shape.dim(0).value() << ","
-          << ifm_tensor_shape.dim(1).value() << "," << ifm_tensor_shape.dim(2).value() << ","
-          << ifm_tensor_shape.dim(3).value() << "), "
-          << "ker(" << ker_tensor_shape.dim(0).value() << "," << ker_tensor_shape.dim(1).value()
-          << "," << ker_tensor_shape.dim(2).value() << "," << ker_tensor_shape.dim(3).value()
-          << ") "
-          << "--> ofm(" << ofm_tensor_shape.dim(0).value() << "," << ofm_tensor_shape.dim(1).value()
-          << "," << ofm_tensor_shape.dim(2).value() << "," << ofm_tensor_shape.dim(3).value() << ")"
-          << std::endl;
+  INFO(l) << "Fix TFConv2D shape = ifm" << ifm_tensor_shape << " ker" << ker_tensor_shape
+          << " --> ofm" << ofm_tensor_shape;
+
   return true;
 }