ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnkit::support::caffe::TensorContext< DType > Class Template Referencefinal

#include <TensorContext.h>

Collaboration diagram for nnkit::support::caffe::TensorContext< DType >:

Public Member Functions

 TensorContext (BlobContext< DType > &blobs)
 
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

template<typename DType>
class nnkit::support::caffe::TensorContext< DType >

Definition at line 37 of file TensorContext.h.

Constructor & Destructor Documentation

◆ TensorContext()

template<typename DType >
nnkit::support::caffe::TensorContext< DType >::TensorContext ( BlobContext< DType > &  blobs)
inline

Definition at line 40 of file TensorContext.h.

40 : _blobs(blobs)
41 {
42 // DO NOTHING
43 }

Member Function Documentation

◆ getConstFloatTensor()

template<typename DType >
void nnkit::support::caffe::TensorContext< DType >::getConstFloatTensor ( uint32_t  n,
const TensorContext< DType >::TypedReader< float > &  f 
) const
inlineoverridevirtual

Reimplemented from nnkit::TensorContext.

Definition at line 90 of file TensorContext.h.

91 {
92 if (!std::is_same<DType, float>::value)
93 {
94 throw std::runtime_error{"type mismatch"};
95 }
96
99
100 auto base = _blobs.region(n);
101 auto view = make_overlay<float, LexicalLayout>(shape(n), base);
102
103 f(*this, n, view);
104 }
nncc::core::ADT::tensor::Shape shape(uint32_t n) const override
Overlay< T > make_overlay(const Shape &shape, T *base)
Definition Overlay.h:48

References nncc::core::ADT::tensor::make_overlay(), and nnkit::support::caffe::TensorContext< DType >::shape().

◆ getMutableFloatTensor()

template<typename DType >
void nnkit::support::caffe::TensorContext< DType >::getMutableFloatTensor ( uint32_t  n,
const TensorContext< DType >::TypedAccessor< float > &  f 
)
inlineoverridevirtual

Reimplemented from nnkit::TensorContext.

Definition at line 74 of file TensorContext.h.

75 {
76 if (!std::is_same<DType, float>::value)
77 {
78 throw std::runtime_error{"type mismatch"};
79 }
80
83
84 auto base = _blobs.region(n);
85 auto view = make_overlay<float, LexicalLayout>(shape(n), base);
86
87 f(*this, n, view);
88 }

References nncc::core::ADT::tensor::make_overlay(), and nnkit::support::caffe::TensorContext< DType >::shape().

◆ isFloatTensor()

template<typename DType >
bool nnkit::support::caffe::TensorContext< DType >::isFloatTensor ( uint32_t  n) const
inlineoverridevirtual

Reimplemented from nnkit::TensorContext.

Definition at line 72 of file TensorContext.h.

72{ return std::is_same<DType, float>::value; }

◆ name()

template<typename DType >
std::string nnkit::support::caffe::TensorContext< DType >::name ( uint32_t  n) const
inlineoverridevirtual

Implements nnkit::TensorContext.

Definition at line 64 of file TensorContext.h.

64{ return _blobs.name(n); }

◆ shape()

◆ size()

template<typename DType >
uint32_t nnkit::support::caffe::TensorContext< DType >::size ( void  ) const
inlineoverridevirtual

Implements nnkit::TensorContext.

Definition at line 62 of file TensorContext.h.

62{ return _blobs.size(); }

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