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/api] Add nnfw_train_set_traininfo() #12384

Merged
merged 4 commits into from
Dec 29, 2023

Conversation

zetwhite
Copy link
Contributor

@zetwhite zetwhite commented Dec 28, 2023

This PR adds nnfw_train_set_traininfo() API into nnfw_experimental header.
The nnfw_train_set_traininfo() API is to set train_info in the session.

ONE-DCO-1.0-Signed-off-by: SeungHui Youn sseung.youn@samsung.com

related issue : #11692

@@ -220,6 +220,15 @@ typedef struct nnfw_train_info
NNFW_TRAIN_OPTIMIZER opt = NNFW_TRAIN_OPTIMIZER_SGD;
} nnfw_train_info;

Copy link
Contributor Author

@zetwhite zetwhite Dec 28, 2023

Choose a reason for hiding this comment

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

For reviewers

This PR just adds one new API (_train_info setter - named nnfw_train_set_traininfo).
But I also have a plan to change nnfw_train_prepare a bit.
The overall direction is like this.

AS-IS

  • nnfw_train_prepare() gets train_info and compiles training model using the given train_info

TO-BE

  • nnfw_set_train_traininfo() set train_info into session
  • nnfw_train_prepare() compile training model using the train_info inside the session

@zetwhite zetwhite added PR/ready for review It is ready to review. Please review it. approval: 2 Require at least 2 approvals labels Dec 28, 2023
@zetwhite zetwhite requested a review from a team December 28, 2023 07:02
@@ -220,6 +220,15 @@ typedef struct nnfw_train_info
NNFW_TRAIN_OPTIMIZER opt = NNFW_TRAIN_OPTIMIZER_SGD;
} nnfw_train_info;

/**
* @brief Set train_info into session
* @note This function should be called in MODEL_LOADED state,
Copy link
Contributor

Choose a reason for hiding this comment

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

User cannot see MODEL_LOADED state, how about removing the content related to MODEL_LOADED?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated :)

*
* @return @c NNFW_STATUS_NO_ERROR If successful
*/
NNFW_STATUS nnfw_train_set_traininfo(nnfw_session *session, const nnfw_train_info *train_info);
Copy link
Contributor Author

@zetwhite zetwhite Dec 28, 2023

Choose a reason for hiding this comment

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

This API should be called after model_loaded.

Because.. If the user set train_info before the model loaded,
train_info in the session can be overwritten while the model loaded.
This can be confusing.

So, To avoid unexpected overwritten while the model loaded, Let's make sure that nnfw_train_set_traininfo is called after the model loaded.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove 'into session" in description as I suggested. I think "into session" is better to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated :)

@zetwhite zetwhite requested a review from a team December 28, 2023 08:12
@@ -220,6 +220,15 @@ typedef struct nnfw_train_info
NNFW_TRAIN_OPTIMIZER opt = NNFW_TRAIN_OPTIMIZER_SGD;
} nnfw_train_info;

/**
* @brief Set train_info into session
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use variable name for description for user.

Suggested change
* @brief Set train_info into session
* @brief Set training info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Updated :)

runtime/onert/api/src/nnfw_api_internal.cc Outdated Show resolved Hide resolved

auto convertLossReductionType = [](const int &type) {
if (type == NNFW_TRAIN_LOSS_REDUCTION_AUTO)
return onert::ir::train::LossReductionType::Invalid;
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
return onert::ir::train::LossReductionType::Invalid;
return onert::ir::train::LossReductionType::Auto;

Maybe it should be Auto type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for catching :)
Updated

This PR addis nnfw_train_set_traininfo() API into nnfw_experimental header.
The 'nnfw_train_set_traininfo()' API is to set train_info in the session.

ONE-DCO-1.0-Signed-off-by: SeungHui Youn sseung.youn@samsung.com
jyoungyun
jyoungyun previously approved these changes Dec 28, 2023
Copy link
Contributor

@jyoungyun jyoungyun left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you!

ragmani
ragmani previously approved these changes Dec 28, 2023
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

@zetwhite zetwhite dismissed stale reviews from ragmani and jyoungyun via 2da9760 December 29, 2023 00:58
Copy link
Contributor

@glistening glistening left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jyoungyun jyoungyun left a comment

Choose a reason for hiding this comment

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

LGTM :)

@glistening glistening merged commit 64b87a6 into Samsung:master Dec 29, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: 2 Require at least 2 approvals 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.

4 participants