[ml-service] Add nntrainer option accepted/tizen/unified/20240502.044621 accepted/tizen/unified/toolchain/20240507.011800 accepted/tizen/unified/x/20240503.091152
authorgichan2-jang <gichan2.jang@samsung.com>
Fri, 26 Apr 2024 04:43:52 +0000 (13:43 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 26 Apr 2024 05:16:04 +0000 (14:16 +0900)
Add nntrainer option to control dependency.
This temporarily solves the cyclic dependency problem when gcov is enabled.

Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
c/src/meson.build
c/src/ml-api-service-offloading.c
c/src/ml-api-service-training-offloading.h
meson.build
meson_options.txt
packaging/machine-learning-api.spec
tests/capi/meson.build

index 10cfd0b..09def28 100644 (file)
@@ -3,7 +3,10 @@ nns_capi_single_srcs = files('ml-api-inference-single.c')
 nns_capi_pipeline_srcs = files('ml-api-inference-pipeline.c')
 nns_capi_service_srcs = files('ml-api-service.c', 'ml-api-service-extension.c', 'ml-api-service-agent-client.c', 'ml-api-service-query-client.c')
 if support_service_offloading
-  nns_capi_service_srcs += files('ml-api-service-offloading.c', 'ml-api-service-training-offloading.c')
+  nns_capi_service_srcs += files('ml-api-service-offloading.c')
+  if support_training_offloading
+    nns_capi_service_srcs += files('ml-api-service-training-offloading.c')
+  endif
 endif
 
 if get_option('enable-tizen')
index 7dcc947..113e72f 100644 (file)
@@ -695,6 +695,7 @@ ml_service_offloading_set_information (ml_service_h handle, const gchar * name,
 {
   ml_service_s *mls = (ml_service_s *) handle;
   _ml_service_offloading_s *offloading_s;
+  int ret = ML_ERROR_NONE;
 
   if (!_ml_service_handle_is_valid (mls)) {
     _ml_error_report_return (ML_ERROR_INVALID_PARAMETER,
@@ -719,11 +720,11 @@ ml_service_offloading_set_information (ml_service_h handle, const gchar * name,
     offloading_s->path = g_strdup (value);
 
     if (offloading_s->offloading_mode == ML_SERVICE_OFFLOADING_MODE_TRAINING) {
-      ml_service_training_offloading_set_path (mls, offloading_s->path);
+      ret = ml_service_training_offloading_set_path (mls, offloading_s->path);
     }
   }
 
-  return ML_ERROR_NONE;
+  return ret;
 }
 
 /**
index 72b12b3..3b2eb86 100644 (file)
@@ -22,6 +22,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
+#if defined(ENABLE_TRAINING_OFFLOADING)
 /**
  * @brief Creates a training offloading handle for ml-service training offloading service.
  * @param[in] mls ml-service handle created by ml_service_new().
@@ -95,7 +96,14 @@ void ml_service_training_offloading_process_received_data (ml_service_s *mls, vo
  * @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
  */
 int ml_service_training_offloading_destroy (ml_service_s *mls);
-
+#else
+#define ml_service_training_offloading_create(...) ML_ERROR_NOT_SUPPORTED
+#define ml_service_training_offloading_set_path(...) ML_ERROR_NOT_SUPPORTED
+#define ml_service_training_offloading_start(...) ML_ERROR_NOT_SUPPORTED
+#define ml_service_training_offloading_stop(...) ML_ERROR_NOT_SUPPORTED
+#define ml_service_training_offloading_process_received_data(...)
+#define ml_service_training_offloading_destroy(...) ML_ERROR_NOT_SUPPORTED
+#endif /* ENABLE_TRAINING_OFFLOADING */
 #ifdef __cplusplus
 }
 #endif  /* __cplusplus */
index f9b6cf5..23c4e64 100644 (file)
@@ -43,6 +43,12 @@ if get_option('enable-ml-service')
   endif
 endif
 
+support_training_offloading = false
+if get_option('enable-nntrainer')
+  add_project_arguments('-DENABLE_TRAINING_OFFLOADING=1', language: ['c', 'cpp'])
+  support_training_offloading = true
+endif
+
 # Set version info
 api_version = meson.project_version()
 api_version_split = api_version.split('.')
index adbc528..2ee628d 100644 (file)
@@ -8,3 +8,4 @@ option('enable-tizen-privilege-check', type: 'boolean', value: false)
 option('enable-ml-service', type: 'boolean', value: false)
 option('java-home', type: 'string', value: '')
 option('enable-gcov', type: 'boolean', value: false, description: 'Generate gcov package')
+option('enable-nntrainer', type: 'boolean', value: false)
index a839968..64dcba5 100644 (file)
@@ -110,6 +110,7 @@ BuildRequires:      pkgconfig(capi-system-info)
 %define                unit_test 1
 %define                release_test 1
 %define                testcoverage 1
+%define                nntrainer_support 0
 %endif
 
 # For test
@@ -314,6 +315,7 @@ HTML pages of lcov results of ML API generated during rpm build
 %define enable_tizen_feature_check -Denable-tizen-feature-check=false
 %define enable_ml_service_check -Denable-ml-service=false
 %define enable_gcov -Denable-gcov=false
+%define enable_nntrainer -Denable-nntrainer=false
 
 %if %{with tizen}
 %define enable_tizen -Denable-tizen=true -Dtizen-version-major=0%{?tizen_version_major} -Dtizen-version-minor=0%{?tizen_version_minor}
@@ -335,6 +337,10 @@ HTML pages of lcov results of ML API generated during rpm build
 %define enable_gcov -Denable-gcov=true
 %endif
 
+%if 0%{?nntrainer_support}
+%define enable_nntrainer -Denable-nntrainer=true
+%endif
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -376,7 +382,7 @@ meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir
        --bindir=%{_bindir} --includedir=%{_includedir} \
        %{enable_test} %{install_test} %{enable_test_coverage} \
        %{enable_tizen} %{enable_tizen_privilege_check} %{enable_tizen_feature_check} \
-       %{enable_ml_service_check} %{enable_gcov} \
+       %{enable_ml_service_check} %{enable_gcov} %{enable_nntrainer} \
        build
 
 ninja -C build %{?_smp_mflags}
@@ -396,9 +402,11 @@ bash %{test_script} ./tests/capi/unittest_capi_service_extension
 bash %{test_script} ./tests/capi/unittest_capi_service_agent_client
 %if 0%{?nnstreamer_edge_support}
 bash %{test_script} ./tests/capi/unittest_capi_service_offloading
+%if 0%{?nntrainer_support}
 bash %{test_script} ./tests/capi/unittest_capi_service_training_offloading
 %endif
 %endif
+%endif
 
 %if 0%{?nnfw_support}
 bash %{test_script} ./tests/capi/unittest_capi_inference_nnfw_runtime
index 7775a0f..8fdb839 100644 (file)
@@ -66,13 +66,15 @@ if get_option('enable-ml-service')
     )
     test('unittest_capi_service_offloading', unittest_capi_service_offloading, env: testenv, timeout: 100)
 
-    unittest_capi_service_training_offloading = executable('unittest_capi_service_training_offloading',
-      'unittest_capi_service_training_offloading.cc',
-      dependencies: service_unittest_deps,
-      install: get_option('install-test'),
-      install_dir: unittest_install_dir
-    )
-    test('unittest_capi_service_training_offloading', unittest_capi_service_training_offloading, env: testenv, timeout: 100)
+    if support_training_offloading
+      unittest_capi_service_training_offloading = executable('unittest_capi_service_training_offloading',
+        'unittest_capi_service_training_offloading.cc',
+        dependencies: service_unittest_deps,
+        install: get_option('install-test'),
+        install_dir: unittest_install_dir
+      )
+      test('unittest_capi_service_training_offloading', unittest_capi_service_training_offloading, env: testenv, timeout: 100)
+    endif
   endif
 endif