Skip to content

Commit 8c030c9

Browse files
authored
[onert] Add API function for retrieving last error message (#16282)
This commit adds dedicated API function nnfw_get_last_error_message() for retrieving last error message in case when other functions return status code other than NNFW_STATUS_NO_ERROR. ONE-DCO-1.0-Signed-off-by: Arkadiusz Bokowy <a.bokowy@samsung.com>
1 parent 94f963b commit 8c030c9

File tree

6 files changed

+436
-277
lines changed

6 files changed

+436
-277
lines changed

runtime/onert/api/nnfw/include/nnfw.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ NNFW_STATUS nnfw_create_session(nnfw_session **session);
212212
*/
213213
NNFW_STATUS nnfw_close_session(nnfw_session *session);
214214

215+
/**
216+
* @brief Get the last error message
217+
*
218+
* This function retrieves the last error message occurred in the session.
219+
*
220+
* @param[in] session The session to get the last error message from
221+
* @param[out] buffer Buffer to store the last error message string
222+
* @param[in] length The size of the buffer
223+
* @return @c NNFW_STATUS_NO_ERROR if successful, otherwise appropriate
224+
* error code and the content of buffer is not changed.
225+
*/
226+
NNFW_STATUS nnfw_get_last_error_message(nnfw_session *session, char *buffer, size_t length);
227+
215228
/**
216229
* @brief Load model from path to model or nnpackage
217230
*

runtime/onert/api/nnfw/src/APIImpl.cc

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ NNFW_STATUS nnfw_close_session(nnfw_session *session)
6969
return NNFW_STATUS_NO_ERROR;
7070
}
7171

72+
NNFW_STATUS nnfw_get_last_error_message(nnfw_session *session, char *buffer, size_t length)
73+
{
74+
NNFW_RETURN_ERROR_IF_NULL(session);
75+
return reinterpret_cast<Session *>(session)->get_last_error_message(buffer, length);
76+
}
77+
7278
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *path)
7379
{
7480
NNFW_RETURN_ERROR_IF_NULL(session);
@@ -170,9 +176,10 @@ NNFW_STATUS nnfw_register_custom_op_info(nnfw_session *session, const char *id,
170176
return reinterpret_cast<Session *>(session)->register_custom_operation(id, info->eval_function);
171177
}
172178

173-
NNFW_STATUS nnfw_apply_tensorinfo(nnfw_session *, uint32_t, nnfw_tensorinfo)
179+
NNFW_STATUS nnfw_apply_tensorinfo(nnfw_session *session, uint32_t, nnfw_tensorinfo)
174180
{
175-
return Session::deprecated("nnfw_apply_tensorinfo: Deprecated");
181+
NNFW_RETURN_ERROR_IF_NULL(session);
182+
return reinterpret_cast<Session *>(session)->deprecated("nnfw_apply_tensorinfo: Deprecated");
176183
}
177184

178185
NNFW_STATUS nnfw_set_input_tensorinfo(nnfw_session *session, uint32_t index,
@@ -188,9 +195,10 @@ NNFW_STATUS nnfw_set_available_backends(nnfw_session *session, const char *backe
188195
return reinterpret_cast<Session *>(session)->set_available_backends(backends);
189196
}
190197

191-
NNFW_STATUS nnfw_set_op_backend(nnfw_session *, const char *, const char *)
198+
NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, const char *, const char *)
192199
{
193-
return Session::deprecated("nnfw_set_op_backend: Deprecated");
200+
NNFW_RETURN_ERROR_IF_NULL(session);
201+
return reinterpret_cast<Session *>(session)->deprecated("nnfw_set_op_backend: Deprecated");
194202
}
195203

196204
NNFW_STATUS nnfw_query_info_u32(nnfw_session *session, NNFW_INFO_ID id, uint32_t *val)
@@ -230,19 +238,22 @@ NNFW_STATUS nnfw_set_backends_per_operation(nnfw_session *session, const char *b
230238
return reinterpret_cast<Session *>(session)->set_backends_per_operation(backend_settings);
231239
}
232240

233-
NNFW_STATUS nnfw_prepare_pipeline(nnfw_session *, const char *)
241+
NNFW_STATUS nnfw_prepare_pipeline(nnfw_session *session, const char *)
234242
{
235-
return Session::deprecated("nnfw_prepare_pipeline: Deprecated");
243+
NNFW_RETURN_ERROR_IF_NULL(session);
244+
return reinterpret_cast<Session *>(session)->deprecated("nnfw_prepare_pipeline: Deprecated");
236245
}
237246

238-
NNFW_STATUS nnfw_push_pipeline_input(nnfw_session *, void *, void *)
247+
NNFW_STATUS nnfw_push_pipeline_input(nnfw_session *session, void *, void *)
239248
{
240-
return Session::deprecated("nnfw_push_pipeline_input: Deprecated");
249+
NNFW_RETURN_ERROR_IF_NULL(session);
250+
return reinterpret_cast<Session *>(session)->deprecated("nnfw_push_pipeline_input: Deprecated");
241251
}
242252

243-
NNFW_STATUS nnfw_pop_pipeline_output(nnfw_session *, void *)
253+
NNFW_STATUS nnfw_pop_pipeline_output(nnfw_session *session, void *)
244254
{
245-
return Session::deprecated("nnfw_pop_pipeline_output: Deprecated");
255+
NNFW_RETURN_ERROR_IF_NULL(session);
256+
return reinterpret_cast<Session *>(session)->deprecated("nnfw_pop_pipeline_output: Deprecated");
246257
}
247258

248259
NNFW_STATUS nnfw_set_workspace(nnfw_session *session, const char *dir)

0 commit comments

Comments
 (0)