ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::ir::TypeInfo Class Reference

#include <TypeInfo.h>

Public Member Functions

 TypeInfo ()=delete
 
 TypeInfo (DataType type)
 
 TypeInfo (DataType type, float scale, int32_t zero_point)
 
DataType type () const
 
float scale () const
 
const std::vector< float > & scales () const
 
int32_t zero_point () const
 
const std::vector< int32_t > & zero_points () const
 
const ir::Sparsitysparsity () const
 
void quantization (float scale, int32_t zero_point)
 
void quantization (std::vector< float > &&scales, std::vector< int32_t > &&zero_points)
 
void sparsity (std::shared_ptr< ir::Sparsity > sparsity)
 
void type (const DataType type)
 

Detailed Description

Definition at line 50 of file TypeInfo.h.

Constructor & Destructor Documentation

◆ TypeInfo() [1/3]

onert::ir::TypeInfo::TypeInfo ( )
delete

◆ TypeInfo() [2/3]

onert::ir::TypeInfo::TypeInfo ( DataType  type)
inlineexplicit

Definition at line 55 of file TypeInfo.h.

55: _type{type}, _sparsity{nullptr} {}
DataType type() const
Definition TypeInfo.h:63

◆ TypeInfo() [3/3]

onert::ir::TypeInfo::TypeInfo ( DataType  type,
float  scale,
int32_t  zero_point 
)
inline

Definition at line 57 of file TypeInfo.h.

57 : _type{type}, _sparsity{nullptr}
58 {
60 }
void quantization(float scale, int32_t zero_point)
Definition TypeInfo.h:69
float scale() const
Definition TypeInfo.h:64
int32_t zero_point() const
Definition TypeInfo.h:66

References quantization(), scale(), and zero_point().

Member Function Documentation

◆ quantization() [1/2]

void onert::ir::TypeInfo::quantization ( float  scale,
int32_t  zero_point 
)
inline

Definition at line 69 of file TypeInfo.h.

70 {
71 assert(requireQuantParam(_type) || scale == 0); // Quantize param type, or scale = 0
72 _quant.scales = {scale};
73 _quant.zero_points = {zero_point};
74 }
bool requireQuantParam(DataType data_type)
Definition DataType.cc:57
std::vector< float > scales
Definition TypeInfo.h:46
std::vector< int32_t > zero_points
Definition TypeInfo.h:47

References onert::ir::requireQuantParam(), scale(), onert::ir::Quantization::scales, zero_point(), and onert::ir::Quantization::zero_points.

Referenced by onert::loader::BaseLoader< LoaderDomain >::loadQuantization(), and TypeInfo().

◆ quantization() [2/2]

void onert::ir::TypeInfo::quantization ( std::vector< float > &&  scales,
std::vector< int32_t > &&  zero_points 
)
inline

Definition at line 75 of file TypeInfo.h.

76 {
77 assert(requireQuantParam(_type)); // Only quantize param types can call this
78 assert(scales.size() != 0); // Not allow empty scales vector when this is called
79 assert(zero_points.size() == 0 ||
80 zero_points.size() == scales.size()); // Symmetric or Asymmetric
81 // Not allow meaningless quantization parameters
82 assert(scales.size() == 1 ||
83 std::all_of(scales.begin(), scales.end(), [](float s) { return s != 0; }));
84
85 _quant.scales = std::move(scales);
86 _quant.zero_points = std::move(zero_points);
87 }
const std::vector< float > & scales() const
Definition TypeInfo.h:65
const std::vector< int32_t > & zero_points() const
Definition TypeInfo.h:67

References onert::ir::requireQuantParam(), onert::ir::Quantization::scales, scales(), onert::ir::Quantization::zero_points, and zero_points().

◆ scale()

float onert::ir::TypeInfo::scale ( ) const
inline

◆ scales()

const std::vector< float > & onert::ir::TypeInfo::scales ( ) const
inline

Definition at line 65 of file TypeInfo.h.

65{ return _quant.scales; }

References onert::ir::Quantization::scales.

Referenced by onert::backend::IPortableTensor::data_scales(), onert::ir::operator==(), and quantization().

◆ sparsity() [1/2]

const ir::Sparsity * onert::ir::TypeInfo::sparsity ( ) const
inline

Definition at line 68 of file TypeInfo.h.

68{ return _sparsity.get(); }

Referenced by onert::loader::BaseLoader< LoaderDomain >::loadSparsity(), and onert::backend::IPortableTensor::sparsity().

◆ sparsity() [2/2]

void onert::ir::TypeInfo::sparsity ( std::shared_ptr< ir::Sparsity sparsity)
inline

Definition at line 88 of file TypeInfo.h.

88{ _sparsity = std::move(sparsity); }

◆ type() [1/2]

◆ type() [2/2]

void onert::ir::TypeInfo::type ( const DataType  type)
inline

Definition at line 91 of file TypeInfo.h.

91{ _type = type; }

References type().

Referenced by type().

◆ zero_point()

int32_t onert::ir::TypeInfo::zero_point ( ) const
inline

◆ zero_points()

const std::vector< int32_t > & onert::ir::TypeInfo::zero_points ( ) const
inline

Definition at line 67 of file TypeInfo.h.

67{ return _quant.zero_points; }

References onert::ir::Quantization::zero_points.

Referenced by onert::backend::IPortableTensor::data_zero_points(), and quantization().


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