Skip to content

Commit

Permalink
add changes for runtime_context
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Balyshev committed Jun 17, 2024
1 parent de9be0b commit 6242800
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions onert-micro/onert-micro/include/core/OMRuntimeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "OMStatus.h"

#include "reader/OMCircleReader.h"
#include "reader/OMWeightOnlyFormatReader.h"

#include <cstdint>

Expand All @@ -32,6 +33,7 @@ class OMRuntimeContext
{
private:
reader::OMCircleReader _reader;
reader::OMWeightOnlyFormatReader _wof_reader;

public:
OMRuntimeContext() = default;
Expand All @@ -53,6 +55,17 @@ class OMRuntimeContext
return Ok;
}

OMStatus setWofFile(char *wof_ptr)
{
OMStatus status;
_wof_reader.parse(wof_ptr);

status = _wof_reader.validate(&_reader);
if (status != Ok)
return status;
return Ok;
}

const bool isConstTensor(uint32_t tensor_index) { return _reader.isConstTensor(tensor_index); }

const reader::CircleValues *getCircleOutputs() { return _reader.outputs(); }
Expand Down
12 changes: 12 additions & 0 deletions onert-micro/onert-micro/src/core/OMRuntimeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ OMStatus OMRuntimeContext::getConstDataByTensorIndex(uint8_t **data, uint16_t te
if (tensor == nullptr)
return UnknownError;

// To handle with separated weights:
// 1) first we try to get weigths from wof file (using wof_reader)
// 2) If it is not null -> return it
// 3) It it is null try to get it from main circle file
uint8_t *buffer_data = reinterpret_cast<uint8_t *>(_wof_reader.buffer(tensor_index));

if (buffer_data != nullptr)
{
*data = buffer_data;
return Ok;
}

auto const *buffer = _reader.buffers()->operator[](tensor->buffer())->data();

if (buffer == nullptr)
Expand Down

0 comments on commit 6242800

Please sign in to comment.