--- /dev/null
+#ifndef __NNFW_SUPPORT_NNAPI_FEATURE_READER_H__
+#define __NNFW_SUPPORT_NNAPI_FEATURE_READER_H__
+
+#include "support/nnapi/feature/Utils.h"
+
+#include "util/feature/Shape.h"
+#include "util/feature/Reader.h"
+
+namespace nnfw
+{
+namespace support
+{
+namespace nnapi
+{
+namespace feature
+{
+
+template<typename T> class Reader;
+
+template<> class Reader<float> : public nnfw::util::feature::Reader<float>
+{
+public:
+ Reader(const nnfw::util::feature::Shape &shape, const float *base)
+ : _shape{shape}, _base{base}
+ {
+ // DO NOTHING
+ }
+
+public:
+ float at(uint32_t ch, uint32_t row, uint32_t col) const override
+ {
+ return *(_base + indexOf(_shape, ch, row, col));
+ }
+
+private:
+ nnfw::util::feature::Shape _shape;
+ const float *_base;
+};
+
+} // namespace feature
+} // namespace nnapi
+} // namespace support
+} // namespace nnfw
+
+#endif // __NNFW_SUPPORT_NNAPI_FEATURE_READER_H__
--- /dev/null
+#ifndef __NNFW_SUPPORT_NNAPI_FEATURE_UTILS_H__
+#define __NNFW_SUPPORT_NNAPI_FEATURE_UTILS_H__
+
+#include "util/feature/Shape.h"
+
+#include <cstdint>
+
+namespace nnfw
+{
+namespace support
+{
+namespace nnapi
+{
+namespace feature
+{
+
+uint32_t indexOf(const nnfw::util::feature::Shape &shape, uint32_t ch, uint32_t row, uint32_t col);
+
+} // namespace feature
+} // namespace nnapi
+} // namespace support
+} // namespace nnfw
+
+#endif // __NNFW_SUPPORT_NNAPI_FEATURE_UTILS_H__
${NNFW_ACL_INCLUDES}
${CMAKE_SOURCE_DIR}/include
)
+target_link_libraries(${LIB_KERNELACL} nnfw_support_nnapi)
if (${TARGET_OS} STREQUAL "tizen")
target_link_libraries(${LIB_KERNELACL} nnfw_util ${NNFW_ACL_LIBS} OpenCL)
else()
#include "util/feature/Reader.h"
#include "util/feature/TextFormatter.h"
+#include "support/nnapi/feature/Reader.h"
+
namespace nnfw
{
namespace support
namespace feature
{
-template<typename T> class Reader;
-
-template<> class Reader<float> : public nnfw::util::feature::Reader<float>
-{
-public:
- Reader(const nnfw::util::feature::Shape &shape, const float *base)
- : _shape{shape}, _base{base}
- {
- // DO NOTHING
- }
-
-public:
- float at(uint32_t ch, uint32_t row, uint32_t col) const override
- {
- return *(_base + getElementOffset(ch, row, col));
- }
-
-private:
- uint32_t getElementOffset(uint32_t ch, uint32_t row, uint32_t col) const
- {
- uint32_t res = 0;
-
- // NNAPI assumes that NHWC ordering for feature map
- res += row * _shape.W * _shape.C;
- res += col * _shape.C;
- res += ch;
-
- return res;
- }
-
-private:
- nnfw::util::feature::Shape _shape;
- const float *_base;
-};
-
+// TODO Extract this function as utility function
+// NOTE It is not a good design to access android::nn::Shape nnfw_support_nnapi lib
nnfw::util::feature::Shape asFeatureShape(const android::nn::Shape& shape)
{
// NNAPI assumes the following ordering:
add_subdirectory(tflite)
+add_subdirectory(nnapi)
--- /dev/null
+file(GLOB_RECURSE SOURCES "src/*.cpp")
+
+add_library(nnfw_support_nnapi ${SOURCES})
+target_include_directories(nnfw_support_nnapi PUBLIC ${CMAKE_SOURCE_DIR}/include)
+target_link_libraries(nnfw_support_nnapi nnfw_util)
--- /dev/null
+#include "support/nnapi/feature/Utils.h"
+
+namespace nnfw
+{
+namespace support
+{
+namespace nnapi
+{
+namespace feature
+{
+
+uint32_t indexOf(const nnfw::util::feature::Shape &shape, uint32_t ch, uint32_t row, uint32_t col)
+{
+ uint32_t res = 0;
+
+ // NNAPI assumes that NHWC ordering for feature map
+ res += row * shape.W * shape.C;
+ res += col * shape.C;
+ res += ch;
+
+ return res;
+}
+
+} // namespace feature
+} // namespace nnapi
+} // namespace support
+} // namespace nnfw