ONE - On-device Neural Engine
Loading...
Searching...
No Matches
tflimport::TflBufferContext Class Reference

Class to read and provide buffer information of tflite. More...

#include <Context.h>

Data Structures

struct  TflBuffer
 

Public Member Functions

 TflBufferContext (const tflite::Model *tfl_model)
 
template<typename T >
TflBuffer< T > tensor_buffer (const tflite::SubGraph *graph, uint32_t tensor_idx) const
 

Detailed Description

Class to read and provide buffer information of tflite.

Definition at line 86 of file Context.h.

Constructor & Destructor Documentation

◆ TflBufferContext()

tflimport::TflBufferContext::TflBufferContext ( const tflite::Model *  tfl_model)
explicit

Definition at line 104 of file Context.cpp.

105{
107
108 tfl_buffers = tfl_model->buffers();
109
110 for (uint32_t buffer_id = 0; buffer_id < tfl_buffers->size(); ++buffer_id)
111 {
112 _buffer_ctx[buffer_id] = (*tfl_buffers)[buffer_id];
113 }
114}
uoffset_t size() const

References flatbuffers::Vector< T >::size().

Member Function Documentation

◆ tensor_buffer()

template<typename T >
TflBuffer< T > tflimport::TflBufferContext::tensor_buffer ( const tflite::SubGraph *  graph,
uint32_t  tensor_idx 
) const
inline

Definition at line 101 of file Context.h.

102 {
103 TflBufferContext::TflBuffer<T> res{nullptr, 0};
104 const auto *tensor = graph->tensors()->Get(tensor_idx);
105 uint32_t tfl_buf_id = tensor->buffer();
106
107 assert(_buffer_ctx.size() > tfl_buf_id);
108
109 const tflite::Buffer *tfl_buffer = _buffer_ctx.at(tfl_buf_id);
110
111 if (auto *array = tfl_buffer->data())
112 {
113 if (size_t size = array->size())
114 {
115 assert(size % sizeof(T) == 0);
116
117 res.len = size / sizeof(T);
118 res.ptr = reinterpret_cast<const T *>(array->data());
119 }
120 }
121
122 return res;
123 }
int32_t size[5]
Definition Slice.cpp:35

References size.

Referenced by tflimport::DepthwiseConv2DGraphBuilder::build(), and tflimport::copy_tensors().


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