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] Introduce fine tuning feature for training #12951

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

mbencer
Copy link
Contributor

@mbencer mbencer commented Apr 30, 2024

This PR adds fine tuning feature to onert. The new methods to nnfw API were added. onert_train tool was also extended to support this feature via --frozen_ops_idx argument.

TEST ENVIRONMENT:

The test methodology was described here and the results are collected in tests report

Issue: #12386

@mbencer mbencer changed the title [onert] Introduce fine tuning feature for traning [onert] Introduce fine tuning feature for training May 6, 2024
@@ -1695,7 +1742,7 @@ NNFW_STATUS nnfw_session::train_export_circle(const char *path)

auto subg = subgs->Get(0); // Get 1st subgraph
if (!idx.valid() || idx.value() >= subg->tensors()->size())
throw std::runtime_error("Trainable tensor index is out of range");
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just a workaround for a problem reproduced even on master to enable exporting trained circle to a file (used in my test scripts to compare weights before and after training).
My assumption is that the trained graph can have more tensors because of the tensors consumed by a Loos function, but not sure how it worked before.

BTW:

 auto model = ::circle::GetModel(mmapfile.buf());
      if (!model)
        throw std::runtime_error("Failed to get model from circle");
      auto subgs = model->subgraphs();
      if (!subgs || subgs->size() != 1)
        throw std::runtime_error("Circle does not has valid subgraph or has multiple subgraphs");

      auto subg = subgs->Get(0); // Get 1st subgraph

can be move outside iterateTrainableTensors but I'll try to deal with it in a separate PR.

}

const auto ir_op_index = onert::ir::OperationIndex{op_index};
auto &options = _coptions[0];
Copy link
Contributor

@jyoungyun jyoungyun May 8, 2024

Choose a reason for hiding this comment

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

How about using TrainingInfo instead of _coptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jyoungyun I like this idea, introduced ;)

@mbencer mbencer requested a review from jyoungyun May 8, 2024 11:10
This commits extend TrainableOperation API with methods to disable/enable weights update of some particular trainable operations.
In trainable operations is stored also status about contribution in backward propagation phase.

ONE-DCO-1.0-Signed-off-by: Mateusz Bencer <m.bencer@partner.samsung.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants