summaryrefslogtreecommitdiff
path: root/compiler/tflite2circle
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/tflite2circle')
-rw-r--r--compiler/tflite2circle/CMakeLists.txt10
-rw-r--r--compiler/tflite2circle/requires.cmake4
-rw-r--r--compiler/tflite2circle/src/BuildBuiltinOptions.h1
-rw-r--r--compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.cpp32
-rw-r--r--compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.h31
-rw-r--r--compiler/tflite2circle/src/BuildBuiltinOptions/TransposeConvOptions.cpp2
-rw-r--r--compiler/tflite2circle/src/CircleModel.cpp34
-rw-r--r--compiler/tflite2circle/src/TFLBuiltinOptions.lst1
-rw-r--r--compiler/tflite2circle/src/TFLOperator.lst1
9 files changed, 101 insertions, 15 deletions
diff --git a/compiler/tflite2circle/CMakeLists.txt b/compiler/tflite2circle/CMakeLists.txt
index a317a6305..73639f390 100644
--- a/compiler/tflite2circle/CMakeLists.txt
+++ b/compiler/tflite2circle/CMakeLists.txt
@@ -1,8 +1,8 @@
nnas_include(TargetRequire)
unset(REQUIRED_TARGETS)
-list(APPEND REQUIRED_TARGETS mio_tflite280)
-list(APPEND REQUIRED_TARGETS mio_circle04)
+list(APPEND REQUIRED_TARGETS mio_tflite2121)
+list(APPEND REQUIRED_TARGETS mio_circle06)
TargetRequire_Return(${REQUIRED_TARGETS})
set(DRIVER "driver/Driver.cpp")
@@ -13,9 +13,9 @@ target_include_directories(tflite2circle PRIVATE src)
target_link_libraries(tflite2circle arser)
target_link_libraries(tflite2circle foder)
target_link_libraries(tflite2circle safemain)
-target_link_libraries(tflite2circle mio_tflite280)
-target_link_libraries(tflite2circle mio_tflite280_helper)
-target_link_libraries(tflite2circle mio_circle04)
+target_link_libraries(tflite2circle mio_tflite2121)
+target_link_libraries(tflite2circle mio_tflite2121_helper)
+target_link_libraries(tflite2circle mio_circle06)
target_link_libraries(tflite2circle vconone)
target_link_libraries(tflite2circle nncc_coverage)
diff --git a/compiler/tflite2circle/requires.cmake b/compiler/tflite2circle/requires.cmake
index 3db9a2f2a..c5528c28a 100644
--- a/compiler/tflite2circle/requires.cmake
+++ b/compiler/tflite2circle/requires.cmake
@@ -1,6 +1,6 @@
require("arser")
require("foder")
-require("mio-tflite280")
-require("mio-circle04")
+require("mio-tflite2121")
+require("mio-circle06")
require("safemain")
require("vconone")
diff --git a/compiler/tflite2circle/src/BuildBuiltinOptions.h b/compiler/tflite2circle/src/BuildBuiltinOptions.h
index 8149197f6..5ed88ce02 100644
--- a/compiler/tflite2circle/src/BuildBuiltinOptions.h
+++ b/compiler/tflite2circle/src/BuildBuiltinOptions.h
@@ -46,6 +46,7 @@
#include "BuildBuiltinOptions/FullyConnectedOptions.h"
#include "BuildBuiltinOptions/GatherOptions.h"
#include "BuildBuiltinOptions/GatherNdOptions.h"
+#include "BuildBuiltinOptions/GeluOptions.h"
#include "BuildBuiltinOptions/GreaterOptions.h"
#include "BuildBuiltinOptions/GreaterEqualOptions.h"
#include "BuildBuiltinOptions/IfOptions.h"
diff --git a/compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.cpp b/compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.cpp
new file mode 100644
index 000000000..92fcd6083
--- /dev/null
+++ b/compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "GeluOptions.h"
+
+namespace tflite2circle
+{
+
+flatbuffers::Offset<circle::GeluOptions>
+build_circle_GeluOptions(flatbuffers::FlatBufferBuilder &fb, const tflite::Operator *op)
+{
+ auto *tflite_builtin_options = op->builtin_options_as_GeluOptions();
+ assert(tflite_builtin_options);
+ circle::GeluOptionsBuilder builtin_options_builder{fb};
+ builtin_options_builder.add_approximate(tflite_builtin_options->approximate());
+ return builtin_options_builder.Finish();
+}
+
+} // namespace tflite2circle
diff --git a/compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.h b/compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.h
new file mode 100644
index 000000000..76955d795
--- /dev/null
+++ b/compiler/tflite2circle/src/BuildBuiltinOptions/GeluOptions.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __BBO_GELU_OPTIONS_H__
+#define __BBO_GELU_OPTIONS_H__
+
+#include <mio/tflite/schema_generated.h>
+#include <mio/circle/schema_generated.h>
+
+namespace tflite2circle
+{
+
+flatbuffers::Offset<circle::GeluOptions>
+build_circle_GeluOptions(flatbuffers::FlatBufferBuilder &fb, const tflite::Operator *op);
+
+} // namespace tflite2circle
+
+#endif // __BBO_GELU_OPTIONS_H__
diff --git a/compiler/tflite2circle/src/BuildBuiltinOptions/TransposeConvOptions.cpp b/compiler/tflite2circle/src/BuildBuiltinOptions/TransposeConvOptions.cpp
index 301f2c421..0873170f7 100644
--- a/compiler/tflite2circle/src/BuildBuiltinOptions/TransposeConvOptions.cpp
+++ b/compiler/tflite2circle/src/BuildBuiltinOptions/TransposeConvOptions.cpp
@@ -31,6 +31,8 @@ build_circle_TransposeConvOptions(flatbuffers::FlatBufferBuilder &fb, const tfli
builtin_options_builder.add_padding(get_circle_padding(tflite_builtin_options->padding()));
builtin_options_builder.add_stride_w(tflite_builtin_options->stride_w());
builtin_options_builder.add_stride_h(tflite_builtin_options->stride_h());
+ builtin_options_builder.add_fused_activation_function(
+ get_circle_activation_function_type(tflite_builtin_options->fused_activation_function()));
return builtin_options_builder.Finish();
}
diff --git a/compiler/tflite2circle/src/CircleModel.cpp b/compiler/tflite2circle/src/CircleModel.cpp
index ac017b8f1..899bc84f7 100644
--- a/compiler/tflite2circle/src/CircleModel.cpp
+++ b/compiler/tflite2circle/src/CircleModel.cpp
@@ -22,7 +22,7 @@
#include "CircleModel.h"
#include "DataLookup.h"
-#include <mio_tflite280/Helper.h>
+#include <mio_tflite2121/Helper.h>
namespace tflite2circle
{
@@ -344,13 +344,31 @@ template <> void Offset<OperatorCodeLink>::build(const TFLFlatBufVec *tflite_fla
circle::OperatorCodeBuilder operator_code_builder{*_fb};
auto de_code = it->deprecated_builtin_code();
auto bt_code = it->builtin_code();
- auto cir_de_code = get_circle_builtin_code(de_code);
- auto cir_bt_code = get_circle_builtin_code(bt_code);
- // correct bt_code where bt_code == 0 for old tflite format
- if (cir_bt_code == 0)
- cir_bt_code = static_cast<circle::BuiltinOperator>(cir_de_code);
- operator_code_builder.add_deprecated_builtin_code(cir_de_code);
- operator_code_builder.add_builtin_code(cir_bt_code);
+
+ // There are two builtin codes (deprecated_builtin, (extended) builtin)
+ // deprecated builtin code uses 0~126
+ // extended builtin code uses 127~
+ // NOTE 127 = BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES
+ if (de_code >= 0 and de_code < 127)
+ {
+ // Use deprecated builtin opcode.
+ auto cir_de_code = get_circle_builtin_code(de_code);
+ auto cir_bt_code = get_circle_builtin_code(bt_code);
+ // correct bt_code where bt_code == 0 for old tflite format
+ if (cir_bt_code == 0)
+ cir_bt_code = static_cast<circle::BuiltinOperator>(cir_de_code);
+ operator_code_builder.add_deprecated_builtin_code(cir_de_code);
+ operator_code_builder.add_builtin_code(cir_bt_code);
+ }
+ else
+ {
+ // Use extended builtin opcode
+ // Set 127 (PLACEHOLDER_FOR_GREATER_OP_CODES) for deprecated builtin code
+ auto cir_bt_code = get_circle_builtin_code(bt_code);
+ operator_code_builder.add_deprecated_builtin_code(
+ tflite::BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES);
+ operator_code_builder.add_builtin_code(cir_bt_code);
+ }
operator_code_builder.add_custom_code(custom_code);
operator_code_builder.add_version(it->version());
auto code = operator_code_builder.Finish();
diff --git a/compiler/tflite2circle/src/TFLBuiltinOptions.lst b/compiler/tflite2circle/src/TFLBuiltinOptions.lst
index 9cbf8032a..ac77c9abf 100644
--- a/compiler/tflite2circle/src/TFLBuiltinOptions.lst
+++ b/compiler/tflite2circle/src/TFLBuiltinOptions.lst
@@ -28,6 +28,7 @@ TFL_BUILTIN_OPTIONS(MulOptions)
TFL_BUILTIN_OPTIONS(PadOptions)
TFL_BUILTIN_OPTIONS(PadV2Options)
TFL_BUILTIN_OPTIONS(GatherOptions)
+TFL_BUILTIN_OPTIONS(GeluOptions)
TFL_BUILTIN_OPTIONS(BatchToSpaceNDOptions)
TFL_BUILTIN_OPTIONS(SpaceToBatchNDOptions)
TFL_BUILTIN_OPTIONS(TransposeOptions)
diff --git a/compiler/tflite2circle/src/TFLOperator.lst b/compiler/tflite2circle/src/TFLOperator.lst
index 72a29fce5..b7db49b0a 100644
--- a/compiler/tflite2circle/src/TFLOperator.lst
+++ b/compiler/tflite2circle/src/TFLOperator.lst
@@ -151,3 +151,4 @@ TFL_OPERATOR(READ_VARIABLE)
TFL_OPERATOR(ASSIGN_VARIABLE)
TFL_OPERATOR(BROADCAST_ARGS)
TFL_OPERATOR(RANDOM_STANDARD_NORMAL)
+TFL_OPERATOR(GELU)