Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion c/include/nnstreamer-tizen-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ typedef struct {
int invoke_dynamic; /**< True for supporting invoke with flexible output. */
int invoke_async; /**< The sub-plugin must support asynchronous output to use this option. If set to TRUE, the sub-plugin can generate multiple outputs asynchronously per single input. Otherwise, only synchronous single-output is expected and async callback is ignored. */
ml_tensors_data_cb invoke_async_cb; /**< Callback function to be called when the sub-plugin generates an output asynchronously. This is only available when invoke_async is set to TRUE. */
void *invoke_async_pdata; /**< Private data to be passed to async callback. */
void *invoke_async_pdata; /**< Private data to be passed to async callback. */
int latency_mode; /**< 1 - log invoke latency, 0 (default) - do not log */
Copy link
Contributor

@songgot songgot Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of this?

/**< 1: Enable latency log, 0 (default): Disable log */

} ml_single_preset;

/**
Expand Down
11 changes: 10 additions & 1 deletion c/src/ml-api-inference-single.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ ml_single_open_custom (ml_single_h * single, ml_single_preset * info)

g_object_set (filter_obj, "framework", fw_name, "accelerator", hw_name,
"model", converted_models, "invoke-dynamic", single_h->invoke_dynamic,
"invoke-async", single_h->invoke_async, NULL);
"invoke-async", single_h->invoke_async, "latency", info->latency_mode, NULL);
g_free (hw_name);

if (info->custom_option) {
Expand Down Expand Up @@ -1318,6 +1318,15 @@ ml_single_open_with_option (ml_single_h * single, const ml_option_h option)
if (ML_ERROR_NONE == ml_option_get (option, "async_data", &value)) {
info.invoke_async_pdata = value;
}
if (ML_ERROR_NONE == ml_option_get (option, "profile", &value)) {
if (g_ascii_strcasecmp ((gchar *) value, "true") == 0) {
info.latency_mode = 1;
} else if (g_ascii_strtoll ((gchar *) value, NULL, 10) > 0) {
info.latency_mode = 1;
} else {
info.latency_mode = 0;
}
}

return ml_single_open_custom (single, &info);
}
Expand Down
16 changes: 16 additions & 0 deletions c/src/ml-api-service-extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,22 @@ _ml_extension_conf_parse_single (ml_service_s * mls, JsonObject * single)
_ml_extension_destroy_tensors_info);
}

/* parse latency profiling option - "profile": "true" or "1" */
if (json_object_has_member (single, "profile")) {
const gchar *profile = json_object_get_string_member (single, "profile");

if (STR_IS_VALID (profile))
ml_option_set (option, "profile", g_strdup (profile), g_free);
}

/* parse latency profiling option - "latency": "true" or "1" */
if (json_object_has_member (single, "latency")) {
const gchar *latency = json_object_get_string_member (single, "latency");

if (STR_IS_VALID (latency))
ml_option_set (option, "profile", g_strdup (latency), g_free);
}

if (json_object_has_member (single, "custom")) {
const gchar *custom = json_object_get_string_member (single, "custom");

Expand Down
3 changes: 2 additions & 1 deletion tests/test_models/config/config_single_imgclf_file.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"single" :
{
"model" : "../tests/test_models/models/mobilenet_v1_1.0_224_quant.tflite"
"model" : "../tests/test_models/models/mobilenet_v1_1.0_224_quant.tflite",
"profile" : "true"
}
}
3 changes: 2 additions & 1 deletion tests/test_models/config/config_single_imgclf_key.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"single" :
{
"key" : "test-single-imgclf"
"key" : "test-single-imgclf",
"latency" : "1"
},
"information" :
{
Expand Down