-
Notifications
You must be signed in to change notification settings - Fork 82
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
[ Init ] Verify optimizer during initialization according to execution mode. #2853
Conversation
…tion mode. - Updates the testing scope of optimization configuration from train() to initialize() - Adds conditions to verify optimization settings and modifies several unit tests running under ExecutionMode::TRAIN without prior optimization setup. Signed-off-by: Eunju Yang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Work!! LGTM!
|
||
if (!opt) { | ||
ml_loge("Optimizer should be set before initialization for training."); | ||
return ML_ERROR_INVALID_PARAMETER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't ML_ERROR_TRY_AGAIN better than ML_ERROR_INVALID_PARAMETER?
nntrainer/nntrainer/nntrainer_error.h
Lines 54 to 65 in db0ed5d
typedef enum { | |
ML_ERROR_NONE = 0, /**< Success! */ | |
ML_ERROR_INVALID_PARAMETER = -EINVAL, /**< Invalid parameter */ | |
ML_ERROR_TRY_AGAIN = | |
-EAGAIN, /**< The pipeline is not ready, yet (not negotiated, yet) */ | |
ML_ERROR_UNKNOWN = _ERROR_UNKNOWN, /**< Unknown error */ | |
ML_ERROR_TIMED_OUT = (_ERROR_UNKNOWN + 1), /**< Time out */ | |
ML_ERROR_NOT_SUPPORTED = | |
(_ERROR_UNKNOWN + 2), /**< The feature is not supported */ | |
ML_ERROR_PERMISSION_DENIED = -EACCES, /**< Permission denied */ | |
ML_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of memory (Since 6.0) */ | |
} ml_error_e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comment. I found that ML_ERROR_TRY_AGAIN
indicates a runtime error, which does not fit the case for this optimizer setup. While I agree that the ML_ERROR_INVALID_PARAMETER
may not perfectly fit for this specific error message, the error code was set based on our previous optimizer validation setup. FYI, I have attached the snippet below:
nntrainer/nntrainer/models/neuralnet.cpp
Lines 1023 to 1026 in db0ed5d
if (!opt) { | |
ml_loge("Cannot train network without optimizer."); | |
return ML_ERROR_INVALID_PARAMETER; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Abstract
Currently, our code requires an optimizer setup even when developers intend to execute the network using INFERENCE mode. To address this issue, the PR've updated the
initialize
method to validate the presence of an appropriate optimizer based on the specified execution mode.nntrainer/nntrainer/models/neuralnet.cpp
Lines 266 to 267 in 24a868d
Additionally, earlier unit tests did not account for varying execution modes, leading to gaps in checking optimizer configurations. Consequently, this PR includes modifications to ensure comprehensive coverage through updated unit test cases.
Self evaluation:
Build test: [x]Passed [ ]Failed [ ]Skipped
Run test: [x]Passed [ ]Failed [ ]Skipped