diff --git a/.gitmodules b/.gitmodules index cabe2a25c..2d20a6af2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ -[submodule "third_party/iniparser"] - path = third_party/iniparser +[submodule "subprojects/iniparser"] + path = subprojects/iniparser url = https://github.com/ndevilla/iniparser.git -[submodule "third_party/ruy"] - path = third_party/ruy +[submodule "subprojects/ruy"] + path = subprojects/ruy url = https://github.com/google/ruy diff --git a/debian/control b/debian/control index c4438e2ef..8c439424d 100644 --- a/debian/control +++ b/debian/control @@ -92,3 +92,9 @@ Depends: nnstreamer-nntrainer-trainer, ${shlibs:Depends}, ${misc:Depends} Description: Development package for nntrainer tensor trainer This is a developement package of nntrainer's tensor trainer. +Package: ruy +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Ruy package + This is a ruy package for NNTrainer. diff --git a/debian/rules b/debian/rules index 449ccce7d..536ada57d 100755 --- a/debian/rules +++ b/debian/rules @@ -31,7 +31,7 @@ override_dh_auto_clean: rm -rf build override_dh_auto_configure: - tar -xf packaging/ruy.tar.gz -C third_party + tar -xf packaging/ruy.tar.gz -C subprojects mkdir -p build meson --buildtype=plain --prefix=/usr --sysconfdir=/etc \ --libdir=lib/$(DEB_HOST_MULTIARCH) --bindir=lib/nntrainer/bin \ @@ -45,7 +45,7 @@ override_dh_auto_configure: -Dcapi-ml-common-actual=capi-ml-common \ -Dcapi-ml-inference-actual=capi-ml-inference \ -Denable-capi=enabled \ - build + build --wrap-mode=nodownload override_dh_auto_build: ninja -C build @@ -58,6 +58,11 @@ override_dh_auto_install: override_dh_install: dh_install --sourcedir=debian/tmp + if [ "$(DEB_HOST_ARCH)" = "amd64" ]; then \ + dh_install /usr/bin/cpuid_dump; \ + else \ + echo "Skipping cpuid_dump on non-x86_64 architecture"; \ + fi override_dh_missing: dh_missing --fail-missing diff --git a/debian/ruy.install b/debian/ruy.install new file mode 100644 index 000000000..9e750a1f3 --- /dev/null +++ b/debian/ruy.install @@ -0,0 +1,6 @@ +/usr/lib/*/libruy*.a +/usr/lib/*/libclog.a +/usr/lib/*/libcpuinfo.a +/usr/bin/cache_info +/usr/bin/cpu_info +/usr/bin/isa_info diff --git a/jni/Android.mk.in b/jni/Android.mk.in index 6226dc574..ecf459599 100644 --- a/jni/Android.mk.in +++ b/jni/Android.mk.in @@ -54,6 +54,23 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) +LOCAL_MODULE := ruy +LOCAL_SRC_FILES := @MESON_RUY_ROOT@/ruy/apply_multiplier.cc \ + @MESON_RUY_ROOT@/ruy/block_map.cc \ + @MESON_RUY_ROOT@/ruy/blocking_counter.cc \ + @MESON_RUY_ROOT@/ruy/context.cc \ + @MESON_RUY_ROOT@/ruy/context_get_ctx.cc \ + @MESON_RUY_ROOT@/ruy/ctx.cc \ + @MESON_RUY_ROOT@/ruy/frontend.cc \ + @MESON_RUY_ROOT@/ruy/kernel_arm32.cc \ + @MESON_RUY_ROOT@/ruy/pack_arm.cc \ +LOCAL_C_INCLUDES := @MESON_RUY_ROOT@/ruy +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) + +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) + LOCAL_MODULE := nntrainer LOCAL_SRC_FILES := @MESON_NNTRAINER_SRCS@ # @todo ML_API_COMMON_ROOT should be included by exporting ml-api-common lib later diff --git a/jni/meson.build b/jni/meson.build index e552919be..450088a55 100644 --- a/jni/meson.build +++ b/jni/meson.build @@ -37,6 +37,10 @@ if iniparser_dep.found() and_conf.set('MESON_INIPARSER_ROOT', iniparser_root) endif +if ruy_dep.found() + and_conf.set('MESON_RUY_ROOT', ruy_root) +endif + if tflite_dep.found() and_conf.set('MESON_HAS_TFLITE', 1) and_conf.set('MESON_TFLITE_ROOT', tflite_root) diff --git a/meson.build b/meson.build index 0ec104d44..cf745f4e7 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,6 @@ project('nntrainer', 'c', 'cpp', 'cpp_std=c++17', 'buildtype=release' ], - subproject_dir: 'third_party' ) # Set version info @@ -370,7 +369,7 @@ endif thread_dep = dependency('threads') # pthread for tensorflow-lite if get_option('platform') == 'android' - iniparser_root = meson.source_root() / 'third_party' / 'iniparser' + iniparser_root = meson.source_root() / 'subprojects' / 'iniparser' iniparser_dep = declare_dependency() else iniparser_dep = dependency('iniparser', required : false, version : '>=3.2') # iniparser @@ -390,6 +389,30 @@ else endif endif +# Configure the Ruy project (CMake) +if get_option('platform') == 'android' + ruy_root = meson.source_root() / 'subprojects' / 'ruy' + ruy_dep = declare_dependency() +else + cmake = import('cmake') + + ruy_options = cmake.subproject_options() + ruy_options.add_cmake_defines({'RUY_MINIMAL_BUILD': true}) + ruy_flags = [ + '-Wno-error=unused-result', + '-Wno-error=comment', + '-Wno-error=maybe-uninitialized', + '-Wno-error=unknown-pragmas', + '-Wno-error=unused-function', + '-Wno-error=stringop-overread', + '-Wno-error=array-parameter' + ] + ruy_options.append_compile_args('c', ruy_flags) + ruy_options.append_compile_args('cpp', ruy_flags) + ruy_proj = cmake.subproject('ruy', options: ruy_options, required: true) + ruy_dep = ruy_proj.dependency('ruy').partial_dependency(includes: true) +endif + if get_option('platform') == 'android' message('preparing ml api') run_command(meson.source_root() / 'jni' / 'prepare_ml-api.sh', meson.build_root() / 'ml-api-inference', check: true) diff --git a/nntrainer/meson.build b/nntrainer/meson.build index b09cb9680..ea00b3829 100644 --- a/nntrainer/meson.build +++ b/nntrainer/meson.build @@ -30,6 +30,7 @@ else nntrainer_base_deps=[ blas_dep, iniparser_dep, + ruy_dep, ml_api_common_dep, libm_dep, libdl_dep, @@ -64,20 +65,13 @@ foreach elem : nntrainer_elements nntrainer_inc_abs += meson.current_source_dir() / elem endforeach -# add third party to include path -fs = import('fs') -if fs.is_dir('../third_party/ruy') - nntrainer_inc += include_directories('../third_party/ruy') - nntrainer_inc_abs += meson.source_root() / 'third_party' / 'ruy' -else - error('The git submodules of the nntrainer repository have not been checked out.\n Try: git submodule update --init') -endif - nntrainer_common_sources = [ 'nntrainer_logger.cpp', 'app_context.cpp' ] +nntrainer_inc_abs += meson.source_root() / 'subprojects' / 'ruy' + if get_option('enable-opencl') nntrainer_headers += meson.current_source_dir() / 'cl_context.h' nntrainer_headers += meson.current_source_dir() / 'cl_buffer_manager.h' diff --git a/packaging/nntrainer.spec b/packaging/nntrainer.spec index d6fb42f8a..29a949916 100644 --- a/packaging/nntrainer.spec +++ b/packaging/nntrainer.spec @@ -97,6 +97,7 @@ BuildRequires: gtest-devel BuildRequires: python3 BuildRequires: python3-numpy BuildRequires: flatbuffers-devel +BuildRequires: cmake %if 0%{?unit_test} BuildRequires: ssat >= 1.1.0 @@ -325,6 +326,10 @@ Requires: nnstreamer-nntrainer-trainer = %{version}-%{release} NNSteamer tensor trainer static package for nntrainer to support inference. %endif #nnstreamer_trainer +%package -n ruy +Summary: Ruy support in NNTrainer +%description -n ruy + %endif #tizen ## Define build options @@ -412,7 +417,7 @@ ln -sf %{_libdir}/pkgconfig/capi-nnstreamer.pc %{_libdir}/pkgconfig/capi-ml-comm %endif # Setup Ruy -tar -xf packaging/ruy.tar.gz -C third_party +tar -xf packaging/ruy.tar.gz -C subprojects mkdir -p build meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} \ @@ -425,7 +430,7 @@ meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} \ %{enable_reduce_tolerance} %{configure_subplugin_install_path} %{enable_debug} \ -Dml-api-support=enabled -Denable-nnstreamer-tensor-filter=enabled \ -Denable-nnstreamer-tensor-trainer=enabled -Denable-capi=enabled \ - %{fp16_support} %{neon_support} %{avx_support} build + %{fp16_support} %{neon_support} %{avx_support} build --wrap-mode=nodownload ninja -C build %{?_smp_mflags} @@ -690,6 +695,21 @@ cp -r result %{buildroot}%{_datadir}/nntrainer/unittest/ %{_libdir}/libnnstreamer_trainer_nntrainer.a %endif #nnstreamer_trainer +# Ruy +%files -n ruy +%manifest nntrainer.manifest +%defattr(-,root,root,-) +%license LICENSE +%{_libdir}/libruy*.a +%{_libdir}/libclog.a +%{_libdir}/libcpuinfo.a +%{_bindir}/cache_info +%{_bindir}/cpu_info +%{_bindir}/isa_info +%ifarch x86_64 +%{_bindir}/cpuid_dump +%endif #x86_64 + %endif #tizen %files applications diff --git a/packaging/ruy.tar.gz b/packaging/ruy.tar.gz index 1d284282f..9fdf9ebbf 100644 Binary files a/packaging/ruy.tar.gz and b/packaging/ruy.tar.gz differ diff --git a/subprojects/iniparser b/subprojects/iniparser new file mode 160000 index 000000000..4bef81128 --- /dev/null +++ b/subprojects/iniparser @@ -0,0 +1 @@ +Subproject commit 4bef811283e0ec1658c60e09950bd5a1ddc92e4b diff --git a/third_party/iniparser.wrap b/subprojects/iniparser.wrap similarity index 100% rename from third_party/iniparser.wrap rename to subprojects/iniparser.wrap diff --git a/third_party/ruy b/subprojects/ruy similarity index 100% rename from third_party/ruy rename to subprojects/ruy diff --git a/subprojects/ruy.wrap b/subprojects/ruy.wrap new file mode 100644 index 000000000..cced841f7 --- /dev/null +++ b/subprojects/ruy.wrap @@ -0,0 +1,4 @@ +[wrap-git] +url = https://github.com/google/ruy +directory = ruy +revision = HEAD diff --git a/test/jni/meson.build b/test/jni/meson.build index a052f4f0c..681776852 100644 --- a/test/jni/meson.build +++ b/test/jni/meson.build @@ -32,6 +32,10 @@ if iniparser_dep.found() and_conf.set('MESON_INIPARSER_ROOT', iniparser_root) endif +if ruy_dep.found() + and_conf.set('MESON_RUY_ROOT', ruy_root) +endif + if tflite_dep.found() and_conf.set('MESON_HAS_TFLITE', 1) and_conf.set('MESON_TFLITE_ROOT', tflite_root) diff --git a/third_party/iniparser b/third_party/iniparser deleted file mode 160000 index 19e0ad6c3..000000000 --- a/third_party/iniparser +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 19e0ad6c37440ba52313e10c6e148dfb9ab417f6