Samsung / ONE

On-device Neural Engine
Other
428 stars 152 forks source link

[onert] Support Checkpoint API #13670

Open jyoungyun opened 1 month ago

jyoungyun commented 1 month ago

What

Let's support Checkpoint API

Why

To save and retrieve intermediate steps in training, this issue implements Checkpoint API and related functions.

Details

API

/**
 * @brief Import circle checkpoint
 * @note  This function should be called on training mode
 *        This function should be called before {@link nnfw_train}
 *
 * @param[in] session The session to export a checkpoint
 * @param[in] path    The path to export a checkpoint
 * @return @c NNFW_STATUS_NO_ERROR if successful
 */
NNFW_STATUS nnfw_train_import_checkpoint(nnfw_session *session, const char *path);

/**
 * @brief Export circle checkpoint
 * @note  This function should be called on training mode
 *        This function should be called after {@link nnfw_train}
 *
 * @param[in] session The session to export a checkpoint
 * @param[in] path    The path to export a checkpoint
 * @return @c NNFW_STATUS_NO_ERROR if successful
 */
NNFW_STATUS nnfw_train_export_checkpoint(nnfw_session *session, const char *path);

These APIs are compatible with onert-micro APIs.

Checkpoint File Spec

Draft: #13561

jyoungyun commented 1 month ago

Checkpoint File Spec

ragmani commented 3 weeks ago

I'm sorry. There is something I missed related to optimizer. Optimizers have properties that should be written in circle checkpoint. Moreover, the space for properties to be written should be flexible because the kinds of properties may vary depending on the optimizer type. You can see properties for SGD, Adam in #11698

jyoungyun commented 3 weeks ago

@ragmani

Moreover, the space for properties to be written should be flexible because the kinds of properties may vary depending on the optimizer type. You can see properties for SGD, Adam in #11698

I think these properites can be saved to the circle+ file. Is there any change data that we need to save?

ragmani commented 3 weeks ago

I think these properites can be saved to the circle+ file. Is there any change data that we need to save?

As we talked offline, there seems to be no need to change data for properties.