[loco] add ctor of DepthwiseFilter PermutingEncoder (#6627)
author채성우/On-Device Lab(SR)/Engineer/삼성전자 <sw4670.chae@samsung.com>
Wed, 14 Aug 2019 10:15:46 +0000 (19:15 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 14 Aug 2019 10:15:46 +0000 (19:15 +0900)
This commit adds ctor of DepthwiseFilter PermutingEncoder.

Signed-off-by: seongwoo <sw4670.chae@samsung.com>
compiler/loco/include/loco/IR/PermutingCodec.h
compiler/loco/src/IR/PermutingCodec.test.cpp

index e9c7b6a..19d45b4 100644 (file)
@@ -233,6 +233,12 @@ public:
   PermutingEncoder() = default;
 
 public:
+  PermutingEncoder(const Permutation<Domain::DepthwiseFilter> &perm) : _perm{perm}
+  {
+    // DO NOTHING
+  }
+
+public:
   bool valid(void) const;
 
 public:
index 8c674b5..eb296d2 100644 (file)
@@ -314,6 +314,32 @@ TEST(PermutingEncoderTest, depthwise_filter)
   ASSERT_EQ(tensor_index.at(3), 2); // NTH(MULTIPLIER)
 }
 
+TEST(PermutingEncoderTest, dpethwisefilter_init)
+{
+  Permutation<Domain::DepthwiseFilter> src_perm;
+
+  src_perm.axis(DepthwiseFilterAxis::Multiplier) = 0;
+  src_perm.axis(DepthwiseFilterAxis::Depth) = 3;
+  src_perm.axis(DepthwiseFilterAxis::Height) = 1;
+  src_perm.axis(DepthwiseFilterAxis::Width) = 2;
+
+  PermutingEncoder<Domain::DepthwiseFilter> dst_enc{src_perm};
+  auto dst_perm = dst_enc.perm();
+
+  EXPECT_EQ(dst_perm->axis(DepthwiseFilterAxis::Multiplier),
+            src_perm.axis(DepthwiseFilterAxis::Multiplier));
+  EXPECT_EQ(dst_perm->axis(DepthwiseFilterAxis::Depth), src_perm.axis(DepthwiseFilterAxis::Depth));
+  EXPECT_EQ(dst_perm->axis(DepthwiseFilterAxis::Height),
+            src_perm.axis(DepthwiseFilterAxis::Height));
+  EXPECT_EQ(dst_perm->axis(DepthwiseFilterAxis::Width), src_perm.axis(DepthwiseFilterAxis::Width));
+
+  // Update on dst perm SHOULD NOT affect the src perm
+  dst_perm->axis(DepthwiseFilterAxis::Height) += 1;
+
+  EXPECT_EQ(src_perm.axis(DepthwiseFilterAxis::Height), 1);
+  EXPECT_EQ(dst_perm->axis(DepthwiseFilterAxis::Height), 2);
+}
+
 TEST(PermutingDecoderTest, feature)
 {
   PermutingDecoder<Domain::Feature> dec;