Remove nnapi library (#4105)
authorДилшоджон Умронхонович Пошшоев/AI Tools Lab /SRR/Engineer/삼성전자 <d.poshshoev@samsung.com>
Wed, 2 Jan 2019 04:13:03 +0000 (07:13 +0300)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 2 Jan 2019 04:13:03 +0000 (13:13 +0900)
Related issue: 4103
Remove nnapi library since just one of its functions is used in
backends: better to move it into neurun/utils

Signed-off-by: Poshshoev Dilshodzhon <d.poshshoev@samsung.com>
libs/nnapi/CMakeLists.txt [deleted file]
libs/nnapi/include/nnapi/feature/Reader.h [deleted file]
libs/nnapi/include/nnapi/feature/Utils.h [deleted file]
libs/nnapi/src/Utils.cpp [deleted file]
runtimes/neurun/CMakeLists.txt
runtimes/neurun/src/backend/acl_cl/CMakeLists.txt
runtimes/neurun/src/backend/acl_cl/StageGenerator.cc
runtimes/neurun/src/backend/cpu/StageGenerator.cc
runtimes/neurun/src/util/Utils.cc [moved from libs/nnapi/src/feature/Utils.cpp with 53% similarity]
runtimes/neurun/src/util/Utils.h [moved from libs/nnapi/include/nnapi/Utils.h with 85% similarity]

diff --git a/libs/nnapi/CMakeLists.txt b/libs/nnapi/CMakeLists.txt
deleted file mode 100644 (file)
index 94be0e9..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-file(GLOB_RECURSE SOURCES "src/*.cpp")
-
-add_library(nnfw_lib_nnapi STATIC ${SOURCES})
-set_property(TARGET nnfw_lib_nnapi PROPERTY POSITION_INDEPENDENT_CODE ON)
-target_include_directories(nnfw_lib_nnapi PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_link_libraries(nnfw_lib_nnapi nnfw_lib_misc)
diff --git a/libs/nnapi/include/nnapi/feature/Reader.h b/libs/nnapi/include/nnapi/feature/Reader.h
deleted file mode 100644 (file)
index 493362a..0000000
+++ /dev/null
@@ -1,77 +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     Reader.h
- * @brief    This file contains Reader class
- * @ingroup  COM_AI_RUNTIME
- */
-
-#ifndef __NNFW_NNAPI_FEATURE_READER_H__
-#define __NNFW_NNAPI_FEATURE_READER_H__
-
-#include "nnapi/feature/Utils.h"
-
-#include "misc/feature/Shape.h"
-#include "misc/feature/Reader.h"
-
-namespace nnfw
-{
-namespace nnapi
-{
-namespace feature
-{
-
-/**
- * @brief Class to read value of feature which is inherited
- *        from nnfw::misc::feature::Reader<T> class
- */
-template <typename T> class Reader : public nnfw::misc::feature::Reader<T>
-{
-public:
-  /**
-   * @brief Construct a new Reader object with base and shape informations
-   * @param[in] shape The shape of a feature
-   * @param[in] base The base address of a feature
-   */
-  Reader(const nnfw::misc::feature::Shape &shape, const T *base) : _shape{shape}, _base{base}
-  {
-    // DO NOTHING
-  }
-
-public:
-  /**
-   * @brief Get the value used by three indexes
-   * @param[in] ch The channel index
-   * @param[in] row The row index
-   * @param[in] col The column index
-   * @return The value at the offset
-   */
-  T at(uint32_t ch, uint32_t row, uint32_t col) const override
-  {
-    return *(_base + indexOf(_shape, ch, row, col));
-  }
-
-private:
-  nnfw::misc::feature::Shape _shape; /**< Shape of feature */
-  const T *_base;                    /**< Base address of feature */
-};
-
-} // namespace feature
-} // namespace nnapi
-} // namespace nnfw
-
-#endif // __NNFW_NNAPI_FEATURE_READER_H__
diff --git a/libs/nnapi/include/nnapi/feature/Utils.h b/libs/nnapi/include/nnapi/feature/Utils.h
deleted file mode 100644 (file)
index 6ffbf5a..0000000
+++ /dev/null
@@ -1,51 +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     Utils.h
- * @brief    This file contains indexOf function
- * @ingroup  COM_AI_RUNTIME
- */
-
-#ifndef __NNFW_NNAPI_FEATURE_UTILS_H__
-#define __NNFW_NNAPI_FEATURE_UTILS_H__
-
-#include "misc/feature/Shape.h"
-
-#include <cstdint>
-
-namespace nnfw
-{
-namespace nnapi
-{
-namespace feature
-{
-
-/**
- * @brief Get index for given parameters
- * @param[in] shape The shape of feature
- * @param[in] ch The channel index
- * @param[in] row The row index
- * @param[in] col The column index
- * @return The value index of given parameters
- */
-uint32_t indexOf(const nnfw::misc::feature::Shape &shape, uint32_t ch, uint32_t row, uint32_t col);
-
-} // namespace feature
-} // namespace nnapi
-} // namespace nnfw
-
-#endif // __NNFW_NNAPI_FEATURE_UTILS_H__
diff --git a/libs/nnapi/src/Utils.cpp b/libs/nnapi/src/Utils.cpp
deleted file mode 100644 (file)
index 7be8572..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "nnapi/Utils.h"
-
-#include <cassert>
-
-namespace nnfw
-{
-namespace nnapi
-{
-
-const char *to_string(const PaddingCode &code)
-{
-  assert((ANEURALNETWORKS_PADDING_SAME == code) || (ANEURALNETWORKS_PADDING_VALID == code));
-
-  switch (code)
-  {
-    case ANEURALNETWORKS_PADDING_SAME:
-      return "ANEURALNETWORKS_PADDING_SAME";
-    case ANEURALNETWORKS_PADDING_VALID:
-      return "ANEURALNETWORKS_PADDING_VALID";
-  }
-
-  return nullptr;
-}
-
-} // namespace nnapi
-} // namespace nnfw
index 5f7f100..e3816d4 100644 (file)
@@ -37,7 +37,6 @@ target_include_directories(${LIB_NEURUN} PUBLIC ${CMAKE_SOURCE_DIR}/externals/te
 target_link_libraries(${LIB_NEURUN} arm_compute)
 target_link_libraries(${LIB_NEURUN} tensorflow-lite)
 target_link_libraries(${LIB_NEURUN} nnfw_lib_misc)
-target_link_libraries(${LIB_NEURUN} nnfw_lib_nnapi)
 target_link_libraries(${LIB_NEURUN} nnfw_lib_cpp14)
 
 target_compile_options(${LIB_NEURUN} PRIVATE -Wall -Wextra -Werror)
index 54897e7..2651f0c 100644 (file)
@@ -7,7 +7,6 @@ target_include_directories(${LIB_NEURUN_BACKEND_ACL_CL} PUBLIC ${NEURUN_INCLUDE_
 target_include_directories(${LIB_NEURUN_BACKEND_ACL_CL} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow) # TODO Remove this file. We should not need this.
 
 target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} arm_compute)
-target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} nnfw_lib_nnapi)
 target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} ${LIB_NEURUN_KERNEL_ACL_CL})
 target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} ${LIB_NEURUN})
 
