From fd1ce0d037e888cd36fa9cd7ec96524bfe4618c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 28 Aug 2019 16:17:06 +0900 Subject: [PATCH] [moco-tf] make_shape_inference_data from T (#6980) This will introduce template make_shape_inference_data() that creates a copy of ShapeInferenceData from src Signed-off-by: SaeHie Park --- .../moco-tf/src/Transforms/FixShapeTransform.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp index 33f3832..2d6355b 100644 --- a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp +++ b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp @@ -65,6 +65,31 @@ template void copy_shape_values(const T *src, ShapeInferenceData *dst) } } +/** + * @brief Make copy of ShapeInferenceData from src + * + * @note T can be ShapeInferenceData or loco::Node based class having shape + * attributes like TFConst, COpCall and so on + */ +template std::unique_ptr make_shape_inference_data(const T *src) +{ + assert(src != nullptr); + + auto shape_data = stdex::make_unique(); + + uint32_t rank = src->rank(); + shape_data->rank(rank); + for (uint32_t index = 0; index < rank; ++index) + { + if (src->dim(index).known()) + shape_data->dim(index) = src->dim(index).value(); + else + shape_data->dim(index).unset(); + } + + return std::move(shape_data); +} + std::unique_ptr make_shape_inference_data(const loco::NodeShape &src) { auto shape_data = stdex::make_unique(); -- 2.7.4