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

#include <OMRuntimeGraph.h>

Public Member Functions

 OMRuntimeGraph ()=default
 
 OMRuntimeGraph (const OMRuntimeGraph &)=delete
 
 OMRuntimeGraph (OMRuntimeGraph &&)=default
 
OMRuntimeGraphoperator= (const OMRuntimeGraph &)=delete
 
OMRuntimeGraph && operator= (const OMRuntimeGraph &&)=delete
 
 ~OMRuntimeGraph ()
 
uint32_t getNumberOfInputs ()
 
uint32_t getNumberOfOutputs ()
 
uint32_t getInputSizeAt (uint32_t position)
 
uint32_t getOutputSizeAt (uint32_t position)
 
void * getInputDataAt (uint32_t position)
 
void * getOutputDataAt (uint32_t position)
 
size_t getInputDataTypeSize (uint32_t position)
 
size_t getOutputDataTypeSize (uint32_t position)
 
OMStatus allocateGraphInputs ()
 
OMStatus reset ()
 
OMRuntimeStoragegetRuntimeStorage ()
 
memory::OMRuntimeAllocatorgetRuntimeAllocator ()
 
OMRuntimeContextgetRuntimeContext ()
 

Detailed Description

Definition at line 33 of file OMRuntimeGraph.h.

Constructor & Destructor Documentation

◆ OMRuntimeGraph() [1/3]

onert_micro::core::OMRuntimeGraph::OMRuntimeGraph ( )
default

◆ OMRuntimeGraph() [2/3]

onert_micro::core::OMRuntimeGraph::OMRuntimeGraph ( const OMRuntimeGraph )
delete

◆ OMRuntimeGraph() [3/3]

onert_micro::core::OMRuntimeGraph::OMRuntimeGraph ( OMRuntimeGraph &&  )
default

◆ ~OMRuntimeGraph()

OMRuntimeGraph::~OMRuntimeGraph ( )

Definition at line 33 of file OMRuntimeGraph.cpp.

34{
35 reset();
36#ifdef OM_MEMORY_ESTIMATE
37 memory::OMMemoryManager::cur_memory_allocated = 0;
38 memory::OMMemoryManager::peak_memory_allocated = 0;
39#endif // OM_MEMORY_ESTIMATE
40}

References reset().

Member Function Documentation

◆ allocateGraphInputs()

OMStatus OMRuntimeGraph::allocateGraphInputs ( )

◆ getInputDataAt()

void * OMRuntimeGraph::getInputDataAt ( uint32_t  position)

Definition at line 42 of file OMRuntimeGraph.cpp.

43{
44 const auto input_index = _context.getGraphInputTensorIndex(position);
45
46 uint8_t *data;
47 _storage.getDataByTensorIndex(&data, input_index);
48
49 if (data == nullptr)
50 {
51 _allocator.allocateGraphInputs(&_context, &_storage);
52 _storage.getDataByTensorIndex(&data, input_index);
53 }
54
55 return reinterpret_cast<void *>(data);
56}
uint32_t getGraphInputTensorIndex(uint32_t index)
OMStatus getDataByTensorIndex(uint8_t **data, uint16_t tensor_index)

References onert_micro::core::memory::OMRuntimeAllocator::allocateGraphInputs(), onert_micro::core::OMRuntimeStorage::getDataByTensorIndex(), and onert_micro::core::OMRuntimeContext::getGraphInputTensorIndex().

Referenced by onert_micro::core::OMTrainingRuntimeModule::evaluateMetric(), and onert_micro::core::OMTrainingRuntimeModule::trainSingleStep().

◆ getInputDataTypeSize()

size_t OMRuntimeGraph::getInputDataTypeSize ( uint32_t  position)

Definition at line 81 of file OMRuntimeGraph.cpp.

82{
83 const auto input_index = _context.getGraphInputTensorIndex(position);
84 const circle::Tensor *input_tensor = _context.getTensorByIndex(static_cast<int32_t>(input_index));
85
86 auto type = input_tensor->type();
87 return sizeof(OMDataType(type));
88}
const circle::Tensor * getTensorByIndex(int32_t tensor_index)
type
Definition infer.py:18
OMDataType
"scalar" value type
Definition OMDataType.h:35

