Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert] Support model file loading from model path #14473

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

hseok-oh
Copy link
Contributor

@hseok-oh hseok-oh commented Dec 18, 2024

This commit updates API to support model file loading from model path.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh [email protected]


Related issue: #14466

@hseok-oh hseok-oh added the PR/ready for review It is ready to review. Please review it. label Dec 18, 2024
@hseok-oh hseok-oh requested review from zetwhite and a team December 18, 2024 04:28
@hseok-oh hseok-oh force-pushed the expand_load_api branch 2 times, most recently from 5c60451 to e6e226d Compare December 18, 2024 04:32
This commit updates API to support model file loading from model path.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
zetwhite
zetwhite previously approved these changes Dec 18, 2024
Copy link
Contributor

@zetwhite zetwhite left a comment

Choose a reason for hiding this comment

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

LGTM!

@zetwhite zetwhite requested a review from a team December 18, 2024 04:45
ragmani
ragmani previously approved these changes Dec 18, 2024
Copy link
Contributor

@ragmani ragmani left a comment

Choose a reason for hiding this comment

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

LGTM

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
@hseok-oh hseok-oh dismissed stale reviews from ragmani and zetwhite via 57b22ee December 18, 2024 06:55
@hseok-oh hseok-oh requested review from zetwhite and ragmani December 18, 2024 07:11
Copy link
Contributor

@seockho-kim seockho-kim left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -48,7 +48,7 @@ NNFW_STATUS nnfw_load_circle_from_buffer(nnfw_session *session, uint8_t *buffer,
NNFW_STATUS nnfw_load_model_from_modelfile(nnfw_session *session, const char *file_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason to maintain the name(nnfw_load_model_from_modelfile)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

onert_run and other test drivers are using this API. It will be removed after migration.

*
* @return @c NNFW_STATUS_NO_ERROR if successful
*/
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *package_file_path);
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *file_path);
Copy link
Contributor

@glistening glistening Dec 18, 2024

Choose a reason for hiding this comment

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

It seems to nnfw_load_model_from_file is going to be used for both nnpkg (= directory) and model (= file), and nnfw_load_model_from_file will be retired. Is it right?

Then, here is my understanding:

As I guess, someone choose this name to distinguish from_memory — flatbuffers-based model created in the memory for test.

Also, I guess file here means not only regular file, but also directory. It may be thought as load_from_filesystem.

Later, if we support archived nnpkg (in zip), we can distinguish nnpkg.zip and a single model by extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I guess, someone choose this name to distinguish from_memory — flatbuffers-based model created in the memory for test.

Exactly! 👍

@@ -213,16 +213,16 @@ NNFW_STATUS nnfw_create_session(nnfw_session **session);
NNFW_STATUS nnfw_close_session(nnfw_session *session);

/**
* @brief Load model from nnpackage file or directory
* @brief Load model from model file or nnpackage directory
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @brief Load model from model file or nnpackage directory
* @brief Load model from path to model or nnpackage

*
* The length of \p package_file_path must not exceed 1024 bytes including zero at the end.
* The length of \p file_path must not exceed 1024 bytes including zero at the end.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The length of \p file_path must not exceed 1024 bytes including zero at the end.
* The length of \p path must not exceed 1024 bytes including zero at the end.

Comment on lines +220 to +221
* @param[in] session nnfw_session loading the given file/dir
* @param[in] file_path Path to the model file or nnpackage directory to be loaded
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param[in] session nnfw_session loading the given file/dir
* @param[in] file_path Path to the model file or nnpackage directory to be loaded
* @param[in] session nnfw_session loading the given file/dir
* @param[in] path path to the model file or nnpackage directory to be loaded

*
* @return @c NNFW_STATUS_NO_ERROR if successful
*/
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *package_file_path);
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *file_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *file_path);
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *path);

Comment on lines +81 to +82
* @param session nnfw_session loading the given file/dir
* @param file_path path to the model file or nnpackage directory to be loaded
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param session nnfw_session loading the given file/dir
* @param file_path path to the model file or nnpackage directory to be loaded
* @param session nnfw_session loading the given file/dir
* @param path path to the model or nnpackage to be loaded

{
NNFW_RETURN_ERROR_IF_NULL(session);
return session->load_model_from_nnpackage(pacakge_file_path);
return session->load_model_from_path(file_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... it is path from here.

@glistening
Copy link
Contributor

I am not opposing this change. My comment is for recording, and optional. I will merge after a few hours.

@glistening glistening merged commit 93d5860 into Samsung:master Dec 19, 2024
9 checks passed
@hseok-oh hseok-oh deleted the expand_load_api branch December 19, 2024 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR/ready for review It is ready to review. Please review it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants