[coco] Introduce depth/height/width to FeatureLayout (#2056)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 31 Oct 2018 07:35:02 +0000 (16:35 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 31 Oct 2018 07:35:02 +0000 (16:35 +0900)
For consistency, this commit introduces depth/height/width method to
FeatureLayout class.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/FeatureLayout.h
contrib/coco/core/src/IR/FeatureLayouts.test.cpp

index a24fe0c..7fed189 100644 (file)
@@ -42,6 +42,10 @@ struct FeatureLayout
   virtual uint32_t batch(void) const = 0;
   virtual const FeatureShape &shape(void) const = 0;
 
+  uint32_t depth(void) const { return shape().depth(); }
+  uint32_t height(void) const { return shape().height(); }
+  uint32_t width(void) const { return shape().width(); }
+
   virtual ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const = 0;
 };
 
index 0233396..9f9772d 100644 (file)
@@ -31,6 +31,9 @@ TEST(FeatureLayoutsTest, BC)
   auto l = coco::FeatureLayouts::BC::create(feature::Shape{C, H, W});
 
   ASSERT_EQ(l->batch(), B);
+  ASSERT_EQ(l->depth(), C);
+  ASSERT_EQ(l->height(), H);
+  ASSERT_EQ(l->width(), W);
 
   // Check whether BC layout is actually channel-wise
   for (uint32_t b = 0; b < B; ++b)