summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/CMakeLists.txt6
-rw-r--r--contrib/README.md10
-rw-r--r--contrib/TFLiteSharp/README.md92
-rw-r--r--contrib/TFLiteSharp/TFLiteNative/CMakeLists.txt67
-rw-r--r--contrib/TFLiteSharp/TFLiteNative/include/tflite_log.h65
-rw-r--r--contrib/TFLiteSharp/TFLiteNative/include/tflite_nativewrapper.h56
-rw-r--r--contrib/TFLiteSharp/TFLiteNative/src/tflite_nativewrapper.cpp142
-rw-r--r--contrib/TFLiteSharp/TFLiteNative/tflite-native.pc.in13
-rw-r--r--contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp.sln25
-rw-r--r--contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.Libraries.cs23
-rw-r--r--contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.TFLite.cs37
-rw-r--r--contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/TFLiteSharp.csproj52
-rw-r--r--contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Datatype.cs31
-rw-r--r--contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Interpreter.cs263
-rw-r--r--contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest.sln31
-rw-r--r--contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/Program.cs38
-rw-r--r--contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/TFLiteSharpTest.csproj12
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp.csproj54
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_App.cs65
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_Main.cs20
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/res/mobilenet_v1_1.0_224.tflitebin16900960 -> 0 bytes
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/res/mouse1.bmpbin2764854 -> 0 bytes
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/res/mouse_224.bmpbin150582 -> 0 bytes
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/shared/res/TFLiteTestApp.pngbin10097 -> 0 bytes
-rw-r--r--contrib/TFLiteSharp/TFLiteTestApp/tizen-manifest.xml14
-rw-r--r--contrib/TFLiteSharp/packaging/TFLiteSharp.manifest5
-rw-r--r--contrib/TFLiteSharp/packaging/TFLiteSharp.spec103
-rw-r--r--contrib/TFLiteSharp/packaging/tflite-native.manifest5
-rw-r--r--contrib/benchmark_acl/CMakeLists.txt24
-rw-r--r--contrib/benchmark_acl/src/Benchmark.cpp74
-rw-r--r--contrib/benchmark_acl/src/Benchmark.h82
-rw-r--r--contrib/benchmark_acl/src/benchmark_googlenet.cpp242
-rw-r--r--contrib/benchmark_acl/src/benchmark_inception_v3.cpp891
-rw-r--r--contrib/benchmark_acl/src/benchmark_mobilenet.cpp265
-rw-r--r--contrib/detection/CMakeLists.txt11
-rw-r--r--contrib/detection/detection.cpp73
-rw-r--r--contrib/labs/CMakeLists.txt5
-rw-r--r--contrib/labs/jniacl/CMakeLists.txt18
-rw-r--r--contrib/labs/jniacl/src/io_accessor.cc100
-rw-r--r--contrib/labs/jniacl/src/io_accessor.h93
-rw-r--r--contrib/labs/jniacl/src/jniacl_main.cc39
-rw-r--r--contrib/labs/kerneltesting/CMakeLists.txt19
-rw-r--r--contrib/labs/kerneltesting/conv2d/CMakeLists.txt15
-rw-r--r--contrib/labs/kerneltesting/conv2d/OperationUtils.h90
-rw-r--r--contrib/labs/kerneltesting/conv2d/common.h89
-rw-r--r--contrib/labs/kerneltesting/conv2d/compatibility.h78
-rw-r--r--contrib/labs/kerneltesting/conv2d/io_accessor.cpp124
-rw-r--r--contrib/labs/kerneltesting/conv2d/io_accessor.h104
-rw-r--r--contrib/labs/kerneltesting/conv2d/nnfw_conv2d_test.cpp607
-rw-r--r--contrib/labs/kerneltesting/conv2d/optimized_ops.h339
-rw-r--r--contrib/labs/kerneltesting/conv2d/types.h146
-rw-r--r--contrib/labs/opencl_test/CMakeLists.txt12
-rw-r--r--contrib/labs/opencl_test/README.md8
-rw-r--r--contrib/labs/opencl_test/src/opencl_test.cc397
-rw-r--r--contrib/labs/tflite_examples/CMakeLists.txt2
-rw-r--r--contrib/labs/tflite_examples/src/conv.cpp330
-rw-r--r--contrib/tflite_classify/.FORMATCHECKED0
-rw-r--r--contrib/tflite_classify/CMakeLists.txt22
-rw-r--r--contrib/tflite_classify/src/ImageClassifier.cc107
-rw-r--r--contrib/tflite_classify/src/ImageClassifier.h99
-rw-r--r--contrib/tflite_classify/src/InferenceInterface.cc114
-rw-r--r--contrib/tflite_classify/src/InferenceInterface.h93
-rw-r--r--contrib/tflite_classify/src/tflite_classify.cc132
-rw-r--r--contrib/tflite_test/CMakeLists.txt16
-rw-r--r--contrib/tflite_test/tflite_test.cpp236
65 files changed, 0 insertions, 6325 deletions
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
deleted file mode 100644
index 78417eacb..000000000
--- a/contrib/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-file(GLOB CONTRIB_CMAKE_FILES "*/CMakeLists.txt")
-
-foreach(CONTRIB_CMAKE_FILE ${CONTRIB_CMAKE_FILES})
- get_filename_component(CONTRIB_BASE ${CONTRIB_CMAKE_FILE} DIRECTORY)
- add_subdirectory(${CONTRIB_BASE})
-endforeach(CONTRIB_CMAKE_FILE ${CONTRIB_CMAKE_FILES})
diff --git a/contrib/README.md b/contrib/README.md
deleted file mode 100644
index 2f8b709eb..000000000
--- a/contrib/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# nnfw contrib
-
-The `contrib` directory is basically a contribution channel where contributors can create a project
-and start the code development. The projects in the `contrib` directory may not be directly related
-to `nnfw` but should have its own purpose that could augment the nnfw project.
-
-If you are interested in proposing a new project, please create a pull request (PR) with a new
-project directory under `contrib` including the description of proposing project. The PR will be
-reviewed by reviewers in `nnfw`, and the acceptance of new project will be determined based on the
-PR reviews.
diff --git a/contrib/TFLiteSharp/README.md b/contrib/TFLiteSharp/README.md
deleted file mode 100644
index 8e43be618..000000000
--- a/contrib/TFLiteSharp/README.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# C-Sharp TFLite API Directory structure
-```
-.
-├── packaging
-│   ├── TFLiteSharp.manifest
-│   └── TFLiteSharp.spec
-├── README.md
-├── TFLiteNative
-│   ├── CMakeLists.txt
-│   ├── include
-│   │   ├── tflite_log.h
-│   │   └── tflite_nativewrapper.h
-│   ├── src
-│   │   └── tflite_nativewrapper.cpp
-│   └── tflite-native.pc.in
-├── TFLiteSharp
-│   ├── TFLiteSharp
-│   │   ├── src
-│   │   │   └── Interpreter.cs
-│   │   └── TFLiteSharp.csproj
-│   └── TFLiteSharp.sln
-└── TFLiteSharpTest
- ├── TFLiteSharpTest
- │   ├── Program.cs
- │   └── TFLiteSharpTest.csproj
- └── TFLiteSharpTest.sln
-```
-
-# Build C-Sharp TFLite
-gbs should be used to build TFLiteSharp package. nnfw is also built by gbs. As in most cases when building nnfw we won't intend to build TFLiteSharp hence we have separated its build process, so in order to build TFLiteSharp below command is needed:
-```
-nnfw$ gbs build --packaging-dir=contrib/TFLiteSharp/packaging/ --spec=TFLiteSharp.spec -A armv7l
-```
-This will first build the TFLiteNative package containing native c++ bindings between c# api and tflite api
-and then it will build TFLiteSharp(c# api package).
-
-Please use gbs.conf file corresponding to tizen image version. In most cases gbs.conf file should be same as the one which is used to build nnfw.
-# C-Sharp TFLite API list
-
-## Interpreter Class
-
-### Constructor
-
-The `Interpreter.cs` class drives model inference with TensorFlow Lite.
-
-#### Initializing an `Interpreter` With a Model File
-
-The `Interpreter` can be initialized with a model file using the constructor:
-
-```c#
-public Interpreter(string modelFile);
-```
-
-Number of threads available to the interpereter can be set by using the following function:
-```c#
-public void SetNumThreads(int num_threads)
-```
-
-### Running a model
-
-If a model takes only one input and returns only one output, the following will trigger an inference run:
-
-```c#
-interpreter.Run(input, output);
-```
-
-For models with multiple inputs, or multiple outputs, use:
-
-```c#
-interpreter.RunForMultipleInputsOutputs(inputs, map_of_indices_to_outputs);
-```
-
-The C# api also provides functions for getting the model's input and output indices given the name of tensors as input:
-
-```c#
-public int GetInputIndex(String tensorName)
-public int GetOutputIndex(String tensorName)
-```
-
-Developer can also enable or disable the use of NN API based on hardware capabilites:
-```c#
-public void SetUseNNAPI(boolean useNNAPI)
-```
-
-### Releasing Resources After Use
-
-An `Interpreter` owns resources. To avoid memory leak, the resources must be
-released after use by:
-
-```c#
-interpreter.Dispose();
-```
diff --git a/contrib/TFLiteSharp/TFLiteNative/CMakeLists.txt b/contrib/TFLiteSharp/TFLiteNative/CMakeLists.txt
deleted file mode 100644
index 8b58aac9c..000000000
--- a/contrib/TFLiteSharp/TFLiteNative/CMakeLists.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(fw_name "tflite-native")
-
-PROJECT(${fw_name})
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(LIB ${LIB_PATH})
-SET(LIBDIR ${PREFIX}/${LIB_PATH})
-
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
-
-INCLUDE(FindPkgConfig)
-
-SET(COMMON_DEPS "tensorflow-lite")
-SET(PC_DEPS "capi-base-common")
-
-IF (TIZEN)
- MESSAGE("Building for Tizen")
- SET(TIZEN_DEPS "dlog")
- PKG_CHECK_MODULES(${fw_name} REQUIRED ${COMMON_DEPS} ${TIZEN_DEPS})
- ADD_DEFINITIONS("-D__TIZEN__")
-ELSE ()
- MESSAGE("Building for Linux")
- PKG_CHECK_MODULES(${fw_name} REQUIRED ${COMMON_DEPS})
-ENDIF ()
-
-FOREACH(flag ${${fw_name}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -fPIC -Wall -Werror")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
-
-aux_source_directory(src SOURCES)
-ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
-
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
-
-SET_TARGET_PROPERTIES(${fw_name}
- PROPERTIES
- VERSION ${FULLVER}
- SOVERSION ${MAJORVER}
- CLEAN_DIRECT_OUTPUT 1
-)
-
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB})
-INSTALL(
- DIRECTORY ${INC_DIR}/ DESTINATION include/
- FILES_MATCHING
- PATTERN "${INC_DIR}/*.h"
- )
-
-SET(PC_NAME ${fw_name})
-SET(PC_REQUIRED ${pc_dependents})
-SET(PC_LDFLAGS -l${fw_name})
-
-CONFIGURE_FILE(
- ${fw_name}.pc.in
- ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
- @ONLY
-)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
diff --git a/contrib/TFLiteSharp/TFLiteNative/include/tflite_log.h b/contrib/TFLiteSharp/TFLiteNative/include/tflite_log.h
deleted file mode 100644
index cf51219fd..000000000
--- a/contrib/TFLiteSharp/TFLiteNative/include/tflite_log.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2018 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 _TFLITE_LOG_H_
-#define _TFLITE_LOG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif /*__cplusplus*/
-
-#define ERROR 1
-#define WARNING 2
-#define INFO 3
-#define DEBUG 4
-
-#ifdef __TIZEN__
-#include <dlog/dlog.h>
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif // LOG_TAG
-#define LOG_TAG "TFLITE_NATIVE"
-
-#define TFLITE_NATIVE_LOG(log_level, format, args...) \
- do { \
- switch (log_level) { \
- case ERROR: \
- LOGE(format, ## args); \
- case WARNING: \
- LOGE(format, ## args); \
- default: \
- LOGI(format, ## args); \
- } \
- } while (0)
-#else // __TIZEN__
-#define LEVEL_TO_STR(level) (\
- ((level) == ERROR) ? "ERROR" : \
- ((level) == WARNING) ? "WARNING" : \
- ((level) == INFO) ? "INFO": \
- ((level) == DEBUG) ? "DEBUG" : "DEFAULT")
-#define TFLITE_NATIVE_LOG(log_level, format, args...) \
- do { \
- printf("%s: %s: ", LEVEL_TO_STR(log_level), __FILE__); \
- printf(format, ## args); \
- printf("\n"); \
- }while (0)
-#endif // __TIZEN__
-
-#ifdef __cplusplus
-}
-#endif /*__cplusplus*/
-
-#endif /*_TFLITE_LOG_H*/
diff --git a/contrib/TFLiteSharp/TFLiteNative/include/tflite_nativewrapper.h b/contrib/TFLiteSharp/TFLiteNative/include/tflite_nativewrapper.h
deleted file mode 100644
index 7fddb5400..000000000
--- a/contrib/TFLiteSharp/TFLiteNative/include/tflite_nativewrapper.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2018 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 _TFLITE_NATIVEWRAPPER_H_
-#define _TFLITE_NATIVEWRAPPER_H_
-
-#include "tensorflow/contrib/lite/kernels/register.h"
-#include "tensorflow/contrib/lite/model.h"
-#include "tensorflow/contrib/lite/string_util.h"
-#include "tensorflow/contrib/lite/tools/mutable_op_resolver.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /*__cplusplus*/
-
-typedef enum
-{
- /** 32-bit signed integer. */
- INT32 = 1,
-
- /** 32-bit single precision floating point. */
- FLOAT32 = 2,
-
- /** 8-bit unsigned integer. */
- UINT8 = 3,
-
- /** 64-bit signed integer. */
- INT64 = 4
-} TFLiteNativeType;
-
-void tflite_interpreter_setNumThreads(long* interpreterHandle, int numThreads);
-
-long long tflite_flatbuffermodel_BuildFromFile(char* modelPath);
-
-long long tflite_builder_interpreterBuilder(long* modelHandle);
-
-void* tflite_interpreter_run(long* interpreterHandle, void* values, int inputLength, int dataType);
-
-#ifdef __cplusplus
-}
-#endif /*__cplusplus*/
-
-#endif /*_TFLITE_NATIVEWRAPPER_H_*/
diff --git a/contrib/TFLiteSharp/TFLiteNative/src/tflite_nativewrapper.cpp b/contrib/TFLiteSharp/TFLiteNative/src/tflite_nativewrapper.cpp
deleted file mode 100644
index 413304637..000000000
--- a/contrib/TFLiteSharp/TFLiteNative/src/tflite_nativewrapper.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2018 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 <iostream>
-#include "tflite_nativewrapper.h"
-#include "tflite_log.h"
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <assert.h>
-
-int getNumBytes(TFLiteNativeType dataType)
-{
- switch (dataType) {
- case INT32:
- return 4;
- case FLOAT32:
- return 4;
- case UINT8:
- return 1;
- case INT64:
- return 8;
- default:
- return 1;
- }
-}
-
-/// <summary>
-/// Set the number of threads available to the interpreter.
-/// </summary>
-/// <param name="interpreterHandle">Handle of the interpreter instance.</param>
-/// <param name="numThreads">Number of threads.</param>
-void tflite_interpreter_setNumThreads(long* interpreterHandle, int numThreads)
-{
- assert(interpreterHandle != nullptr);
- tflite::Interpreter* interpreter = reinterpret_cast<tflite::Interpreter*>(*interpreterHandle);
-
- interpreter->SetNumThreads(numThreads);
-
- TFLITE_NATIVE_LOG(DEBUG, "Number of threads: %d", numThreads);
- return;
-}
-
-/// <summary>
-/// Creates a Flat Buffer Model from the given .tflite model.
-/// </summary>
-/// <param name="modelPath">Path of the model.</param>
-long long
-tflite_flatbuffermodel_BuildFromFile(char* modelPath)
-{
- if (modelPath == nullptr) {
- TFLITE_NATIVE_LOG(ERROR, "Invalid parameter");
- return 0;
- }
- TFLITE_NATIVE_LOG(ERROR, "Model Path: %s", modelPath);
-
- if (access(modelPath, F_OK) == -1) {
- TFLITE_NATIVE_LOG(ERROR, "Failed to access model [%s]",
- strerror(errno));
- return 0;
- }
-
- auto model = tflite::FlatBufferModel::BuildFromFile(modelPath);
-
- TFLITE_NATIVE_LOG(DEBUG, "Successfully loaded model");
- return reinterpret_cast<long>(model.release());
-}
-
-/// <summary>
-/// Creates an interpreter instance taking the flatbuffer model as input.
-/// </summary>
-/// <param name="modelHandle">Address of the flatbuffer model.</param>
-long long
-tflite_builder_interpreterBuilder(long* modelHandle)
-{
- assert(modelHandle != nullptr);
- tflite::FlatBufferModel* model = reinterpret_cast<tflite::FlatBufferModel*>(*modelHandle);
-
- tflite::ops::builtin::BuiltinOpResolver resolver;
- std::unique_ptr<tflite::Interpreter> interpreter;
-
- TfLiteStatus status = tflite::InterpreterBuilder (*model, resolver)(&interpreter);
-
- if (status != kTfLiteOk) {
- TFLITE_NATIVE_LOG(DEBUG, "Cannot create interpreter");
- return 0;
- }
- TFLITE_NATIVE_LOG(DEBUG, "CheckPoint interpreter");
- return reinterpret_cast<long>(interpreter.release());
-}
-
-/// <summary>
-/// Runs the inference given the inputs.
-/// </summary>
-/// <param name="interpreterHandle">Address of the interpreter instance.</param>
-/// <param name="values">Input values for the model.</param>
-/// <param name="inpLength">Length of the input.</param>
-/// <param name="dataType">Data type key of the input.</param>
-void* tflite_interpreter_run(long* interpreterHandle, void* values, int inputLength,
- int dataType)
-{
- assert(interpreterHandle != nullptr);
- tflite::Interpreter* interpreter = reinterpret_cast<tflite::Interpreter*>(*interpreterHandle);
-
- int inputTensorIndex = interpreter->inputs()[0];
-
- //TODO:: input tensor size will be passed as a parameter. It is hardcoded for now.
- interpreter->ResizeInputTensor(inputTensorIndex,
- { 1, 224, 224, 3 });
-
- if (interpreter->AllocateTensors() != kTfLiteOk) {
- TFLITE_NATIVE_LOG(ERROR, "Failed to allocate tensors!");
- return nullptr;
- }
-
- float* inputTensorPointer = interpreter->typed_tensor<float>(inputTensorIndex);
-
- int numBytes = getNumBytes((TFLiteNativeType) dataType);
-
- memcpy(inputTensorPointer, values, inputLength * numBytes);
-
- if (interpreter->Invoke() != kTfLiteOk) {
- TFLITE_NATIVE_LOG(ERROR, "Failed to invoke");
- }
-
- float* output = interpreter->typed_output_tensor<float>(0);
- return output;
-}
-
diff --git a/contrib/TFLiteSharp/TFLiteNative/tflite-native.pc.in b/contrib/TFLiteSharp/TFLiteNative/tflite-native.pc.in
deleted file mode 100644
index eec103acc..000000000
--- a/contrib/TFLiteSharp/TFLiteNative/tflite-native.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=/usr
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@/
-
-Name: @PC_NAME@
-Description: @PACKAGE_DESCRIPTION@
-Version: @VERSION@
-Requires: @PC_REQUIRED@ tensorflow-lite
-Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir}
diff --git a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp.sln b/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp.sln
deleted file mode 100644
index 985466cef..000000000
--- a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26730.16
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TFLiteSharp", "TFLiteSharp\TFLiteSharp.csproj", "{22D47176-D5AD-4AD4-8867-8788139DF71C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {22D47176-D5AD-4AD4-8867-8788139DF71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {22D47176-D5AD-4AD4-8867-8788139DF71C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {22D47176-D5AD-4AD4-8867-8788139DF71C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {22D47176-D5AD-4AD4-8867-8788139DF71C}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {1B276F69-8E79-4501-AF04-6D340690762B}
- EndGlobalSection
-EndGlobal
diff --git a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.Libraries.cs b/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.Libraries.cs
deleted file mode 100644
index db8d9f612..000000000
--- a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.Libraries.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-internal static partial class Interop
-{
- internal static partial class Libraries
- {
- public const string TFLite = "libtflite-native.so";
- }
-}
diff --git a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.TFLite.cs b/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.TFLite.cs
deleted file mode 100644
index c7c7b24aa..000000000
--- a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/Interop/Interop.TFLite.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class TFLite
- {
- [DllImport(Libraries.TFLite, EntryPoint = "tflite_flatbuffermodel_BuildFromFile")]
- internal static extern IntPtr TFLiteFlatBufferModelBuildFromFile(string path);
-
- [DllImport(Libraries.TFLite, EntryPoint = "tflite_builder_interpreterBuilder")]
- internal static extern IntPtr TFLiteBuilderInterpreterBuilder(ref IntPtr modelHandle);
-
- [DllImport(Libraries.TFLite, EntryPoint = "tflite_interpreter_setNumThreads")]
- internal static extern void TFLiteInterpreterSetNumThreads(int numThreads);
-
- [DllImport(Libraries.TFLite, EntryPoint = "tflite_interpreter_run")]
- internal static extern IntPtr TFLiteInterpreterRun(ref IntPtr interpreterHandle, IntPtr values, int inpLen, int dataType);
-
- }
-}
diff --git a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/TFLiteSharp.csproj b/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/TFLiteSharp.csproj
deleted file mode 100644
index e0490bfb8..000000000
--- a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/TFLiteSharp.csproj
+++ /dev/null
@@ -1,52 +0,0 @@
-<Project>
- <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
-
- <PropertyGroup Label="Globals">
- <TizenProjectExtensionsPath>$(MSBuildExtensionsPath)\Tizen\VisualStudio\</TizenProjectExtensionsPath>
- </PropertyGroup>
-
- <Import Project="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props" Condition="Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props')" />
-
- <PropertyGroup>
- <OutputType>Library</OutputType>
- <TargetFramework>netstandard2.0</TargetFramework>
- </PropertyGroup>
-
- <!--
- This Property Group for msbuild command line.
- If project build on Visual Studio, it would be set automatically through the certificate manager.
- <PropertyGroup>
- <AuthorPath>author_test.p12</AuthorPath>
- <AuthorPass>author_test</AuthorPass>
- <DistributorPath>tizen-distributor-signer.p12</DistributorPath>
- <DistributorPass>tizenpkcs12passfordsigner</DistributorPass>
- </PropertyGroup>
- -->
-
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugType>portable</DebugType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>None</DebugType>
- </PropertyGroup>
- <ItemGroup>
- <Compile Remove="res\**" />
- <EmbeddedResource Remove="res\**" />
- <None Remove="res\**" />
- </ItemGroup>
-
- <ItemGroup>
- <Folder Include="Interop\" />
- <Folder Include="lib\" />
- </ItemGroup>
-
- <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
- <Import Project="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets" Condition="Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets')" />
-
- <!-- Install Check 'Visual Studio for Tizen' for developing on Visual Studio -->
- <Target Name="TizenVsixInstallCheck" BeforeTargets="CompileDesignTime">
- <Warning Condition="!Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props')" Text="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props is not exist.&#xA; you need to check if 'Visual Studio for Tizen' is installed" />
- <Warning Condition="!Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets')" Text="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets is not exist.\&#xA; you need to check if 'Visual Studio for Tizen' is installed" />
- </Target>
-</Project>
-
diff --git a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Datatype.cs b/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Datatype.cs
deleted file mode 100644
index 404d1663e..000000000
--- a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Datatype.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/** Type of elements in a {@link TfLiteTensor}. */
-enum DataType
-{
- /** 32-bit signed integer. */
- INT32 = 1,
-
- /** 32-bit single precision floating point. */
- FLOAT32 = 2,
-
- /** 8-bit unsigned integer. */
- UINT8 = 3,
-
- /** 64-bit signed integer. */
- INT64 = 4
-}
diff --git a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Interpreter.cs b/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Interpreter.cs
deleted file mode 100644
index f1b4a8e07..000000000
--- a/contrib/TFLiteSharp/TFLiteSharp/TFLiteSharp/src/Interpreter.cs
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-
-namespace TFLite
-{
-
- /// <summary>
- /// Driver class to drive model inference with TensorFlow Lite. Interpreter
- /// encapsulates a pre-trained model file in whihc the operations are performed
- /// @class Interpreter
- /// </summary>
- public class Interpreter : IDisposable
- {
- // Handle to hold the model instance
- private IntPtr m_modelHandle;
- // Handle to hold the interpreter instance
- private IntPtr m_interpreterHandle;
-
- /// <summary>
- /// Interpreter Constructor. Inititalizes an interpreter.
- /// </summary>
- ///<param name="modelPath">a File of a pre-trained TF Lite model. </param>
- public Interpreter(string modelPath)
- {
- //Constructor to initialize the interpreter with a model file
- m_modelHandle = Interop.TFLite.TFLiteFlatBufferModelBuildFromFile(modelPath);
- if(m_modelHandle == IntPtr.Zero)
- {
- //TODO: routine for handling null pointer.
- }
- m_interpreterHandle = Interop.TFLite.TFLiteBuilderInterpreterBuilder(ref m_modelHandle);
- if (m_interpreterHandle == IntPtr.Zero)
- {
- //TODO: routine for handling null pointer.
- }
- }
-
- /// <summary>
- /// Set the number of threads available to the interpreter.
- /// </summary>
- /// <param name="numThreads">Number of threads.</param>
- public void SetNumThreads(int numThreads)
- {
- Interop.TFLite.TFLiteInterpreterSetNumThreads(numThreads);
- return;
- }
-
- /// <summary>
- /// Runs model inference if the model takes only one input, and provides only
- /// one output.
- /// </summary>
- /// <param name="input">input an array or multidimensional array.</param>
- /// <param name="output">outputs a multidimensional array of output data.</param>
- public void Run(Array input, ref Array output)
- {
- Array[] inputs = { input };
- Dictionary<int, Array> outputs = new Dictionary<int, Array>();
-
- RunForMultipleInputsOutputs(inputs, ref outputs);
- output = outputs[0];
-
- return;
- }
-
- /// <summary>
- /// Runs model inference if the model takes multiple inputs, or returns multiple
- /// outputs.
- /// </summary>
- /// <param name="inputs">input an array of input data.</param>
- /// <param name="outputs">outputs a map mapping output indices to multidimensional
- /// arrays of output data.</param>
- public void RunForMultipleInputsOutputs(Array[] inputs, ref Dictionary<int, Array> outputs)
- {
- if(m_interpreterHandle == IntPtr.Zero)
- {
- //TODO:: exception handling
- }
-
- if (inputs == null || inputs.Length == 0)
- {
- //TODO::throw new IllegalArgumentException("Input error: Inputs should not be null or empty.");
- }
-
- DataType[] dataTypes = new DataType[inputs.Length];//To be used in multi-dimensional case
-
- for (int i = 0; i < inputs.Length; ++i)
- {
- dataTypes[i] = DataTypeOf(inputs[i]);
- }
-
- //TODO:: Support for multi dimesional array to be added.
- IntPtr pnt = Marshal.AllocHGlobal(inputs[0].Length);
-
- switch (dataTypes[0])
- {
- case DataType.INT32:
- Marshal.Copy((int[])inputs[0], 0, pnt, inputs[0].Length);
- break;
- case DataType.FLOAT32:
- Marshal.Copy((float[])inputs[0], 0, pnt, inputs[0].Length);
- break;
- case DataType.UINT8:
- Marshal.Copy((byte[])inputs[0], 0, pnt, inputs[0].Length);
- break;
- case DataType.INT64:
- Marshal.Copy((long[])inputs[0], 0, pnt, inputs[0].Length);
- break;
- default:
- Marshal.Copy((byte[])inputs[0], 0, pnt, inputs[0].Length);
- break;
- }
-
- //Currently this handles only single input with single dimension.
- IntPtr outputsHandles = Interop.TFLite.TFLiteInterpreterRun(ref m_interpreterHandle, pnt, inputs[0].Length, (int)dataTypes[0]);
-
- if (outputsHandles == null)
- {
- //throw new IllegalStateException("Internal error: Interpreter has no outputs.");
- }
-
- switch (dataTypes[0])
- {
- case DataType.INT32:
- int[] managedArrayInt = new int[inputs[0].Length];
- Marshal.Copy(outputsHandles, managedArrayInt, 0, inputs[0].Length);
- outputs.Add(0, managedArrayInt);
- break;
- case DataType.FLOAT32:
- float[] managedArrayFloat = new float[inputs[0].Length];
- Marshal.Copy(outputsHandles, managedArrayFloat, 0, inputs[0].Length);
- outputs.Add(0, managedArrayFloat);
- break;
- case DataType.UINT8:
- byte[] managedArrayByte = new byte[inputs[0].Length];
- Marshal.Copy(outputsHandles, managedArrayByte, 0, inputs[0].Length);
- outputs.Add(0, managedArrayByte);
- break;
- case DataType.INT64:
- long[] managedArrayLong = new long[inputs[0].Length];
- Marshal.Copy(outputsHandles, managedArrayLong, 0, inputs[0].Length);
- outputs.Add(0, managedArrayLong);
- break;
- default:
- byte[] managedArrayDefault = new byte[inputs[0].Length];
- Marshal.Copy(outputsHandles, managedArrayDefault, 0, inputs[0].Length);
- outputs.Add(0, managedArrayDefault);
- break;
- }
- return;
- }
-
- static DataType DataTypeOf(Array a)
- {
- if (a.GetValue(0).GetType()==typeof(int))
- {
- return DataType.INT32;
- }
- else if (a.GetValue(0).GetType() == typeof(float))
- {
- return DataType.FLOAT32;
- }
- else if (a.GetValue(0).GetType() == typeof(byte))
- {
- return DataType.UINT8;
- }
- else if(a.GetValue(0).GetType() == typeof(long))
- {
- return DataType.INT64;
- }
- else
- {
- return DataType.UINT8;
- //TODO: throw exception
- }
-
- }
-
- /// <summary>
- /// Resizes idx-th input of the native model to the given dims.
- /// </summary>
- /// <param name="idx">index of the input.</param>
- /// <param name="dims">Dimensions to which input needs to be resized.</param>
- public void ResizeInput(int idx, int[] dims)
- {
- return;
- }
-
- /// <summary>
- /// Gets index of an input given the tensor name of the input.
- /// </summary>
- /// <param name="tensorName">Name of the tensor.</param>
- public int GetInputIndex(string tensorName)
- {
- return 0;
- }
-
- /// <summary>
- /// Gets index of output given the tensor name of the input.
- /// </summary>
- /// <param name="tensorName">Name of the tensor.</param>
- public int GetOutputIndex(string tensorName)
- {
- return 0;
- }
-
- /// <summary>
- /// Turns on/off Android NNAPI for hardware acceleration when it is available.
- /// </summary>
- /// <param name="useNNAPI">set the boolean value to turn on/off nnapi.</param>
- public void SetUseNNAPI(bool useNNAPI)
- {
- return;
- }
-
- /// <summary>
- /// Release resources associated with the Interpreter.
- /// </summary>
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool bDisposing)
- {
- if (m_interpreterHandle != IntPtr.Zero)
- {
- // Call the function to dispose this class
- m_interpreterHandle = IntPtr.Zero;
- }
-
- if (bDisposing)
- {
- // No need to call the finalizer since we've now cleaned
- // up the unmanaged memory
- GC.SuppressFinalize(this);
- }
- }
-
- // This finalizer is called when Garbage collection occurs, but only if
- // the IDisposable.Dispose method wasn't already called.
- ~Interpreter()
- {
- Dispose(false);
- }
- }
-}
diff --git a/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest.sln b/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest.sln
deleted file mode 100644
index e260a72c7..000000000
--- a/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26730.16
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TFLiteSharpTest", "TFLiteSharpTest\TFLiteSharpTest.csproj", "{D35A178F-9EF3-4B07-9E53-A91AA7A030B3}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TFLiteSharp", "..\TFLiteSharp\TFLiteSharp\TFLiteSharp.csproj", "{C06BC425-9BC3-43C7-A9D3-E12849E0C129}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D35A178F-9EF3-4B07-9E53-A91AA7A030B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D35A178F-9EF3-4B07-9E53-A91AA7A030B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D35A178F-9EF3-4B07-9E53-A91AA7A030B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D35A178F-9EF3-4B07-9E53-A91AA7A030B3}.Release|Any CPU.Build.0 = Release|Any CPU
- {C06BC425-9BC3-43C7-A9D3-E12849E0C129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C06BC425-9BC3-43C7-A9D3-E12849E0C129}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C06BC425-9BC3-43C7-A9D3-E12849E0C129}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C06BC425-9BC3-43C7-A9D3-E12849E0C129}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {8F946511-2BE4-40A5-A48C-A5684C62755D}
- EndGlobalSection
-EndGlobal
diff --git a/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/Program.cs b/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/Program.cs
deleted file mode 100644
index e559bec36..000000000
--- a/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/Program.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-
-namespace TFLiteSharpTest
-{
- class Program
- {
- static void Main(string[] args)
- {
- //Constructing a new interpreter instance from the modelfile
- TFLite.Interpreter interpreter = new TFLite.Interpreter("modelpath/modelfile.tflite");
- Console.WriteLine("Interpreter Built Successfully");
-
- //Setting the number of threads of the interpreter
- interpreter.SetNumThreads(1);
-
- //Declaring input and output variables;
- Array input = new int[5] { 1, 2, 3, 4, 5 };
- Array output = new int[5];
-
- //Call to invoke the interpreter and run the inference to populate output
- interpreter.Run(input, out output);
- Console.WriteLine("Output generated Successfully");
-
- //get input, output indices
- Console.WriteLine("Input index for tensorname: " + interpreter.GetInputIndex("tensorname"));
- Console.WriteLine("Output index for tensorname: " + interpreter.GetOutputIndex("tensorname"));
-
- //Resizing the dimensions
- int[] dims = new int[3] { 1, 2, 3 };
- interpreter.ResizeInput(1, dims);
-
- //Disposing the interpreter to free resources at the end
- interpreter.Dispose();
-
- Console.WriteLine("Run Complete");
- }
- }
-}
diff --git a/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/TFLiteSharpTest.csproj b/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/TFLiteSharpTest.csproj
deleted file mode 100644
index b143ee598..000000000
--- a/contrib/TFLiteSharp/TFLiteSharpTest/TFLiteSharpTest/TFLiteSharpTest.csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <PropertyGroup>
- <OutputType>Exe</OutputType>
- <TargetFramework>netcoreapp2.0</TargetFramework>
- </PropertyGroup>
-
- <ItemGroup>
- <ProjectReference Include="..\..\TFLiteSharp\TFLiteSharp\TFLiteSharp.csproj" />
- </ItemGroup>
-
-</Project>
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp.csproj b/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp.csproj
deleted file mode 100644
index 1c9ed6037..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp.csproj
+++ /dev/null
@@ -1,54 +0,0 @@
-<Project>
- <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
-
- <!-- Setting Tizen Extension Path -->
- <PropertyGroup Label="Globals">
- <TizenProjectExtensionsPath>$(MSBuildExtensionsPath)\Tizen\VisualStudio\</TizenProjectExtensionsPath>
- </PropertyGroup>
-
- <!-- Import Tizen property in Tizen.NET SDK -->
- <Import Project="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props" Condition="Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props')" />
-
- <!-- Property Group for .NET Core Project -->
- <PropertyGroup>
- <OutputType>Exe</OutputType>
- <TargetFramework>netstandard2.0</TargetFramework>
- </PropertyGroup>
-
- <!-- Property Group for Tizen Project -->
- <PropertyGroup>
- <TizenCreateTpkOnBuild>true</TizenCreateTpkOnBuild>
- <PackageTargetFallback>$(PackageTargetFallback);portable-net45+wp80+win81+wpa81</PackageTargetFallback>
- </PropertyGroup>
-
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugType>portable</DebugType>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>None</DebugType>
- </PropertyGroup>
-
- <ItemGroup>
- <Folder Include="lib\" />
- <Folder Include="res\" />
- </ItemGroup>
-
- <!-- Include Nuget Package for Tizen Project building -->
- <ItemGroup>
- <PackageReference Include="Tizen.NET" Version="3.0.0" />
- <PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />
- <PackageReference Include="Xamarin.Forms.Platform.Tizen" Version="2.3.5-r256-001" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\TFLiteSharp\TFLiteSharp\TFLiteSharp.csproj" />
- </ItemGroup>
-
- <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
- <Import Project="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets" Condition="Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets')" />
-
- <!-- Install Check 'Visual Studio for Tizen' for developing on Visual Studio -->
- <Target Name="TizenVsixInstallCheck" BeforeTargets="CompileDesignTime">
- <Warning Condition="!Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props')" Text="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.props is not exist.&#xA; you need to check if 'Visual Studio for Tizen' is installed" />
- <Warning Condition="!Exists('$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets')" Text="$(TizenProjectExtensionsPath)Tizen.NET.ProjectType.targets is not exist.\&#xA; you need to check if 'Visual Studio for Tizen' is installed" />
- </Target>
-</Project>
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_App.cs b/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_App.cs
deleted file mode 100644
index 49a08604d..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_App.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Xamarin.Forms;
-
-namespace TFLiteTestApp
-{
- public class App : Application
- {
- public App()
- {
- TFLite.Interpreter interpreter = null;
- try
- {
- interpreter = new TFLite.Interpreter(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "mobilenet_v1_1.0_224.tflite");
- }
- catch(Exception e)
- {
- Tizen.Log.Debug("tflite", "Error: " + e);
- }
-
- Tizen.Log.Debug("tflite", "Interpreter Initialised");
- Array Output = new byte[1000];
-
- Array input = new byte[150582];
- input = File.ReadAllBytes(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "mouse_224.bmp");
-
- interpreter.Run(input, ref Output);
- //val variable to check if the Output array is being populated or not.
- byte val = ((byte[])Output)[0];
- // The root page of your application
- MainPage = new ContentPage
- {
- Content = new StackLayout
- {
- VerticalOptions = LayoutOptions.Center,
- Children = {
- new Label {
- HorizontalTextAlignment = TextAlignment.Center,
- Text = "Welcome to Xamarin Forms!"
- }
- }
- }
- };
- }
-
- protected override void OnStart()
- {
- // Handle when your app starts
- }
-
- protected override void OnSleep()
- {
- // Handle when your app sleeps
- }
-
- protected override void OnResume()
- {
- // Handle when your app resumes
- }
- }
-}
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_Main.cs b/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_Main.cs
deleted file mode 100644
index 2a8f747a4..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/TFLiteTestApp_Main.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-namespace TFLiteTestApp
-{
- class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
- {
- protected override void OnCreate()
- {
- base.OnCreate();
- LoadApplication(new App());
- }
-
- static void Main(string[] args)
- {
- var app = new Program();
- global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
- app.Run(args);
- }
- }
-}
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/res/mobilenet_v1_1.0_224.tflite b/contrib/TFLiteSharp/TFLiteTestApp/res/mobilenet_v1_1.0_224.tflite
deleted file mode 100644
index d34691eb6..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/res/mobilenet_v1_1.0_224.tflite
+++ /dev/null
Binary files differ
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/res/mouse1.bmp b/contrib/TFLiteSharp/TFLiteTestApp/res/mouse1.bmp
deleted file mode 100644
index 1734ca318..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/res/mouse1.bmp
+++ /dev/null
Binary files differ
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/res/mouse_224.bmp b/contrib/TFLiteSharp/TFLiteTestApp/res/mouse_224.bmp
deleted file mode 100644
index ccfed6ad3..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/res/mouse_224.bmp
+++ /dev/null
Binary files differ
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/shared/res/TFLiteTestApp.png b/contrib/TFLiteSharp/TFLiteTestApp/shared/res/TFLiteTestApp.png
deleted file mode 100644
index 9f3cb9860..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/shared/res/TFLiteTestApp.png
+++ /dev/null
Binary files differ
diff --git a/contrib/TFLiteSharp/TFLiteTestApp/tizen-manifest.xml b/contrib/TFLiteSharp/TFLiteTestApp/tizen-manifest.xml
deleted file mode 100644
index 62a8d4c7c..000000000
--- a/contrib/TFLiteSharp/TFLiteTestApp/tizen-manifest.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="4" package="org.tizen.example.TFLiteTestApp" version="1.0.0">
- <profile name="common" />
- <ui-application appid="org.tizen.example.TFLiteTestApp"
- exec="TFLiteTestApp.dll"
- type="dotnet"
- multiple="false"
- taskmanage="true"
- nodisplay="false"
- launch_mode="single">
- <label>TFLiteTestApp</label>
- <icon>TFLiteTestApp.png</icon>
- </ui-application>
-</manifest>
diff --git a/contrib/TFLiteSharp/packaging/TFLiteSharp.manifest b/contrib/TFLiteSharp/packaging/TFLiteSharp.manifest
deleted file mode 100644
index 75b0fa5e3..000000000
--- a/contrib/TFLiteSharp/packaging/TFLiteSharp.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
diff --git a/contrib/TFLiteSharp/packaging/TFLiteSharp.spec b/contrib/TFLiteSharp/packaging/TFLiteSharp.spec
deleted file mode 100644
index dcb65a864..000000000
--- a/contrib/TFLiteSharp/packaging/TFLiteSharp.spec
+++ /dev/null
@@ -1,103 +0,0 @@
-Name: TFLiteSharp
-Summary: Tensorflow lite native cpp wrapper and C# API
-Version: 1.0.0
-Release: 1
-Group: Development/Libraries
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
-Source1: %{name}.manifest
-Source2: tflite-native.manifest
-
-%description
-%{summary}
-
-%package TFLiteNative
-Summary: Tensorflow lite native cpp wrapper
-Group: Development/Libraries
-BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(tensorflow-lite)
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description TFLiteNative
-Native CPP Wrapper for Tensorflow lite
-
-%package TFLiteNative-devel
-Summary: Tensorflow lite native cpp wrapper (Development)
-Requires: %{name} = %{version}-%{release}
-
-%description TFLiteNative-devel
-Tensorflow lite native cpp wrapper (Development)
-
-%package TFLiteSharp
-Summary: Tensorflow lite API for C#
-Group: Development/Libraries
-AutoReqProv: no
-ExcludeArch: aarch64
-
-BuildRequires: dotnet-build-tools
-
-%define Assemblies TFLiteSharp
-
-%description TFLiteSharp
-Tensorflow lite API for C#
-
-%dotnet_import_sub_packages
-
-%prep
-%setup -q
-cp %{SOURCE1} .
-cp %{SOURCE2} .
-%if 0%{?tizen:1}
-%define TARGET_OS tizen
-%else
-%define TARGET_OS linux
-%endif
-
-%build
-MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%if "%{TARGET_OS}" == "tizen"
-cmake VERBOSE=1 -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
- -DLIB_INSTALL_DIR=%{_libdir} -DINCLUDE_INSTALL_DIR=%{_includedir} \
- -DLIB_PATH=%{_lib} -DTIZEN=1 contrib/TFLiteSharp/TFLiteNative
-%else
-cmake VERBOSE=1 -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
- -DLIB_INSTALL_DIR=%{_libdir} -DINCLUDE_INSTALL_DIR=%{_includedir} \
- -DLIB_PATH=%{_lib} contrib/TFLiteSharp/TFLiteNative
-%endif
-
-make %{?_smp_mflags}
-
-cd contrib/TFLiteSharp/
-for ASM in %{Assemblies}; do
-%dotnet_build $ASM
-%dotnet_pack $ASM
-done
-
-%install
-%make_install
-cd contrib/TFLiteSharp/TFLiteSharp
-for ASM in %{Assemblies}; do
-%dotnet_install $ASM
-done
-
-%post -p /sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
-%files
-%manifest %{name}.manifest
-%license LICENSE
-
-%files TFLiteNative
-%manifest tflite-native.manifest
-%{_libdir}/libtflite-native.so*
-
-%files TFLiteNative-devel
-%{_includedir}/*
-%{_libdir}/pkgconfig/tflite-native.pc
-%{_libdir}/libtflite-native.so*
-
-%files TFLiteSharp
-%attr(644,root,root) %{dotnet_assembly_files}
diff --git a/contrib/TFLiteSharp/packaging/tflite-native.manifest b/contrib/TFLiteSharp/packaging/tflite-native.manifest
deleted file mode 100644
index 75b0fa5e3..000000000
--- a/contrib/TFLiteSharp/packaging/tflite-native.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
diff --git a/contrib/benchmark_acl/CMakeLists.txt b/contrib/benchmark_acl/CMakeLists.txt
deleted file mode 100644
index b5fa3e529..000000000
--- a/contrib/benchmark_acl/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-if(NOT BUILD_BENCHMARK_ACL)
- return()
-endif(NOT BUILD_BENCHMARK_ACL)
-
-nnfw_find_package(ARMCompute REQUIRED)
-
-add_library(arm_compute_benchmark SHARED "src/Benchmark.cpp")
-target_include_directories(arm_compute_benchmark PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
-target_link_libraries(arm_compute_benchmark arm_compute_graph)
-install(TARGETS arm_compute_benchmark DESTINATION lib)
-
-# GoogLeNet benchmark
-add_executable(benchmark_googlenet "src/benchmark_googlenet.cpp")
-target_link_libraries(benchmark_googlenet arm_compute_benchmark)
-
-# GoogLeNet benchmark
-add_executable(benchmark_inception_v3 "src/benchmark_inception_v3.cpp")
-target_link_libraries(benchmark_inception_v3 arm_compute_benchmark)
-
-# MobileNet benchmark
-add_executable(benchmark_mobilenet "src/benchmark_mobilenet.cpp")
-target_link_libraries(benchmark_mobilenet arm_compute_benchmark)
-
-install(TARGETS benchmark_googlenet benchmark_inception_v3 benchmark_mobilenet DESTINATION bin)
diff --git a/contrib/benchmark_acl/src/Benchmark.cpp b/contrib/benchmark_acl/src/Benchmark.cpp
deleted file mode 100644
index ba6001232..000000000
--- a/contrib/benchmark_acl/src/Benchmark.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2018 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 "Benchmark.h"
-
-#include <cstdlib>
-
-Count::Count() : _value(1)
-{
- auto env = std::getenv("COUNT");
-
- if (env)
- {
- _value = atoi(env);
- }
-}
-
-uint32_t Count::value(void) const { return _value; }
-
-#include <boost/accumulators/accumulators.hpp>
-#include <boost/accumulators/statistics/stats.hpp>
-#include <boost/accumulators/statistics/mean.hpp>
-
-#include <iostream>
-#include <chrono>
-
-using namespace boost::accumulators;
-
-void run_benchmark(arm_compute::graph::frontend::Stream &graph)
-{
- // NOTE Here the number of warming-up iterations is hardcoded
- // TODO Decide the number of warming-up iterations appropriately
- for (uint32_t n = 0; n < 3; ++n)
- {
- auto beg = std::chrono::steady_clock::now();
- graph.run();
- auto end = std::chrono::steady_clock::now();
- auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - beg);
-
- std::cout << "Warming-up " << n << ": " << elapsed.count() << "ms" << std::endl;
- }
-
- accumulator_set<double, stats<tag::mean>> acc;
-
- const Count count;
-
- for (uint32_t n = 0; n < count.value(); ++n)
- {
- auto beg = std::chrono::steady_clock::now();
- graph.run();
- auto end = std::chrono::steady_clock::now();
- auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - beg);
-
- std::cout << "Iteration " << n << ": " << elapsed.count() << "ms" << std::endl;
-
- acc(elapsed.count());
- }
-
- std::cout << "--------" << std::endl;
- std::cout << "Mean: " << mean(acc) << "ms" << std::endl;
-}
diff --git a/contrib/benchmark_acl/src/Benchmark.h b/contrib/benchmark_acl/src/Benchmark.h
deleted file mode 100644
index 200f40952..000000000
--- a/contrib/benchmark_acl/src/Benchmark.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2018 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 __ACL_BENCHMARK_H__
-#define __ACL_BENCHMARK_H__
-
-#include "arm_compute/graph/ITensorAccessor.h"
-#include "arm_compute/graph.h"
-#include "arm_compute/core/CL/OpenCL.h"
-
-struct InputAccessor final : public arm_compute::graph::ITensorAccessor
-{
- InputAccessor() = default;
- /** Allows instances to move constructed */
- InputAccessor(InputAccessor &&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor &tensor) override
- {
- return true;
- }
-};
-
-struct OutputAccessor final : public arm_compute::graph::ITensorAccessor
-{
- OutputAccessor() = default;
- /** Allows instances to move constructed */
- OutputAccessor(OutputAccessor &&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor &tensor) override
- {
- return false;
- }
-};
-
-template <typename T> std::unique_ptr<arm_compute::graph::ITensorAccessor> get_accessor()
-{
- return std::unique_ptr<T>(new T());
-}
-
-class Count
-{
-public:
- Count();
-
-public:
- uint32_t value(void) const;
-
-private:
- uint32_t _value;
-};
-
-inline arm_compute::graph::Target set_target_hint(int target)
-{
- if(target == 1 && arm_compute::opencl_is_available())
- {
- // If type of target is OpenCL, check if OpenCL is available and initialize the scheduler
- return arm_compute::graph::Target::CL;
- }
- else
- {
- return arm_compute::graph::Target::NEON;
- }
-}
-
-void run_benchmark(arm_compute::graph::frontend::Stream &graph);
-
-#endif
diff --git a/contrib/benchmark_acl/src/benchmark_googlenet.cpp b/contrib/benchmark_acl/src/benchmark_googlenet.cpp
deleted file mode 100644
index 8b0fbfdac..000000000
--- a/contrib/benchmark_acl/src/benchmark_googlenet.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- * Copyright (c) 2017 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#include "arm_compute/graph.h"
-
-#include "Benchmark.h"
-
-#include <cstdlib>
-#include <tuple>
-
-using namespace arm_compute::graph::frontend;
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_input_accessor(void)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_random_accessor(float lower, float upper)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_weights_accessor(const std::string &path, const std::string &data_file, DataLayout file_layout = DataLayout::NCHW)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_output_accessor(void)
-{
- return get_accessor<OutputAccessor>();
-}
-
-/** Example demonstrating how to implement Googlenet's network using the Compute Library's graph API
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] image, [optional] labels, [optional] Fast math for convolution layer (0 = DISABLED, 1 = ENABLED) )
- */
-class GraphGooglenetExample
-{
-public:
- void do_setup(int argc, char **argv)
- {
- std::string data_path; /* Path to the trainable data */
- std::string image; /* Image data */
- std::string label; /* Label data */
-
- const std::array<float, 3> mean_rgb{ { 122.68f, 116.67f, 104.01f } };
- // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON
- const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0;
- Target target_hint = set_target_hint(target);
- FastMathHint fast_math_hint = FastMathHint::Disabled;
-
- // Parse arguments
- if(argc < 2)
- {
- // Print help
- std::cout << "Usage: " << argv[0] << " [target] [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 2)
- {
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 3)
- {
- data_path = argv[2];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No image provided: using random values\n\n";
- }
- else if(argc == 4)
- {
- data_path = argv[2];
- image = argv[3];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " [labels] [fast_math_hint]\n\n";
- std::cout << "No text file with labels provided: skipping output accessor\n\n";
- }
- else if(argc == 5)
- {
- data_path = argv[2];
- image = argv[3];
- label = argv[4];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " " << argv[4] << " [fast_math_hint]\n\n";
- std::cout << "No fast math info provided: disabling fast math\n\n";
- }
- else
- {
- data_path = argv[2];
- image = argv[3];
- label = argv[4];
- fast_math_hint = (std::strtol(argv[5], nullptr, 1) == 0) ? FastMathHint::Disabled : FastMathHint::Enabled;
- }
-
- graph << target_hint
- << fast_math_hint
- << InputLayer(TensorDescriptor(TensorShape(224U, 224U, 3U, 1U), DataType::F32),
- get_input_accessor())
- << ConvolutionLayer(
- 7U, 7U, 64U,
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv1/conv1_7x7_s2_w.npy"),
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv1/conv1_7x7_s2_b.npy"),
- PadStrideInfo(2, 2, 3, 3))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
- << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)))
- << NormalizationLayer(NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f))
- << ConvolutionLayer(
- 1U, 1U, 64U,
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv2/conv2_3x3_reduce_w.npy"),
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv2/conv2_3x3_reduce_b.npy"),
- PadStrideInfo(1, 1, 0, 0))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
- << ConvolutionLayer(
- 3U, 3U, 192U,
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv2/conv2_3x3_w.npy"),
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv2/conv2_3x3_b.npy"),
- PadStrideInfo(1, 1, 1, 1))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
- << NormalizationLayer(NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f))
- << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)));
- graph << get_inception_node(data_path, "inception_3a", 64, std::make_tuple(96U, 128U), std::make_tuple(16U, 32U), 32U);
- graph << get_inception_node(data_path, "inception_3b", 128, std::make_tuple(128U, 192U), std::make_tuple(32U, 96U), 64U);
- graph << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)));
- graph << get_inception_node(data_path, "inception_4a", 192, std::make_tuple(96U, 208U), std::make_tuple(16U, 48U), 64U);
- graph << get_inception_node(data_path, "inception_4b", 160, std::make_tuple(112U, 224U), std::make_tuple(24U, 64U), 64U);
- graph << get_inception_node(data_path, "inception_4c", 128, std::make_tuple(128U, 256U), std::make_tuple(24U, 64U), 64U);
- graph << get_inception_node(data_path, "inception_4d", 112, std::make_tuple(144U, 288U), std::make_tuple(32U, 64U), 64U);
- graph << get_inception_node(data_path, "inception_4e", 256, std::make_tuple(160U, 320U), std::make_tuple(32U, 128U), 128U);
- graph << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)));
- graph << get_inception_node(data_path, "inception_5a", 256, std::make_tuple(160U, 320U), std::make_tuple(32U, 128U), 128U);
- graph << get_inception_node(data_path, "inception_5b", 384, std::make_tuple(192U, 384U), std::make_tuple(48U, 128U), 128U);
- graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 7, PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL)))
- << FullyConnectedLayer(
- 1000U,
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/loss3/loss3_classifier_w.npy"),
- get_weights_accessor(data_path, "/cnn_data/googlenet_model/loss3/loss3_classifier_b.npy"))
- << SoftmaxLayer()
- << OutputLayer(get_output_accessor());
-
- // Finalize graph
- GraphConfig config;
- config.use_tuner = (target == 2);
- graph.finalize(target_hint, config);
- }
- void do_run()
- {
- run_benchmark(graph);
- }
-
-private:
- Stream graph{ 0, "GoogleNet" };
-
- ConcatLayer get_inception_node(const std::string &data_path, std::string &&param_path,
- unsigned int a_filt,
- std::tuple<unsigned int, unsigned int> b_filters,
- std::tuple<unsigned int, unsigned int> c_filters,
- unsigned int d_filt)
- {
- std::string total_path = "/cnn_data/googlenet_model/" + param_path + "/" + param_path + "_";
- SubStream i_a(graph);
- i_a << ConvolutionLayer(
- 1U, 1U, a_filt,
- get_weights_accessor(data_path, total_path + "1x1_w.npy"),
- get_weights_accessor(data_path, total_path + "1x1_b.npy"),
- PadStrideInfo(1, 1, 0, 0))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
-
- SubStream i_b(graph);
- i_b << ConvolutionLayer(
- 1U, 1U, std::get<0>(b_filters),
- get_weights_accessor(data_path, total_path + "3x3_reduce_w.npy"),
- get_weights_accessor(data_path, total_path + "3x3_reduce_b.npy"),
- PadStrideInfo(1, 1, 0, 0))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
- << ConvolutionLayer(
- 3U, 3U, std::get<1>(b_filters),
- get_weights_accessor(data_path, total_path + "3x3_w.npy"),
- get_weights_accessor(data_path, total_path + "3x3_b.npy"),
- PadStrideInfo(1, 1, 1, 1))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
-
- SubStream i_c(graph);
- i_c << ConvolutionLayer(
- 1U, 1U, std::get<0>(c_filters),
- get_weights_accessor(data_path, total_path + "5x5_reduce_w.npy"),
- get_weights_accessor(data_path, total_path + "5x5_reduce_b.npy"),
- PadStrideInfo(1, 1, 0, 0))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
- << ConvolutionLayer(
- 5U, 5U, std::get<1>(c_filters),
- get_weights_accessor(data_path, total_path + "5x5_w.npy"),
- get_weights_accessor(data_path, total_path + "5x5_b.npy"),
- PadStrideInfo(1, 1, 2, 2))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
-
- SubStream i_d(graph);
- i_d << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)))
- << ConvolutionLayer(
- 1U, 1U, d_filt,
- get_weights_accessor(data_path, total_path + "pool_proj_w.npy"),
- get_weights_accessor(data_path, total_path + "pool_proj_b.npy"),
- PadStrideInfo(1, 1, 0, 0))
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
-
- return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
- }
-};
-
-/** Main program for Googlenet
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] image, [optional] labels, [optional] Fast math for convolution layer (0 = DISABLED, 1 = ENABLED) )
- */
-int main(int argc, char **argv)
-{
- GraphGooglenetExample example;
-
- example.do_setup(argc, argv);
- example.do_run();
-
- return 0;
-}
diff --git a/contrib/benchmark_acl/src/benchmark_inception_v3.cpp b/contrib/benchmark_acl/src/benchmark_inception_v3.cpp
deleted file mode 100644
index 382851f50..000000000
--- a/contrib/benchmark_acl/src/benchmark_inception_v3.cpp
+++ /dev/null
@@ -1,891 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- * Copyright (c) 2017-2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#include "arm_compute/graph.h"
-
-#include "Benchmark.h"
-
-#include <cstdlib>
-#include <tuple>
-
-using namespace arm_compute::graph::frontend;
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_input_accessor(void)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_random_accessor(float lower, float upper)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_weights_accessor(const std::string &path, const std::string &data_file, DataLayout file_layout = DataLayout::NCHW)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_output_accessor(void)
-{
- return get_accessor<OutputAccessor>();
-}
-
-/** Example demonstrating how to implement InceptionV3's network using the Compute Library's graph API
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] image, [optional] labels )
- */
-class InceptionV3Example
-{
-public:
- void do_setup(int argc, char **argv)
- {
- std::string data_path; /* Path to the trainable data */
- std::string image; /* Image data */
- std::string label; /* Label data */
-
- // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON
- const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0;
- Target target_hint = set_target_hint(target);
- FastMathHint fast_math_hint = FastMathHint::Disabled;
-
- // Parse arguments
- if(argc < 2)
- {
- // Print help
- std::cout << "Usage: " << argv[0] << " [target] [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 2)
- {
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 3)
- {
- data_path = argv[2];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No image provided: using random values\n\n";
- }
- else if(argc == 4)
- {
- data_path = argv[2];
- image = argv[3];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " [labels] [fast_math_hint]\n\n";
- std::cout << "No text file with labels provided: skipping output accessor\n\n";
- }
- else if(argc == 5)
- {
- data_path = argv[2];
- image = argv[3];
- label = argv[4];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " " << argv[4] << " [fast_math_hint]\n\n";
- std::cout << "No fast math info provided: disabling fast math\n\n";
- }
- else
- {
- data_path = argv[2];
- image = argv[3];
- label = argv[4];
- fast_math_hint = (std::strtol(argv[5], nullptr, 1) == 0) ? FastMathHint::Disabled : FastMathHint::Enabled;
- }
-
- graph << target_hint
- << fast_math_hint
- << InputLayer(TensorDescriptor(TensorShape(299U, 299U, 3U, 1U), DataType::F32),
- get_input_accessor())
- << ConvolutionLayer(3U, 3U, 32U,
- get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
- .set_name("Conv2d_1a_3x3/convolution")
- << BatchNormalizationLayer(get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
- << ConvolutionLayer(3U, 3U, 32U,
- get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
- .set_name("Conv2d_2a_3x3/convolution")
- << BatchNormalizationLayer(get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
-
- << ConvolutionLayer(3U, 3U, 64U,
- get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
- .set_name("Conv2d_2b_3x3/convolution")
- << BatchNormalizationLayer(get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu")
-
- << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name("MaxPool_3a_3x3/MaxPool")
-
- << ConvolutionLayer(1U, 1U, 80U,
- get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
- .set_name("Conv2d_3b_1x1/convolution")
- << BatchNormalizationLayer(get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu")
-
- << ConvolutionLayer(3U, 3U, 192U,
- get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
- .set_name("Conv2d_4a_3x3/convolution")
- << BatchNormalizationLayer(get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu")
-
- << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name("MaxPool_5a_3x3/MaxPool");
-
- graph << get_inception_node_A(data_path, "Mixed_5b", 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
- 32U)
- .set_name("Mixed_5b/concat");
- graph << get_inception_node_A(data_path, "Mixed_5c", 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
- 64U, true)
- .set_name("Mixed_5c/concat");
- graph << get_inception_node_A(data_path, "Mixed_5d", 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
- 64U)
- .set_name("Mixed_5d/concat");
-
- graph << get_inception_node_B(data_path, "Mixed_6a", 384U, std::make_tuple(64U, 96U, 96U)).set_name("Mixed_6a/concat");
-
- graph << get_inception_node_C(data_path, "Mixed_6b", 192U, std::make_tuple(128U, 128U, 192U),
- std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U)
- .set_name("Mixed_6b/concat");
- graph << get_inception_node_C(data_path, "Mixed_6c", 192U, std::make_tuple(160U, 160U, 192U),
- std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
- .set_name("Mixed_6c/concat");
- graph << get_inception_node_C(data_path, "Mixed_6d", 192U, std::make_tuple(160U, 160U, 192U),
- std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
- .set_name("Mixed_6d/concat");
- graph << get_inception_node_C(data_path, "Mixed_6e", 192U, std::make_tuple(192U, 192U, 192U),
- std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U)
- .set_name("Mixed_6e/concat");
-
- graph << get_inception_node_D(data_path, "Mixed_7a", std::make_tuple(192U, 320U),
- std::make_tuple(192U, 192U, 192U, 192U))
- .set_name("Mixed_7a/concat");
-
- graph << get_inception_node_E(data_path, "Mixed_7b", 320U, std::make_tuple(384U, 384U, 384U),
- std::make_tuple(448U, 384U, 384U, 384U), 192U)
- .set_name("Mixed_7b/concat");
- graph << get_inception_node_E(data_path, "Mixed_7c", 320U, std::make_tuple(384U, 384U, 384U),
- std::make_tuple(448U, 384U, 384U, 384U), 192U, true)
- .set_name("Mixed_7c/concat");
-
- graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 8, PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL))).set_name("Logits/AvgPool_1a_8x8/AvgPool")
- << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy"),
- get_weights_accessor(data_path,
- "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"),
- PadStrideInfo(1, 1, 0, 0))
- .set_name("Logits/Conv2d_1c_1x1/convolution")
- << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape")
- << SoftmaxLayer().set_name("Predictions/Softmax")
- << OutputLayer(get_output_accessor());
-
- // Finalize graph
- GraphConfig config;
- config.use_tuner = (target == 2);
- graph.finalize(target_hint, config);
- }
-
- void do_run()
- {
- run_benchmark(graph);
- }
-
-private:
- Stream graph{ 0, "InceptionV3" };
-
-private:
- ConcatLayer get_inception_node_A(const std::string &data_path, std::string &&param_path,
- unsigned int a_filt,
- std::tuple<unsigned int, unsigned int> b_filters,
- std::tuple<unsigned int, unsigned int, unsigned int> c_filters,
- unsigned int d_filt,
- bool is_name_different = false)
- {
- std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
-
- // This is due to a naming issue in the tf model
- std::string conv_id0 = "_0a_";
- std::string conv_id1 = "2d_0b_";
- if(is_name_different)
- {
- conv_id0 = "_0b_";
- conv_id1 = "_1_0c_";
- }
-
- SubStream i_a(graph);
- i_a << ConvolutionLayer(
- 1U, 1U, a_filt,
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
-
- SubStream i_b(graph);
- i_b << ConvolutionLayer(
- 1U, 1U, std::get<0>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/Relu")
- << ConvolutionLayer(
- 5U, 5U, std::get<1>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 2, 2))
- .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/Relu");
-
- SubStream i_c(graph);
- i_c << ConvolutionLayer(
- 1U, 1U, std::get<0>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<1>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 1, 1))
- .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<2>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 1, 1))
- .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
-
- SubStream i_d(graph);
- i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
- << ConvolutionLayer(
- 1U, 1U, d_filt,
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
-
- return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
- }
-
- ConcatLayer get_inception_node_B(const std::string &data_path, std::string &&param_path,
- unsigned int a_filt,
- std::tuple<unsigned int, unsigned int, unsigned int> b_filters)
- {
- std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
- SubStream i_a(graph);
- i_a << ConvolutionLayer(
- 3U, 3U, a_filt,
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(2, 2, 0, 0))
- .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_1x1/Relu");
-
- SubStream i_b(graph);
- i_b << ConvolutionLayer(
- 1U, 1U, std::get<0>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<1>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 1, 1))
- .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<2>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(2, 2, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_1x1/Relu");
-
- SubStream i_c(graph);
- i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name(param_path + "/Branch_2/MaxPool_1a_3x3/MaxPool");
-
- return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
- }
-
- ConcatLayer get_inception_node_C(const std::string &data_path, std::string &&param_path,
- unsigned int a_filt,
- std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
- std::tuple<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
- unsigned int d_filt)
- {
- std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
- SubStream i_a(graph);
- i_a << ConvolutionLayer(
- 1U, 1U, a_filt,
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
-
- SubStream i_b(graph);
- i_b << ConvolutionLayer(
- 1U, 1U, std::get<0>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 7U, 1U, std::get<1>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 3, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
- << ConvolutionLayer(
- 1U, 7U, std::get<2>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 3))
- .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0c_7x1/Relu");
-
- SubStream i_c(graph);
- i_c << ConvolutionLayer(
- 1U, 1U, std::get<0>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 1U, 7U, std::get<1>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 3))
- .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
- << ConvolutionLayer(
- 7U, 1U, std::get<2>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 3, 0))
- .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
- << ConvolutionLayer(
- 1U, 7U, std::get<3>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 3))
- .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
- << ConvolutionLayer(
- 7U, 1U, std::get<4>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 3, 0))
- .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
-
- SubStream i_d(graph);
- i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
- << ConvolutionLayer(
- 1U, 1U, d_filt,
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
-
- return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
- }
-
- ConcatLayer get_inception_node_D(const std::string &data_path, std::string &&param_path,
- std::tuple<unsigned int, unsigned int> a_filters,
- std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters)
- {
- std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
- SubStream i_a(graph);
- i_a << ConvolutionLayer(
- 1U, 1U, std::get<0>(a_filters),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<1>(a_filters),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(2, 2, 0, 0))
- .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_3x3/Relu");
-
- SubStream i_b(graph);
- i_b << ConvolutionLayer(
- 1U, 1U, std::get<0>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 7U, 1U, std::get<1>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 3, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
- << ConvolutionLayer(
- 1U, 7U, std::get<2>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 3))
- .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<3>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(2, 2, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_3x3/Relu");
-
- SubStream i_c(graph);
- i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name(param_path + "/Branch_2/MaxPool_1a_3x3/MaxPool");
-
- return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
- }
-
- ConcatLayer get_inception_node_E(const std::string &data_path, std::string &&param_path,
- unsigned int a_filt,
- std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
- std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
- unsigned int d_filt,
- bool is_name_different = false)
- {
- // This is due to a naming issue in the tf model
- std::string conv_id = "_0b_";
- if(is_name_different)
- {
- conv_id = "_0c_";
- }
-
- std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
- SubStream i_a(graph);
- i_a << ConvolutionLayer(
- 1U, 1U, a_filt,
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
-
- SubStream i_b(graph);
- i_b << ConvolutionLayer(
- 1U, 1U, std::get<0>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
-
- SubStream i_b1(static_cast<IStream &>(i_b));
- i_b1 << ConvolutionLayer(
- 3U, 1U, std::get<1>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 1, 0))
- .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
-
- SubStream i_b2(static_cast<IStream &>(i_b));
- i_b2 << ConvolutionLayer(
- 1U, 3U, std::get<2>(b_filters),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 1))
- .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/Relu");
-
- // Merge b1 and b2
- i_b << ConcatLayer(std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat");
-
- SubStream i_c(graph);
- i_c << ConvolutionLayer(
- 1U, 1U, std::get<0>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
- << ConvolutionLayer(
- 3U, 3U, std::get<1>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 1, 1))
- .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu");
-
- SubStream i_c1(static_cast<IStream &>(i_c));
- i_c1 << ConvolutionLayer(
- 3U, 1U, std::get<2>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 1, 0))
- .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
-
- SubStream i_c2(static_cast<IStream &>(i_c));
- i_c2 << ConvolutionLayer(
- 1U, 3U, std::get<3>(c_filters),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 1))
- .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_3x1/Relu");
-
- // Merge i_c1 and i_c2
- i_c << ConcatLayer(std::move(i_c1), std::move(i_c2)).set_name(param_path + "/Branch_2/concat");
-
- SubStream i_d(graph);
- i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
- << ConvolutionLayer(
- 1U, 1U, d_filt,
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(1, 1, 0, 0))
- .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
- get_random_accessor(1.f, 1.f),
- get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
-
- return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
- }
-};
-
-/** Main program for Inception V3
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] image, [optional] labels, [optional] Fast math for convolution layer (0 = DISABLED, 1 = ENABLED) )
- */
-int main(int argc, char **argv)
-{
- InceptionV3Example example;
-
- example.do_setup(argc, argv);
- example.do_run();
-
- return 0;
-}
diff --git a/contrib/benchmark_acl/src/benchmark_mobilenet.cpp b/contrib/benchmark_acl/src/benchmark_mobilenet.cpp
deleted file mode 100644
index 085be184e..000000000
--- a/contrib/benchmark_acl/src/benchmark_mobilenet.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- * Copyright (c) 2017 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#include "arm_compute/graph.h"
-
-#include "Benchmark.h"
-
-#include <cstdlib>
-
-using namespace arm_compute::graph::frontend;
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_input_accessor(void)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_random_accessor(float lower, float upper)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_weights_accessor(const std::string &path, const std::string &data_file, DataLayout file_layout = DataLayout::NCHW)
-{
- return get_accessor<InputAccessor>();
-}
-
-inline std::unique_ptr<arm_compute::graph::ITensorAccessor> get_output_accessor(void)
-{
- return get_accessor<OutputAccessor>();
-}
-
-/** Example demonstrating how to implement MobileNet's network using the Compute Library's graph API
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL), [optional] Path to the weights folder, [optional] image, [optional] labels )
- */
-class GraphMobilenetExample
-{
-public:
- void do_setup(int argc, char **argv)
- {
- std::string data_path; /* Path to the trainable data */
- std::string image; /* Image data */
- std::string label; /* Label data */
-
- // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON
- const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0;
- Target target_hint = set_target_hint(target);
- ConvolutionMethod convolution_hint = ConvolutionMethod::GEMM;
- DepthwiseConvolutionMethod depthwise_convolution_hint = DepthwiseConvolutionMethod::Optimized3x3;
- FastMathHint fast_math_hint = FastMathHint::Disabled;
-
- // Set model to execute. 0 (MobileNetV1_1.0_224), 1 (MobileNetV1_0.75_160)
- int model_id = (argc > 2) ? std::strtol(argv[2], nullptr, 10) : 0;
- ARM_COMPUTE_ERROR_ON_MSG(model_id > 1, "Invalid model ID. Model must be 0 (MobileNetV1_1.0_224) or 1 (MobileNetV1_0.75_160)");
- int layout_id = (argc > 3) ? std::strtol(argv[3], nullptr, 10) : 0;
- ARM_COMPUTE_ERROR_ON_MSG(layout_id > 1, "Invalid layout ID. Layout must be 0 (NCHW) or 1 (NHWC)");
-
- float depth_scale = (model_id == 0) ? 1.f : 0.75;
- unsigned int spatial_size = (model_id == 0) ? 224 : 160;
- std::string model_path = (model_id == 0) ? "/cnn_data/mobilenet_v1_1_224_model/" : "/cnn_data/mobilenet_v1_075_160_model/";
- TensorDescriptor input_descriptor_nchw = TensorDescriptor(TensorShape(spatial_size, spatial_size, 3U, 1U), DataType::F32);
- TensorDescriptor input_descriptor_nhwc = TensorDescriptor(TensorShape(3U, spatial_size, spatial_size, 1U), DataType::F32).set_layout(DataLayout::NHWC);
- TensorDescriptor input_descriptor = (layout_id == 0) ? input_descriptor_nchw : input_descriptor_nhwc;
-
- // Parse arguments
- if(argc < 2)
- {
- // Print help
- std::cout << "Usage: " << argv[0] << " [target] [model] [layout] [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No model ID provided: using MobileNetV1_1.0_224\n\n";
- std::cout << "No data layout provided: using NCHW\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 2)
- {
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " [model] [layout] [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No model ID provided: using MobileNetV1_1.0_224\n\n";
- std::cout << "No data layout provided: using NCHW\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 3)
- {
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " [layout] [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No data layout provided: using NCHW\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 4)
- {
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " [path_to_data] [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No data folder provided: using random values\n\n";
- }
- else if(argc == 5)
- {
- data_path = argv[4];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " " << argv[4] << " [image] [labels] [fast_math_hint]\n\n";
- std::cout << "No image provided: using random values\n\n";
- std::cout << "No text file with labels provided: skipping output accessor\n\n";
- }
- else if(argc == 6)
- {
- data_path = argv[4];
- image = argv[5];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " [labels] [fast_math_hint]\n\n";
- std::cout << "No text file with labels provided: skipping output accessor\n\n";
- }
- else if(argc == 7)
- {
- data_path = argv[4];
- image = argv[5];
- label = argv[6];
- std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " " << argv[4] << " [fast_math_hint]\n\n";
- std::cout << "No fast math info provided: disabling fast math\n\n";
- }
- else
- {
- data_path = argv[4];
- image = argv[5];
- label = argv[6];
- fast_math_hint = (std::strtol(argv[7], nullptr, 1) == 0) ? FastMathHint::Disabled : FastMathHint::Enabled;
- }
-
- // Add model path to data path
- if(!data_path.empty())
- {
- data_path += model_path;
- }
-
- graph << target_hint
- << convolution_hint
- << depthwise_convolution_hint
- << fast_math_hint
- << InputLayer(input_descriptor,
- get_input_accessor())
- << ConvolutionLayer(
- 3U, 3U, 32U * depth_scale,
- get_weights_accessor(data_path, "Conv2d_0_weights.npy", DataLayout::NCHW),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR))
- .set_name("Conv2d_0")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, "Conv2d_0_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, "Conv2d_0_BatchNorm_moving_variance.npy"),
- get_weights_accessor(data_path, "Conv2d_0_BatchNorm_gamma.npy"),
- get_weights_accessor(data_path, "Conv2d_0_BatchNorm_beta.npy"),
- 0.001f)
- .set_name("Conv2d_0/BatchNorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.f)).set_name("Conv2d_0/Relu6");
- graph << get_dwsc_node(data_path, "Conv2d_1", 64 * depth_scale, PadStrideInfo(1, 1, 1, 1), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_2", 128 * depth_scale, PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_3", 128 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_4", 256 * depth_scale, PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_5", 256 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_6", 512 * depth_scale, PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_7", 512 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_8", 512 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_9", 512 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_10", 512 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_11", 512 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_12", 1024 * depth_scale, PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << get_dwsc_node(data_path, "Conv2d_13", 1024 * depth_scale, PadStrideInfo(1, 1, 1, 1, 1, 1, DimensionRoundingType::CEIL), PadStrideInfo(1, 1, 0, 0));
- graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)).set_name("Logits/AvgPool_1a")
- << ConvolutionLayer(
- 1U, 1U, 1001U,
- get_weights_accessor(data_path, "Logits_Conv2d_1c_1x1_weights.npy", DataLayout::NCHW),
- get_weights_accessor(data_path, "Logits_Conv2d_1c_1x1_biases.npy"),
- PadStrideInfo(1, 1, 0, 0))
- .set_name("Logits/Conv2d_1c_1x1")
- << ReshapeLayer(TensorShape(1001U)).set_name("Reshape")
- << SoftmaxLayer().set_name("Softmax")
- << OutputLayer(get_output_accessor());
-
- // Finalize graph
- GraphConfig config;
- config.use_tuner = (target == 2);
- graph.finalize(target_hint, config);
- }
- void do_run()
- {
- run_benchmark(graph);
- }
-
-private:
- Stream graph{ 0, "MobileNetV1" };
-
- ConcatLayer get_dwsc_node(const std::string &data_path, std::string &&param_path,
- unsigned int conv_filt,
- PadStrideInfo dwc_pad_stride_info, PadStrideInfo conv_pad_stride_info)
- {
- std::string total_path = param_path + "_";
- SubStream sg(graph);
- sg << DepthwiseConvolutionLayer(
- 3U, 3U,
- get_weights_accessor(data_path, total_path + "depthwise_depthwise_weights.npy", DataLayout::NCHW),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- dwc_pad_stride_info)
- .set_name(total_path + "depthwise/depthwise")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "depthwise_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "depthwise_BatchNorm_moving_variance.npy"),
- get_weights_accessor(data_path, total_path + "depthwise_BatchNorm_gamma.npy"),
- get_weights_accessor(data_path, total_path + "depthwise_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(total_path + "depthwise/BatchNorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.f)).set_name(total_path + "depthwise/Relu6")
- << ConvolutionLayer(
- 1U, 1U, conv_filt,
- get_weights_accessor(data_path, total_path + "pointwise_weights.npy", DataLayout::NCHW),
- std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
- conv_pad_stride_info)
- .set_name(total_path + "pointwise/Conv2D")
- << BatchNormalizationLayer(
- get_weights_accessor(data_path, total_path + "pointwise_BatchNorm_moving_mean.npy"),
- get_weights_accessor(data_path, total_path + "pointwise_BatchNorm_moving_variance.npy"),
- get_weights_accessor(data_path, total_path + "pointwise_BatchNorm_gamma.npy"),
- get_weights_accessor(data_path, total_path + "pointwise_BatchNorm_beta.npy"),
- 0.001f)
- .set_name(total_path + "pointwise/BatchNorm")
- << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.f)).set_name(total_path + "pointwise/Relu6");
-
- return ConcatLayer(std::move(sg));
- }
-};
-
-/** Main program for MobileNetV1
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner),
- * [optional] Model ID (0 = MobileNetV1_1.0_224, 1 = MobileNetV1_0.75_160),
- * [optional] Path to the weights folder,
- * [optional] image,
- * [optional] labels,
- * [optional] data layout,
- * [optional] Fast math for convolution layer (0 = DISABLED, 1 = ENABLED) )
- */
-int main(int argc, char **argv)
-{
- GraphMobilenetExample example;
-
- example.do_setup(argc, argv);
- example.do_run();
-
- return 0;
-}
diff --git a/contrib/detection/CMakeLists.txt b/contrib/detection/CMakeLists.txt
deleted file mode 100644
index 37d91b527..000000000
--- a/contrib/detection/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-if(NOT BUILD_DETECTION_APP)
- return()
-endif(NOT BUILD_DETECTION_APP)
-
-nnfw_find_package(Tensorflow REQUIRED)
-
-list(APPEND SOURCES detection.cpp)
-
-add_executable(detection ${SOURCES})
-target_link_libraries(detection nnfw_lib_misc)
-target_link_libraries(detection tensorflow-core)
diff --git a/contrib/detection/detection.cpp b/contrib/detection/detection.cpp
deleted file mode 100644
index 8a988ccf5..000000000
--- a/contrib/detection/detection.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2018 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 <tensorflow/core/public/session.h>
-
-#include <iostream>
-#include <stdexcept>
-
-#include <cassert>
-#include <cstring>
-
-#include "misc/benchmark.h"
-
-#define CHECK_TF(e) { \
- if(!(e).ok()) \
- { \
- throw std::runtime_error{"'" #e "' FAILED"}; \
- } \
-}
-
-int main(int argc, char **argv)
-{
- if (argc < 2)
- {
- std::cerr << "USAGE: " << argv[0] << " [T/F model path] [output 0] [output 1] ..." << std::endl;
- return 255;
- }
-
- std::vector<std::string> output_nodes;
-
- for (int argn = 2; argn < argc; ++argn)
- {
- output_nodes.emplace_back(argv[argn]);
- }
-
- tensorflow::Session* sess;
-
- CHECK_TF(tensorflow::NewSession(tensorflow::SessionOptions(), &sess));
-
- tensorflow::GraphDef graph_def;
-
- CHECK_TF(ReadBinaryProto(tensorflow::Env::Default(), argv[1], &graph_def));
- CHECK_TF(sess->Create(graph_def));
-
- tensorflow::Tensor input(tensorflow::DT_FLOAT, tensorflow::TensorShape({1, 320, 320, 3}));
- std::vector<tensorflow::Tensor> outputs;
-
- for (uint32_t n = 0; n < 5; ++n)
- {
- std::chrono::milliseconds elapsed(0);
-
- nnfw::misc::benchmark::measure(elapsed) << [&] (void) {
- CHECK_TF(sess->Run({{"input_node", input}}, output_nodes, {}, &outputs));
- };
-
- std::cout << "Takes " << elapsed.count() << "ms" << std::endl;
- }
-
- return 0;
-}
diff --git a/contrib/labs/CMakeLists.txt b/contrib/labs/CMakeLists.txt
deleted file mode 100644
index 57e28c11a..000000000
--- a/contrib/labs/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-if(NOT BUILD_LABS)
- return()
-endif(NOT BUILD_LABS)
-
-add_subdirectories()
diff --git a/contrib/labs/jniacl/CMakeLists.txt b/contrib/labs/jniacl/CMakeLists.txt
deleted file mode 100644
index f66127b84..000000000
--- a/contrib/labs/jniacl/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Simple Android JNI execution test of ACL
-#
-
-if(NOT "${TARGET_OS}" STREQUAL "android")
- return()
-endif(NOT "${TARGET_OS}" STREQUAL "android")
-
-nnfw_find_package(ARMCompute REQUIRED)
-
-link_directories(${CMAKE_INSTALL_PREFIX}/lib)
-
-set(JNIACL_SRCS src/jniacl_main.cc
- src/io_accessor.cc)
-
-add_library(jniacl_jni SHARED ${JNIACL_SRCS})
-target_include_directories(jniacl_jni PUBLIC ${TFLITE_JNI_INCLUDES} src)
-target_link_libraries(jniacl_jni arm_compute_graph log)
diff --git a/contrib/labs/jniacl/src/io_accessor.cc b/contrib/labs/jniacl/src/io_accessor.cc
deleted file mode 100644
index 103660716..000000000
--- a/contrib/labs/jniacl/src/io_accessor.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (c) 2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#include "io_accessor.h"
-#include <ostream>
-#include <android/log.h>
-
-bool InputAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- // Subtract the mean value from each channel
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) = _test_input;
- _test_input += _inc ? 1.0 : 0.0;
-
- __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "Input %d, %d = %lf\r\n",
- id.y(), id.x(), *reinterpret_cast<float *>(tensor.ptr_to_element(id)));
- });
- return true;
-}
-
-bool OutputAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- // Subtract the mean value from each channel
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- __android_log_print(ANDROID_LOG_DEBUG, "Output", "Input %d, %d = %lf\r\n",
- id.y(), id.x(), *reinterpret_cast<float *>(tensor.ptr_to_element(id)));
- });
- return false; // end the network
-}
-
-bool WeightAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- // Subtract the mean value from each channel
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) = _test_weight;
- _test_weight += _inc ? 1.0 : 0.0;
- });
- return true;
-}
-
-bool BiasAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- // Subtract the mean value from each channel
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) = 0.0;
- });
- return true;
-}
diff --git a/contrib/labs/jniacl/src/io_accessor.h b/contrib/labs/jniacl/src/io_accessor.h
deleted file mode 100644
index 4033020e0..000000000
--- a/contrib/labs/jniacl/src/io_accessor.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (c) 2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef __IO_ACCESSOR_H__
-#define __IO_ACCESSOR_H__
-
-#include <arm_compute/graph/ITensorAccessor.h>
-
-class InputAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- InputAccessor(bool inc) : _inc(inc) { _test_input = 1.0; }
- InputAccessor(InputAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-
-private:
- bool _inc;
- float _test_input;
-};
-
-class OutputAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- OutputAccessor() = default;
- OutputAccessor(OutputAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-};
-
-class WeightAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- WeightAccessor(bool inc) : _inc(inc) { _test_weight = 1.0; }
- WeightAccessor(WeightAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-
-private:
- bool _inc;
- float _test_weight;
-};
-
-class BiasAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- BiasAccessor() = default;
- BiasAccessor(BiasAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-};
-
-#endif // __IO_ACCESSOR_H__
diff --git a/contrib/labs/jniacl/src/jniacl_main.cc b/contrib/labs/jniacl/src/jniacl_main.cc
deleted file mode 100644
index 515f28732..000000000
--- a/contrib/labs/jniacl/src/jniacl_main.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <jni.h>
-#include <string>
-
-#include <arm_compute/graph/Graph.h>
-#include <arm_compute/graph/Nodes.h>
-
-#include "io_accessor.h"
-
-extern "C" JNIEXPORT jstring JNICALL
-Java_com_samsung_testaclexec_ActivityMain_RunACLJNI(JNIEnv *env, jobject)
-{
- using arm_compute::DataType;
- using arm_compute::graph::Tensor;
- using arm_compute::graph::TargetHint;
- using arm_compute::graph::Graph;
- using arm_compute::TensorInfo;
- using arm_compute::TensorShape;
-
- arm_compute::graph::Graph graph;
- TargetHint target_hint = TargetHint::OPENCL;
- bool autoinc = true;
-
- graph << target_hint
- << Tensor(TensorInfo(TensorShape(3U, 3U, 1U, 1U), 1, DataType::F32),
- std::unique_ptr<InputAccessor>(new InputAccessor(autoinc)))
- << arm_compute::graph::ConvolutionLayer(
- 3U, 3U, 1U,
- std::unique_ptr<WeightAccessor>(new WeightAccessor(autoinc)),
- std::unique_ptr<BiasAccessor>(new BiasAccessor()),
- arm_compute::PadStrideInfo(1, 1, 0, 0))
- << Tensor(std::unique_ptr<OutputAccessor>(new OutputAccessor()));
- ;
-
- graph.run();
-
- std::string hello = "SoftMax Run OK";
-
- return env->NewStringUTF(hello.c_str());
-}
diff --git a/contrib/labs/kerneltesting/CMakeLists.txt b/contrib/labs/kerneltesting/CMakeLists.txt
deleted file mode 100644
index 5792d0fe8..000000000
--- a/contrib/labs/kerneltesting/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-if(NOT ${TARGET_ARCH_BASE} STREQUAL "arm")
- return()
-endif(NOT ${TARGET_ARCH_BASE} STREQUAL "arm")
-
-nnfw_find_package(ARMCompute REQUIRED)
-
-function(add_kerneltesting TESTNAME SRC_FILES)
- link_directories(${CMAKE_INSTALL_PREFIX}/lib)
- add_executable(${TESTNAME} ${SRC_FILES})
- target_include_directories(${TESTNAME} PUBLIC
- ${NNFW_INCLUDE_DIR})
- target_link_libraries(${TESTNAME} nnfw_lib_misc arm_compute_graph)
- install(TARGETS ${TESTNAME} DESTINATION bin)
-endfunction()
-
-# TODO: Enable conv2d on Tizen
-if (NOT ${TARGET_OS} STREQUAL "tizen")
- add_subdirectory(conv2d)
-endif()
diff --git a/contrib/labs/kerneltesting/conv2d/CMakeLists.txt b/contrib/labs/kerneltesting/conv2d/CMakeLists.txt
deleted file mode 100644
index 25e01f584..000000000
--- a/contrib/labs/kerneltesting/conv2d/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-set(KERNELTESTING_CONV2D kerneltesting_conv2d)
-
-set(KERNELTESTING_CONV2D_SRCS "nnfw_conv2d_test.cpp"
- "io_accessor.cpp")
-
-set(GEMLOWP_INCUDE ${TFLITE_DEPEND_DIR}/gemmlowp/public)
-set(EIGN_INCLUDE ${TFLITE_DEPEND_DIR}/eigen
- ${TFLITE_DEPEND_DIR}/eigen/Eigen)
-
-add_kerneltesting(${KERNELTESTING_CONV2D} "${KERNELTESTING_CONV2D_SRCS}")
-
-target_include_directories(${KERNELTESTING_CONV2D} PUBLIC
- ${GEMLOWP_INCUDE}
- ${EIGN_INCLUDE}
- )
diff --git a/contrib/labs/kerneltesting/conv2d/OperationUtils.h b/contrib/labs/kerneltesting/conv2d/OperationUtils.h
deleted file mode 100644
index 0beac80a4..000000000
--- a/contrib/labs/kerneltesting/conv2d/OperationUtils.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * 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 ANDROID_ML_NN_COMMON_OPERATIONS_UTILS_H
-#define ANDROID_ML_NN_COMMON_OPERATIONS_UTILS_H
-
-#include <cstdint>
-#include <vector>
-#include <ostream>
-
-#define LOG(ERROR) std::cerr
-
-// Macro to check if the input parameters for operation are valid or not.
-#define NN_CHECK(v) \
- do { \
- if (!(v)) { \
- LOG(ERROR) << "NN_CHECK failed: " << #v << "'\n"; \
- return false; \
- } \
- } while(0);
-
-#define NN_CHECK_EQ(actual, expected) \
- NN_CHECK((actual) == (expected))
-
-#define NN_OPS_CHECK NN_CHECK
-
-enum PaddingScheme {
- kPaddingUnknown = 0,
- kPaddingSame = 1,
- kPaddingValid = 2,
-};
-
-enum class FusedActivationFunc : int32_t {
- NONE = 0,
- RELU = 1,
- RELU1 = 2,
- RELU6 = 3,
-};
-
-
-#define ANDROID_NN_MACRO_DISPATCH(macro) \
- switch (activation) { \
- case (int32_t) FusedActivationFunc::NONE: \
- macro(kNone); \
- break; \
- case (int32_t) FusedActivationFunc::RELU: \
- macro(kRelu); \
- break; \
- case (int32_t) FusedActivationFunc::RELU1: \
- macro(kRelu1); \
- break; \
- case (int32_t) FusedActivationFunc::RELU6: \
- macro(kRelu6); \
- break; \
- default: \
- LOG(ERROR) << "Unsupported fused activation function type"; \
- return false; \
- }
-
-
-#endif // ANDROID_ML_NN_COMMON_OPERATIONS_UTILS_H
diff --git a/contrib/labs/kerneltesting/conv2d/common.h b/contrib/labs/kerneltesting/conv2d/common.h
deleted file mode 100644
index 8e675e664..000000000
--- a/contrib/labs/kerneltesting/conv2d/common.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * 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 ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_COMMON_H_
-#define ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_COMMON_H_
-
-#ifndef USE_NEON
-#if defined(__ARM_NEON__) || defined(__ARM_NEON)
-#define USE_NEON
-#include <arm_neon.h>
-#endif
-#endif
-
-#include <gemmlowp.h>
-#include "types.h"
-
-template <FusedActivationFunctionType Ac>
-struct ActivationFunctionImpl {};
-
-template <>
-struct ActivationFunctionImpl<FusedActivationFunctionType::kNone> {
- static float Eval(float x) { return x; }
-};
-
-template <>
-struct ActivationFunctionImpl<FusedActivationFunctionType::kRelu> {
- static float Eval(float x) { return x < 0.f ? 0.f : x; }
-};
-
-template <>
-struct ActivationFunctionImpl<FusedActivationFunctionType::kRelu1> {
- static float Eval(float x) { return x > 1.f ? 1.f : x < -1.f ? -1.f : x; }
-};
-
-template <>
-struct ActivationFunctionImpl<FusedActivationFunctionType::kRelu6> {
- static float Eval(float x) { return x > 6.f ? 6.f : x < 0.f ? 0.f : x; }
-};
-
-template <FusedActivationFunctionType Ac>
-float ActivationFunction(float x) {
- return ActivationFunctionImpl<Ac>::Eval(x);
-}
-
-inline int32 MultiplyByQuantizedMultiplierSmallerThanOne(
- int32 x, int32 quantized_multiplier, int right_shift) {
- using gemmlowp::RoundingDivideByPOT;
- using gemmlowp::SaturatingRoundingDoublingHighMul;
- return RoundingDivideByPOT(
- SaturatingRoundingDoublingHighMul(x, quantized_multiplier), right_shift);
-}
-
-inline int32 MultiplyByQuantizedMultiplierGreaterThanOne(
- int32 x, int32 quantized_multiplier, int left_shift) {
- using gemmlowp::SaturatingRoundingDoublingHighMul;
- return SaturatingRoundingDoublingHighMul(x * (1 << left_shift),
- quantized_multiplier);
-}
-
-#endif // ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_COMMON_H_
diff --git a/contrib/labs/kerneltesting/conv2d/compatibility.h b/contrib/labs/kerneltesting/conv2d/compatibility.h
deleted file mode 100644
index db8ba04bc..000000000
--- a/contrib/labs/kerneltesting/conv2d/compatibility.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * 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 ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_COMPATIBILITY_H_
-#define ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_COMPATIBILITY_H_
-
-#ifndef ANDROID_ML_NN_COMPATIBILITY
-#define ANDROID_ML_NN_COMPATIBILITY
-
-#include <cassert>
-#include <cstdint>
-
-#ifndef DCHECK
-#define DCHECK(condition) (condition) ? (void)0 : assert(false)
-#endif
-
-#ifndef DCHECK_EQ
-#define DCHECK_EQ(x, y) ((x) == (y)) ? (void)0 : assert(false)
-#endif
-
-#ifndef DCHECK_GE
-#define DCHECK_GE(x, y) ((x) >= (y)) ? (void)0 : assert(false)
-#endif
-
-#ifndef DCHECK_GT
-#define DCHECK_GT(x, y) ((x) > (y)) ? (void)0 : assert(false)
-#endif
-
-#ifndef DCHECK_LE
-#define DCHECK_LE(x, y) ((x) <= (y)) ? (void)0 : assert(false)
-#endif
-
-#ifndef DCHECK_LT
-#define DCHECK_LT(x, y) ((x) < (y)) ? (void)0 : assert(false)
-#endif
-
-#ifndef CHECK_EQ
-#define CHECK_EQ(x, y) ((x) == (y)) ? (void)0 : assert(false)
-#endif
-
-using uint8 = std::uint8_t;
-using int16 = std::int16_t;
-using uint16 = std::uint16_t;
-using int32 = std::int32_t;
-using uint32 = std::uint32_t;
-
-#endif
-
-#endif // ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_COMPATIBILITY_H_
diff --git a/contrib/labs/kerneltesting/conv2d/io_accessor.cpp b/contrib/labs/kerneltesting/conv2d/io_accessor.cpp
deleted file mode 100644
index 6d3cd9d04..000000000
--- a/contrib/labs/kerneltesting/conv2d/io_accessor.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (c) 2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#include "io_accessor.h"
-
-InputAccessor::InputAccessor(const float* inputData, const Shape& inputShape)
- : _inputData(inputData)
- , _inputShape(inputShape)
-{
-}
-
-WeightAccessor::WeightAccessor(const float* filterData, const Shape& filterShape)
- : _filterData(filterData)
- , _filterShape(filterShape)
-{
-}
-
-BiasAccessor::BiasAccessor(const float* biasData, const Shape& biasShape)
- : _biasData(biasData)
- , _biasShape(biasShape)
-{
-}
-
-OutputAccessor::OutputAccessor(float* outputData, const Shape& outputShape)
- : _outputData(outputData)
- , _outputShape(outputShape)
-{
-}
-
-bool InputAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- uint32_t width = getSizeOfDimension(_inputShape, 2);
- uint32_t offset = id.y() * width + id.x();
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) =
- *(_inputData + offset);
- });
- return true;
-}
-
-bool WeightAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- uint32_t width = getSizeOfDimension(_filterShape, 2);
- uint32_t offset = id.y() * width + id.x();
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) =
- *(_filterData + offset);
- });
- return true;
-}
-
-bool BiasAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- uint32_t width = getSizeOfDimension(_biasShape, 2);
- uint32_t offset = id.y() * width + id.x();
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) =
- *(_biasData + offset);
- });
- return true;
-}
-
-bool OutputAccessor::access_tensor(arm_compute::ITensor &tensor)
-{
- arm_compute::Window window;
- window.use_tensor_dimensions(tensor.info()->tensor_shape());
-
- execute_window_loop(window, [&](const arm_compute::Coordinates& id)
- {
- uint32_t width = getSizeOfDimension(_outputShape, 2);
- uint32_t offset = id.y() * width + id.x();
- *(_outputData + offset) =
- *reinterpret_cast<float *>(tensor.ptr_to_element(id));
- });
- return false; // end the network
-}
diff --git a/contrib/labs/kerneltesting/conv2d/io_accessor.h b/contrib/labs/kerneltesting/conv2d/io_accessor.h
deleted file mode 100644
index 0201f7242..000000000
--- a/contrib/labs/kerneltesting/conv2d/io_accessor.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (c) 2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef __CONV2D_IO_ACCESSOR_H__
-#define __CONV2D_IO_ACCESSOR_H__
-
-#include <arm_compute/graph/ITensorAccessor.h>
-#include <arm_compute/runtime/CL/CLFunctions.h>
-
-#include "types.h"
-
-class InputAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- InputAccessor(const float* inputData, const Shape& inputShape);
- InputAccessor(InputAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-
-private:
- const float* _inputData;
- const Shape& _inputShape;
-};
-
-class WeightAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- WeightAccessor(const float* filterData, const Shape& filterShape);
- WeightAccessor(WeightAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-
-private:
- const float* _filterData;
- const Shape& _filterShape;
-};
-
-class BiasAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- BiasAccessor(const float* biasData, const Shape& biasShape);
- BiasAccessor(BiasAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-
-private:
- const float* _biasData;
- const Shape& _biasShape;
-};
-
-class OutputAccessor : public arm_compute::graph::ITensorAccessor
-{
-public:
- OutputAccessor(float* outputData, const Shape& outputShape);
- OutputAccessor(OutputAccessor&&) = default;
-
- // Inherited methods overriden:
- bool access_tensor(arm_compute::ITensor& tensor) override;
-
-private:
- float* _outputData;
- const Shape& _outputShape;
-};
-
-#endif // __CONV2D_IO_ACCESSOR_H__
diff --git a/contrib/labs/kerneltesting/conv2d/nnfw_conv2d_test.cpp b/contrib/labs/kerneltesting/conv2d/nnfw_conv2d_test.cpp
deleted file mode 100644
index 190be016e..000000000
--- a/contrib/labs/kerneltesting/conv2d/nnfw_conv2d_test.cpp
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (c) 2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <vector>
-#include <cassert>
-
-#include <Eigen/Core>
-#include <gemmlowp.h>
-
-#include "types.h"
-#include "common.h"
-#include "optimized_ops.h"
-#include "OperationUtils.h"
-
-#include <arm_compute/graph.h>
-
-#include <arm_compute/runtime/CL/CLFunctions.h>
-#include <arm_compute/runtime/CL/functions/CLConvolution.h>
-
-#include "io_accessor.h"
-#include "misc/environment.h"
-
-static constexpr int kStaticBufferSize = 1605632;
-static char static_scratch_buffer[kStaticBufferSize];
-
-#define ANDROID_NN_CONV_PARAMETERS(Type) \
- uint32_t height = getSizeOfDimension(inputShape, 1); \
- uint32_t width = getSizeOfDimension(inputShape, 2); \
- uint32_t filterHeight = getSizeOfDimension(filterShape, 1); \
- uint32_t filterWidth = getSizeOfDimension(filterShape, 2); \
- uint32_t outHeight = getSizeOfDimension(outputShape, 1); \
- uint32_t outWidth = getSizeOfDimension(outputShape, 2); \
- uint32_t inDepth = getSizeOfDimension(inputShape, 3); \
- \
- uint32_t paddingHeight = (uint32_t)padding_top; \
- uint32_t paddingWidth = (uint32_t)padding_left; \
- \
- Dims<4> im2colDim; \
- im2colDim.sizes[3] = (int)getSizeOfDimension(outputShape, 0); \
- im2colDim.sizes[2] = (int)getSizeOfDimension(outputShape, 1); \
- im2colDim.sizes[1] = (int)getSizeOfDimension(outputShape, 2); \
- im2colDim.sizes[0] = (int)inDepth * filterHeight * filterWidth; \
- \
- im2colDim.strides[0] = 1; \
- for (int i=1; i<4; i++) { \
- im2colDim.strides[i] = im2colDim.strides[i-1] * im2colDim.sizes[i-1]; \
- } \
- \
- Type* im2colData = nullptr; \
- int im2colByteSize = sizeof(Type); \
- for (int i=0; i<4; i++) { \
- im2colByteSize *= im2colDim.sizes[i]; \
- } \
- if (im2colByteSize <= kStaticBufferSize) { \
- im2colData = reinterpret_cast<Type *>(static_scratch_buffer); \
- } else { \
- im2colData = new (std::nothrow) Type[im2colByteSize / sizeof(Type)]; \
- }
-
-
-bool convFloat32(const float* inputData, const Shape& inputShape,
- const float* filterData, const Shape& filterShape,
- const float* biasData, const Shape& biasShape,
- int32_t padding_left, int32_t padding_right,
- int32_t padding_top, int32_t padding_bottom,
- int32_t stride_width, int32_t stride_height,
- int32_t activation,
- float* outputData, const Shape& outputShape) {
-
- ANDROID_NN_CONV_PARAMETERS(float)
-
- #define ANDROID_NN_CONV(activation) \
- Conv<FusedActivationFunctionType::activation>( \
- inputData, convertShapeToDims(inputShape), \
- filterData, convertShapeToDims(filterShape), \
- biasData, convertShapeToDims(biasShape), \
- stride_width, stride_height, paddingWidth, paddingHeight, \
- outputData, convertShapeToDims(outputShape), \
- im2colData, im2colDim)
-
- ANDROID_NN_MACRO_DISPATCH(ANDROID_NN_CONV)
-
- #undef ANDROID_NN_CONV
-
- if (im2colByteSize > kStaticBufferSize) {
- delete[] im2colData;
- }
- return true;
-}
-
-//-----------------------------------------------------------------------------
-
-using arm_compute::DataType;
-using arm_compute::graph::Target;
-using arm_compute::graph::TensorDescriptor;
-using arm_compute::TensorShape;
-using arm_compute::graph::frontend::InputLayer;
-using arm_compute::graph::frontend::OutputLayer;
-
-namespace acl_graph {
-
-bool convFloat32(const float* inputData, const Shape& inputShape,
- const float* filterData, const Shape& filterShape,
- const float* biasData, const Shape& biasShape,
- int32_t padding_left, int32_t padding_right,
- int32_t padding_top, int32_t padding_bottom,
- int32_t stride_width, int32_t stride_height,
- int32_t activation,
- float* outputData, const Shape& outputShape)
-{
- // Try with simple build-run with ACL Layer
- arm_compute::graph::frontend::Stream graph{0, "ACL_CONV2D_TEST"};
-
- Target target_hint = nnfw::misc::get_env_int("NNFW_ACL_USENEON")
- ? Target::NEON : Target::CL;
-
- // Not sure about which index is which value
- uint32_t tsi_c = getSizeOfDimension(inputShape, 0);
- uint32_t tsi_h = getSizeOfDimension(inputShape, 1);
- uint32_t tsi_w = getSizeOfDimension(inputShape, 2);
- uint32_t tsi_n = getSizeOfDimension(inputShape, 3);
-
- uint32_t tsk_h = getSizeOfDimension(filterShape, 1);
- uint32_t tsk_w = getSizeOfDimension(filterShape, 2);
- uint32_t tsk_n = getSizeOfDimension(filterShape, 3);
-
- graph << target_hint
- << InputLayer(TensorDescriptor(TensorShape(tsi_w, tsi_h, tsi_c, tsi_n), DataType::F32),
- std::unique_ptr<InputAccessor>(new InputAccessor(inputData, inputShape)))
- << arm_compute::graph::frontend::ConvolutionLayer(
- tsk_w, tsk_h, tsk_n,
- std::unique_ptr<WeightAccessor>(new WeightAccessor(filterData, filterShape)),
- std::unique_ptr<BiasAccessor>(new BiasAccessor(biasData, biasShape)),
- arm_compute::PadStrideInfo(stride_width, stride_height, padding_top, padding_bottom))
- ;
- if (activation != static_cast<int32_t>(FusedActivationFunc::NONE)) {
- arm_compute::ActivationLayerInfo::ActivationFunction actFunc =
- arm_compute::ActivationLayerInfo::ActivationFunction::RELU;
-
- graph << arm_compute::graph::frontend::ActivationLayer(arm_compute::ActivationLayerInfo(actFunc));
- // Activation does not provide output Tensor and makes next layer fail to add to graph
- // when it's the last(output) layer. To solve this, need to add a dummy layer.
- uint32_t tso_c = getSizeOfDimension(outputShape, 0);
- uint32_t tso_h = getSizeOfDimension(outputShape, 1);
- uint32_t tso_w = getSizeOfDimension(outputShape, 2);
- uint32_t tso_n = getSizeOfDimension(outputShape, 3);
- graph << arm_compute::graph::frontend::ReshapeLayer(TensorShape(tso_w, tso_h, tso_c, tso_n));
- }
- graph << OutputLayer(std::unique_ptr<OutputAccessor>(new OutputAccessor(outputData, outputShape)))
- ;
-
- graph.run();
-
- return true;
-}
-
-} // namespace acl_graph
-
-//-----------------------------------------------------------------------------
-
-using arm_compute::TensorInfo;
-
-namespace acl_runtime {
-
-TensorShape calculate_convolution_layer_output_shape(
- const arm_compute::TensorShape &input_shape,
- const arm_compute::TensorShape &weights_shape,
- const arm_compute::PadStrideInfo &conv_info)
-{
- unsigned int output_width = 0;
- unsigned int output_height = 0;
-
- // Get output width and height
- std::tie(output_width, output_height) =
- arm_compute::scaled_dimensions(
- input_shape.x(), input_shape.y(),
- weights_shape.x(), weights_shape.y(),
- conv_info);
-
- // Create output shape
- TensorShape output_shape = input_shape;
- output_shape.set(0, output_width);
- output_shape.set(1, output_height);
- output_shape.set(2, weights_shape[3]);
-
- return output_shape;
-}
-
-bool convFloat32(const float* inputData, const Shape& inputShape,
- const float* filterData, const Shape& filterShape,
- const float* biasData, const Shape& biasShape,
- int32_t padding_left, int32_t padding_right,
- int32_t padding_top, int32_t padding_bottom,
- int32_t stride_width, int32_t stride_height,
- int32_t activation,
- float* outputData, const Shape& outputShape)
-{
- arm_compute::CLScheduler::get().default_init();
-
- uint32_t tsi_c = getSizeOfDimension(inputShape, 0);
- uint32_t tsi_h = getSizeOfDimension(inputShape, 1);
- uint32_t tsi_w = getSizeOfDimension(inputShape, 2);
- uint32_t tsi_n = getSizeOfDimension(inputShape, 3);
-
- uint32_t tsk_h = getSizeOfDimension(filterShape, 1);
- uint32_t tsk_w = getSizeOfDimension(filterShape, 2);
- uint32_t tsk_n = getSizeOfDimension(filterShape, 3);
-
- TensorShape input_shape = TensorShape(tsi_w, tsi_h, tsi_c, tsi_n);
- TensorShape filter_shape = TensorShape(tsi_w, tsi_h, tsi_c, tsi_n);
- arm_compute::PadStrideInfo conv_info =
- arm_compute::PadStrideInfo(stride_width, stride_height, padding_top, padding_bottom);
-
- TensorShape output_shape = calculate_convolution_layer_output_shape(
- input_shape, filter_shape, conv_info);
-
- uint32_t tso_c = output_shape[0];
- uint32_t tso_w = output_shape[1];
- uint32_t tso_h = output_shape[2];
- uint32_t tso_n = output_shape[3];
-
- arm_compute::CLTensor input, output, bias, filter;
-
- input.allocator()->init(TensorInfo(tsi_w, tsi_h, arm_compute::Format::F32));
- output.allocator()->init(TensorInfo(tso_w, tso_h, arm_compute::Format::F32));
- bias.allocator()->init(TensorInfo(tso_w, tso_h, arm_compute::Format::F32));
- filter.allocator()->init(TensorInfo(tsk_w, tsk_h, arm_compute::Format::F32));
-
- input.allocator()->allocate();
- output.allocator()->allocate();
- bias.allocator()->allocate();
- filter.allocator()->allocate();
-
- input.map();
- InputAccessor ia(inputData, inputShape);
- ia.access_tensor(input);
- input.unmap();
-
- bias.map();
- BiasAccessor ba(biasData, biasShape);
- ba.access_tensor(bias);
- bias.unmap();
-
- filter.map();
- WeightAccessor fa(filterData, filterShape);
- fa.access_tensor(filter);
- filter.unmap();
-
- arm_compute::CLConvolutionLayer conv_f;
- conv_f.configure(&input, &filter, &bias, &output, conv_info);
-
- arm_compute::CLScheduler::get().sync();
-
- conv_f.run();
-
- output.map();
- OutputAccessor oa(outputData, outputShape);
- oa.access_tensor(output);
- output.unmap();
-
- return true;
-}
-
-} // namespace acl_runtime
-
-//-----------------------------------------------------------------------------
-
-enum COMPUTE_TYPE {
- COMPUTE_DEFAULT = 0,
- COMPUTE_ACLGRAPH,
- COMPUTE_ACLRT
-};
-
-bool convFloat32(const float* inputData, const Shape& inputShape,
- const float* filterData, const Shape& filterShape,
- const float* biasData, const Shape& biasShape,
- int32_t padding_left, int32_t padding_right,
- int32_t padding_top, int32_t padding_bottom,
- int32_t stride_width, int32_t stride_height,
- int32_t activation,
- float* outputData, const Shape& outputShape,
- COMPUTE_TYPE compType) {
-
- switch (compType)
- {
- case COMPUTE_DEFAULT :
- return convFloat32(inputData, inputShape, filterData, filterShape,
- biasData, biasShape, padding_left, padding_right,
- padding_top, padding_bottom, stride_width, stride_height,
- activation, outputData, outputShape);
-
- case COMPUTE_ACLGRAPH :
- return acl_graph::convFloat32(inputData, inputShape, filterData, filterShape,
- biasData, biasShape, padding_left, padding_right,
- padding_top, padding_bottom, stride_width, stride_height,
- activation, outputData, outputShape);
-
- case COMPUTE_ACLRT :
- return acl_runtime::convFloat32(inputData, inputShape, filterData, filterShape,
- biasData, biasShape, padding_left, padding_right,
- padding_top, padding_bottom, stride_width, stride_height,
- activation, outputData, outputShape);
- }
- return false;
-}
-
-//-----------------------------------------------------------------------------
-
-void dumpData(const char* name, const float* data, const Shape& shape)
-{
- uint32_t height = getSizeOfDimension(shape, 1);
- uint32_t width = getSizeOfDimension(shape, 2);
-
- std::cout << "---" << name << "---" << std::endl;
- for (int h = 0; h < height; h++) {
- std::cout << "H=" << h << " | ";
- for (int w = 0; w < width; w++) {
- std::cout << data[h * width + w] << ",";
- }
- std::cout << std::endl;
- }
-}
-
-void initData(float* outputData, int num, float value)
-{
- for (int i = 0; i < num; i++) {
- *(outputData + i) = value;
- }
-}
-
-void initDataSeq(float* outputData, int num, float value)
-{
- for (int i = 0; i < num; i++) {
- *(outputData + i) = value;
- value += 1.0;
- }
-}
-
-// compareData
-// return true if result == expected with the shape info,
-// otherwise false
-bool compareData(const float* result, const float* expected, const Shape& shape)
-{
- NN_CHECK_EQ(shape.dimensions.size(), 4);
-
- uint32_t height = getSizeOfDimension(shape, 1);
- uint32_t width = getSizeOfDimension(shape, 2);
- uint32_t numitems = height * width;
- for (int item = 0; item < numitems; item++) {
- if (*(result + item) != *(expected + item)) {
- LOG(ERROR) << "compareData failed: result " << *(result + item)
- << ", expected " << *(expected + item) << std::endl;
- return false;
- }
- }
- return true;
-}
-
-int test_3x3_1x1_one(COMPUTE_TYPE comptype)
-{
- float inputData[9];
- const Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float filterData[9];
- const Shape filterShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float biasData[1] = { 1.0 };
- const Shape biasShape = { OperandType::FLOAT32, {1,1,1,1}, 1.0, 0 };
- int32_t padding_left = 0;
- int32_t padding_right = 0;
- int32_t padding_top = 0;
- int32_t padding_bottom = 0;
- int32_t stride_width = 1;
- int32_t stride_height = 1;
- int32_t activation = static_cast<int32_t>(FusedActivationFunc::RELU);
- float* outputData = new float[9];
- const Shape outputShape = { OperandType::FLOAT32, {1,1,1,1}, 1.0, 0 };
- float* expectData = new float[9];
- bool bret;
-
- initData(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
- initData(filterData, sizeof(filterData) / sizeof(filterData[0]), 1.0);
- initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
- initData(expectData, sizeof(expectData) / sizeof(expectData[0]), 0.0);
-
- bret = convFloat32(inputData, inputShape,
- filterData, filterShape,
- biasData, biasShape,
- padding_left, padding_right,
- padding_top, padding_bottom,
- stride_width, stride_height,
- activation,
- expectData, outputShape,
- COMPUTE_DEFAULT);
-
- bret = convFloat32(inputData, inputShape,
- filterData, filterShape,
- biasData, biasShape,
- padding_left, padding_right,
- padding_top, padding_bottom,
- stride_width, stride_height,
- activation,
- outputData, outputShape,
- comptype);
-
- dumpData("Input ", inputData, inputShape);
- dumpData("Filter ", filterData, filterShape);
- dumpData("Bias ", biasData, biasShape);
- dumpData("Output ", outputData, outputShape);
- std::cout << std::endl;
-
- bret = compareData(outputData, expectData, outputShape);
-
- delete outputData;
- delete expectData;
-
- if (!bret)
- {
- LOG(ERROR) << "TEST FAILED " << __FUNCTION__ << std::endl;
- return -1;
- }
- return 0;
-}
-
-int test_3x3_3x3_one(void)
-{
- float inputData[9];
- const Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float filterData[9];
- const Shape filterShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float biasData[1] = { 1.0 };
- const Shape biasShape = { OperandType::FLOAT32, {1,1,1,1}, 1.0, 0 };
- int32_t padding_left = 1;
- int32_t padding_right = 1;
- int32_t padding_top = 1;
- int32_t padding_bottom = 1;
- int32_t stride_width = 1;
- int32_t stride_height = 1;
- int32_t activation = static_cast<int32_t>(FusedActivationFunc::RELU);
- float* outputData = new float[9];
- const Shape outputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float* expectData = new float[9];
- bool bret;
-
- initData(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
- initData(filterData, sizeof(filterData) / sizeof(filterData[0]), 1.0);
- initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
- initData(expectData, sizeof(expectData) / sizeof(expectData[0]), 0.0);
-
- bret = convFloat32(inputData, inputShape,
- filterData, filterShape,
- biasData, biasShape,
- padding_left, padding_right,
- padding_top, padding_bottom,
- stride_width, stride_height,
- activation,
- expectData, outputShape,
- COMPUTE_DEFAULT);
-
- bret = convFloat32(inputData, inputShape,
- filterData, filterShape,
- biasData, biasShape,
- padding_left, padding_right,
- padding_top, padding_bottom,
- stride_width, stride_height,
- activation,
- outputData, outputShape,
- COMPUTE_ACLGRAPH);
-
- dumpData("Input ", inputData, inputShape);
- dumpData("Filter ", filterData, filterShape);
- dumpData("Bias ", biasData, biasShape);
- dumpData("Output ", outputData, outputShape);
- std::cout << std::endl;
-
- bret = compareData(outputData, expectData, outputShape);
-
- delete outputData;
- delete expectData;
-
- if (!bret)
- {
- LOG(ERROR) << "TEST FAILED " << __FUNCTION__ << std::endl;
- return -1;
- }
- return 0;
-}
-
-int test_3x3_3x3_seq(void)
-{
- float inputData[9];
- const Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float filterData[9];
- const Shape filterShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float biasData[1] = { 1.0 };
- const Shape biasShape = { OperandType::FLOAT32, {1,1,1,1}, 1.0, 0 };
- int32_t padding_left = 1;
- int32_t padding_right = 1;
- int32_t padding_top = 1;
- int32_t padding_bottom = 1;
- int32_t stride_width = 1;
- int32_t stride_height = 1;
- int32_t activation = static_cast<int32_t>(FusedActivationFunc::RELU);
- float* outputData = new float[9];
- const Shape outputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 };
- float* expectData = new float[9];
- bool bret;
-
- initDataSeq(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
- initDataSeq(filterData, sizeof(filterData) / sizeof(filterData[0]), 1.0);
- initDataSeq(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
- initData(expectData, sizeof(expectData) / sizeof(expectData[0]), 0.0);
-
- bret = convFloat32(inputData, inputShape,
- filterData, filterShape,
- biasData, biasShape,
- padding_left, padding_right,
- padding_top, padding_bottom,
- stride_width, stride_height,
- activation,
- expectData, outputShape,
- COMPUTE_DEFAULT);
-
- bret = convFloat32(inputData, inputShape,
- filterData, filterShape,
- biasData, biasShape,
- padding_left, padding_right,
- padding_top, padding_bottom,
- stride_width, stride_height,
- activation,
- outputData, outputShape,
- COMPUTE_ACLGRAPH);
-
- dumpData("Input ", inputData, inputShape);
- dumpData("Filter ", filterData, filterShape);
- dumpData("Bias ", biasData, biasShape);
- dumpData("Output ", outputData, outputShape);
- std::cout << std::endl;
-
- bret = compareData(outputData, expectData, outputShape);
-
- delete outputData;
- delete expectData;
-
- if (!bret)
- {
- LOG(ERROR) << "TEST FAILED " << __FUNCTION__ << std::endl;
- return -1;
- }
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- int result;
-
- // input 3x3, output 1x1, all data 1.0
- result = test_3x3_1x1_one(COMPUTE_ACLGRAPH);
- if (result) return result;
- result = test_3x3_1x1_one(COMPUTE_ACLRT);
- if (result) return result;
-
- // input 3x3, output 3x3, all data 1.0
- result = test_3x3_3x3_one();
- if (result) return result;
-
- result = test_3x3_3x3_seq();
- if (result) return result;
-
- return result;
-}
diff --git a/contrib/labs/kerneltesting/conv2d/optimized_ops.h b/contrib/labs/kerneltesting/conv2d/optimized_ops.h
deleted file mode 100644
index 1d8c4ff28..000000000
--- a/contrib/labs/kerneltesting/conv2d/optimized_ops.h
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * 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 ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_OPTIMIZED_OPS_H_
-#define ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_OPTIMIZED_OPS_H_
-
-// Make a local VectorMap typedef allowing to map a float array
-// as a Eigen matrix expression. The same explanation as for VectorMap
-// above also applies here.
-template <typename Scalar>
-using MatrixMap = typename std::conditional<
- std::is_const<Scalar>::value,
- Eigen::Map<const Eigen::Matrix<typename std::remove_const<Scalar>::type,
- Eigen::Dynamic, Eigen::Dynamic>>,
- Eigen::Map<Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>>>::type;
-
-template <typename Scalar, int N>
-MatrixMap<Scalar> MapAsMatrixWithFirstDimAsRows(Scalar* data,
- const Dims<N>& dims) {
- const int rows = dims.sizes[0];
- int cols = 1;
- for (int d = 1; d < N; d++) {
- cols *= dims.sizes[d];
- }
- return MatrixMap<Scalar>(data, rows, cols);
-}
-
-template <typename Scalar, int N>
-MatrixMap<Scalar> MapAsMatrixWithLastDimAsCols(Scalar* data,
- const Dims<N>& dims) {
- const int cols = dims.sizes[N - 1];
- int rows = 1;
- for (int d = 0; d < N - 1; d++) {
- rows *= dims.sizes[d];
- }
- return MatrixMap<Scalar>(data, rows, cols);
-}
-
-template <typename T>
-inline void ExtractPatchIntoBufferColumn(
- const Dims<4>& input_dims, int w, int h, int b, int kheight, int kwidth,
- int stride_width, int stride_height, int pad_width, int pad_height,
- int in_width, int in_height, int in_depth, int single_buffer_length,
- int buffer_id, const T* in_data, T* conv_buffer_data, uint8 byte_zero) {
- gemmlowp::ScopedProfilingLabel label("ExtractPatchIntoBufferColumn");
- // This chunk of code reshapes all the inputs corresponding to
- // output (b, h, w) to a column vector in conv_buffer(:, buffer_id).
- const int kwidth_times_indepth = kwidth * in_depth;
- const int inwidth_times_indepth = in_width * in_depth;
- const int ih_ungated_start = h * stride_height - pad_height;
- const int ih_ungated_end = (ih_ungated_start + kheight);
- const int ih_end = std::min(ih_ungated_end, in_height);
- const int iw_ungated_start = w * stride_width - pad_width;
- const int iw_ungated_end = (iw_ungated_start + kwidth);
- const int iw_end = std::min(iw_ungated_end, in_width);
- // If the patch is off the edge of the input image, skip writing those rows
- // and columns from the patch into the output array.
- const int h_offset = std::max(0, -ih_ungated_start);
- const int w_offset = std::max(0, -iw_ungated_start);
- const int ih_start = std::max(0, ih_ungated_start);
- const int iw_start = std::max(0, iw_ungated_start);
- const int single_row_num =
- std::min(kwidth - w_offset, in_width - iw_start) * in_depth;
- const int output_row_offset = (buffer_id * single_buffer_length);
- int out_offset =
- output_row_offset + (h_offset * kwidth + w_offset) * in_depth;
- int in_offset = Offset(input_dims, 0, iw_start, ih_start, b);
-
- // Express all of the calculations as padding around the input patch.
- const int top_padding = h_offset;
- const int bottom_padding = (ih_ungated_end - ih_end);
- const int left_padding = w_offset;
- const int right_padding = (iw_ungated_end - iw_end);
- assert(single_row_num ==
- ((kwidth - (left_padding + right_padding)) * in_depth));
-
- // Write out zeroes to the elements representing the top rows of the input
- // patch that are off the edge of the input image.
- if (top_padding > 0) {
- const int top_row_elements = (top_padding * kwidth * in_depth);
- memset(conv_buffer_data + output_row_offset, byte_zero,
- (top_row_elements * sizeof(T)));
- }
-
- // If the patch is on the interior of the input image horizontally, just copy
- // over the rows sequentially, otherwise add zero padding at the start or end.
- if ((left_padding == 0) && (right_padding == 0)) {
- for (int ih = ih_start; ih < ih_end; ++ih) {
- memcpy(conv_buffer_data + out_offset, in_data + in_offset,
- single_row_num * sizeof(T));
- out_offset += kwidth_times_indepth;
- in_offset += inwidth_times_indepth;
- }
- } else {
- for (int ih = ih_start; ih < ih_end; ++ih) {
- if (left_padding > 0) {
- const int left_start = (out_offset - (left_padding * in_depth));
- memset(conv_buffer_data + left_start, byte_zero,
- (left_padding * in_depth * sizeof(T)));
- }
- memcpy(conv_buffer_data + out_offset, in_data + in_offset,
- single_row_num * sizeof(T));
- if (right_padding > 0) {
- const int right_start = (out_offset + single_row_num);
- memset(conv_buffer_data + right_start, byte_zero,
- (right_padding * in_depth * sizeof(T)));
- }
- out_offset += kwidth_times_indepth;
- in_offset += inwidth_times_indepth;
- }
- }
-
- // If the bottom of the patch falls off the input image, pad the values
- // representing those input rows with zeroes.
- if (bottom_padding > 0) {
- const int bottom_row_elements = (bottom_padding * kwidth * in_depth);
- const int bottom_start =
- output_row_offset +
- ((top_padding + (ih_end - ih_start)) * kwidth * in_depth);
- memset(conv_buffer_data + bottom_start, byte_zero,
- (bottom_row_elements * sizeof(T)));
- }
-}
-
-#ifdef USE_NEON
-template <FusedActivationFunctionType Ac>
-void AddBiasAndEvalActivationFunction(const float* bias_data,
- const Dims<4>& bias_dims,
- float* array_data,
- const Dims<4>& array_dims) {
- gemmlowp::ScopedProfilingLabel label("AddBiasAndEvalActivationFunction");
- const int bias_size = bias_dims.sizes[3] * bias_dims.strides[3];
- const int array_size = array_dims.sizes[3] * array_dims.strides[3];
- DCHECK_EQ((array_size % bias_size), 0);
- float* array_ptr = array_data;
- float* array_end_ptr = array_ptr + array_size;
- const auto zero = vdupq_n_f32(0);
- const auto six = vdupq_n_f32(6);
- const auto neg_one = vdupq_n_f32(-1);
- const auto one = vdupq_n_f32(1);
- for (; array_ptr != array_end_ptr; array_ptr += bias_size) {
- int i = 0;
- for (; i <= bias_size - 16; i += 16) {
- auto b0 = vld1q_f32(bias_data + i);
- auto b1 = vld1q_f32(bias_data + i + 4);
- auto b2 = vld1q_f32(bias_data + i + 8);
- auto b3 = vld1q_f32(bias_data + i + 12);
- auto a0 = vld1q_f32(array_ptr + i);
- auto a1 = vld1q_f32(array_ptr + i + 4);
- auto a2 = vld1q_f32(array_ptr + i + 8);
- auto a3 = vld1q_f32(array_ptr + i + 12);
- auto x0 = vaddq_f32(a0, b0);
- auto x1 = vaddq_f32(a1, b1);
- auto x2 = vaddq_f32(a2, b2);
- auto x3 = vaddq_f32(a3, b3);
- if (Ac == FusedActivationFunctionType::kRelu ||
- Ac == FusedActivationFunctionType::kRelu6) {
- x0 = vmaxq_f32(zero, x0);
- x1 = vmaxq_f32(zero, x1);
- x2 = vmaxq_f32(zero, x2);
- x3 = vmaxq_f32(zero, x3);
- if (Ac == FusedActivationFunctionType::kRelu6) {
- x0 = vminq_f32(six, x0);
- x1 = vminq_f32(six, x1);
- x2 = vminq_f32(six, x2);
- x3 = vminq_f32(six, x3);
- }
- } else if (Ac == FusedActivationFunctionType::kRelu1) {
- x0 = vmaxq_f32(neg_one, x0);
- x1 = vmaxq_f32(neg_one, x1);
- x2 = vmaxq_f32(neg_one, x2);
- x3 = vmaxq_f32(neg_one, x3);
- x0 = vminq_f32(one, x0);
- x1 = vminq_f32(one, x1);
- x2 = vminq_f32(one, x2);
- x3 = vminq_f32(one, x3);
- }
- vst1q_f32(array_ptr + i, x0);
- vst1q_f32(array_ptr + i + 4, x1);
- vst1q_f32(array_ptr + i + 8, x2);
- vst1q_f32(array_ptr + i + 12, x3);
- }
- for (; i <= bias_size - 4; i += 4) {
- auto b = vld1q_f32(bias_data + i);
- auto a = vld1q_f32(array_ptr + i);
- auto x = vaddq_f32(a, b);
- if (Ac == FusedActivationFunctionType::kRelu ||
- Ac == FusedActivationFunctionType::kRelu6) {
- x = vmaxq_f32(zero, x);
- if (Ac == FusedActivationFunctionType::kRelu6) {
- x = vminq_f32(six, x);
- }
- } else if (Ac == FusedActivationFunctionType::kRelu1) {
- x = vmaxq_f32(neg_one, x);
- x = vminq_f32(one, x);
- }
- vst1q_f32(array_ptr + i, x);
- }
- for (; i < bias_size; i++) {
- array_ptr[i] = ActivationFunction<Ac>(array_ptr[i] + bias_data[i]);
- }
- }
-}
-#else // not NEON
-template <FusedActivationFunctionType Ac>
-void AddBiasAndEvalActivationFunction(const float* bias_data,
- const Dims<4>& bias_dims,
- float* array_data,
- const Dims<4>& array_dims) {
- gemmlowp::ScopedProfilingLabel label("AddBiasAndEvalActivationFunction");
- const int bias_size = bias_dims.sizes[3] * bias_dims.strides[3];
- const int array_size = array_dims.sizes[3] * array_dims.strides[3];
- DCHECK_EQ((array_size % bias_size), 0);
- for (int array_offset = 0; array_offset < array_size;
- array_offset += bias_size) {
- for (int i = 0; i < bias_size; i++) {
- array_data[array_offset + i] =
- ActivationFunction<Ac>(array_data[array_offset + i] + bias_data[i]);
- }
- }
-}
-#endif
-
-template <typename Lhs, typename Rhs, typename Result>
-void Gemm(const Eigen::MatrixBase<Lhs>& lhs, const Eigen::MatrixBase<Rhs>& rhs,
- Eigen::MatrixBase<Result>* result) {
- if (rhs.cols() == 1) {
- gemmlowp::ScopedProfilingLabel label("GEMV");
- result->col(0).noalias() = lhs * rhs.col(0);
- } else {
- gemmlowp::ScopedProfilingLabel label("GEMM");
- result->noalias() = lhs * rhs;
- }
-}
-
-template <typename T>
-void Im2col(const T* input_data, const Dims<4>& input_dims, int stride_width,
- int stride_height, int pad_width, int pad_height, int kheight,
- int kwidth, uint8 byte_zero, T* output_data,
- const Dims<4>& output_dims) {
- gemmlowp::ScopedProfilingLabel label("Im2col");
- DCHECK(IsPackedWithoutStrides(input_dims));
- DCHECK(IsPackedWithoutStrides(output_dims));
- const int batches = MatchingArraySize(input_dims, 3, output_dims, 3);
- const int input_depth = ArraySize(input_dims, 0);
- const int input_width = ArraySize(input_dims, 1);
- const int input_height = ArraySize(input_dims, 2);
- const int output_depth = ArraySize(output_dims, 0);
- const int output_width = ArraySize(output_dims, 1);
- const int output_height = ArraySize(output_dims, 2);
-
- int buffer_id = 0;
- // Loop over the output nodes.
- for (int b = 0; b < batches; ++b) {
- for (int h = 0; h < output_height; ++h) {
- for (int w = 0; w < output_width; ++w) {
- ExtractPatchIntoBufferColumn(
- input_dims, w, h, b, kheight, kwidth, stride_width, stride_height,
- pad_width, pad_height, input_width, input_height, input_depth,
- output_depth, buffer_id, input_data, output_data, byte_zero);
- ++buffer_id;
- }
- }
- }
-}
-
-template <FusedActivationFunctionType Ac>
-void Conv(const float* input_data, const Dims<4>& input_dims,
- const float* filter_data, const Dims<4>& filter_dims,
- const float* bias_data, const Dims<4>& bias_dims, int stride_width,
- int stride_height, int pad_width, int pad_height, float* output_data,
- const Dims<4>& output_dims, float* im2col_data,
- const Dims<4>& im2col_dims) {
- (void)im2col_data;
- (void)im2col_dims;
- gemmlowp::ScopedProfilingLabel label("Conv");
-
- const float* gemm_input_data = nullptr;
- const Dims<4>* gemm_input_dims = nullptr;
- const int filter_width = ArraySize(filter_dims, 1);
- const int filter_height = ArraySize(filter_dims, 2);
- const bool need_im2col = stride_width != 1 || stride_height != 1 ||
- filter_width != 1 || filter_height != 1;
- if (need_im2col) {
- DCHECK(im2col_data);
- Im2col(input_data, input_dims, stride_width, stride_height, pad_width,
- pad_height, filter_height, filter_width, 0, im2col_data,
- im2col_dims);
- gemm_input_data = im2col_data;
- gemm_input_dims = &im2col_dims;
- } else {
- DCHECK(!im2col_data);
- gemm_input_data = input_data;
- gemm_input_dims = &input_dims;
- }
-
- const auto im2col_matrix_map =
- MapAsMatrixWithFirstDimAsRows(gemm_input_data, *gemm_input_dims);
- const auto filter_matrix_map =
- MapAsMatrixWithLastDimAsCols(filter_data, filter_dims);
- auto output_matrix_map =
- MapAsMatrixWithFirstDimAsRows(output_data, output_dims);
-
- Gemm(filter_matrix_map.transpose(), im2col_matrix_map, &output_matrix_map);
-
- AddBiasAndEvalActivationFunction<Ac>(bias_data, bias_dims, output_data,
- output_dims);
-}
-
-#endif // ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_OPTIMIZED_OPS_H_
diff --git a/contrib/labs/kerneltesting/conv2d/types.h b/contrib/labs/kerneltesting/conv2d/types.h
deleted file mode 100644
index 3d09457c7..000000000
--- a/contrib/labs/kerneltesting/conv2d/types.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * 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 ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_TYPES_H_
-#define ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_TYPES_H_
-
-enum class OperandType : int32_t {
- FLOAT32 = 0,
- INT32 = 1,
- UINT32 = 2,
- TENSOR_FLOAT32 = 3,
- TENSOR_INT32 = 4,
- TENSOR_QUANT8_ASYMM = 5,
- OEM = 10000,
- TENSOR_OEM_BYTE = 10001,
-};
-
-#include "compatibility.h"
-
-enum class FusedActivationFunctionType { kNone, kRelu6, kRelu1, kRelu };
-
-template <int N>
-struct Dims {
- int sizes[N];
- int strides[N];
-};
-
-// The type and dimensions of an operand.
-struct Shape {
- OperandType type;
- std::vector<uint32_t> dimensions;
- float scale;
- int32_t offset;
-};
-
-inline uint32_t getSizeOfDimension(const Shape& shape, uint32_t dimensionIdx) {
- if (dimensionIdx >= shape.dimensions.size()) {
- // TODO, log the error
- return 0;
- }
- return shape.dimensions[dimensionIdx];
-}
-
-inline Dims<4> convertShapeToDims(const Shape& shape) {
- Dims<4> dims;
- for (int i=0; i<4; i++) {
- dims.sizes[i] = 1;
- }
-
- if (shape.dimensions.size() == 1) {
- dims.sizes[0] = (int)getSizeOfDimension(shape, 0);
- } else {
- for (int i=0; i<4; i++) {
- int src = (int)shape.dimensions.size()-i-1;
- if (src >= 0) {
- dims.sizes[i] = (int)getSizeOfDimension(shape, src);
- }
- }
- }
-
- dims.strides[0] = 1;
- for (int i = 1; i<4; i++) {
- dims.strides[i] = dims.strides[i-1] * dims.sizes[i-1];
- }
- return dims;
-}
-
-inline int Offset(const Dims<4>& dims, int i0, int i1, int i2, int i3) {
- DCHECK(i0 >= 0 && i0 < dims.sizes[0]);
- DCHECK(i1 >= 0 && i1 < dims.sizes[1]);
- DCHECK(i2 >= 0 && i2 < dims.sizes[2]);
- DCHECK(i3 >= 0 && i3 < dims.sizes[3]);
- return i0 * dims.strides[0] + i1 * dims.strides[1] + i2 * dims.strides[2] +
- i3 * dims.strides[3];
-}
-
-// Get array size, DCHECKing that the dim index is in range.
-template <int N>
-int ArraySize(const Dims<N>& array, int index) {
- DCHECK(index >= 0 && index < N);
- return array.sizes[index];
-}
-
-// Get common array size, DCHECKing that they all agree.
-template <typename ArrayType1, typename ArrayType2>
-int MatchingArraySize(const ArrayType1& array1, int index1,
- const ArrayType2& array2, int index2) {
- DCHECK_EQ(ArraySize(array1, index1), ArraySize(array2, index2));
- return ArraySize(array1, index1);
-}
-
-template <typename ArrayType1, typename ArrayType2, typename... Args>
-int MatchingArraySize(const ArrayType1& array1, int index1,
- const ArrayType2& array2, int index2, Args... args) {
- DCHECK_EQ(ArraySize(array1, index1), ArraySize(array2, index2));
- return MatchingArraySize(array1, index1, args...);
-}
-
-inline int RequiredBufferSizeForDims(const Dims<4>& dims) {
- int max_offset = 0;
- for (int i = 0; i < 4; i++) {
- max_offset += (dims.sizes[i] - 1) * dims.strides[i];
- }
- return max_offset + 1;
-}
-
-template <int N>
-bool IsPackedWithoutStrides(const Dims<N>& dims) {
- int expected_stride = 1;
- for (int d = 0; d < N; d++) {
- if (dims.strides[d] != expected_stride) return false;
- expected_stride *= dims.sizes[d];
- }
- return true;
-}
-
-#endif // ANDROID_ML_NN_COMMON_OPERATIONS_INTERNAL_TYPES_H_
diff --git a/contrib/labs/opencl_test/CMakeLists.txt b/contrib/labs/opencl_test/CMakeLists.txt
deleted file mode 100644
index 5e99fa051..000000000
--- a/contrib/labs/opencl_test/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-if(NOT ${TARGET_ARCH_BASE} STREQUAL "arm")
- return()
-endif(NOT ${TARGET_ARCH_BASE} STREQUAL "arm")
-
-list(APPEND OPENCL_INFO_SOURCE "src/opencl_test.cc")
-
-add_executable(opencl_test ${OPENCL_INFO_SOURCE})
-target_include_directories(opencl_test PUBLIC ${CMAKE_SOURCE_DIR}/externals/acl)
-target_include_directories(opencl_test PUBLIC ${CMAKE_SOURCE_DIR}/externals/acl/include)
-target_include_directories(opencl_test PUBLIC ${CMAKE_SOURCE_DIR}/libs/ARMComputeEx)
-target_link_libraries(opencl_test arm_compute)
-target_link_libraries(opencl_test arm_compute_ex)
diff --git a/contrib/labs/opencl_test/README.md b/contrib/labs/opencl_test/README.md
deleted file mode 100644
index 950528f81..000000000
--- a/contrib/labs/opencl_test/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-This directory contains experients of OpenCL code.
-
-How to run:
-```
-LD_LIBRARY_PATH=Product/out/lib Product/obj/contrib/opencl_test/opencl_test [option]
-```
- - `[option]`
- - `-g`: prints devices inside GPU and check if they use same memory address
diff --git a/contrib/labs/opencl_test/src/opencl_test.cc b/contrib/labs/opencl_test/src/opencl_test.cc
deleted file mode 100644
index 93994ae43..000000000
--- a/contrib/labs/opencl_test/src/opencl_test.cc
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/*******************************************************************************
- * Copyright (c) 2008-2015 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and/or associated documentation files (the
- * "Materials"), to deal in the Materials without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Materials, and to
- * permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
- ******************************************************************************/
-
-#include "arm_compute/core/CL/OpenCL.h"
-#include "arm_compute/core/CL/OpenCLEx.h"
-
-#include <iostream>
-#include <vector>
-
-void printDeviceInfo(int n, cl::Device &device, cl::Device &default_device)
-{
- bool is_default = (device() == default_device());
- std::cout << "\t\t\t#" << n << " Device: (id: " << device() << ") "
- << (is_default ? " -> default" : "") << "\n";
-
- const auto name = device.getInfo<CL_DEVICE_NAME>();
- std::cout << "\t\t\t\tName: " << name << "\n";
-
- const auto compute_unit = device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>();
- std::cout << "\t\t\t\tMax Compute Unit: " << compute_unit << "\n";
-
- const auto max_work_item_size = device.getInfo<CL_DEVICE_MAX_WORK_ITEM_SIZES>();
- std::cout << "\t\t\t\tMax Work Item Size: [";
- for (auto size : max_work_item_size)
- std::cout << size << ",";
- std::cout << "]\n";
-
- const auto max_work_group_size = device.getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>();
- std::cout << "\t\t\t\tMax Work Grpup Size: " << max_work_group_size << "\n";
-
- const auto max_clock_frequency = device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>();
- std::cout << "\t\t\t\tMax Clock Frequency: " << max_clock_frequency << "\n";
-
- std::cout << "\n";
-}
-
-
-class OpenCLGpu
-{
- public:
- cl::Platform platform_;
- cl::Context context_;
- cl::vector<cl::Device> devices_;
- std::vector<cl::CommandQueue*> q_;
- cl::Program program_;
-
- OpenCLGpu()
- {
- cl_int cl_error;
-
- platform_ = cl::Platform::getDefault();
-
- try
- {
- cl_context_properties properties[3] = {
- CL_CONTEXT_PLATFORM, (cl_context_properties)platform_(), 0
- };
-
- context_ = cl::Context(CL_DEVICE_TYPE_GPU, properties, NULL, NULL, &cl_error);
- }
- catch (cl::Error &err) // thrown when there is no Context for this platform
- {
- std::cout << "\t\t No Context Found\n";
- return;
- }
-
- devices_ = context_.getInfo<CL_CONTEXT_DEVICES>();
-
- for (int dev_id = 0; dev_id < devices_.size(); dev_id++)
- {
- cl::CommandQueue* que = new cl::CommandQueue(context_, devices_[dev_id]);
- q_.emplace_back(que);
- }
- }
-
- ~OpenCLGpu()
- {
- for (auto each_q : q_)
- delete each_q;
- }
-
- void buildProgram(std::string& kernel_source_code)
- {
- std::vector<std::string> programStrings {kernel_source_code};
-
- program_ = cl::Program(context_, programStrings);
-
- try
- {
- program_.build("-cl-std=CL1.2");
- }
- catch (cl::Error &err)
- {
- cl_int buildErr = CL_SUCCESS;
- auto buildInfo = program_.getBuildInfo<CL_PROGRAM_BUILD_LOG>(&buildErr);
- for (auto &pair : buildInfo) {
- std::cerr << pair.second << std::endl << std::endl;
- }
- }
- }
-};
-
-
-void checkContextMem()
-{
- cl_int cl_error;
-
- // get context, devices
- //
- std::cout << "\nChecking if devices in GPU shares the same memory address:\n\n";
-
- OpenCLGpu gpu;
-
- std::cout << "\nDevices in GPU:\n\n";
-
- auto &devices = gpu.devices_;
- auto default_device = cl::Device::getDefault();
-
- int d = 0;
- for (auto device : devices)
- printDeviceInfo(++d, device, default_device);
-
- if (d < 2)
- {
- std::cout << "\t\t This options works when there are n (>= 2) devices.\n";
- return;
- }
-
- // allocate and map memory
-
- typedef cl_int T;
- const int items_per_device = 128;
- const int length = items_per_device * devices.size();
-
- std::vector<T> input(length);
- std::vector<T> output(length, 0);
-
- for (int i = 0; i < length; i++)
- input[i] = i;
-
- cl::Buffer input_buf(gpu.context_, (cl_mem_flags)CL_MEM_USE_HOST_PTR, length*sizeof(T), input.data(), &cl_error);
- cl::Buffer output_buf(gpu.context_, (cl_mem_flags)CL_MEM_USE_HOST_PTR, length*sizeof(T), output.data(), &cl_error);
-
- // compile test cl code
-
- std::string kernel_source {
- "typedef int T; \n" \
- "kernel void memory_test( \n" \
- " const int dev_id, \n" \
- " global T* input, \n" \
- " global T* output, \n" \
- " const int start_idx, \n" \
- " const int count) \n" \
- "{ \n" \
- " int input_idx = get_global_id(0); \n" \
- " if(input_idx < count) \n" \
- " { \n" \
- " int output_idx = start_idx + input_idx; \n" \
- " output[output_idx] = input[input_idx] + dev_id; \n" \
- " } \n" \
- "} \n"
- };
-
- gpu.buildProgram(kernel_source);
-
- try
- {
- auto kernel_functor = cl::KernelFunctor<cl_int, cl::Buffer, cl::Buffer, cl_int, cl_int>
- (gpu.program_, "memory_test"); // name should be same as cl function name
-
- // create a queue per device and queue a kernel job
-
- for (int dev_id = 0; dev_id < devices.size(); dev_id++)
- {
- kernel_functor(
- cl::EnqueueArgs(
- *(gpu.q_[dev_id]),
- cl::NDRange(items_per_device)),
- (cl_int)dev_id, // dev id
- input_buf,
- output_buf,
- (cl_int)(items_per_device * dev_id), // start index
- (cl_int)(items_per_device), // count
- cl_error
- );
- }
-
- // sync
-
- for (d = 0; d < devices.size(); d++)
- (gpu.q_[d])->finish();
-
- // check if memory state changed by all devices
-
- cl::copy(*(gpu.q_[0]), output_buf, begin(output), end(output));
-
- bool use_same_memory = true;
-
- for (int dev_id = 0; dev_id < devices.size(); dev_id++)
- {
- for (int i = 0; i < items_per_device; ++i)
- {
- int output_idx = items_per_device * dev_id + i;
- if (output[output_idx] != input[i] + dev_id)
- {
- std::cout << "Output[" << output_idx << "] : "
- << "expected = " << input[i] + dev_id
- << "; actual = " << output[output_idx] << "\n";
- use_same_memory = false;
- break;
- }
- }
- }
-
- if (use_same_memory)
- std::cout << "\n=> Mapped memory addresses used by devices in GPU are same.\n\n";
- else
- std::cout << "\n=> Mapped memory addresses used by devices in GPU are different.\n\n";
- }
- catch (cl::Error &err)
- {
- std::cerr << "error: code: " << err.err() << ", what: " << err.what() << std::endl;
- }
-}
-
-void printHelp()
-{
- std::cout << "opencl information: \n\n";
- std::cout << "\t -h : help\n";
- std::cout << "\t -g : print if memory map is shared among devices in GPU (in default platform)\n\n";
- std::cout << "\t -s : test for synchronized work by two devices in a GPU\n\n";
-}
-
-#include <mutex>
-#include <chrono>
-#include <thread>
-#include <condition_variable>
-
-#define MAX_DEVICE_NUM 8 // just for testing
-
-int kernel_idx[MAX_DEVICE_NUM];
-unsigned char kernel_completed = 0x00; // bit 0 = 1 means kernel by device[0] was completed.
-unsigned char kernel_completed_flag; // if comparing kernel_completed with this var, all kernels are completed
-int device_num;
-std::mutex kernel_complete_handler_mutex;
-
-std::condition_variable wakeup_main;
-std::mutex wakeup_main_mutex;
-
-void notifyKernelFinished(cl_event ev, cl_int ev_info, void * device_idx)
-{
- std::cout << "callback from device[" << *((int*)device_idx) << "] : ==> completed.\n";
-
- std::unique_lock<std::mutex> lock(kernel_complete_handler_mutex);
-
- kernel_completed |= 0x01 << *((int*)device_idx);
- if (kernel_completed == kernel_completed_flag)
- wakeup_main.notify_one();
-}
-
-void testSync()
-{
- OpenCLGpu gpu;
-
- cl_int cl_error;
- typedef cl_int T;
- const int items_per_device = 1024*768;
- const int length = items_per_device * gpu.devices_.size();
-
- std::vector<T> output(length, 0);
-
- cl::Buffer output_buf(gpu.context_, (cl_mem_flags)CL_MEM_USE_HOST_PTR, length*sizeof(T), output.data(), &cl_error);
-
- std::string kernel_source {
- "kernel void test(global float* output, const int count) \n" \
- "{ \n" \
- " int idx = get_global_id(0); \n" \
- " if(idx < count) \n" \
- " { \n" \
- " float x = hypot(idx/1.111, idx*1.111); \n" \
- " for (int y = 0; y < 200; y++) \n" \
- " x = rootn(log(pown(rootn(log(pown(x, 20)), 5), 20)), 5); \n" \
- " output[idx] = x; \n" \
- " } \n" \
- "} \n"
- };
-
- gpu.buildProgram(kernel_source);
-
- try
- {
- auto kernel_functor = cl::KernelFunctor<cl::Buffer, cl_int>
- (gpu.program_, "test"); // name should be same as cl function name
-
- // variable init
- cl::Event ev[MAX_DEVICE_NUM];
-
- device_num = gpu.devices_.size();
-
- kernel_completed = 0;
- kernel_completed_flag = 0;
- for (int i = 0; i < device_num; i++)
- {
- kernel_idx[i] = i;
- kernel_completed_flag |= 0x01 << i;
- }
-
- // create a queue per device and queue a kernel job
- // queueing with callback function
- for (int dev_id = 0; dev_id < gpu.devices_.size(); dev_id++)
- {
- ev[dev_id] = kernel_functor(
- cl::EnqueueArgs(
- *(gpu.q_[dev_id]),
- cl::NDRange(items_per_device)),
- output_buf,
- (cl_int)(items_per_device), // count
- cl_error
- );
- ev[dev_id].setCallback(CL_COMPLETE, notifyKernelFinished, (void*)(kernel_idx+dev_id));
-
- // how to check kernel execution status
- //
- // auto status = ev[dev_id].getInfo<CL_EVENT_COMMAND_EXECUTION_STATUS>();
- // std::cout << "Event status = " << (status == CL_QUEUED ? "CL_QUEUED" : status == CL_SUBMITTED ? "CL_SUBMITTED" : status == CL_COMPLETE ? "CL_COMPLETE" : "unknown")
- // << std::endl;
- // std::cout << "Event status code = " << status << std::endl;
- }
-
- // long wait until kernels are over
- {
- std::unique_lock<std::mutex> lk(wakeup_main_mutex);
- wakeup_main.wait(lk, []{ return (kernel_completed == kernel_completed_flag); });
-
- std::cout << "all devices were completed.\n";
- }
- }
- catch (cl::Error &err)
- {
- std::cerr << "error: code: " << err.err() << ", what: " << err.what() << std::endl;
- }
-
-}
-
-int main(const int argc, char **argv)
-{
- if (argc < 2)
- printHelp();
- else
- {
- std::string option = argv[1];
-
- if (option == "-h") // help
- printHelp();
- else if (option == "-g") // check if devices in GPU uses same memory address
- checkContextMem();
- else if (option == "-s") // check synchronization between devices in GPU
- testSync();
- }
- return 0;
-}
diff --git a/contrib/labs/tflite_examples/CMakeLists.txt b/contrib/labs/tflite_examples/CMakeLists.txt
deleted file mode 100644
index 463bc5531..000000000
--- a/contrib/labs/tflite_examples/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_executable(tflite_conv_example "src/conv.cpp")
-target_link_libraries(tflite_conv_example tensorflow-lite ${LIB_PTHREAD} dl nnfw_lib_tflite)
diff --git a/contrib/labs/tflite_examples/src/conv.cpp b/contrib/labs/tflite_examples/src/conv.cpp
deleted file mode 100644
index e517da9f3..000000000
--- a/contrib/labs/tflite_examples/src/conv.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (c) 2018 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 "tflite/ext/kernels/register.h"
-#include "tensorflow/contrib/lite/model.h"
-#include "tensorflow/contrib/lite/builtin_op_data.h"
-
-#include <iostream>
-
-using namespace tflite;
-using namespace nnfw::tflite;
-
-namespace vector
-{
-
-template <typename T> struct View
-{
- virtual ~View() = default;
-
- virtual int32_t size(void) const = 0;
- virtual T at(uint32_t off) const = 0;
-};
-}
-
-namespace feature
-{
-
-struct Shape
-{
- int32_t C;
- int32_t H;
- int32_t W;
-};
-
-template <typename T> struct View
-{
- virtual ~View() = default;
-
- virtual const Shape &shape(void) const = 0;
- virtual T at(uint32_t ch, uint32_t row, uint32_t col) const = 0;
-};
-}
-
-namespace kernel
-{
-
-struct Shape
-{
- int32_t N;
- int32_t C;
- int32_t H;
- int32_t W;
-};
-
-template <typename T> struct View
-{
- virtual ~View() = default;
-
- virtual const Shape &shape(void) const = 0;
- virtual T at(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col) const = 0;
-};
-}
-
-const int32_t N = 1;
-const int32_t C = 2;
-
-class SampleBiasObject final : public vector::View<float>
-{
-public:
- SampleBiasObject() : _size(N)
- {
- // DO NOTHING
- }
-
-public:
- int32_t size(void) const override { return _size; }
-
- float at(uint32_t off) const override { return 0.0f; }
-
-private:
- int32_t _size;
-};
-
-class SampleFeatureObject final : public feature::View<float>
-{
-public:
- SampleFeatureObject()
- {
- _shape.C = C;
- _shape.H = 3;
- _shape.W = 4;
-
- const uint32_t size = _shape.C * _shape.H * _shape.W;
-
- for (uint32_t off = 0; off < size; ++off)
- {
- _value.emplace_back(off);
- }
-
- assert(_value.size() == size);
- }
-
-public:
- const feature::Shape &shape(void) const override { return _shape; };
-
- float at(uint32_t ch, uint32_t row, uint32_t col) const override
- {
- return _value.at(ch * _shape.H * _shape.W + row * _shape.W + col);
- }
-
-public:
- float &at(uint32_t ch, uint32_t row, uint32_t col)
- {
- return _value.at(ch * _shape.H * _shape.W + row * _shape.W + col);
- }
-
-private:
- feature::Shape _shape;
- std::vector<float> _value;
-};
-
-class SampleKernelObject final : public kernel::View<float>
-{
-public:
- SampleKernelObject()
- {
- _shape.N = N;
- _shape.C = C;
- _shape.H = 3;
- _shape.W = 4;
-
- const uint32_t size = _shape.N * _shape.C * _shape.H * _shape.W;
-
- for (uint32_t off = 0; off < size; ++off)
- {
- _value.emplace_back(off);
- }
-
- assert(_value.size() == size);
- }
-
-public:
- const kernel::Shape &shape(void) const override { return _shape; };
-
- float at(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col) const override
- {
- return _value.at(nth * _shape.C * _shape.H * _shape.W + ch * _shape.H * _shape.W +
- row * _shape.W + col);
- }
-
-private:
- kernel::Shape _shape;
- std::vector<float> _value;
-};
-
-int main(int argc, char **argv)
-{
- const SampleFeatureObject ifm;
- const SampleKernelObject kernel;
- const SampleBiasObject bias;
-
- const int32_t IFM_C = ifm.shape().C;
- const int32_t IFM_H = ifm.shape().H;
- const int32_t IFM_W = ifm.shape().W;
-
- const int32_t KER_N = kernel.shape().N;
- const int32_t KER_C = kernel.shape().C;
- const int32_t KER_H = kernel.shape().H;
- const int32_t KER_W = kernel.shape().W;
-
- const int32_t OFM_C = kernel.shape().N;
- const int32_t OFM_H = (IFM_H - KER_H) + 1;
- const int32_t OFM_W = (IFM_W - KER_W) + 1;
-
- // Assumption on this example
- assert(IFM_C == KER_C);
- assert(KER_N == bias.size());
-
- // Comment from 'context.h'
- //
- // Parameters for asymmetric quantization. Quantized values can be converted
- // back to float using:
- // real_value = scale * (quantized_value - zero_point);
- //
- // Q: Is this necessary?
- TfLiteQuantizationParams quantization;
-
- quantization.scale = 1;
- quantization.zero_point = 0;
-
- Interpreter interp;
-
- // On AddTensors(N) call, T/F Lite interpreter creates N tensors whose index is [0 ~ N)
- interp.AddTensors(5);
-
- // Configure OFM
- interp.SetTensorParametersReadWrite(0, kTfLiteFloat32 /* type */, "output" /* name */,
- {1 /*N*/, OFM_H, OFM_W, OFM_C} /* dims */, quantization);
-
- // Configure IFM
- interp.SetTensorParametersReadWrite(1, kTfLiteFloat32 /* type */, "input" /* name */,
- {1 /*N*/, IFM_H, IFM_W, IFM_C} /* dims */, quantization);
-
- // Configure Filter
- const uint32_t kernel_size = KER_N * KER_C * KER_H * KER_W;
- float kernel_data[kernel_size] = {
- 0.0f,
- };
-
- // Fill kernel data in NHWC order
- {
- uint32_t off = 0;
-
- for (uint32_t nth = 0; nth < KER_N; ++nth)
- {
- for (uint32_t row = 0; row < KER_H; ++row)
- {
- for (uint32_t col = 0; col < KER_W; ++col)
- {
- for (uint32_t ch = 0; ch < KER_C; ++ch)
- {
- const auto value = kernel.at(nth, ch, row, col);
- kernel_data[off++] = value;
- }
- }
- }
- }
-
- assert(kernel_size == off);
- }
-
- interp.SetTensorParametersReadOnly(
- 2, kTfLiteFloat32 /* type */, "filter" /* name */, {KER_N, KER_H, KER_W, KER_C} /* dims */,
- quantization, reinterpret_cast<const char *>(kernel_data), sizeof(kernel_data));
-
- // Configure Bias
- const uint32_t bias_size = bias.size();
- float bias_data[bias_size] = {
- 0.0f,
- };
-
- // Fill bias data
- for (uint32_t off = 0; off < bias.size(); ++off)
- {
- bias_data[off] = bias.at(off);
- }
-
- interp.SetTensorParametersReadOnly(3, kTfLiteFloat32 /* type */, "bias" /* name */,
- {bias.size()} /* dims */, quantization,
- reinterpret_cast<const char *>(bias_data), sizeof(bias_data));
-
- // Add Convolution Node
- //
- // NOTE AddNodeWithParameters take the ownership of param, and deallocate it with free
- // So, param should be allocated with malloc
- TfLiteConvParams *param = reinterpret_cast<TfLiteConvParams *>(malloc(sizeof(TfLiteConvParams)));
-
- param->padding = kTfLitePaddingValid;
- param->stride_width = 1;
- param->stride_height = 1;
- param->activation = kTfLiteActRelu;
-
- // Run Convolution and store its result into Tensor #0
- // - Read IFM from Tensor #1
- // - Read Filter from Tensor #2,
- // - Read Bias from Tensor #3
- interp.AddNodeWithParameters({1, 2, 3}, {0}, nullptr, 0, reinterpret_cast<void *>(param),
- BuiltinOpResolver().FindOp(BuiltinOperator_CONV_2D, 1));
-
- // Set Tensor #1 as Input #0, and Tensor #0 as Output #0
- interp.SetInputs({1});
- interp.SetOutputs({0});
-
- // Let's use NNAPI (if possible)
- interp.UseNNAPI(true);
-
- // Allocate Tensor
- interp.AllocateTensors();
-
- // Fill IFM data in HWC order
- {
- uint32_t off = 0;
-
- for (uint32_t row = 0; row < ifm.shape().H; ++row)
- {
- for (uint32_t col = 0; col < ifm.shape().W; ++col)
- {
- for (uint32_t ch = 0; ch < ifm.shape().C; ++ch)
- {
- const auto value = ifm.at(ch, row, col);
- interp.typed_input_tensor<float>(0)[off++] = value;
- }
- }
- }
- }
-
- // Let's Rock-n-Roll!
- interp.Invoke();
-
- // Print OFM
- {
- uint32_t off = 0;
-
- for (uint32_t row = 0; row < OFM_H; ++row)
- {
- for (uint32_t col = 0; col < OFM_W; ++col)
- {
- for (uint32_t ch = 0; ch < kernel.shape().N; ++ch)
- {
- std::cout << interp.typed_output_tensor<float>(0)[off++] << std::endl;
- }
- }
- }
- }
-
- return 0;
-}
diff --git a/contrib/tflite_classify/.FORMATCHECKED b/contrib/tflite_classify/.FORMATCHECKED
deleted file mode 100644
index e69de29bb..000000000
--- a/contrib/tflite_classify/.FORMATCHECKED
+++ /dev/null
diff --git a/contrib/tflite_classify/CMakeLists.txt b/contrib/tflite_classify/CMakeLists.txt
deleted file mode 100644
index 3ae4adcc7..000000000
--- a/contrib/tflite_classify/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-if(NOT BUILD_TFLITE_CLASSIFY_APP)
- return()
-endif(NOT BUILD_TFLITE_CLASSIFY_APP)
-
-list(APPEND SOURCES "src/tflite_classify.cc")
-list(APPEND SOURCES "src/ImageClassifier.cc")
-list(APPEND SOURCES "src/InferenceInterface.cc")
-
-## Required package
-find_package(OpenCV REQUIRED)
-find_package(Boost REQUIRED COMPONENTS system filesystem)
-
-# Without this line, this appliation couldn't search the opencv library that were already installed in ${ROOTFS_ARM}/usr/lib/arm-linux-gnueabihf directory
-set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${ROOTFS_ARM}/usr/lib/arm-linux-gnueabihf -Wl,--rpath=${ROOTFS_ARM}/lib/arm-linux-gnueabihf")
-
-add_executable(tflite_classify ${SOURCES})
-target_include_directories(tflite_classify PRIVATE src)
-target_link_libraries(tflite_classify tensorflow-lite ${LIB_PTHREAD} dl nnfw_lib_tflite)
-target_link_libraries(tflite_classify ${Boost_LIBRARIES})
-target_link_libraries(tflite_classify ${OpenCV_LIBRARIES})
-
-install(TARGETS tflite_classify DESTINATION bin)
diff --git a/contrib/tflite_classify/src/ImageClassifier.cc b/contrib/tflite_classify/src/ImageClassifier.cc
deleted file mode 100644
index fae4f066c..000000000
--- a/contrib/tflite_classify/src/ImageClassifier.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2018 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 "ImageClassifier.h"
-
-#include <fstream>
-#include <queue>
-#include <algorithm>
-
-ImageClassifier::ImageClassifier(const std::string &model_file, const std::string &label_file,
- const int input_size, const int image_mean, const int image_std,
- const std::string &input_name, const std::string &output_name,
- const bool use_nnapi)
- : _inference(new InferenceInterface(model_file, use_nnapi)), _input_size(input_size),
- _image_mean(image_mean), _image_std(image_std), _input_name(input_name),
- _output_name(output_name)
-{
- // Load label
- std::ifstream label_stream(label_file.c_str());
- assert(label_stream);
-
- std::string line;
- while (std::getline(label_stream, line))
- {
- _labels.push_back(line);
- }
- _num_classes = _inference->getTensorSize(_output_name);
- std::cout << "Output tensor size is " << _num_classes << ", label size is " << _labels.size()
- << std::endl;
-
- // Pre-allocate buffers
- _fdata.reserve(_input_size * _input_size * 3);
- _outputs.reserve(_num_classes);
-}
-
-std::vector<Recognition> ImageClassifier::recognizeImage(const cv::Mat &image)
-{
- // Resize image
- cv::Mat cropped;
- cv::resize(image, cropped, cv::Size(_input_size, _input_size), 0, 0, cv::INTER_AREA);
-
- // Preprocess the image data from 0~255 int to normalized float based
- // on the provided parameters
- _fdata.clear();
- for (int y = 0; y < cropped.rows; ++y)
- {
- for (int x = 0; x < cropped.cols; ++x)
- {
- cv::Vec3b color = cropped.at<cv::Vec3b>(y, x);
- color[0] = color[0] - (float)_image_mean / _image_std;
- color[1] = color[1] - (float)_image_mean / _image_std;
- color[2] = color[2] - (float)_image_mean / _image_std;
-
- _fdata.push_back(color[0]);
- _fdata.push_back(color[1]);
- _fdata.push_back(color[2]);
-
- cropped.at<cv::Vec3b>(y, x) = color;
- }
- }
-
- // Copy the input data into model
- _inference->feed(_input_name, _fdata, 1, _input_size, _input_size, 3);
-
- // Run the inference call
- _inference->run(_output_name);
-
- // Copy the output tensor back into the output array
- _inference->fetch(_output_name, _outputs);
-
- // Find the best classifications
- auto compare = [](const Recognition &lhs, const Recognition &rhs) {
- return lhs.confidence < rhs.confidence;
- };
-
- std::priority_queue<Recognition, std::vector<Recognition>, decltype(compare)> pq(compare);
- for (int i = 0; i < _num_classes; ++i)
- {
- if (_outputs[i] > _threshold)
- {
- pq.push(Recognition(_outputs[i], _labels[i]));
- }
- }
-
- std::vector<Recognition> results;
- int min = std::min(pq.size(), _max_results);
- for (int i = 0; i < min; ++i)
- {
- results.push_back(pq.top());
- pq.pop();
- }
-
- return results;
-}
diff --git a/contrib/tflite_classify/src/ImageClassifier.h b/contrib/tflite_classify/src/ImageClassifier.h
deleted file mode 100644
index 1ba19afb0..000000000
--- a/contrib/tflite_classify/src/ImageClassifier.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/**
- * @file ImageClassifier.h
- * @brief This file contains ImageClassifier class and Recognition structure
- * @ingroup COM_AI_RUNTIME
- */
-
-#ifndef __TFLITE_CLASSIFY_IMAGE_CLASSIFIER_H__
-#define __TFLITE_CLASSIFY_IMAGE_CLASSIFIER_H__
-
-#include "InferenceInterface.h"
-
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include <opencv2/opencv.hpp>
-
-/**
- * @brief struct to define an immutable result returned by a Classifier
- */
-struct Recognition
-{
-public:
- /**
- * @brief Construct a new Recognition object with confidence and title
- * @param[in] _confidence A sortable score for how good the recognition is relative to others.
- * Higher should be better.
- * @param[in] _title Display name for the recognition
- */
- Recognition(float _confidence, std::string _title) : confidence(_confidence), title(_title) {}
-
- float confidence; /** A sortable score for how good the recognition is relative to others. Higher
- should be better. */
- std::string title; /** Display name for the recognition */
-};
-
-/**
- * @brief Class to define a classifier specialized to label images
- */
-class ImageClassifier
-{
-public:
- /**
- * @brief Construct a new ImageClassifier object with parameters
- * @param[in] model_file The filepath of the model FlatBuffer protocol buffer
- * @param[in] label_file The filepath of label file for classes
- * @param[in] input_size The input size. A square image of input_size x input_size is assumed
- * @param[in] image_mean The assumed mean of the image values
- * @param[in] image_std The assumed std of the image values
- * @param[in] input_name The label of the image input node
- * @param[in] output_name The label of the output node
- * @param[in] use_nnapi The flag to distinguish between TfLite interpreter and NNFW runtime
- */
- ImageClassifier(const std::string &model_file, const std::string &label_file,
- const int input_size, const int image_mean, const int image_std,
- const std::string &input_name, const std::string &output_name,
- const bool use_nnapi);
-
- /**
- * @brief Recognize the given image data
- * @param[in] image The image data to recognize
- * @return An immutable result vector array
- */
- std::vector<Recognition> recognizeImage(const cv::Mat &image);
-
-private:
- const float _threshold = 0.1f;
- const unsigned int _max_results = 3;
-
- std::unique_ptr<InferenceInterface> _inference;
- int _input_size;
- int _image_mean;
- int _image_std;
- std::string _input_name;
- std::string _output_name;
-
- std::vector<std::string> _labels;
- std::vector<float> _fdata;
- std::vector<float> _outputs;
- int _num_classes;
-};
-
-#endif // __TFLITE_CLASSIFY_IMAGE_CLASSIFIER_H__
diff --git a/contrib/tflite_classify/src/InferenceInterface.cc b/contrib/tflite_classify/src/InferenceInterface.cc
deleted file mode 100644
index 160943477..000000000
--- a/contrib/tflite_classify/src/InferenceInterface.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2018 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 "InferenceInterface.h"
-
-using namespace tflite;
-using namespace tflite::ops::builtin;
-
-InferenceInterface::InferenceInterface(const std::string &model_file, const bool use_nnapi)
- : _interpreter(nullptr), _model(nullptr), _sess(nullptr)
-{
- // Load model
- StderrReporter error_reporter;
- _model = FlatBufferModel::BuildFromFile(model_file.c_str(), &error_reporter);
- BuiltinOpResolver resolver;
- InterpreterBuilder builder(*_model, resolver);
- builder(&_interpreter);
-
- if (use_nnapi)
- {
- _sess = std::make_shared<nnfw::tflite::NNAPISession>(_interpreter.get());
- }
- else
- {
- _sess = std::make_shared<nnfw::tflite::InterpreterSession>(_interpreter.get());
- }
-
- _sess->prepare();
-}
-
-InferenceInterface::~InferenceInterface() { _sess->teardown(); }
-
-void InferenceInterface::feed(const std::string &input_name, const std::vector<float> &data,
- const int batch, const int height, const int width, const int channel)
-{
- // Set input tensor
- for (const auto &id : _interpreter->inputs())
- {
- if (_interpreter->tensor(id)->name == input_name)
- {
- assert(_interpreter->tensor(id)->type == kTfLiteFloat32);
- float *p = _interpreter->tensor(id)->data.f;
-
- // TODO consider batch
- for (int y = 0; y < height; ++y)
- {
- for (int x = 0; x < width; ++x)
- {
- for (int c = 0; c < channel; ++c)
- {
- *p++ = data[y * width * channel + x * channel + c];
- }
- }
- }
- }
- }
-}
-
-void InferenceInterface::run(const std::string &output_name)
-{
- // Run model
- _sess->run();
-}
-
-void InferenceInterface::fetch(const std::string &output_name, std::vector<float> &outputs)
-{
- // Get output tensor
- for (const auto &id : _interpreter->outputs())
- {
- if (_interpreter->tensor(id)->name == output_name)
- {
- assert(_interpreter->tensor(id)->type == kTfLiteFloat32);
- assert(getTensorSize(output_name) == outputs.capacity());
- float *p = _interpreter->tensor(id)->data.f;
-
- outputs.clear();
- for (int i = 0; i < outputs.capacity(); ++i)
- {
- outputs.push_back(p[i]);
- }
- }
- }
-}
-
-int InferenceInterface::getTensorSize(const std::string &name)
-{
- for (const auto &id : _interpreter->outputs())
- {
- if (_interpreter->tensor(id)->name == name)
- {
- TfLiteTensor *t = _interpreter->tensor(id);
- int v = 1;
- for (int i = 0; i < t->dims->size; ++i)
- {
- v *= t->dims->data[i];
- }
- return v;
- }
- }
- return -1;
-}
diff --git a/contrib/tflite_classify/src/InferenceInterface.h b/contrib/tflite_classify/src/InferenceInterface.h
deleted file mode 100644
index 06ebb3dad..000000000
--- a/contrib/tflite_classify/src/InferenceInterface.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-/**
- * @file InferenceInterface.h
- * @brief This file contains class for running the actual inference model
- * @ingroup COM_AI_RUNTIME
- */
-
-#ifndef __TFLITE_CLASSIFY_INFERENCE_INTERFACE_H__
-#define __TFLITE_CLASSIFY_INFERENCE_INTERFACE_H__
-
-#include "tflite/ext/kernels/register.h"
-#include "tensorflow/contrib/lite/model.h"
-
-#include "tflite/InterpreterSession.h"
-#include "tflite/NNAPISession.h"
-
-#include <iostream>
-#include <string>
-
-/**
- * @brief Class to define a inference interface for recognizing data
- */
-class InferenceInterface
-{
-public:
- /**
- * @brief Construct a new InferenceInterface object with parameters
- * @param[in] model_file The filepath of the model FlatBuffer protocol buffer
- * @param[in] use_nnapi The flag to distinguish between TfLite interpreter and NNFW runtime
- */
- InferenceInterface(const std::string &model_file, const bool use_nnapi);
-
- /**
- * @brief Destructor an InferenceInterface object
- */
- ~InferenceInterface();
-
- /**
- * @brief Copy the input data into model
- * @param[in] input_name The label of the image input node
- * @param[in] data The actual data to be copied into input tensor
- * @param[in] batch The number of batch size
- * @param[in] height The number of height size
- * @param[in] width The number of width size
- * @param[in] channel The number of channel size
- * @return N/A
- */
- void feed(const std::string &input_name, const std::vector<float> &data, const int batch,
- const int height, const int width, const int channel);
- /**
- * @brief Run the inference call
- * @param[in] output_name The label of the output node
- * @return N/A
- */
- void run(const std::string &output_name);
-
- /**
- * @brief Copy the output tensor back into the output array
- * @param[in] output_node The label of the output node
- * @param[in] outputs The output data array
- * @return N/A
- */
- void fetch(const std::string &output_name, std::vector<float> &outputs);
-
- /**
- * @brief Get tensor size
- * @param[in] name The label of the node
- * @result The size of tensor
- */
- int getTensorSize(const std::string &name);
-
-private:
- std::unique_ptr<tflite::Interpreter> _interpreter;
- std::unique_ptr<tflite::FlatBufferModel> _model;
- std::shared_ptr<nnfw::tflite::Session> _sess;
-};
-
-#endif // __TFLITE_CLASSIFY_INFERENCE_INTERFACE_H__
diff --git a/contrib/tflite_classify/src/tflite_classify.cc b/contrib/tflite_classify/src/tflite_classify.cc
deleted file mode 100644
index 40c15f331..000000000
--- a/contrib/tflite_classify/src/tflite_classify.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2018 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 "ImageClassifier.h"
-
-#include <iostream>
-
-#include <boost/filesystem.hpp>
-#include <opencv2/opencv.hpp>
-
-namespace fs = boost::filesystem;
-
-int main(const int argc, char **argv)
-{
- const std::string MODEL_FILE = "tensorflow_inception_graph.tflite";
- const std::string LABEL_FILE = "imagenet_comp_graph_label_strings.txt";
-
- const std::string INPUT_NAME = "input";
- const std::string OUTPUT_NAME = "output";
- const int INPUT_SIZE = 224;
- const int IMAGE_MEAN = 117;
- const int IMAGE_STD = 1;
- const int OUTPUT_SIZE = 1008;
-
- const int FRAME_WIDTH = 640;
- const int FRAME_HEIGHT = 480;
-
- bool use_nnapi = false;
- bool debug_mode = false;
-
- if (std::getenv("USE_NNAPI") != nullptr)
- {
- use_nnapi = true;
- }
-
- if (std::getenv("DEBUG_MODE") != nullptr)
- {
- debug_mode = true;
- }
-
- std::cout << "USE_NNAPI : " << use_nnapi << std::endl;
- std::cout << "DEBUG_MODE : " << debug_mode << std::endl;
-
- std::cout << "Model : " << MODEL_FILE << std::endl;
- std::cout << "Label : " << LABEL_FILE << std::endl;
-
- if (!fs::exists(MODEL_FILE))
- {
- std::cerr << "model file not found: " << MODEL_FILE << std::endl;
- exit(1);
- }
-
- if (!fs::exists(LABEL_FILE))
- {
- std::cerr << "label file not found: " << LABEL_FILE << std::endl;
- exit(1);
- }
-
- // Create ImageClassifier
- std::unique_ptr<ImageClassifier> classifier(
- new ImageClassifier(MODEL_FILE, LABEL_FILE, INPUT_SIZE, IMAGE_MEAN, IMAGE_STD, INPUT_NAME,
- OUTPUT_NAME, use_nnapi));
-
- // Cam setting
- cv::VideoCapture cap(0);
- cv::Mat frame;
-
- // Initialize camera
- cap.set(CV_CAP_PROP_FRAME_WIDTH, FRAME_WIDTH);
- cap.set(CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT);
- cap.set(CV_CAP_PROP_FPS, 5);
-
- std::vector<Recognition> results;
- clock_t begin, end;
- while (cap.isOpened())
- {
- // Get image data
- if (!cap.read(frame))
- {
- std::cout << "Frame is null..." << std::endl;
- break;
- }
-
- if (debug_mode)
- {
- begin = clock();
- }
- // Recognize image
- results = classifier->recognizeImage(frame);
- if (debug_mode)
- {
- end = clock();
- }
-
- // Show result data
- std::cout << std::endl;
- if (results.size() > 0)
- {
- for (int i = 0; i < results.size(); ++i)
- {
- std::cout << results[i].title << ": " << results[i].confidence << std::endl;
- }
- }
- else
- {
- std::cout << "." << std::endl;
- }
- if (debug_mode)
- {
- std::cout << "Frame: " << FRAME_WIDTH << "x" << FRAME_HEIGHT << std::endl;
- std::cout << "Crop: " << INPUT_SIZE << "x" << INPUT_SIZE << std::endl;
- std::cout << "Inference time(ms): " << ((end - begin) / (CLOCKS_PER_SEC / 1000)) << std::endl;
- }
- }
-
- cap.release();
-
- return 0;
-}
diff --git a/contrib/tflite_test/CMakeLists.txt b/contrib/tflite_test/CMakeLists.txt
deleted file mode 100644
index 760952a84..000000000
--- a/contrib/tflite_test/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-if(NOT BUILD_TFLITE_TEST)
- return()
-endif(NOT BUILD_TFLITE_TEST)
-
-nnfw_find_package(Tensorflow QUIET)
-
-if(NOT Tensorflow_FOUND)
- return()
-endif(NOT Tensorflow_FOUND)
-
-list(APPEND SOURCES tflite_test.cpp)
-
-add_executable(tflite_test ${SOURCES})
-target_link_libraries(tflite_test PRIVATE nnfw_lib_tflite)
-target_link_libraries(tflite_test PRIVATE tensorflow-lite)
-target_link_libraries(tflite_test PRIVATE tensorflow-core)
diff --git a/contrib/tflite_test/tflite_test.cpp b/contrib/tflite_test/tflite_test.cpp
deleted file mode 100644
index 4ee9e5a8d..000000000
--- a/contrib/tflite_test/tflite_test.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2018 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 <tensorflow/contrib/lite/model.h>
-#include <tensorflow/core/public/session.h>
-
-#include "tflite/Assert.h"
-#include "tflite/Session.h"
-#include "tflite/InterpreterSession.h"
-#include "tflite/NNAPISession.h"
-#include "tflite/ext/kernels/register.h"
-
-#include "misc/fp32.h"
-
-#include <iostream>
-
-#include <string>
-#include <vector>
-
-#define TF_ENSURE(e) { \
- if(!(e).ok()) \
- { \
- throw std::runtime_error{"'" #e "' FAILED"}; \
- } \
-}
-
-using namespace tflite;
-using namespace tflite::ops::builtin;
-
-std::unique_ptr<FlatBufferModel> BuildModelFromFile(const std::string &path)
-{
- static StderrReporter reporter;
- return FlatBufferModel::BuildFromFile(path.c_str(), &reporter);
-}
-
-std::unique_ptr<Interpreter> BuildInterpFromModel(const std::unique_ptr<FlatBufferModel> &model)
-{
- std::unique_ptr<Interpreter> interp;
-
- BuiltinOpResolver resolver;
- InterpreterBuilder builder(*model, resolver);
-
- TFLITE_ENSURE(builder(&interp));
-
- return std::move(interp);
-}
-
-tensorflow::TensorShape asTensorflowShape(const TfLiteTensor *tensor)
-{
- tensorflow::TensorShape shape;
-
- const int rank = tensor->dims->size;
-
- for (int axis = 0; axis < rank; ++axis)
- {
- shape.AddDim(tensor->dims->data[axis]);
- }
-
- return shape;
-}
-
-uint32_t count_elements(const TfLiteTensor *tensor)
-{
- const int rank = tensor->dims->size;
-
- if (rank == 0)
- {
- return 0;
- }
-
- uint32_t res = 1;
-
- for (int axis = 0; axis < rank; ++axis)
- {
- res *= tensor->dims->data[axis];
- }
-
- return res;
-}
-
-int main(int argc, char **argv)
-{
- bool use_nnapi = false;
-
- if (std::getenv("USE_NNAPI") != nullptr)
- {
- use_nnapi = true;
- }
-
- if (argc < 3)
- {
- std::cerr << "USAGE: " << argv[0] << " [T/F lite model] [T/F model]" << std::endl;
- return 255;
- }
-
- //
- // Prepare Tensorflow Lite session
- //
- const std::string lite_model_path{argv[1]};
-
- auto lite_model = BuildModelFromFile(lite_model_path);
- auto lite_interp = BuildInterpFromModel(lite_model);
-
- std::shared_ptr<nnfw::tflite::Session> lite_sess;
-
- if (use_nnapi)
- {
- lite_sess = std::make_shared<nnfw::tflite::NNAPISession>(lite_interp.get());
- }
- else
- {
- lite_sess = std::make_shared<nnfw::tflite::InterpreterSession>(lite_interp.get());
- }
-
- //
- // Prepare Tensorflow session
- //
- const std::string full_model_path{argv[2]};
-
- tensorflow::Session* full_sess;
- tensorflow::GraphDef full_model;
-
- TF_ENSURE(tensorflow::NewSession(tensorflow::SessionOptions(), &full_sess));
- TF_ENSURE(ReadBinaryProto(tensorflow::Env::Default(), full_model_path, &full_model));
- TF_ENSURE(full_sess->Create(full_model));
-
- //
- //
- //
- std::vector<tensorflow::Tensor> input_nodes;
- std::vector<std::string> input_names;
-
- for (uint32_t n = 0; n < lite_interp->inputs().size(); ++n)
- {
- const TfLiteTensor *tensor = lite_interp->tensor(lite_interp->inputs().at(n));
-
- input_nodes.emplace_back(tensorflow::DT_FLOAT, asTensorflowShape(tensor));
- input_names.emplace_back(tensor->name);
- }
-
- assert(input_nodes.size() == input_names.size());
- assert(input_nodes.size() == lite_interp->inputs().size());
-
- std::vector<std::string> output_names;
- std::vector<tensorflow::Tensor> output_nodes;
-
- for (uint32_t n = 0; n < lite_interp->outputs().size(); ++n)
- {
- const TfLiteTensor *tensor = lite_interp->tensor(lite_interp->outputs().at(n));
-
- output_names.emplace_back(tensor->name);
- }
-
- assert(output_names.size() == lite_interp->outputs().size());
- // output_nodes will be initialized after Tensorflow Session run
- assert(output_nodes.size() == 0);
-
- //
- // Prepare inference
- //
- lite_sess->prepare();
-
- // TODO Feed Inputs (for both Tensorflow and Tensorflow Lite)
- std::vector<std::pair<std::string, tensorflow::Tensor>> inputs;
-
- for (uint32_t n = 0; n < input_nodes.size(); ++n)
- {
- inputs.emplace_back(input_names.at(0), input_nodes.at(0));
- }
-
- //
- // Run inference
- //
- TF_ENSURE(full_sess->Run(inputs, output_names, {}, &output_nodes));
-
- lite_sess->run();
-
- //
- // Compare Output
- //
- auto equals = [] (float lhs, float rhs) {
- // TODO Allow users to set tolerance
- if (nnfw::misc::fp32::absolute_epsilon_equal(lhs, rhs))
- {
- return true;
- }
-
- return nnfw::misc::fp32::epsilon_equal(lhs, rhs);
- };
-
- const uint32_t output_count = output_names.size();
-
- bool matched = true;
-
- for (uint32_t n = 0; n < output_count; ++n)
- {
- const TfLiteTensor *tensor = lite_interp->tensor(lite_interp->outputs().at(n));
-
- // TODO Compare shape
-
- const auto element_count = count_elements(tensor);
-
- std::cout << "Compare output #" << n << "(" << tensor->name << ", " << element_count << " elements)" << std::endl;
- for (uint32_t index = 0; index < element_count; ++index)
- {
- const auto full_value = output_nodes.at(n).flat<float>().data()[index];
- const auto lite_value = lite_sess->interp()->typed_output_tensor<float>(n)[index];
-
- if (!equals(full_value, lite_value))
- {
- std::cerr << full_value << " is expected, but " << lite_value << " is obtaeind (at " << n << ":" << index << ")" << std::endl;
- matched = false;
- }
- }
- }
-
- //
- // Cleanup
- //
- lite_sess->teardown();
-
- return matched ? 0 : 255;
-}