ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnkit::support::tflite::TensorContext Class Referencefinal

#include <TensorContext.h>

Collaboration diagram for nnkit::support::tflite::TensorContext:

Public Member Functions

 TensorContext (TensorSet &tensors)
 
uint32_t size (void) const override
 
std::string name (uint32_t n) const override
 
nncc::core::ADT::tensor::Shape shape (uint32_t n) const override
 
bool isFloatTensor (uint32_t n) const override
 
void getMutableFloatTensor (uint32_t n, const TensorContext::TypedAccessor< float > &f) override
 
void getConstFloatTensor (uint32_t n, const TensorContext::TypedReader< float > &f) const override
 
- Public Member Functions inherited from nnkit::TensorContext
virtual ~TensorContext ()=default
 
virtual bool isS32Tensor (uint32_t n) const
 
virtual void getMutableS32Tensor (uint32_t n, const TypedAccessor< int32_t > &cb)
 
virtual void getConstS32Tensor (uint32_t n, const TypedReader< int32_t > &cb) const
 

Additional Inherited Members

- Public Types inherited from nnkit::TensorContext
template<typename T >
using TypedReader = std::function< void(const TensorContext &, uint32_t n, const nncc::core::ADT::tensor::Reader< T > &)>
 
template<typename T >
using TypedAccessor = std::function< void(const TensorContext &, uint32_t n, nncc::core::ADT::tensor::Accessor< T > &)>
 

Detailed Description

Definition at line 31 of file TensorContext.h.

Constructor & Destructor Documentation

◆ TensorContext()

nnkit::support::tflite::TensorContext::TensorContext ( TensorSet tensors)
inline

Definition at line 34 of file TensorContext.h.

34 : _tensors(tensors)
35 {
36 // DO NOTHING
37 }

Member Function Documentation

◆ getConstFloatTensor()

void nnkit::support::tflite::TensorContext::getConstFloatTensor ( uint32_t  n,
const TensorContext::TypedReader< float > &  f 
) const
overridevirtual

Reimplemented from nnkit::TensorContext.

Definition at line 49 of file TensorContext.cpp.

51{
54
55 auto t = _tensors.at(n);
56
57 float *data = reinterpret_cast<float *>(t->data.f);
58 auto overlay = make_overlay<float, LexicalLayout>(shape(n), data);
59
60 f(*this, n, overlay);
61}
nncc::core::ADT::tensor::Shape shape(uint32_t n) const override
Overlay< T > make_overlay(const Shape &shape, T *base)
Definition Overlay.h:48
virtual TfLiteTensor * at(uint32_t n) const =0

References nnkit::support::tflite::TensorSet::at(), nncc::core::ADT::tensor::make_overlay(), and shape().

◆ getMutableFloatTensor()

void nnkit::support::tflite::TensorContext::getMutableFloatTensor ( uint32_t  n,
const TensorContext::TypedAccessor< float > &  f 
)
overridevirtual

Reimplemented from nnkit::TensorContext.

Definition at line 35 of file TensorContext.cpp.

37{
40
41 auto t = _tensors.at(n);
42
43 float *data = reinterpret_cast<float *>(t->data.f);
44 auto overlay = make_overlay<float, LexicalLayout>(shape(n), data);
45
46 f(*this, n, overlay);
47}

References nnkit::support::tflite::TensorSet::at(), nncc::core::ADT::tensor::make_overlay(), and shape().

◆ isFloatTensor()

bool nnkit::support::tflite::TensorContext::isFloatTensor ( uint32_t  n) const
inlineoverridevirtual

Reimplemented from nnkit::TensorContext.

Definition at line 50 of file TensorContext.h.

50{ return _tensors.at(n)->type == kTfLiteFloat32; }

References nnkit::support::tflite::TensorSet::at().

◆ name()

std::string nnkit::support::tflite::TensorContext::name ( uint32_t  n) const
inlineoverridevirtual

Implements nnkit::TensorContext.

Definition at line 43 of file TensorContext.h.

43{ return _tensors.at(n)->name; }

References nnkit::support::tflite::TensorSet::at().

◆ shape()

nncc::core::ADT::tensor::Shape nnkit::support::tflite::TensorContext::shape ( uint32_t  n) const
overridevirtual

◆ size()

uint32_t nnkit::support::tflite::TensorContext::size ( void  ) const
inlineoverridevirtual

Implements nnkit::TensorContext.

Definition at line 40 of file TensorContext.h.

40{ return _tensors.size(); }
virtual uint32_t size(void) const =0

References nnkit::support::tflite::TensorSet::size().


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