From 3e61ae83e1ca43b019d612e8f7930a535e49bc76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=B2=9C=EA=B5=90/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 23 Oct 2019 09:02:07 +0900 Subject: [PATCH] [exo] Export TFLDepthwiseConv2D (#8396) This commit introduces export stage for TFLDepthwiseConv2D Signed-off-by: Cheongyo Bahk --- compiler/exo/src/TFLite/TFLOperationExporter.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/compiler/exo/src/TFLite/TFLOperationExporter.cpp b/compiler/exo/src/TFLite/TFLOperationExporter.cpp index e7edaf8..8f1299c 100644 --- a/compiler/exo/src/TFLite/TFLOperationExporter.cpp +++ b/compiler/exo/src/TFLite/TFLOperationExporter.cpp @@ -56,7 +56,7 @@ public: void visit(locoex::TFLConcatenation *) final; void visit(locoex::TFLConst *) final{/* skip, everything is done in exportOpDefinedTensors */}; void visit(locoex::TFLConv2D *) final; - // TODO TFLDepthwiseConv2D + void visit(locoex::TFLDepthwiseConv2D *) final; void visit(locoex::TFLDiv *) final; void visit(locoex::TFLMaxPool2D *) final; void visit(locoex::TFLMul *) final; @@ -173,7 +173,26 @@ void OperationExporter::visit(locoex::TFLConv2D *node) gd._operators.push_back(op_offset); } -// TODO TFLDepthwiseConv2D +void OperationExporter::visit(locoex::TFLDepthwiseConv2D *node) +{ + uint32_t op_idx = gd.registerBuiltinOpcode(tflite::BuiltinOperator_DEPTHWISE_CONV_2D); + + // Make input, output and options for operator + std::vector inputs_vec{get_tensor_index(node->input()), get_tensor_index(node->filter()), + get_tensor_index(node->bias())}; + std::vector outputs_vec{get_tensor_index(static_cast(node))}; + auto inputs = builder.CreateVector(inputs_vec); + auto outputs = builder.CreateVector(outputs_vec); + tflite::Padding padding = getOpPadding(node->padding()); + auto options = CreateDepthwiseConv2DOptions(builder, padding, node->stride()->w(), + node->stride()->h(), node->depthMultiplier(), + to_tflite_actfunc(node->fusedActivationFunction())); + + // Make DEPTHWISE_CONV_2D operator + auto op_offset = CreateOperator(builder, op_idx, inputs, outputs, + tflite::BuiltinOptions_DepthwiseConv2DOptions, options.Union()); + gd._operators.push_back(op_offset); +} void OperationExporter::visit(locoex::TFLDiv *node) { -- 2.7.4