From de99a7c02ebb549a6e3b212ea2a91e8405bcf51e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Wed, 12 Dec 2018 17:39:07 +0900 Subject: [PATCH] Update namespace and ifdef for tflite library (#3968) * Update namespace and ifdef for tflite library Make tflite/extend directory for ported codes from public tensorflow Update namespace except extended directory Update ifdef in header Signed-off-by: Hyeongseok Oh * Rename tflite/extend to tflite/ext * Fix format * Update ifdef in ext * Flatten namespace nnfw::tflite::interp to nnfw::tflite * Add comment for endif --- contrib/tf_test/tf_test.cpp | 8 +-- contrib/tflite_classify/src/InferenceInterface.cc | 4 +- contrib/tflite_classify/src/InferenceInterface.h | 4 +- libs/tflite/include/tflite/Assert.h | 6 +- libs/tflite/include/tflite/Diff.h | 12 ++-- libs/tflite/include/tflite/FeatureView.h | 9 +-- libs/tflite/include/tflite/InputIndex.h | 9 +-- libs/tflite/include/tflite/InterpreterSession.h | 9 +-- libs/tflite/include/tflite/NNAPISession.h | 11 ++-- libs/tflite/include/tflite/OutputIndex.h | 9 +-- libs/tflite/include/tflite/Quantization.h | 6 +- libs/tflite/include/tflite/Session.h | 9 +-- libs/tflite/include/tflite/TensorLogger.h | 9 +-- libs/tflite/include/tflite/TensorShapeUtils.h | 9 +-- libs/tflite/include/tflite/TensorUtils.h | 9 +-- libs/tflite/include/tflite/TensorView.h | 9 +-- libs/tflite/include/tflite/{ => ext}/kernels/Abs.h | 6 +- .../include/tflite/{ => ext}/kernels/CustomOps.h | 14 ++--- .../tflite/{ => ext}/kernels/SquaredDifference.h | 6 +- .../tflite/{ => ext}/kernels/TensorFlowMax.h | 6 +- .../tflite/{ => ext}/kernels/TensorFlowSum.h | 6 +- .../include/tflite/{ => ext}/kernels/register.h | 6 +- .../include/tflite/{ => ext}/nnapi_delegate.h | 8 +-- libs/tflite/include/tflite/interp/Builder.h | 12 +--- .../include/tflite/interp/FlatBufferBuilder.h | 12 +--- .../tflite/include/tflite/interp/FunctionBuilder.h | 12 +--- libs/tflite/src/Diff.cpp | 64 +++++++++++----------- libs/tflite/src/FeatureView.cpp | 3 - libs/tflite/src/TensorShapeUtils.cpp | 3 - libs/tflite/src/TensorView.test.cpp | 4 +- libs/tflite/src/{ => ext}/kernels/Abs.cpp | 2 +- .../src/{ => ext}/kernels/SquaredDifference.cpp | 2 +- .../tflite/src/{ => ext}/kernels/TensorFlowMax.cpp | 2 +- .../tflite/src/{ => ext}/kernels/TensorFlowSum.cpp | 2 +- libs/tflite/src/{ => ext}/kernels/register.cpp | 4 +- libs/tflite/src/{ => ext}/nnapi_delegate.cpp | 2 +- .../nnapi_delegate_ex_AddOpsAndParams_lambda.inc | 0 libs/tflite/src/interp/FlatBufferBuilder.cpp | 8 +-- libs/tflite/src/interp/FunctionBuilder.cpp | 6 -- tools/nnapi_test/src/nnapi_test.cc | 4 +- tools/tflite_benchmark/src/tflite_benchmark.cc | 12 ++-- .../benchmark_tflite_model.cc | 4 +- tools/tflite_examples/src/conv.cpp | 2 +- tools/tflite_run/src/tensor_loader.cc | 4 +- tools/tflite_run/src/tensor_loader.h | 4 +- tools/tflite_run/src/tflite_run.cc | 14 ++--- 46 files changed, 150 insertions(+), 216 deletions(-) rename libs/tflite/include/tflite/{ => ext}/kernels/Abs.h (89%) rename libs/tflite/include/tflite/{ => ext}/kernels/CustomOps.h (84%) rename libs/tflite/include/tflite/{ => ext}/kernels/SquaredDifference.h (92%) rename libs/tflite/include/tflite/{ => ext}/kernels/TensorFlowMax.h (93%) rename libs/tflite/include/tflite/{ => ext}/kernels/TensorFlowSum.h (88%) rename libs/tflite/include/tflite/{ => ext}/kernels/register.h (89%) rename libs/tflite/include/tflite/{ => ext}/nnapi_delegate.h (93%) rename libs/tflite/src/{ => ext}/kernels/Abs.cpp (98%) rename libs/tflite/src/{ => ext}/kernels/SquaredDifference.cpp (98%) rename libs/tflite/src/{ => ext}/kernels/TensorFlowMax.cpp (99%) rename libs/tflite/src/{ => ext}/kernels/TensorFlowSum.cpp (99%) rename libs/tflite/src/{ => ext}/kernels/register.cpp (99%) rename libs/tflite/src/{ => ext}/nnapi_delegate.cpp (99%) rename libs/tflite/src/{ => ext}/nnapi_delegate_ex_AddOpsAndParams_lambda.inc (100%) diff --git a/contrib/tf_test/tf_test.cpp b/contrib/tf_test/tf_test.cpp index 56ec1d2..20c5c58 100644 --- a/contrib/tf_test/tf_test.cpp +++ b/contrib/tf_test/tf_test.cpp @@ -21,7 +21,7 @@ #include "tflite/Session.h" #include "tflite/InterpreterSession.h" #include "tflite/NNAPISession.h" -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "util/fp32.h" @@ -114,15 +114,15 @@ int main(int argc, char **argv) auto lite_model = BuildModelFromFile(lite_model_path); auto lite_interp = BuildInterpFromModel(lite_model); - std::shared_ptr lite_sess; + std::shared_ptr lite_sess; if (use_nnapi) { - lite_sess = std::make_shared(lite_interp.get()); + lite_sess = std::make_shared(lite_interp.get()); } else { - lite_sess = std::make_shared(lite_interp.get()); + lite_sess = std::make_shared(lite_interp.get()); } // diff --git a/contrib/tflite_classify/src/InferenceInterface.cc b/contrib/tflite_classify/src/InferenceInterface.cc index 27d3382..1609434 100644 --- a/contrib/tflite_classify/src/InferenceInterface.cc +++ b/contrib/tflite_classify/src/InferenceInterface.cc @@ -31,11 +31,11 @@ InferenceInterface::InferenceInterface(const std::string &model_file, const bool if (use_nnapi) { - _sess = std::make_shared(_interpreter.get()); + _sess = std::make_shared(_interpreter.get()); } else { - _sess = std::make_shared(_interpreter.get()); + _sess = std::make_shared(_interpreter.get()); } _sess->prepare(); diff --git a/contrib/tflite_classify/src/InferenceInterface.h b/contrib/tflite_classify/src/InferenceInterface.h index b15a044..06ebb3d 100644 --- a/contrib/tflite_classify/src/InferenceInterface.h +++ b/contrib/tflite_classify/src/InferenceInterface.h @@ -23,7 +23,7 @@ #ifndef __TFLITE_CLASSIFY_INFERENCE_INTERFACE_H__ #define __TFLITE_CLASSIFY_INFERENCE_INTERFACE_H__ -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "tflite/InterpreterSession.h" @@ -87,7 +87,7 @@ public: private: std::unique_ptr _interpreter; std::unique_ptr _model; - std::shared_ptr _sess; + std::shared_ptr _sess; }; #endif // __TFLITE_CLASSIFY_INFERENCE_INTERFACE_H__ diff --git a/libs/tflite/include/tflite/Assert.h b/libs/tflite/include/tflite/Assert.h index ee19568..6d12d37 100644 --- a/libs/tflite/include/tflite/Assert.h +++ b/libs/tflite/include/tflite/Assert.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_ASSERT_H__ -#define __NNFW_SUPPORT_TFLITE_ASSERT_H__ +#ifndef __NNFW_TFLITE_ASSERT_H__ +#define __NNFW_TFLITE_ASSERT_H__ #include "tensorflow/contrib/lite/context.h" @@ -42,4 +42,4 @@ } \ } -#endif // __NNFW_SUPPORT_TFLITE_ASSERT_H__ +#endif // __NNFW_TFLITE_ASSERT_H__ diff --git a/libs/tflite/include/tflite/Diff.h b/libs/tflite/include/tflite/Diff.h index 45b7c9e..dc24964 100644 --- a/libs/tflite/include/tflite/Diff.h +++ b/libs/tflite/include/tflite/Diff.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_COMPARE_H__ -#define __NNFW_SUPPORT_TFLITE_COMPARE_H__ +#ifndef __NNFW_TFLITE_DIFF_H__ +#define __NNFW_TFLITE_DIFF_H__ #include "tensorflow/contrib/lite/interpreter.h" @@ -77,8 +77,8 @@ public: * @return @c true if two TensorView values are same, otherwise @c false */ template - bool compareSingleTensorView(const nnfw::support::tflite::TensorView &expected, - const nnfw::support::tflite::TensorView &obtained, int id) const; + bool compareSingleTensorView(const nnfw::tflite::TensorView &expected, + const nnfw::tflite::TensorView &obtained, int id) const; private: const nnfw::util::tensor::Comparator &_comparator; @@ -174,7 +174,7 @@ public: * @param[in] builder Interpreter Builder used to run * @return 0 if test succeeds, otherwise failure */ - int run(const nnfw::support::tflite::interp::Builder &builder); + int run(const nnfw::tflite::Builder &builder); public: /** @@ -196,4 +196,4 @@ public: static RandomTestRunner make(int seed); }; -#endif // __NNFW_SUPPORT_TFLITE_COMPARE_H__ +#endif // __NNFW_TFLITE_DIFF_H__ diff --git a/libs/tflite/include/tflite/FeatureView.h b/libs/tflite/include/tflite/FeatureView.h index b7266ca..992d26b 100644 --- a/libs/tflite/include/tflite/FeatureView.h +++ b/libs/tflite/include/tflite/FeatureView.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_FEATURE_VIEW_H__ -#define __NNFW_SUPPORT_TFLITE_FEATURE_VIEW_H__ +#ifndef __NNFW_TFLITE_FEATURE_VIEW_H__ +#define __NNFW_TFLITE_FEATURE_VIEW_H__ #include "tensorflow/contrib/lite/interpreter.h" @@ -33,8 +33,6 @@ namespace nnfw { -namespace support -{ namespace tflite { @@ -103,7 +101,6 @@ private: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_FEATURE_VIEW_H__ +#endif // __NNFW_TFLITE_FEATURE_VIEW_H__ diff --git a/libs/tflite/include/tflite/InputIndex.h b/libs/tflite/include/tflite/InputIndex.h index 3c66885..f535b26 100644 --- a/libs/tflite/include/tflite/InputIndex.h +++ b/libs/tflite/include/tflite/InputIndex.h @@ -20,13 +20,11 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_INPUT_INDEX_H__ -#define __NNFW_SUPPORT_TFLITE_INPUT_INDEX_H__ +#ifndef __NNFW_TFLITE_INPUT_INDEX_H__ +#define __NNFW_TFLITE_INPUT_INDEX_H__ namespace nnfw { -namespace support -{ namespace tflite { @@ -57,7 +55,6 @@ private: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_INPUT_INDEX_H__ +#endif // __NNFW_TFLITE_INPUT_INDEX_H__ diff --git a/libs/tflite/include/tflite/InterpreterSession.h b/libs/tflite/include/tflite/InterpreterSession.h index 70bac22..deaf05a 100644 --- a/libs/tflite/include/tflite/InterpreterSession.h +++ b/libs/tflite/include/tflite/InterpreterSession.h @@ -20,15 +20,13 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_INTERPRETER_SESSION_H__ -#define __NNFW_SUPPORT_TFLITE_INTERPRETER_SESSION_H__ +#ifndef __NNFW_TFLITE_INTERPRETER_SESSION_H__ +#define __NNFW_TFLITE_INTERPRETER_SESSION_H__ #include "Session.h" namespace nnfw { -namespace support -{ namespace tflite { @@ -96,7 +94,6 @@ private: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_INTERPRETER_SESSION_H__ +#endif // __NNFW_TFLITE_INTERPRETER_SESSION_H__ diff --git a/libs/tflite/include/tflite/NNAPISession.h b/libs/tflite/include/tflite/NNAPISession.h index 1c5e501..ec9fbd8 100644 --- a/libs/tflite/include/tflite/NNAPISession.h +++ b/libs/tflite/include/tflite/NNAPISession.h @@ -20,16 +20,14 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_NNAPI_SESSION_H__ -#define __NNFW_SUPPORT_TFLITE_NNAPI_SESSION_H__ +#ifndef __NNFW_TFLITE_NNAPI_SESSION_H__ +#define __NNFW_TFLITE_NNAPI_SESSION_H__ #include "Session.h" -#include "tflite/nnapi_delegate.h" +#include "tflite/ext/nnapi_delegate.h" namespace nnfw { -namespace support -{ namespace tflite { @@ -98,7 +96,6 @@ private: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_NNAPI_SESSION_H__ +#endif // __NNFW_TFLITE_NNAPI_SESSION_H__ diff --git a/libs/tflite/include/tflite/OutputIndex.h b/libs/tflite/include/tflite/OutputIndex.h index d438416..dd1ca8d 100644 --- a/libs/tflite/include/tflite/OutputIndex.h +++ b/libs/tflite/include/tflite/OutputIndex.h @@ -20,13 +20,11 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_OUTPUT_INDEX_H__ -#define __NNFW_SUPPORT_TFLITE_OUTPUT_INDEX_H__ +#ifndef __NNFW_TFLITE_OUTPUT_INDEX_H__ +#define __NNFW_TFLITE_OUTPUT_INDEX_H__ namespace nnfw { -namespace support -{ namespace tflite { @@ -57,7 +55,6 @@ private: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_OUTPUT_INDEX_H__ +#endif // __NNFW_TFLITE_OUTPUT_INDEX_H__ diff --git a/libs/tflite/include/tflite/Quantization.h b/libs/tflite/include/tflite/Quantization.h index fb1b675..4a8a0f1 100644 --- a/libs/tflite/include/tflite/Quantization.h +++ b/libs/tflite/include/tflite/Quantization.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_QUANTIZATION_H__ -#define __NNFW_SUPPORT_TFLITE_QUANTIZATION_H__ +#ifndef __NNFW_TFLITE_QUANTIZATION_H__ +#define __NNFW_TFLITE_QUANTIZATION_H__ /** * @brief Union to provide bitwise conversion of integer and float @@ -41,4 +41,4 @@ static const float FLOAT_NEAREST_TO_1 = BitwiseIntToFloat{0x3f7fffff}.f; */ TfLiteQuantizationParams make_default_quantization(void); -#endif // __NNFW_SUPPORT_TFLITE_QUANTIZATION_H__ +#endif // __NNFW_TFLITE_QUANTIZATION_H__ diff --git a/libs/tflite/include/tflite/Session.h b/libs/tflite/include/tflite/Session.h index 0385208..4f2e5c5 100644 --- a/libs/tflite/include/tflite/Session.h +++ b/libs/tflite/include/tflite/Session.h @@ -20,15 +20,13 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_SESSION_H__ -#define __NNFW_SUPPORT_TFLITE_SESSION_H__ +#ifndef __NNFW_TFLITE_SESSION_H__ +#define __NNFW_TFLITE_SESSION_H__ #include namespace nnfw { -namespace support -{ namespace tflite { @@ -66,7 +64,6 @@ struct Session }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_INTERP_SESSION_H__ +#endif // __NNFW_TFLITE_INTERP_SESSION_H__ diff --git a/libs/tflite/include/tflite/TensorLogger.h b/libs/tflite/include/tflite/TensorLogger.h index 9af5ffe..d5e19c7 100644 --- a/libs/tflite/include/tflite/TensorLogger.h +++ b/libs/tflite/include/tflite/TensorLogger.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_TENSOR_LOGGER_H__ -#define __NNFW_SUPPORT_TFLITE_TENSOR_LOGGER_H__ +#ifndef __NNFW_TFLITE_TENSOR_LOGGER_H__ +#define __NNFW_TFLITE_TENSOR_LOGGER_H__ #include "util/tensor/IndexIterator.h" #include "tflite/TensorView.h" @@ -33,8 +33,6 @@ namespace nnfw { -namespace support -{ namespace tflite { @@ -165,7 +163,6 @@ private: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_TENSOR_LOGGER_H__ +#endif // __NNFW_TFLITE_TENSOR_LOGGER_H__ diff --git a/libs/tflite/include/tflite/TensorShapeUtils.h b/libs/tflite/include/tflite/TensorShapeUtils.h index 99b90e9..7a3f72d 100644 --- a/libs/tflite/include/tflite/TensorShapeUtils.h +++ b/libs/tflite/include/tflite/TensorShapeUtils.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_TENSOR_SHAPE_UTILS_H__ -#define __NNFW_SUPPORT_TFLITE_TENSOR_SHAPE_UTILS_H__ +#ifndef __NNFW_TFLITE_TENSOR_SHAPE_UTILS_H__ +#define __NNFW_TFLITE_TENSOR_SHAPE_UTILS_H__ #include "util/tensor/Shape.h" @@ -29,8 +29,6 @@ namespace nnfw { -namespace support -{ namespace tflite { @@ -61,7 +59,6 @@ nnfw::util::tensor::Shape broadcast(const nnfw::util::tensor::Shape &lhs_shape, const nnfw::util::tensor::Shape &rhs_shape); } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_TENSOR_SHAPE_UTILS_H__ +#endif // __NNFW_TFLITE_TENSOR_SHAPE_UTILS_H__ diff --git a/libs/tflite/include/tflite/TensorUtils.h b/libs/tflite/include/tflite/TensorUtils.h index b454453..6266c5d 100644 --- a/libs/tflite/include/tflite/TensorUtils.h +++ b/libs/tflite/include/tflite/TensorUtils.h @@ -20,15 +20,13 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_TENSOR_UTILS_H__ -#define __NNFW_SUPPORT_TFLITE_TENSOR_UTILS_H__ +#ifndef __NNFW_TFLITE_TENSOR_UTILS_H__ +#define __NNFW_TFLITE_TENSOR_UTILS_H__ #include namespace nnfw { -namespace support -{ namespace tflite { @@ -51,7 +49,6 @@ inline bool isFeatureTensor(const TfLiteTensor *tensor) } } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_TENSOR_UTILS_H__ +#endif // __NNFW_TFLITE_TENSOR_UTILS_H__ diff --git a/libs/tflite/include/tflite/TensorView.h b/libs/tflite/include/tflite/TensorView.h index 97216e4..3e0c2fb 100644 --- a/libs/tflite/include/tflite/TensorView.h +++ b/libs/tflite/include/tflite/TensorView.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_TENSOR_VIEW_H__ -#define __NNFW_SUPPORT_TFLITE_TENSOR_VIEW_H__ +#ifndef __NNFW_TFLITE_TENSOR_VIEW_H__ +#define __NNFW_TFLITE_TENSOR_VIEW_H__ #include "tensorflow/contrib/lite/interpreter.h" @@ -32,8 +32,6 @@ namespace nnfw { -namespace support -{ namespace tflite { @@ -117,7 +115,6 @@ public: }; } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_TENSOR_VIEW_H__ +#endif // __NNFW_TFLITE_TENSOR_VIEW_H__ diff --git a/libs/tflite/include/tflite/kernels/Abs.h b/libs/tflite/include/tflite/ext/kernels/Abs.h similarity index 89% rename from libs/tflite/include/tflite/kernels/Abs.h rename to libs/tflite/include/tflite/ext/kernels/Abs.h index aaf96ae..4ea8569 100644 --- a/libs/tflite/include/tflite/kernels/Abs.h +++ b/libs/tflite/include/tflite/ext/kernels/Abs.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __NNFW_SUPPORT_TFLITE_KERNELS_ABS_H__ -#define __NNFW_SUPPORT_TFLITE_KERNELS_ABS_H__ +#ifndef __NNFW_TFLITE_EXT_KERNELS_ABS_H__ +#define __NNFW_TFLITE_EXT_KERNELS_ABS_H__ #include "tensorflow/contrib/lite/context.h" @@ -41,4 +41,4 @@ TfLiteStatus EvalAbs(TfLiteContext *context, TfLiteNode *node); } // namespace ops } // namespace tflite -#endif +#endif // __NNFW_TFLITE_EXT_KERNELS_ABS_H__ diff --git a/libs/tflite/include/tflite/kernels/CustomOps.h b/libs/tflite/include/tflite/ext/kernels/CustomOps.h similarity index 84% rename from libs/tflite/include/tflite/kernels/CustomOps.h rename to libs/tflite/include/tflite/ext/kernels/CustomOps.h index b106ca2..2642445 100644 --- a/libs/tflite/include/tflite/kernels/CustomOps.h +++ b/libs/tflite/include/tflite/ext/kernels/CustomOps.h @@ -20,14 +20,14 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_KERNELS_CUSTOM_OP_H__ -#define __NNFW_SUPPORT_TFLITE_KERNELS_CUSTOM_OP_H__ +#ifndef __NNFW_TFLITE_EXT_KERNELS_CUSTOM_OP_H__ +#define __NNFW_TFLITE_EXT_KERNELS_CUSTOM_OP_H__ #include "tensorflow/contrib/lite/context.h" -#include "tflite/kernels/TensorFlowMax.h" -#include "tflite/kernels/SquaredDifference.h" -#include "tflite/kernels/TensorFlowSum.h" -#include "tflite/kernels/Abs.h" +#include "tflite/ext/kernels/TensorFlowMax.h" +#include "tflite/ext/kernels/SquaredDifference.h" +#include "tflite/ext/kernels/TensorFlowSum.h" +#include "tflite/ext/kernels/Abs.h" namespace tflite { @@ -60,4 +60,4 @@ REGISTER_FUNCTION(Abs) } // namespace ops } // namespace tflite -#endif // __NNFW_SUPPORT_TFLITE_KERNELS_CUSTOM_OP_H__ +#endif // __NNFW_TFLITE_EXT_KERNELS_CUSTOM_OP_H__ diff --git a/libs/tflite/include/tflite/kernels/SquaredDifference.h b/libs/tflite/include/tflite/ext/kernels/SquaredDifference.h similarity index 92% rename from libs/tflite/include/tflite/kernels/SquaredDifference.h rename to libs/tflite/include/tflite/ext/kernels/SquaredDifference.h index 0ceb83b..9bf2936 100644 --- a/libs/tflite/include/tflite/kernels/SquaredDifference.h +++ b/libs/tflite/include/tflite/ext/kernels/SquaredDifference.h @@ -21,8 +21,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_KERNELS_SQUARED_DIFFERENCE_H__ -#define __NNFW_SUPPORT_TFLITE_KERNELS_SQUARED_DIFFERENCE_H__ +#ifndef __NNFW_TFLITE_EXT_KERNELS_SQUARED_DIFFERENCE_H__ +#define __NNFW_TFLITE_EXT_KERNELS_SQUARED_DIFFERENCE_H__ #include "tensorflow/contrib/lite/context.h" @@ -76,4 +76,4 @@ TfLiteStatus EvalSquaredDifference(TfLiteContext *context, TfLiteNode *node); } // namespace ops } // namespace tflite -#endif +#endif // __NNFW_TFLITE_EXT_KERNELS_SQUARED_DIFFERENCE_H__ diff --git a/libs/tflite/include/tflite/kernels/TensorFlowMax.h b/libs/tflite/include/tflite/ext/kernels/TensorFlowMax.h similarity index 93% rename from libs/tflite/include/tflite/kernels/TensorFlowMax.h rename to libs/tflite/include/tflite/ext/kernels/TensorFlowMax.h index 9cc8215..9fb8b73 100644 --- a/libs/tflite/include/tflite/kernels/TensorFlowMax.h +++ b/libs/tflite/include/tflite/ext/kernels/TensorFlowMax.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_KERNELS_TENSORFLOW_MAX_H__ -#define __NNFW_SUPPORT_TFLITE_KERNELS_TENSORFLOW_MAX_H__ +#ifndef __NNFW_TFLITE_EXT_KERNELS_TENSORFLOW_MAX_H__ +#define __NNFW_TFLITE_EXT_KERNELS_TENSORFLOW_MAX_H__ #include "tensorflow/contrib/lite/context.h" @@ -75,4 +75,4 @@ TfLiteStatus EvalTensorFlowMax(TfLiteContext *context, TfLiteNode *node); } // namespace ops } // namespace tflite -#endif +#endif // __NNFW_TFLITE_EXT_KERNELS_TENSORFLOW_MAX_H__ diff --git a/libs/tflite/include/tflite/kernels/TensorFlowSum.h b/libs/tflite/include/tflite/ext/kernels/TensorFlowSum.h similarity index 88% rename from libs/tflite/include/tflite/kernels/TensorFlowSum.h rename to libs/tflite/include/tflite/ext/kernels/TensorFlowSum.h index b1eff63..6479c92 100644 --- a/libs/tflite/include/tflite/kernels/TensorFlowSum.h +++ b/libs/tflite/include/tflite/ext/kernels/TensorFlowSum.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __NNFW_SUPPORT_TFLITE_KERNELS_TENSORFLOW_SUM_H__ -#define __NNFW_SUPPORT_TFLITE_KERNELS_TENSORFLOW_SUM_H__ +#ifndef __NNFW_TFLITE_EXT_KERNELS_TENSORFLOW_SUM_H__ +#define __NNFW_TFLITE_EXT_KERNELS_TENSORFLOW_SUM_H__ #include "tensorflow/contrib/lite/context.h" @@ -41,4 +41,4 @@ TfLiteStatus EvalTensorFlowSum(TfLiteContext *context, TfLiteNode *node); } // namespace ops } // namespace tflite -#endif +#endif // __NNFW_TFLITE_EXT_KERNELS_TENSORFLOW_SUM_H__ diff --git a/libs/tflite/include/tflite/kernels/register.h b/libs/tflite/include/tflite/ext/kernels/register.h similarity index 89% rename from libs/tflite/include/tflite/kernels/register.h rename to libs/tflite/include/tflite/ext/kernels/register.h index 389c351..b1884fe 100644 --- a/libs/tflite/include/tflite/kernels/register.h +++ b/libs/tflite/include/tflite/ext/kernels/register.h @@ -19,8 +19,8 @@ limitations under the License. // NOTE This header is derived from the following file (in TensorFlow) // 'externals/tensorflow/tensorflow/contrib/lite/kernels/register.h' -#ifndef __NNFW_SUPPORT_TFLITE_KERNELS_REGISTER_H__ -#define __NNFW_SUPPORT_TFLITE_KERNELS_REGISTER_H__ +#ifndef __NNFW_TFLITE_EXT_KERNELS_REGISTER_H__ +#define __NNFW_TFLITE_EXT_KERNELS_REGISTER_H__ #include #include "tensorflow/contrib/lite/context.h" @@ -40,6 +40,6 @@ class BuiltinOpResolver : public MutableOpResolver { } // namespace ops } // namespace tflite -#endif // __NNFW_SUPPORT_TFLITE_KERNELS_REGISTER_H__ +#endif // __NNFW_TFLITE_EXT_KERNELS_REGISTER_H__ // clang-format on diff --git a/libs/tflite/include/tflite/nnapi_delegate.h b/libs/tflite/include/tflite/ext/nnapi_delegate.h similarity index 93% rename from libs/tflite/include/tflite/nnapi_delegate.h rename to libs/tflite/include/tflite/ext/nnapi_delegate.h index b396d77..076975c 100644 --- a/libs/tflite/include/tflite/nnapi_delegate.h +++ b/libs/tflite/include/tflite/ext/nnapi_delegate.h @@ -19,8 +19,8 @@ limitations under the License. // NOTE This header is derived from the following file (in TensorFlow v1.12) // 'externals/tensorflow/tensorflow/contrib/lite/nnapi_delegate.h' -#ifndef __NNFW_SUPPORT_TFLITE_NNAPI_DELEGATE_H__ -#define __NNFW_SUPPORT_TFLITE_NNAPI_DELEGATE_H__ +#ifndef __NNFW_TFLITE_EXT_NNAPI_DELEGATE_H__ +#define __NNFW_TFLITE_EXT_NNAPI_DELEGATE_H__ #include "tensorflow/contrib/lite/allocation.h" #ifdef OBS_BUILD @@ -39,7 +39,7 @@ class ANeuralNetworksCompilation; namespace nnfw { -class NNAPIAllocation : public tflite::MMAPAllocation { +class NNAPIAllocation : public ::tflite::MMAPAllocation { public: NNAPIAllocation(const char* filename, ::tflite::ErrorReporter* error_reporter); ~NNAPIAllocation(); @@ -90,6 +90,6 @@ class NNAPIDelegate { } // namespace nnfw -#endif // TENSORFLOW_CONTRIB_LITE_NNAPI_DELEGATE_H_ +#endif // __NNFW_TFLITE_EXT_NNAPI_DELEGATE_H__ // clang-format on diff --git a/libs/tflite/include/tflite/interp/Builder.h b/libs/tflite/include/tflite/interp/Builder.h index 8bfceb6..b4d0824 100644 --- a/libs/tflite/include/tflite/interp/Builder.h +++ b/libs/tflite/include/tflite/interp/Builder.h @@ -20,19 +20,15 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_INTERP_BUILDER_H__ -#define __NNFW_SUPPORT_TFLITE_INTERP_BUILDER_H__ +#ifndef __NNFW_TFLITE_INTERP_BUILDER_H__ +#define __NNFW_TFLITE_INTERP_BUILDER_H__ #include namespace nnfw { -namespace support -{ namespace tflite { -namespace interp -{ /** * @brief Structure to Builder @@ -51,9 +47,7 @@ struct Builder virtual std::unique_ptr<::tflite::Interpreter> build(void) const = 0; }; -} // namespace interp } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_INTERP_BUILDER_H__ +#endif // __NNFW_TFLITE_INTERP_BUILDER_H__ diff --git a/libs/tflite/include/tflite/interp/FlatBufferBuilder.h b/libs/tflite/include/tflite/interp/FlatBufferBuilder.h index 2758686..13470b8 100644 --- a/libs/tflite/include/tflite/interp/FlatBufferBuilder.h +++ b/libs/tflite/include/tflite/interp/FlatBufferBuilder.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_INTERP_FLAT_BUFFER_BUILDER_H__ -#define __NNFW_SUPPORT_TFLITE_INTERP_FLAT_BUFFER_BUILDER_H__ +#ifndef __NNFW_TFLITE_INTERP_FLAT_BUFFER_BUILDER_H__ +#define __NNFW_TFLITE_INTERP_FLAT_BUFFER_BUILDER_H__ #include @@ -29,12 +29,8 @@ namespace nnfw { -namespace support -{ namespace tflite { -namespace interp -{ /** * @brief Class to define FlatBufferBuilder which is inherited from Builder @@ -62,9 +58,7 @@ private: const ::tflite::FlatBufferModel &_model; }; -} // namespace interp } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_INTERP_FLAT_BUFFER_BUILDER_H__ +#endif // __NNFW_TFLITE_INTERP_FLAT_BUFFER_BUILDER_H__ diff --git a/libs/tflite/include/tflite/interp/FunctionBuilder.h b/libs/tflite/include/tflite/interp/FunctionBuilder.h index bdf765d..0643759 100644 --- a/libs/tflite/include/tflite/interp/FunctionBuilder.h +++ b/libs/tflite/include/tflite/interp/FunctionBuilder.h @@ -20,8 +20,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __NNFW_SUPPORT_TFLITE_INTERP_FUNCTION_BUILDER_H__ -#define __NNFW_SUPPORT_TFLITE_INTERP_FUNCTION_BUILDER_H__ +#ifndef __NNFW_TFLITE_INTERP_FUNCTION_BUILDER_H__ +#define __NNFW_TFLITE_INTERP_FUNCTION_BUILDER_H__ #include @@ -29,12 +29,8 @@ namespace nnfw { -namespace support -{ namespace tflite { -namespace interp -{ /** * @brief Class to define FunctionBuilder which is inherited from Builder @@ -65,9 +61,7 @@ private: SetupFunc _fn; }; -} // namespace interp } // namespace tflite -} // namespace support } // namespace nnfw -#endif // __NNFW_SUPPORT_TFLITE_INTERP_FUNCTION_BUILDER_H__ +#endif // __NNFW_TFLITE_INTERP_FUNCTION_BUILDER_H__ diff --git a/libs/tflite/src/Diff.cpp b/libs/tflite/src/Diff.cpp index f2b4254..3759c66 100644 --- a/libs/tflite/src/Diff.cpp +++ b/libs/tflite/src/Diff.cpp @@ -15,7 +15,7 @@ */ #include "tflite/Diff.h" -#include "tflite/nnapi_delegate.h" +#include "tflite/ext/nnapi_delegate.h" #include "util/fp32.h" @@ -79,9 +79,9 @@ void DiffSummary::notify(const nnfw::util::tensor::Index &index, float expected, } template -bool TfLiteInterpMatchApp::compareSingleTensorView( - const nnfw::support::tflite::TensorView &expected, - const nnfw::support::tflite::TensorView &obtained, int id) const +bool TfLiteInterpMatchApp::compareSingleTensorView(const nnfw::tflite::TensorView &expected, + const nnfw::tflite::TensorView &obtained, + int id) const { std::vector> diffs; assert(expected.shape() == obtained.shape()); @@ -125,8 +125,8 @@ bool TfLiteInterpMatchApp::compareSingleTensorView( template <> bool TfLiteInterpMatchApp::compareSingleTensorView( - const nnfw::support::tflite::TensorView &expected, - const nnfw::support::tflite::TensorView &obtained, int id) const + const nnfw::tflite::TensorView &expected, + const nnfw::tflite::TensorView &obtained, int id) const { DiffSummary summary; @@ -206,32 +206,32 @@ bool TfLiteInterpMatchApp::run(::tflite::Interpreter &interp, ::tflite::Interpre comparators[kTfLiteUInt8] = [this](int id, ::tflite::Interpreter &interp, ::tflite::Interpreter &nnapi) { - const auto expected = nnfw::support::tflite::TensorView::make(interp, id); - const auto obtained = nnfw::support::tflite::TensorView::make(nnapi, id); + const auto expected = nnfw::tflite::TensorView::make(interp, id); + const auto obtained = nnfw::tflite::TensorView::make(nnapi, id); return compareSingleTensorView(expected, obtained, id); }; comparators[kTfLiteInt32] = [this](int id, ::tflite::Interpreter &interp, ::tflite::Interpreter &nnapi) { - const auto expected = nnfw::support::tflite::TensorView::make(interp, id); - const auto obtained = nnfw::support::tflite::TensorView::make(nnapi, id); + const auto expected = nnfw::tflite::TensorView::make(interp, id); + const auto obtained = nnfw::tflite::TensorView::make(nnapi, id); return compareSingleTensorView(expected, obtained, id); }; comparators[kTfLiteFloat32] = [this](int id, ::tflite::Interpreter &interp, ::tflite::Interpreter &nnapi) { - const auto expected = nnfw::support::tflite::TensorView::make(interp, id); - const auto obtained = nnfw::support::tflite::TensorView::make(nnapi, id); + const auto expected = nnfw::tflite::TensorView::make(interp, id); + const auto obtained = nnfw::tflite::TensorView::make(nnapi, id); return compareSingleTensorView(expected, obtained, id); }; comparators[kTfLiteBool] = [this](int id, ::tflite::Interpreter &interp, ::tflite::Interpreter &nnapi) { - const auto expected = nnfw::support::tflite::TensorView::make(interp, id); - const auto obtained = nnfw::support::tflite::TensorView::make(nnapi, id); + const auto expected = nnfw::tflite::TensorView::make(interp, id); + const auto obtained = nnfw::tflite::TensorView::make(nnapi, id); return compareSingleTensorView(expected, obtained, id); }; @@ -277,7 +277,7 @@ template <> uint8_t RandomGenerator::generate(void) // // Random Test Runner // -int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) +int RandomTestRunner::run(const nnfw::tflite::Builder &builder) { auto tfl_interp = builder.build(); auto nnapi = builder.build(); @@ -301,8 +301,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteInt32); assert(nnapi->tensor(id)->type == kTfLiteInt32); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -322,8 +322,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteInt32); assert(nnapi->tensor(id)->type == kTfLiteInt32); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -341,8 +341,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteUInt8); assert(nnapi->tensor(id)->type == kTfLiteUInt8); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -366,8 +366,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteUInt8); assert(nnapi->tensor(id)->type == kTfLiteUInt8); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -391,8 +391,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteFloat32); assert(nnapi->tensor(id)->type == kTfLiteFloat32); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -417,8 +417,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteFloat32); assert(nnapi->tensor(id)->type == kTfLiteFloat32); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -443,8 +443,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteBool); assert(nnapi->tensor(id)->type == kTfLiteBool); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -469,8 +469,8 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(tfl_interp->tensor(id)->type == kTfLiteBool); assert(nnapi->tensor(id)->type == kTfLiteBool); - auto tfl_interp_view = nnfw::support::tflite::TensorView::make(*tfl_interp, id); - auto nnapi_view = nnfw::support::tflite::TensorView::make(*nnapi, id); + auto tfl_interp_view = nnfw::tflite::TensorView::make(*tfl_interp, id); + auto nnapi_view = nnfw::tflite::TensorView::make(*nnapi, id); assert(tfl_interp_view.shape() == nnapi_view.shape()); @@ -579,7 +579,7 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) std::cout << "[NNAPI TEST] PASSED" << std::endl; if (_param.tensor_logging) - nnfw::support::tflite::TensorLogger::instance().save(_param.log_path, *tfl_interp); + nnfw::tflite::TensorLogger::instance().save(_param.log_path, *tfl_interp); return 0; } diff --git a/libs/tflite/src/FeatureView.cpp b/libs/tflite/src/FeatureView.cpp index 7b226ed..3b34ce4 100644 --- a/libs/tflite/src/FeatureView.cpp +++ b/libs/tflite/src/FeatureView.cpp @@ -21,8 +21,6 @@ namespace nnfw { -namespace support -{ namespace tflite { @@ -69,5 +67,4 @@ float &FeatureView::at(uint32_t ch, uint32_t row, uint32_t col) } } // namespace tflite -} // namespace support } // namespace nnfw diff --git a/libs/tflite/src/TensorShapeUtils.cpp b/libs/tflite/src/TensorShapeUtils.cpp index 3913748..1c8714e 100644 --- a/libs/tflite/src/TensorShapeUtils.cpp +++ b/libs/tflite/src/TensorShapeUtils.cpp @@ -2,8 +2,6 @@ namespace nnfw { -namespace support -{ namespace tflite { @@ -47,5 +45,4 @@ nnfw::util::tensor::Shape broadcast(const nnfw::util::tensor::Shape &lhs_shape, } } // namespace tflite -} // namespace support } // namespace nnfw diff --git a/libs/tflite/src/TensorView.test.cpp b/libs/tflite/src/TensorView.test.cpp index 0c461fe..61bc47e 100644 --- a/libs/tflite/src/TensorView.test.cpp +++ b/libs/tflite/src/TensorView.test.cpp @@ -23,7 +23,7 @@ void int_test(void) int value[6] = {1, 2, 3, 4, 5, 6}; const nnfw::util::tensor::Shape shape{2, 3}; - const nnfw::support::tflite::TensorView view{shape, value}; + const nnfw::tflite::TensorView view{shape, value}; assert(view.at(nnfw::util::tensor::Index{0, 0}) == 1); assert(view.at(nnfw::util::tensor::Index{0, 1}) == 2); @@ -38,7 +38,7 @@ int main(int argc, char **argv) float value[6] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}; const nnfw::util::tensor::Shape shape{2, 3}; - const nnfw::support::tflite::TensorView view{shape, value}; + const nnfw::tflite::TensorView view{shape, value}; assert(view.at(nnfw::util::tensor::Index{0, 0}) == 1.0f); assert(view.at(nnfw::util::tensor::Index{0, 1}) == 2.0f); diff --git a/libs/tflite/src/kernels/Abs.cpp b/libs/tflite/src/ext/kernels/Abs.cpp similarity index 98% rename from libs/tflite/src/kernels/Abs.cpp rename to libs/tflite/src/ext/kernels/Abs.cpp index 87f09de..047fead 100644 --- a/libs/tflite/src/kernels/Abs.cpp +++ b/libs/tflite/src/ext/kernels/Abs.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/Abs.h" +#include "tflite/ext/kernels/Abs.h" #include "tensorflow/contrib/lite/kernels/kernel_util.h" #include diff --git a/libs/tflite/src/kernels/SquaredDifference.cpp b/libs/tflite/src/ext/kernels/SquaredDifference.cpp similarity index 98% rename from libs/tflite/src/kernels/SquaredDifference.cpp rename to libs/tflite/src/ext/kernels/SquaredDifference.cpp index fda7436..9cecdeb 100644 --- a/libs/tflite/src/kernels/SquaredDifference.cpp +++ b/libs/tflite/src/ext/kernels/SquaredDifference.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/SquaredDifference.h" +#include "tflite/ext/kernels/SquaredDifference.h" #include "tensorflow/contrib/lite/kernels/kernel_util.h" #include diff --git a/libs/tflite/src/kernels/TensorFlowMax.cpp b/libs/tflite/src/ext/kernels/TensorFlowMax.cpp similarity index 99% rename from libs/tflite/src/kernels/TensorFlowMax.cpp rename to libs/tflite/src/ext/kernels/TensorFlowMax.cpp index 7a85bc8..2817175 100644 --- a/libs/tflite/src/kernels/TensorFlowMax.cpp +++ b/libs/tflite/src/ext/kernels/TensorFlowMax.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/TensorFlowMax.h" +#include "tflite/ext/kernels/TensorFlowMax.h" #include "tensorflow/contrib/lite/kernels/kernel_util.h" #include diff --git a/libs/tflite/src/kernels/TensorFlowSum.cpp b/libs/tflite/src/ext/kernels/TensorFlowSum.cpp similarity index 99% rename from libs/tflite/src/kernels/TensorFlowSum.cpp rename to libs/tflite/src/ext/kernels/TensorFlowSum.cpp index 1eba62f..da614ab 100644 --- a/libs/tflite/src/kernels/TensorFlowSum.cpp +++ b/libs/tflite/src/ext/kernels/TensorFlowSum.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/TensorFlowSum.h" +#include "tflite/ext/kernels/TensorFlowSum.h" #include "tensorflow/contrib/lite/kernels/kernel_util.h" #include diff --git a/libs/tflite/src/kernels/register.cpp b/libs/tflite/src/ext/kernels/register.cpp similarity index 99% rename from libs/tflite/src/kernels/register.cpp rename to libs/tflite/src/ext/kernels/register.cpp index 9757e4a..ed4cd2c 100644 --- a/libs/tflite/src/kernels/register.cpp +++ b/libs/tflite/src/ext/kernels/register.cpp @@ -16,8 +16,8 @@ limitations under the License. // NOTE This code is derived from the following file (in TensorFlow) // 'externals/tensorflow/tensorflow/contrib/lite/kernels/register.cc' -#include "tflite/kernels/register.h" -#include "tflite/kernels/CustomOps.h" +#include "tflite/ext/kernels/register.h" +#include "tflite/ext/kernels/CustomOps.h" // TODO Use namespace nnfw namespace tflite diff --git a/libs/tflite/src/nnapi_delegate.cpp b/libs/tflite/src/ext/nnapi_delegate.cpp similarity index 99% rename from libs/tflite/src/nnapi_delegate.cpp rename to libs/tflite/src/ext/nnapi_delegate.cpp index c196a7a..0cc5a74 100644 --- a/libs/tflite/src/nnapi_delegate.cpp +++ b/libs/tflite/src/ext/nnapi_delegate.cpp @@ -19,7 +19,7 @@ limitations under the License. // NOTE This code is derived from the following file (in TensorFlow v1.12) // 'externals/tensorflow/tensorflow/contrib/lite/nnapi_delegate.cc' -#include "tflite/nnapi_delegate.h" +#include "tflite/ext/nnapi_delegate.h" #include #include #include diff --git a/libs/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc b/libs/tflite/src/ext/nnapi_delegate_ex_AddOpsAndParams_lambda.inc similarity index 100% rename from libs/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc rename to libs/tflite/src/ext/nnapi_delegate_ex_AddOpsAndParams_lambda.inc diff --git a/libs/tflite/src/interp/FlatBufferBuilder.cpp b/libs/tflite/src/interp/FlatBufferBuilder.cpp index 87e022c..84246d3 100644 --- a/libs/tflite/src/interp/FlatBufferBuilder.cpp +++ b/libs/tflite/src/interp/FlatBufferBuilder.cpp @@ -16,16 +16,12 @@ #include "tflite/interp/FlatBufferBuilder.h" -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" namespace nnfw { -namespace support -{ namespace tflite { -namespace interp -{ std::unique_ptr<::tflite::Interpreter> FlatBufferBuilder::build(void) const { @@ -40,7 +36,5 @@ std::unique_ptr<::tflite::Interpreter> FlatBufferBuilder::build(void) const return std::move(interpreter); } -} // namespace interp } // namespace tflite -} // namespace support } // namespace nnfw diff --git a/libs/tflite/src/interp/FunctionBuilder.cpp b/libs/tflite/src/interp/FunctionBuilder.cpp index c06d86d..eab940c 100644 --- a/libs/tflite/src/interp/FunctionBuilder.cpp +++ b/libs/tflite/src/interp/FunctionBuilder.cpp @@ -18,12 +18,8 @@ namespace nnfw { -namespace support -{ namespace tflite { -namespace interp -{ std::unique_ptr<::tflite::Interpreter> FunctionBuilder::build(void) const { @@ -34,7 +30,5 @@ std::unique_ptr<::tflite::Interpreter> FunctionBuilder::build(void) const return std::move(res); } -} // namespace interp } // namespace tflite -} // namespace support } // namespace nnfw diff --git a/tools/nnapi_test/src/nnapi_test.cc b/tools/nnapi_test/src/nnapi_test.cc index 4a19087..31452b2 100644 --- a/tools/nnapi_test/src/nnapi_test.cc +++ b/tools/nnapi_test/src/nnapi_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "tflite/interp/FlatBufferBuilder.h" @@ -41,7 +41,7 @@ int main(const int argc, char **argv) auto model = FlatBufferModel::BuildFromFile(filename, &error_reporter); - const nnfw::support::tflite::interp::FlatBufferBuilder builder(*model); + const nnfw::tflite::FlatBufferBuilder builder(*model); try { diff --git a/tools/tflite_benchmark/src/tflite_benchmark.cc b/tools/tflite_benchmark/src/tflite_benchmark.cc index 03e7760..30400a3 100644 --- a/tools/tflite_benchmark/src/tflite_benchmark.cc +++ b/tools/tflite_benchmark/src/tflite_benchmark.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "tflite/Assert.h" @@ -126,15 +126,15 @@ int main(const int argc, char **argv) interpreter->SetNumThreads(thread_count); - std::shared_ptr sess; + std::shared_ptr sess; if (use_nnapi) { - sess = std::make_shared(interpreter.get()); + sess = std::make_shared(interpreter.get()); } else { - sess = std::make_shared(interpreter.get()); + sess = std::make_shared(interpreter.get()); } // @@ -152,7 +152,7 @@ int main(const int argc, char **argv) if (tensor->type == kTfLiteInt32) { // Generate singed 32-bit integer (s32) input - auto tensor_view = nnfw::support::tflite::TensorView::make(*interpreter, id); + auto tensor_view = nnfw::tflite::TensorView::make(*interpreter, id); int32_t value = 0; @@ -167,7 +167,7 @@ int main(const int argc, char **argv) else if (tensor->type == kTfLiteUInt8) { // Generate unsigned 8-bit integer input - auto tensor_view = nnfw::support::tflite::TensorView::make(*interpreter, id); + auto tensor_view = nnfw::tflite::TensorView::make(*interpreter, id); uint8_t value = 0; diff --git a/tools/tflite_benchmark_model/benchmark_tflite_model.cc b/tools/tflite_benchmark_model/benchmark_tflite_model.cc index a02cf53..c31b23c 100644 --- a/tools/tflite_benchmark_model/benchmark_tflite_model.cc +++ b/tools/tflite_benchmark_model/benchmark_tflite_model.cc @@ -42,7 +42,7 @@ limitations under the License. #ifdef TFLITE_FLEX #include "tensorflow/contrib/lite/delegates/flex/delegate.h" #endif // TFLITE_FLEX -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "tensorflow/contrib/lite/op_resolver.h" #include "tensorflow/contrib/lite/string_util.h" @@ -50,7 +50,7 @@ limitations under the License. // For profiling nnapi_delegate #include "util/profiling/profiling.h" -#include "tflite/nnapi_delegate.h" +#include "tflite/ext/nnapi_delegate.h" namespace { nnfw::NNAPIDelegate nnfw_delegate_; diff --git a/tools/tflite_examples/src/conv.cpp b/tools/tflite_examples/src/conv.cpp index 56f5d3e..43693b9 100644 --- a/tools/tflite_examples/src/conv.cpp +++ b/tools/tflite_examples/src/conv.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "tensorflow/contrib/lite/builtin_op_data.h" diff --git a/tools/tflite_run/src/tensor_loader.cc b/tools/tflite_run/src/tensor_loader.cc index 678ff08..6c1ad26 100644 --- a/tools/tflite_run/src/tensor_loader.cc +++ b/tools/tflite_run/src/tensor_loader.cc @@ -48,7 +48,7 @@ void TensorLoader::load(const std::string &filename) assert(tensor->bytes % sizeof(float) == 0); offset += (tensor->bytes / sizeof(float)); - _tensor_map.insert(std::make_pair(o, nnfw::support::tflite::TensorView(shape, base))); + _tensor_map.insert(std::make_pair(o, nnfw::tflite::TensorView(shape, base))); } // The file size and total output tensor size must match @@ -57,7 +57,7 @@ void TensorLoader::load(const std::string &filename) file.close(); } -const nnfw::support::tflite::TensorView &TensorLoader::get(int tensor_idx) const +const nnfw::tflite::TensorView &TensorLoader::get(int tensor_idx) const { auto found = _tensor_map.find(tensor_idx); assert(found != _tensor_map.end()); diff --git a/tools/tflite_run/src/tensor_loader.h b/tools/tflite_run/src/tensor_loader.h index 2d4fdb7..fc4a37a 100644 --- a/tools/tflite_run/src/tensor_loader.h +++ b/tools/tflite_run/src/tensor_loader.h @@ -21,13 +21,13 @@ class TensorLoader public: TensorLoader(tflite::Interpreter &interpreter); void load(const std::string &filename); - const nnfw::support::tflite::TensorView &get(int tensor_idx) const; + const nnfw::tflite::TensorView &get(int tensor_idx) const; size_t getNums() const { return _tensor_map.size(); } private: tflite::Interpreter &_interpreter; std::unique_ptr _raw_data; - std::unordered_map> _tensor_map; + std::unordered_map> _tensor_map; }; } // end of namespace TFLiteRun diff --git a/tools/tflite_run/src/tflite_run.cc b/tools/tflite_run/src/tflite_run.cc index 142ae1e..3fe870b 100644 --- a/tools/tflite_run/src/tflite_run.cc +++ b/tools/tflite_run/src/tflite_run.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite/kernels/register.h" +#include "tflite/ext/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "bin_image.h" @@ -75,15 +75,15 @@ int main(const int argc, char **argv) interpreter->SetNumThreads(1); }; - std::shared_ptr sess; + std::shared_ptr sess; if (use_nnapi) { - sess = std::make_shared(interpreter.get()); + sess = std::make_shared(interpreter.get()); } else { - sess = std::make_shared(interpreter.get()); + sess = std::make_shared(interpreter.get()); } sess->prepare(); @@ -127,7 +127,7 @@ int main(const int argc, char **argv) if (tensor->type == kTfLiteInt32) { // Generate singed 32-bit integer (s32) input - auto tensor_view = nnfw::support::tflite::TensorView::make(*interpreter, o); + auto tensor_view = nnfw::tflite::TensorView::make(*interpreter, o); int32_t value = 0; @@ -142,7 +142,7 @@ int main(const int argc, char **argv) else if (tensor->type == kTfLiteUInt8) { // Generate unsigned 8-bit integer input - auto tensor_view = nnfw::support::tflite::TensorView::make(*interpreter, o); + auto tensor_view = nnfw::tflite::TensorView::make(*interpreter, o); uint8_t value = 0; @@ -258,7 +258,7 @@ int main(const int argc, char **argv) for (const auto &o : interpreter->outputs()) { auto expected = tensor_loader.get(o); - auto obtained = nnfw::support::tflite::TensorView::make(*interpreter, o); + auto obtained = nnfw::tflite::TensorView::make(*interpreter, o); res = res && app.compareSingleTensorView(expected, obtained, o); } -- 2.7.4