ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
souschef::ExplicitFloat16DataChef Class Referencefinal

#include <Explicit.h>

Collaboration diagram for souschef::ExplicitFloat16DataChef:

Public Member Functions

 ExplicitFloat16DataChef ()
 
std::vector< uint8_t > generate (int32_t count) const override
 Generate a sequence of 'count' elements as a byte sequence.
 
void insert (const float &value)
 
- Public Member Functions inherited from souschef::DataChef
virtual ~DataChef ()=default
 

Detailed Description

Definition at line 99 of file Explicit.h.

Constructor & Destructor Documentation

◆ ExplicitFloat16DataChef()

souschef::ExplicitFloat16DataChef::ExplicitFloat16DataChef ( )
inline

Definition at line 102 of file Explicit.h.

103 {
104 // DO NOTHING
105 }

Member Function Documentation

◆ generate()

std::vector< uint8_t > souschef::ExplicitFloat16DataChef::generate ( int32_t  count) const
overridevirtual

Generate a sequence of 'count' elements as a byte sequence.

Let D be the return value of generate(N). Then, D.size() == N * sizeof(T) where T is the element type.

Implements souschef::DataChef.

Definition at line 80 of file Explicit.cpp.

81{
82 std::vector<uint8_t> res;
83
84 for (uint32_t n = 0; n < count; ++n)
85 {
86 float const fvalue = (n < _values.size()) ? _values.at(n) : 0.0;
87 uint16_t const value = fp16_ieee_from_fp32_value(fvalue);
88 auto const arr = reinterpret_cast<const uint8_t *>(&value);
89
90 for (uint32_t b = 0; b < sizeof(uint16_t); ++b)
91 {
92 res.emplace_back(arr[b]);
93 }
94 }
95
96 return res;
97}
arr
Definition infer.py:92

◆ insert()

void souschef::ExplicitFloat16DataChef::insert ( const float &  value)
inline

Definition at line 111 of file Explicit.h.

111{ _values.emplace_back(value); }

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