ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert_micro::core::OMRuntimeContext Class Reference

#include <OMRuntimeContext.h>

Public Member Functions

 OMRuntimeContext ()=default
 
 OMRuntimeContext (const OMRuntimeContext &)=delete
 
OMRuntimeContextoperator= (const OMRuntimeContext &)=delete
 
OMRuntimeContext && operator= (const OMRuntimeContext &&)=delete
 
 OMRuntimeContext (OMRuntimeContext &&)=default
 
 ~OMRuntimeContext ()=default
 
OMStatus setModel (const char *model_ptr, uint32_t graph_index)
 
OMStatus setWofFile (char *wof_ptr)
 
OMStatus setTrainConfigFile (char *train_config_file_ptr)
 
std::unordered_map< uint16_t, uint8_t > getTrainableOpsIndexes ()
 
bool isConstTensor (uint32_t tensor_index)
 
const reader::CircleValuesgetCircleOutputs ()
 
const reader::CircleValuesgetCircleInputs ()
 
const reader::CircleTensorsgetCircleTensors ()
 
const reader::CircleOperatorsgetCircleOperators ()
 
const reader::CircleOperatorCodesgetCircleOpcodes ()
 
const circle::Operator * getCircleOperatorAt (uint16_t index)
 
const circle::Tensor * getTensorByIndex (int32_t tensor_index)
 
uint32_t getGraphInputTensorIndex (uint32_t index)
 
uint32_t getGraphOutputTensorIndex (uint32_t index)
 
OMStatus getConstDataByTensorIndex (uint8_t **data, uint16_t tensor_index)
 

Detailed Description

Definition at line 36 of file OMRuntimeContext.h.

Constructor & Destructor Documentation

◆ OMRuntimeContext() [1/3]

onert_micro::core::OMRuntimeContext::OMRuntimeContext ( )
default

◆ OMRuntimeContext() [2/3]

onert_micro::core::OMRuntimeContext::OMRuntimeContext ( const OMRuntimeContext )
delete

◆ OMRuntimeContext() [3/3]

onert_micro::core::OMRuntimeContext::OMRuntimeContext ( OMRuntimeContext &&  )
default

◆ ~OMRuntimeContext()

onert_micro::core::OMRuntimeContext::~OMRuntimeContext ( )
default

Member Function Documentation

◆ getCircleInputs()

◆ getCircleOpcodes()

◆ getCircleOperatorAt()

const circle::Operator * OMRuntimeContext::getCircleOperatorAt ( uint16_t  index)

Definition at line 22 of file OMRuntimeContext.cpp.

23{
24 const auto *operators = _reader.operators();
25 assert(index < operators->size());
26 return operators->operator[](index);
27}
const CircleOperators * operators() const
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54
int32_t size[5]
Definition Slice.cpp:35

References onert_micro::core::reader::OMCircleReader::operators(), and size.

Referenced by onert_micro::import::OMDynamicShapesHandler::importDynamicShapesFromTrainConfig(), and onert_micro::execute::OMRuntimeKernel::readKernel().

◆ getCircleOperators()

◆ getCircleOutputs()

◆ getCircleTensors()

const reader::CircleTensors * onert_micro::core::OMRuntimeContext::getCircleTensors ( )
inline

Definition at line 94 of file OMRuntimeContext.h.

94{ return _reader.tensors(); }
const CircleTensors * tensors() const

References onert_micro::core::reader::OMCircleReader::tensors().

◆ getConstDataByTensorIndex()

OMStatus OMRuntimeContext::getConstDataByTensorIndex ( uint8_t **  data,
uint16_t  tensor_index 
)

Definition at line 53 of file OMRuntimeContext.cpp.

54{
55 auto *tensor = getTensorByIndex(tensor_index);
56
57 if (tensor == nullptr)
58 return UnknownError;
59
60 // To handle with separated weights:
61 // 1) first we try to get weigths from wof file (using wof_reader)
62 // 2) If it is not null -> return it
63 // 3) It it is null try to get it from main circle file
64 uint8_t *buffer_data = reinterpret_cast<uint8_t *>(_wof_reader.buffer(tensor_index));
65
66 if (buffer_data != nullptr)
67 {
68 *data = buffer_data;
69 return Ok;
70 }
71
72 auto const *buffer = _reader.buffers()->operator[](tensor->buffer())->data();
73
74 if (buffer == nullptr)
75 return Ok;
76
77 *data = const_cast<uint8_t *>(buffer->data());
78
79 return Ok;
80}
const circle::Tensor * getTensorByIndex(int32_t tensor_index)
const CircleBuffers * buffers() const

References onert_micro::core::reader::OMWeightOnlyFormatReader::buffer(), onert_micro::core::reader::OMCircleReader::buffers(), getTensorByIndex(), onert_micro::Ok, and onert_micro::UnknownError.

Referenced by onert_micro::execute::OMRuntimeKernel::getDataFromStorage(), onert_micro::train::optimizers::Adam::updateWeights(), and onert_micro::train::optimizers::SGD::updateWeights().

◆ getGraphInputTensorIndex()

uint32_t OMRuntimeContext::getGraphInputTensorIndex ( uint32_t  index)

◆ getGraphOutputTensorIndex()

uint32_t OMRuntimeContext::getGraphOutputTensorIndex ( uint32_t  index)

◆ getTensorByIndex()

◆ getTrainableOpsIndexes()

◆ isConstTensor()

◆ operator=() [1/2]

OMRuntimeContext && onert_micro::core::OMRuntimeContext::operator= ( const OMRuntimeContext &&  )
delete

◆ operator=() [2/2]

OMRuntimeContext & onert_micro::core::OMRuntimeContext::operator= ( const OMRuntimeContext )
delete

◆ setModel()

OMStatus onert_micro::core::OMRuntimeContext::setModel ( const char *  model_ptr,
uint32_t  graph_index 
)
inline

Definition at line 51 of file OMRuntimeContext.h.

52 {
53 OMStatus status;
54 status = _reader.parse(model_ptr);
55 if (status != Ok)
56 return status;
57 status = _reader.select_subgraph(graph_index);
58 if (status != Ok)
59 return status;
60 return Ok;
61 }
OMStatus parse(const char *model_ptr)
OMStatus select_subgraph(uint32_t subgraph)

References onert_micro::Ok, onert_micro::core::reader::OMCircleReader::parse(), and onert_micro::core::reader::OMCircleReader::select_subgraph().

Referenced by onert_micro::core::OMRuntimeModule::importModel(), and onert_micro::core::OMTrainingRuntimeModule::importTrainModel().

◆ setTrainConfigFile()

OMStatus onert_micro::core::OMRuntimeContext::setTrainConfigFile ( char *  train_config_file_ptr)
inline

Definition at line 74 of file OMRuntimeContext.h.

75 {
76 OMStatus status = Ok;
77 _train_config_reader.parse(train_config_file_ptr);
78
79 status = _train_config_reader.validate(&_reader);
80 if (status != Ok)
81 return status;
82 return Ok;
83 }

References onert_micro::Ok, onert_micro::core::reader::OMTrainingConfigReader::parse(), and onert_micro::core::reader::OMTrainingConfigReader::validate().

Referenced by onert_micro::core::OMRuntimeModule::importModel(), and onert_micro::core::OMTrainingRuntimeModule::importTrainModel().

◆ setWofFile()

OMStatus onert_micro::core::OMRuntimeContext::setWofFile ( char *  wof_ptr)
inline

The documentation for this class was generated from the following files: