[exo-tflite] Convert FeatureShape to ShapeDescription (#6254)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 6 Aug 2019 01:45:47 +0000 (10:45 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 6 Aug 2019 01:45:47 +0000 (10:45 +0900)
This commit introduces "to_shape_description" helper which constructs
ShapeDescription (which exo-tflite internally uses) from FeatureShape.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
compiler/exo-tflite/src/ExporterUtils.cpp
compiler/exo-tflite/src/ExporterUtils.h

index 891e413..bdb953f 100644 (file)
@@ -33,12 +33,30 @@ ShapeDescription to_shape_description(const loco::TensorShape &shape)
   return res;
 }
 
+ShapeDescription to_shape_description(const loco::FeatureShape &shape)
+{
+  ShapeDescription res;
+
+  res._rank_known = true;
+
+  // T/F Lite encodes a feature map as a NHWC tensor
+  res._dims.resize(4);
+  res._dims.at(0) = shape.count().value();
+  res._dims.at(1) = shape.height().value();
+  res._dims.at(2) = shape.width().value();
+  res._dims.at(3) = shape.depth().value();
+
+  return res;
+}
+
 ShapeDescription to_shape_description(const loco::NodeShape &shape)
 {
   switch (shape.domain())
   {
     case loco::Domain::Tensor:
       return to_shape_description(shape.as<loco::TensorShape>());
+    case loco::Domain::Feature:
+      return to_shape_description(shape.as<loco::FeatureShape>());
     default:
       break;
   }
index 4854fca..5a82ba7 100644 (file)
@@ -49,6 +49,7 @@ struct ShapeDescription
 };
 
 ShapeDescription to_shape_description(const loco::TensorShape &shape);
+ShapeDescription to_shape_description(const loco::FeatureShape &shape);
 ShapeDescription to_shape_description(const loco::NodeShape &shape);
 
 /**