ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::CircleReader Class Reference

Loads Circle file and provides helpers to access attributes. More...

#include <CircleReader.h>

Public Member Functions

 CircleReader ()=default
 
CircleOperatorCodes opcodes () const
 
CircleBuffers buffers () const
 
CircleTensors tensors () const
 
CircleOperators operators () const
 
VectorWrapper< int32_t > inputs () const
 
VectorWrapper< int32_t > outputs () const
 
std::string name () const
 
CircleMetadataSet metadata () const
 
uint32_t num_subgraph () const
 
circle::BuiltinOperator builtin_code (const circle::Operator *op) const
 
std::string opcode_name (const circle::Operator *op) const
 
bool parse (const circle::Model *model)
 
bool parse (const circle::Model *model, const uint8_t *data, const size_t size)
 
bool select_subgraph (uint32_t subgraph)
 
const uint8_t * file_data (uint64_t offset) const
 
size_t file_size (void) const
 

Detailed Description

Loads Circle file and provides helpers to access attributes.

Definition at line 90 of file CircleReader.h.

Constructor & Destructor Documentation

◆ CircleReader()

luci::CircleReader::CircleReader ( )
default

Member Function Documentation

◆ buffers()

CircleBuffers luci::CircleReader::buffers ( ) const
inline

Definition at line 104 of file CircleReader.h.

104{ return wrap(_model->buffers()); }
VectorWrapper< T > wrap(const flatbuffers::Vector< T > *vec)

References luci::wrap().

Referenced by luci::CircleImportMetadata::CircleImportMetadata(), luci_interpreter::RuntimeGraph::getConstDataByTensor(), and luci_interpreter::Tensor::is_constant_tensor().

◆ builtin_code()

circle::BuiltinOperator luci_interpreter::CircleReader::builtin_code ( const circle::Operator *  op) const

Definition at line 316 of file CircleReader.cpp.

317{
318 assert(op != nullptr);
319
320 const auto op_codes = opcodes();
321 uint32_t index = op->opcode_index();
322 assert(index < op_codes.size());
323 const auto opcode = op_codes[index];
324 assert(opcode != nullptr);
325
327}
CircleOperatorCodes opcodes() const
::circle::BuiltinOperator builtin_code_neutral(const ::circle::OperatorCode *opcode)
Definition Helper.cpp:33
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References mio::circle::builtin_code_neutral(), and opcodes().

Referenced by luci_interpreter::GraphLoader::checkInplaceOps(), luci_interpreter::RuntimeGraph::configure(), luci_interpreter::RuntimeGraph::execute(), and run().

◆ file_data()

const uint8_t * luci::CircleReader::file_data ( uint64_t  offset) const

Definition at line 386 of file CircleReader.cpp.

387{
388 assert(_file_data);
389 assert(offset < _file_size);
390 return (_file_data == nullptr) ? nullptr : _file_data + offset;
391}
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540

References offset().

◆ file_size()

size_t luci::CircleReader::file_size ( void  ) const
inline

Definition at line 125 of file CircleReader.h.

125{ return _file_size; }

◆ inputs()

◆ metadata()

CircleMetadataSet luci::CircleReader::metadata ( ) const
inline

Definition at line 110 of file CircleReader.h.

110{ return wrap(_model->metadata()); }

References luci::wrap().

Referenced by luci::CircleImportMetadata::CircleImportMetadata().

◆ name()

std::string luci::CircleReader::name ( ) const
inline

Definition at line 109 of file CircleReader.h.

109{ return fb_string2std_string(_current_subgraph->name()); }
std::string fb_string2std_string(const flatbuffers::String *fb_str)

References luci::fb_string2std_string().

◆ num_subgraph()

uint32_t luci::CircleReader::num_subgraph ( ) const
inline

Definition at line 112 of file CircleReader.h.

112{ return wrap(_model->subgraphs()).size(); }

References luci::wrap().

Referenced by luci_interpreter::ModuleLoader::load(), run(), and select_subgraph().

◆ opcode_name()

std::string luci::CircleReader::opcode_name ( const circle::Operator *  op) const

Definition at line 329 of file CircleReader.cpp.

330{
331 assert(op != nullptr);
332
333 const auto op_codes = opcodes();
334 uint32_t index = op->opcode_index();
335 assert(index < op_codes.size());
336 const auto opcode = op_codes[index];
337
338 return mio::circle::opcode_name(opcode);
339}
std::string opcode_name(const ::circle::OperatorCode *opcode)
Definition Helper.cpp:38

References mio::circle::opcode_name(), and opcodes().

◆ opcodes()

CircleOperatorCodes luci::CircleReader::opcodes ( ) const
inline

Definition at line 103 of file CircleReader.h.

103{ return wrap(_model->operator_codes()); }

References luci::wrap().

Referenced by luci::GraphBuilder::build(), luci::GraphBuilderMultiOutput::build(), luci::CircleWhileGraphBuilder::build(), builtin_code(), and opcode_name().

◆ operators()

CircleOperators luci::CircleReader::operators ( ) const
inline

Definition at line 106 of file CircleReader.h.

106{ return wrap(_current_subgraph->operators()); }

References luci::wrap().

Referenced by luci_interpreter::GraphLoader::checkInplaceOps(), luci_interpreter::RuntimeGraph::configure(), luci_interpreter::RuntimeGraph::execute(), and run().

◆ outputs()

◆ parse() [1/2]

bool luci_interpreter::CircleReader::parse ( const circle::Model *  model)

Definition at line 341 of file CircleReader.cpp.

342{
343 assert(model != nullptr);
344
345 // for direct pointer access
346 _model = model;
347
348 return true;
349}

Referenced by luci_interpreter::ModuleLoader::load(), and run().

◆ parse() [2/2]

bool luci::CircleReader::parse ( const circle::Model *  model,
const uint8_t *  data,
const size_t  size 
)

Definition at line 351 of file CircleReader.cpp.

352{
353 assert(model != nullptr);
354 assert(data != nullptr);
355 assert(size > 0);
356
357 // for direct pointer access
358 _model = model;
359
360 _file_data = data;
361 _file_size = size;
362
363 return true;
364}
const T * data(const std::vector< T, Alloc > &v)
int32_t size[5]
Definition Slice.cpp:35

References flatbuffers::data(), and size.

◆ select_subgraph()

bool luci_interpreter::CircleReader::select_subgraph ( uint32_t  subgraph)

Definition at line 366 of file CircleReader.cpp.

367{
368 if (num_subgraph() <= sgindex)
369 {
370 assert(false);
371 return false;
372 }
373
374 // for direct pointer access
375 auto subgraphs = _model->subgraphs();
376 assert(subgraphs != nullptr);
377
378 _current_subgraph = subgraphs->Get(sgindex);
379 assert(_current_subgraph != nullptr);
380
381 return true;
382}
uint32_t num_subgraph() const

References num_subgraph().

Referenced by luci_interpreter::ModuleLoader::load(), run(), and luci_interpreter::RuntimeModule::selectSubgraph().

◆ tensors()


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