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

#include <TensorContext.h>

Collaboration diagram for nnkit::support::tf::TensorContext:

Public Member Functions

 TensorContext (const std::vector< std::unique_ptr< ParsedTensor > > &tensors, TensorDataMap &data_map)
 
 TensorContext (const TensorContext &)=delete
 
 TensorContext (TensorContext &&)=delete
 
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 nnkit::TensorContext::TypedAccessor< float > &f) override
 
void getConstFloatTensor (uint32_t n, const nnkit::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 35 of file TensorContext.h.

Constructor & Destructor Documentation

◆ TensorContext() [1/3]

nnkit::support::tf::TensorContext::TensorContext ( const std::vector< std::unique_ptr< ParsedTensor > > &  tensors,
TensorDataMap data_map 
)
inline

Definition at line 38 of file TensorContext.h.

39 : _tensors(tensors), _data_map(data_map)
40 {
41 // empty
42 }

◆ TensorContext() [2/3]

nnkit::support::tf::TensorContext::TensorContext ( const TensorContext )
delete

◆ TensorContext() [3/3]

nnkit::support::tf::TensorContext::TensorContext ( TensorContext &&  )
delete

Member Function Documentation

◆ getConstFloatTensor()

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

Reimplemented from nnkit::TensorContext.

Definition at line 45 of file TensorContext.cpp.

47{ // for output
50
51 const ParsedTensor *parsed_tensor = _tensors.at(n).get();
52 float *data = reinterpret_cast<float *>(_data_map.data(parsed_tensor));
53 auto overlay = make_overlay<float, LexicalLayout>(shape(n), data);
54
55 f(*this, n, overlay);
56}
nncc::core::ADT::tensor::Shape shape(uint32_t n) const override
uint8_t * data(const ParsedTensor *parsed_tensor)
Overlay< T > make_overlay(const Shape &shape, T *base)
Definition Overlay.h:48

References nnkit::support::tf::TensorDataMap::data(), nncc::core::ADT::tensor::make_overlay(), and shape().

◆ getMutableFloatTensor()

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

Reimplemented from nnkit::TensorContext.

Definition at line 32 of file TensorContext.cpp.

34{ // for input
37
38 const ParsedTensor *parsed_tensor = _tensors.at(n).get();
39 float *data = reinterpret_cast<float *>(_data_map.data(parsed_tensor));
40 auto overlay = make_overlay<float, LexicalLayout>(shape(n), data);
41
42 f(*this, n, overlay);
43}

References nnkit::support::tf::TensorDataMap::data(), nncc::core::ADT::tensor::make_overlay(), and shape().

◆ isFloatTensor()

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

Reimplemented from nnkit::TensorContext.

Definition at line 64 of file TensorContext.h.

64{ return _tensors.at(n)->isFloatTensor(); }

◆ name()

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

Implements nnkit::TensorContext.

Definition at line 51 of file TensorContext.h.

52 {
53 return _tensors.at(n)->name();
54 }

◆ shape()

nncc::core::ADT::tensor::Shape nnkit::support::tf::TensorContext::shape ( uint32_t  n) const
inlineoverridevirtual

◆ size()

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

Implements nnkit::TensorContext.

Definition at line 48 of file TensorContext.h.

48{ return _tensors.size(); }

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