Skip to content

Commit

Permalink
[onert/train] Apply inline variable to the metadata name (#14641)
Browse files Browse the repository at this point in the history
This commit applies inline variable to the metadata name.

ONE-DCO-1.0-Signed-off-by: ragmani <[email protected]>
  • Loading branch information
ragmani authored Feb 12, 2025
1 parent 5677089 commit 54d7f1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions runtime/onert/core/include/loader/TrainInfoLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace onert
namespace loader
{

// TODO change this line to use inline variable after C++17
extern const char *const TRAININFO_METADATA_NAME;
inline const char *const TRAININFO_METADATA_NAME = "CIRCLE_TRAINING";

std::unique_ptr<ir::train::TrainingInfo> loadTrainingInfo(const uint8_t *buffer, const size_t size);

Expand Down
7 changes: 3 additions & 4 deletions runtime/onert/core/src/exporter/CircleExporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "exec/Execution.h"
#include "ir/train/TrainingInfo.h"
#include "loader/TrainInfoLoader.h"
#include "circle_schema_generated.h"
#include "TrainInfoBuilder.h"

Expand Down Expand Up @@ -98,13 +99,11 @@ void CircleExporter::updateWeight(const std::unique_ptr<exec::Execution> &exec)

void CircleExporter::updateMetadata(const std::unique_ptr<ir::train::TrainingInfo> &training_info)
{
const char *const TRAININFO_METADATA_NAME = "CIRCLE_TRAINING";

TrainInfoBuilder tbuilder(training_info);
bool found = false;
for (const auto &meta : _model->metadata)
{
if (meta->name == std::string{TRAININFO_METADATA_NAME})
if (meta->name == std::string{loader::TRAININFO_METADATA_NAME})
{
std::lock_guard<std::mutex> guard(_mutex);
const uint32_t buf_idx = meta->buffer;
Expand All @@ -131,7 +130,7 @@ void CircleExporter::updateMetadata(const std::unique_ptr<ir::train::TrainingInf
memcpy(buffer->data.data(), tbuilder.get(), buffer->size);

auto meta = std::make_unique<::circle::MetadataT>();
meta->name = std::string{TRAININFO_METADATA_NAME};
meta->name = std::string{loader::TRAININFO_METADATA_NAME};
meta->buffer = _model->buffers.size();

_model->buffers.push_back(std::move(buffer));
Expand Down
2 changes: 0 additions & 2 deletions runtime/onert/core/src/loader/TrainInfoLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace onert
namespace loader
{

const char *const TRAININFO_METADATA_NAME = "CIRCLE_TRAINING";

namespace
{

Expand Down

0 comments on commit 54d7f1e

Please sign in to comment.