/externals/absl
/externals/nonius
/externals/boost
+/externals/NNPACK
+/externals/python*
+/externals/FXdiv
+/externals/cpuinfo
+/externals/PSIMD
+/externals/pthreadpool
+/externals/FP16
# tflkit info files
/tools/tflkit/*.info
option(DOWNLOAD_FARMHASH "Download farmhash source" ON)
option(DOWNLOAD_GEMMLOWP "Download GEMM low precesion library source" ON)
option(DOWNLOAD_NEON2SSE "Download NEON2SSE library source" ON)
+option(DOWNLOAD_NNPACK "Download NNPACK source" ON)
option(DOWNLOAD_FLATBUFFERS "Download FlatBuffers source" ON)
option(BUILD_TENSORFLOW_LITE "Build TensorFlow Lite from the downloaded source" ON)
option(DOWNLOAD_ARMCOMPUTE "Download ARM Compute source" ON)
"-mfpu=neon-vfpv4"
"-funsafe-math-optimizations"
"-ftree-vectorize"
+ "-mfp16-format=ieee"
)
option(BUILD_ANDROID_TFLITE "Enable android support for TensorFlow Lite" OFF)
option(DOWNLOAD_ARMCOMPUTE "Download ARM Compute source" ON)
option(DOWNLOAD_NEON2SSE "Download NEON2SSE library source" OFF)
+option(DOWNLOAD_NNPACK "Download NNPACK library source" OFF)
--- /dev/null
+function(_cpuinfoSource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(CPUINFO_URL ${EXTERNAL_DOWNLOAD_SERVER}/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz)
+
+ ExternalSource_Get("cpuinfo" ${DOWNLOAD_NNPACK} ${CPUINFO_URL})
+
+ set(CPUINFO_SOURCE_DIR ${cpuinfo_SOURCE_DIR} PARENT_SCOPE)
+ set(CPUINFO_SOURCE_FOUND ${cpuinfo_SOURCE_GET} PARENT_SCOPE)
+endfunction(_cpuinfoSource_import)
+
+_cpuinfoSource_import()
--- /dev/null
+function(_enum34Source_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://bitbucket.org")
+ set(ENUM34_URL ${EXTERNAL_DOWNLOAD_SERVER}/stoneleaf/enum34/get/1.1.6.tar.gz)
+
+ ExternalSource_Get("python_enum" ${DOWNLOAD_NNPACK} ${ENUM34_URL})
+
+ set(PYTHON_ENUM_SOURCE_DIR ${python_enum_SOURCE_DIR} PARENT_SCOPE)
+ set(PYTHON_ENUM_SOURCE_FOUND ${python_enum_SOURCE_GET} PARENT_SCOPE)
+endfunction(_enum34Source_import)
+
+_enum34Source_import()
--- /dev/null
+function(_FP16Source_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(FP16_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/FP16/archive/febbb1c163726b5db24bed55cc9dc42529068997.tar.gz)
+
+ ExternalSource_Get("FP16" ${DOWNLOAD_NNPACK} ${FP16_URL})
+
+ set(FP16_SOURCE_DIR ${FP16_SOURCE_DIR} PARENT_SCOPE)
+ set(FP16_SOURCE_FOUND ${FP16_SOURCE_GET} PARENT_SCOPE)
+endfunction(_FP16Source_import)
+
+_FP16Source_import()
--- /dev/null
+function(_FXdivSource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(FXDIV_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/FXdiv/archive/f8c5354679ec2597792bc70a9e06eff50c508b9a.tar.gz)
+
+ ExternalSource_Get("FXdiv" ${DOWNLOAD_NNPACK} ${FXDIV_URL})
+
+ set(FXDIV_SOURCE_DIR ${FXdiv_SOURCE_DIR} PARENT_SCOPE)
+ set(FXDIV_SOURCE_FOUND ${FXdiv_SOURCE_GET} PARENT_SCOPE)
+endfunction(_FXdivSource_import)
+
+_FXdivSource_import()
--- /dev/null
+function(_NNPACK_Import)
+ nnfw_find_package(NNPACKSource QUIET)
+
+ if(NOT NNPACK_SOURCE_FOUND)
+ set(NNPACK_FOUND FALSE PARENT_SCOPE)
+ message(STATUS "NNPACK not found")
+ return()
+ endif(NOT NNPACK_SOURCE_FOUND)
+
+ nnfw_find_package(CpuinfoSource REQUIRED)
+ nnfw_find_package(FP16Source REQUIRED)
+ nnfw_find_package(FXdivSource REQUIRED)
+ nnfw_find_package(PSIMDSource REQUIRED)
+ nnfw_find_package(PthreadpoolSource REQUIRED)
+ nnfw_find_package(SixSource REQUIRED)
+ nnfw_find_package(Enum34Source REQUIRED)
+ nnfw_find_package(OpcodesSource REQUIRED)
+ nnfw_find_package(PeachpySource REQUIRED)
+
+ # workaround for CI
+ set(THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by CMakeLists.txt." FORCE)
+ if(NOT TARGET nnpack)
+ # Allows us to build nnpack at build time
+ set(NNPACK_BUILD_TESTS OFF CACHE BOOL "")
+ set(NNPACK_BUILD_BENCHMARKS OFF CACHE BOOL "")
+ set(NNPACK_LIBRARY_TYPE "static" CACHE STRING "")
+ set(PTHREADPOOL_LIBRARY_TYPE "static" CACHE STRING "")
+ set(CPUINFO_LIBRARY_TYPE "static" CACHE STRING "")
+ add_extdirectory("${NNPACK_SOURCE_DIR}" nnpack)
+ # We build static versions of nnpack and pthreadpool but link
+ # them into a shared library (high-perf-backend), so they need PIC.
+ set_property(TARGET nnpack PROPERTY POSITION_INDEPENDENT_CODE ON)
+ set_property(TARGET pthreadpool PROPERTY POSITION_INDEPENDENT_CODE ON)
+ set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
+ endif()
+
+ set(NNPACK_FOUND TRUE PARENT_SCOPE)
+ set(NNPACK_INCLUDE_DIRS
+ $<TARGET_PROPERTY:nnpack,INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:pthreadpool,INCLUDE_DIRECTORIES> PARENT_SCOPE)
+ set(NNPACK_LIBRARIES $<TARGET_FILE:nnpack> $<TARGET_FILE:cpuinfo> PARENT_SCOPE)
+
+endfunction(_NNPACK_Import)
+
+_NNPACK_Import()
--- /dev/null
+function(_NNPACKSource_import)
+ if(NOT DOWNLOAD_NNPACK)
+ set(NNPACKSource_FOUND FALSE PARENT_SCOPE)
+ message(WARN "NNPACK not downloaded")
+ return()
+ endif(NOT DOWNLOAD_NNPACK)
+
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(NNPACK_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/NNPACK/archive/c039579abe21f5756e0f0e45e8e767adccc11852.tar.gz)
+ ExternalSource_Get("NNPACK" ${DOWNLOAD_NNPACK} ${NNPACK_URL})
+
+ set(NNPACK_SOURCE_DIR ${NNPACK_SOURCE_DIR} PARENT_SCOPE)
+ set(NNPACK_INCLUDE_DIR ${NNPACK_SOURCE_DIR}/include PARENT_SCOPE)
+ set(NNPACK_SOURCE_FOUND ${NNPACK_SOURCE_GET} PARENT_SCOPE)
+endfunction(_NNPACKSource_import)
+
+_NNPACKSource_import()
--- /dev/null
+function(_PeachpySource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(PEACHPY_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/Opcodes/archive/6e2b0cd9f1403ecaf164dea7019dd54db5aea252.tar.gz)
+ ExternalSource_Get("python_opcodes" ${DOWNLOAD_NNPACK} ${PEACHPY_URL})
+
+ set(PYTHON_OPCODES_SOURCE_DIR ${python_opcodes_SOURCE_DIR} PARENT_SCOPE)
+ set(PYTHON_OPCODES_SOURCE_FOUND ${python_opcodes_SOURCE_GET} PARENT_SCOPE)
+endfunction(_PeachpySource_import)
+
+_PeachpySource_import()
--- /dev/null
+function(_PSIMDSource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(PSIMD_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/psimd/archive/90a938f30ba414ada2f4b00674ee9631d7d85e19.tar.gz)
+
+ ExternalSource_Get("PSIMD" ${DOWNLOAD_NNPACK} ${PSIMD_URL})
+
+ set(PSIMD_SOURCE_DIR ${PSIMD_SOURCE_DIR} PARENT_SCOPE)
+ set(PSIMD_SOURCE_FOUND ${PSIMD_SOURCE_GET} PARENT_SCOPE)
+endfunction(_PSIMDSource_import)
+
+_PSIMDSource_import()
--- /dev/null
+function(_PeachpySource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(PEACHPY_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/PeachPy/archive/01d15157a973a4ae16b8046313ddab371ea582db.tar.gz)
+
+ ExternalSource_Get("python_peachpy" ${DOWNLOAD_NNPACK} ${PEACHPY_URL})
+ FIND_PACKAGE(PythonInterp)
+
+ # Generate opcodes:
+ SET(ENV{PYTHONPATH} ${PYTHON_SIX_SOURCE_DIR}:${PYTHON_ENUM_SOURCE_DIR}:${PYTHON_OPCODES_SOURCE_DIR})
+ EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ./setup.py generate
+ WORKING_DIRECTORY ${python_peachpy_SOURCE_DIR}
+ RESULT_VARIABLE BUILT_PP)
+ set(PYTHON_PEACHPY_SOURCE_DIR ${python_peachpy_SOURCE_DIR} PARENT_SCOPE)
+ set(PYTHON_PEACHPY_SOURCE_FOUND ${python_peachpy_SOURCE_GET} PARENT_SCOPE)
+endfunction(_PeachpySource_import)
+
+_PeachpySource_import()
--- /dev/null
+function(_pthreadpoolSource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(PTHREADPOOL_URL ${EXTERNAL_DOWNLOAD_SERVER}/Maratyszcza/pthreadpool/archive/6673a4c71fe35e077c6843a74017d9c25610c537.tar.gz)
+
+ ExternalSource_Get("pthreadpool" ${DOWNLOAD_NNPACK} ${PTHREADPOOL_URL})
+
+ set(PTHREADPOOL_SOURCE_DIR ${pthreadpool_SOURCE_DIR} PARENT_SCOPE)
+ set(PTHREADPOOL_SOURCE_FOUND ${pthreadpool_SOURCE_GET} PARENT_SCOPE)
+endfunction(_pthreadpoolSource_import)
+
+_pthreadpoolSource_import()
--- /dev/null
+function(_SIXSource_import)
+ nnfw_include(ExternalSourceTools)
+ nnfw_include(OptionTools)
+
+ envoption(EXTERNAL_DOWNLOAD_SERVER "https://github.com")
+ set(six_URL ${EXTERNAL_DOWNLOAD_SERVER}/benjaminp/six/archive/1.11.0.tar.gz)
+
+ ExternalSource_Get("python_six" ${DOWNLOAD_NNPACK} ${six_URL})
+
+ set(PYTHON_SIX_SOURCE_DIR ${python_six_SOURCE_DIR} PARENT_SCOPE)
+ set(PYTHON_SIX_SOURCE_FOUND ${python_six_SOURCE_GET} PARENT_SCOPE)
+endfunction(_SIXSource_import)
+
+_SIXSource_import()
add_subdirectory(acl_cl)
add_subdirectory(acl_neon)
add_subdirectory(acl_common)
+add_subdirectory(hi_perf_cpu)
--- /dev/null
+set(LIB_NEURUN_BACKEND_HI_PERF_CPU neurun_backend_hi_perf)
+
+nnfw_find_package(NNPACK QUIET)
+IF(NOT ${NNPACK_FOUND})
+ message(STATUS "NNPACK not found => not building high performance cpu backend")
+ return()
+ENDIF(NOT ${NNPACK_FOUND})
+add_subdirectory(kernel)
+
+file(GLOB_RECURSE SOURCES "*.cc")
+file(GLOB_RECURSE REMOVE_KERNEL_SOURCES "kernel/*.cc")
+file(GLOB_RECURSE TESTS "*.test.cc")
+#list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES})
+list(REMOVE_ITEM SOURCES ${TESTS})
+
+add_library(${LIB_NEURUN_BACKEND_HI_PERF_CPU} SHARED ${SOURCES})
+
+target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} nnfw_lib_misc)
+target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} nnfw_lib_cpp14)
+target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} ${LIB_NEURUN_KERNEL_NNPACK})
+target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} neurun-core)
+
+target_compile_options(${LIB_NEURUN_BACKEND_HI_PERF_CPU} PRIVATE -Wall -Wextra -Werror)
+
+set_target_properties(${LIB_NEURUN_BACKEND_HI_PERF_CPU} PROPERTIES OUTPUT_NAME backend_NNPACK)
+install(TARGETS ${LIB_NEURUN_BACKEND_HI_PERF_CPU} DESTINATION lib)
+
+target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} nnpack pthreadpool cpuinfo)
+target_include_directories(${LIB_NEURUN_BACKEND_HI_PERF_CPU} PRIVATE ${NNPACK_INCLUDE_DIRS})
+
+# Unit Tests
+set(TEST_NEURUN_BACKEND_HI_PERF_CPU test_neurun_backend_hi_perf)
+
+add_executable(${TEST_NEURUN_BACKEND_HI_PERF_CPU} ${TESTS})
+target_link_libraries(${TEST_NEURUN_BACKEND_HI_PERF_CPU} ${LIB_NEURUN_BACKEND_HI_PERF_CPU})
+target_link_libraries(${TEST_NEURUN_BACKEND_HI_PERF_CPU} gtest gtest_main ${LIB_PTHREAD})
+add_test(${TEST_NEURUN_BACKEND_HI_PERF_CPU} ${TEST_NEURUN_BACKEND_HI_PERF_CPU})
+target_include_directories(${TEST_NEURUN_BACKEND_HI_PERF_CPU} PRIVATE ${NNPACK_INCLUDE_DIR})
+
+install(TARGETS ${TEST_NEURUN_BACKEND_HI_PERF_CPU} DESTINATION unittest)
--- /dev/null
+/*
+ * Copyright (c) 2019 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 <gtest/gtest.h>
+
+#include "nnpack.h"
+
+TEST(High_performance_backend, NNPACK_Test)
+{
+ // Check that it is possible to import
+ const enum nnp_status init_status = nnp_initialize();
+
+ // One of the allowed nnp status codes
+ ASSERT_GE(init_status, 0);
+ ASSERT_LE(init_status, 54);
+
+ // If it is possible to test, test relu
+ if (init_status == nnp_status_success)
+ {
+ float in[] = {-1, 1, -1, 1};
+ float out[4];
+ nnp_relu_output(1, 4, in, out, 0, nullptr);
+ for (int i = 0; i < 4; i++)
+ {
+ ASSERT_EQ(out[i], in[i] >= 0 ? in[i] : 0);
+ }
+ }
+ nnp_deinitialize();
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "StageGenerator.h"
+// to force compilation
--- /dev/null
+/*
+ * Copyright (c) 2019 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 NNFW_STAGEGENERATOR_H
+#define NNFW_STAGEGENERATOR_H
+
+#include <backend/IStageGenerator.h>
+
+#include "model/Operands.h"
+#include "TensorBuilder.h"
+
+namespace neurun
+{
+namespace backend
+{
+namespace hi_perf_cpu
+{
+
+class StageGenerator : public IStageGenerator
+{
+public:
+ StageGenerator(const neurun::model::Operands &ctx,
+ const std::shared_ptr<TensorBuilder> &tensor_builder);
+ std::shared_ptr<ITensorBuilder> tensor_builder() override;
+ // TODO add more ops
+
+private:
+ const neurun::model::Operands &_ctx;
+ std::shared_ptr<TensorBuilder> _tensor_builder;
+};
+
+} // namespace hi_perf_cpu
+} // namespace backend
+} // namespace neurun
+
+#endif // NNFW_STAGEGENERATOR_H
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "TensorBuilder.h"
+// to force compilation
--- /dev/null
+/*
+ * Copyright (c) 2019 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 NNFW_TENSORBUILDER_H
+#define NNFW_TENSORBUILDER_H
+
+#include <unordered_map>
+
+#include <backend/ITensorBuilder.h>
+#include <backend/operand/Object.h>
+#include "model/OperandIndexMap.h"
+
+namespace neurun
+{
+namespace backend
+{
+namespace hi_perf_cpu
+{
+
+class TensorBuilder : public ITensorBuilder
+{
+public:
+ TensorBuilder();
+
+private:
+};
+
+} // namespace hi_perf_cpu
+} // namespace backend
+} // namespace neurun
+
+#endif // NNFW_TENSORBUILDER_H