index 915cf14..89bbd7b 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "NeuralNetworks.h"
 
-#include "nnapi/Utils.h"
+#include "util/Utils.h"
 
 template <typename T> std::unique_ptr<T> make_layer(void) { return std::unique_ptr<T>{new T}; }
 
@@ -367,7 +367,7 @@ void StageGenerator::visit(const model::operation::AvgPool2DNode &node)
   VERBOSE(AvgPool2D) << "KER_W: " << kw << std::endl;
   VERBOSE(AvgPool2D) << "STRIDE_H: " << vstride << std::endl;
   VERBOSE(AvgPool2D) << "STRIDE_W: " << hstride << std::endl;
-  VERBOSE(AvgPool2D) << "PAD: " << ::nnfw::nnapi::to_string(padding_type) << std::endl;
+  VERBOSE(AvgPool2D) << "PAD: " << neurun::util::to_string(padding_type) << std::endl;
   VERBOSE(AvgPool2D) << "PAD(T): " << param.padding.top << std::endl;
   VERBOSE(AvgPool2D) << "PAD(B): " << param.padding.bottom << std::endl;
   VERBOSE(AvgPool2D) << "PAD(L): " << param.padding.left << std::endl;
index c218be6..694bb4d 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "util/logging.h"
 
-#include "nnapi/Utils.h"
+#include "util/Utils.h"
 
 namespace neurun
 {
@@ -309,7 +309,7 @@ void StageGenerator::visit(const model::operation::AvgPool2DNode &node)
   VERBOSE(AvgPool2D) << "KER_W: " << kw << std::endl;
   VERBOSE(AvgPool2D) << "STRIDE_H: " << vstride << std::endl;
   VERBOSE(AvgPool2D) << "STRIDE_W: " << hstride << std::endl;
-  VERBOSE(AvgPool2D) << "PAD: " << ::nnfw::nnapi::to_string(padding_type) << std::endl;
+  VERBOSE(AvgPool2D) << "PAD: " << util::to_string(padding_type) << std::endl;
   VERBOSE(AvgPool2D) << "PAD(T): " << param.padding.top << std::endl;
   VERBOSE(AvgPool2D) << "PAD(B): " << param.padding.bottom << std::endl;
   VERBOSE(AvgPool2D) << "PAD(L): " << param.padding.left << std::endl;
similarity index 53%
rename from libs/nnapi/src/feature/Utils.cpp
rename to runtimes/neurun/src/util/Utils.cc
index eaa033c..def02db 100644 (file)
@@ -5,7 +5,7 @@
  * 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
+ *      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,
  * limitations under the License.
  */
 
-#include "nnapi/feature/Utils.h"
+#include "Utils.h"
 
-namespace nnfw
-{
-namespace nnapi
+#include <cassert>
+
+namespace neurun
 {
-namespace feature
+namespace util
 {
 
-uint32_t indexOf(const nnfw::misc::feature::Shape &shape, uint32_t ch, uint32_t row, uint32_t col)
+const char *to_string(const PaddingCode &code)
 {
-  uint32_t res = 0;
+  assert((ANEURALNETWORKS_PADDING_SAME == code) || (ANEURALNETWORKS_PADDING_VALID == code));
 
-  // NNAPI assumes that NHWC ordering for feature map
-  res += row * shape.W * shape.C;
-  res += col * shape.C;
-  res += ch;
+  switch (code)
+  {
+    case ANEURALNETWORKS_PADDING_SAME:
+      return "ANEURALNETWORKS_PADDING_SAME";
+    case ANEURALNETWORKS_PADDING_VALID:
+      return "ANEURALNETWORKS_PADDING_VALID";
+  }
 
-  return res;
+  return nullptr;
 }
 
-} // namespace feature
-} // namespace nnapi
-} // namespace nnfw
+} // namespace util
+} // namespace neurun
similarity index 85%
rename from libs/nnapi/include/nnapi/Utils.h
rename to runtimes/neurun/src/util/Utils.h
index f9738fe..a1e5bf0 100644 (file)
  * @ingroup  COM_AI_RUNTIME
  */
 
-#ifndef __NNFW_NNAPI_UTILS_H__
-#define __NNFW_NNAPI_UTILS_H__
+#ifndef __NEURUN_UTIL_UTILS_H__
+#define __NEURUN_UTIL_UTILS_H__
 
 #include "NeuralNetworks.h"
 
-namespace nnfw
+namespace neurun
 {
-namespace nnapi
+namespace util
 {
 
 /**
@@ -37,7 +37,7 @@ namespace nnapi
  */
 const char *to_string(const PaddingCode &code);
 
-} // namespace nnapi
-} // namespace nnfw
+} // namespace util
+} // namespace neurun
 
-#endif // __NNFW_NNAPI_UTILS_H__
+#endif // __NEURUN_UTIL_UTILS_H__