References onert_micro::core::OMRuntimeContext::getGraphInputTensorIndex(), and onert_micro::core::OMRuntimeContext::getTensorByIndex().

Referenced by onert_micro::core::OMTrainingRuntimeModule::evaluateMetric(), and onert_micro::core::OMTrainingRuntimeModule::trainSingleStep().

◆ getInputSizeAt()

uint32_t OMRuntimeGraph::getInputSizeAt ( uint32_t  position)

◆ getNumberOfInputs()

uint32_t OMRuntimeGraph::getNumberOfInputs ( )

Definition at line 118 of file OMRuntimeGraph.cpp.

119{
120 auto *inputs = _context.getCircleInputs();
121 if (inputs == nullptr)
122 return 0;
123
124 return inputs->size();
125}
const reader::CircleValues * getCircleInputs()

References onert_micro::core::OMRuntimeContext::getCircleInputs().

Referenced by onert_micro::core::OMTrainingRuntimeModule::evaluateMetric(), and onert_micro::core::OMTrainingRuntimeModule::trainSingleStep().

◆ getNumberOfOutputs()

uint32_t OMRuntimeGraph::getNumberOfOutputs ( )

Definition at line 109 of file OMRuntimeGraph.cpp.

110{
111 auto *outputs = _context.getCircleOutputs();
112 if (outputs == nullptr)
113 return 0;
114
115 return outputs->size();
116}
uoffset_t size() const
const reader::CircleValues * getCircleOutputs()

References onert_micro::core::OMRuntimeContext::getCircleOutputs(), and flatbuffers::Vector< T >::size().

◆ getOutputDataAt()

void * OMRuntimeGraph::getOutputDataAt ( uint32_t  position)

Definition at line 58 of file OMRuntimeGraph.cpp.

59{
60 const auto output_index = _context.getGraphOutputTensorIndex(position);
61
62 uint8_t *data;
63 _storage.getDataByTensorIndex(&data, output_index);
64 return reinterpret_cast<void *>(data);
65}
uint32_t getGraphOutputTensorIndex(uint32_t index)

References onert_micro::core::OMRuntimeStorage::getDataByTensorIndex(), and onert_micro::core::OMRuntimeContext::getGraphOutputTensorIndex().

◆ getOutputDataTypeSize()

size_t OMRuntimeGraph::getOutputDataTypeSize ( uint32_t  position)

Definition at line 90 of file OMRuntimeGraph.cpp.

91{
92 const auto output_index = _context.getGraphOutputTensorIndex(position);
93 const circle::Tensor *output_tensor =
94 _context.getTensorByIndex(static_cast<int32_t>(output_index));
95
96 auto type = output_tensor->type();
97 return sizeof(OMDataType(type));
98}

References onert_micro::core::OMRuntimeContext::getGraphOutputTensorIndex(), and onert_micro::core::OMRuntimeContext::getTensorByIndex().

◆ getOutputSizeAt()

uint32_t OMRuntimeGraph::getOutputSizeAt ( uint32_t  position)

Definition at line 72 of file OMRuntimeGraph.cpp.

73{
74 const auto output_index = _context.getGraphOutputTensorIndex(position);
75 const circle::Tensor *output_tensor = _context.getTensorByIndex(output_index);
76
77 OMRuntimeShape shape(output_tensor);
78 return shape.flatSize();
79}

References onert_micro::core::OMRuntimeShape::flatSize(), onert_micro::core::OMRuntimeContext::getGraphOutputTensorIndex(), and onert_micro::core::OMRuntimeContext::getTensorByIndex().

◆ getRuntimeAllocator()

memory::OMRuntimeAllocator & onert_micro::core::OMRuntimeGraph::getRuntimeAllocator ( )
inline

◆ getRuntimeContext()

OMRuntimeContext & onert_micro::core::OMRuntimeGraph::getRuntimeContext ( )
inline

◆ getRuntimeStorage()

OMRuntimeStorage & onert_micro::core::OMRuntimeGraph::getRuntimeStorage ( )
inline

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ reset()


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