From: 박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 6 Aug 2019 01:45:47 +0000 (+0900) Subject: [exo-tflite] Convert FeatureShape to ShapeDescription (#6254) X-Git-Tag: submit/tizen/20190809.050447~133 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3282bb83b4c51a719c857fbee70a049fa05cf3d8;p=platform%2Fcore%2Fml%2Fnnfw.git [exo-tflite] Convert FeatureShape to ShapeDescription (#6254) This commit introduces "to_shape_description" helper which constructs ShapeDescription (which exo-tflite internally uses) from FeatureShape. Signed-off-by: Jonghyun Park --- diff --git a/compiler/exo-tflite/src/ExporterUtils.cpp b/compiler/exo-tflite/src/ExporterUtils.cpp index 891e413..bdb953f 100644 --- a/compiler/exo-tflite/src/ExporterUtils.cpp +++ b/compiler/exo-tflite/src/ExporterUtils.cpp @@ -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()); + case loco::Domain::Feature: + return to_shape_description(shape.as()); default: break; } diff --git a/compiler/exo-tflite/src/ExporterUtils.h b/compiler/exo-tflite/src/ExporterUtils.h index 4854fca..5a82ba7 100644 --- a/compiler/exo-tflite/src/ExporterUtils.h +++ b/compiler/exo-tflite/src/ExporterUtils.h @@ -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); /**