Skip to content

Commit

Permalink
[ml-service] code clean - error handling, parse tensor data
Browse files Browse the repository at this point in the history
 - Remove unnecessary error handling
 - Handle error case
 - Parse tensor data more than 1

Signed-off-by: gichan2-jang <[email protected]>
  • Loading branch information
gichan-jang authored and jaeyun-jung committed Apr 4, 2024
1 parent 33440e3 commit 5062d48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
22 changes: 12 additions & 10 deletions c/src/ml-api-service-offloading.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ _mlrs_process_service_offloading (nns_edge_data_h data_h, void *user_data)

done:
if (info_h) {
ret = ml_information_destroy (info_h);
_ml_error_report ("Failed to destroy service info handle.");
ml_information_destroy (info_h);
}

return ret;
Expand Down Expand Up @@ -667,8 +666,8 @@ ml_service_offloading_create (ml_service_h handle, ml_option_h option)
offloading_s->table =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
if (!offloading_s->table) {
_ml_error_report
("Failed to allocate memory for the table of ml-service offloading. Out of memory?");
_ml_error_report_return (ML_ERROR_OUT_OF_MEMORY,
"Failed to allocate memory for the table of ml-service offloading. Out of memory?");
}

if (ML_ERROR_NONE == ml_option_get (option, "path", (void **) (&_path))) {
Expand Down Expand Up @@ -707,6 +706,7 @@ ml_service_offloading_request (ml_service_h handle, const char *key,
ml_tensors_data_s *_in = NULL;
JsonNode *service_node;
JsonObject *service_obj;
guint i;

check_feature_state (ML_FEATURE_SERVICE);

Expand Down Expand Up @@ -797,12 +797,14 @@ ml_service_offloading_request (ml_service_h handle, const char *key,
}
}
_in = (ml_tensors_data_s *) input;
ret =
nns_edge_data_add (data_h, _in->tensors[0].data, _in->tensors[0].size,
NULL);
if (NNS_EDGE_ERROR_NONE != ret) {
_ml_error_report ("Failed to add camera data to the edge data.");
goto done;
for (i = 0; i < _in->num_tensors; i++) {
ret =
nns_edge_data_add (data_h, _in->tensors[i].data, _in->tensors[i].size,
NULL);
if (NNS_EDGE_ERROR_NONE != ret) {
_ml_error_report ("Failed to add camera data to the edge data.");
goto done;
}
}

ret = nns_edge_send (offloading_s->edge_h, data_h);
Expand Down
3 changes: 0 additions & 3 deletions c/src/ml-api-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,6 @@ _ml_service_get_type (JsonObject * object)
type = ML_SERVICE_TYPE_EXTENSION;
} else if (json_object_has_member (object, "offloading")) {
type = ML_SERVICE_TYPE_OFFLOADING;
} else {
_ml_error_report
("Failed to parse configuration file, cannot get the valid type from configuration.");
}

return type;
Expand Down

0 comments on commit 5062d48

Please sign in to comment.