Skip to content

Commit

Permalink
[ml-service] Add nntrainer option
Browse files Browse the repository at this point in the history
Add nntrainer option to control dependency.
This temporarily solves the cyclic dependency problem when gcov is enabled.

Signed-off-by: gichan2-jang <[email protected]>
  • Loading branch information
gichan-jang authored and jaeyun-jung committed Apr 26, 2024
1 parent 493439a commit 7b25555
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 12 deletions.
5 changes: 4 additions & 1 deletion c/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions c/src/ml-api-service-offloading.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion c/src/ml-api-service-training-offloading.h
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down Expand Up @@ -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 */
Expand Down
6 changes: 6 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 9 additions & 1 deletion packaging/machine-learning-api.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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} .
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions tests/capi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7b25555

Please sign in to comment.