16 inline std::unique_ptr<Encoder<T>>
MakeEncoder(
const TensorInfo& info,
void* data =
nullptr);
21 switch(
info.GetDataType())
25 return std::make_unique<QASymmS8Encoder>(
26 static_cast<int8_t*
>(data),
27 info.GetQuantizationScale(),
28 info.GetQuantizationOffset());
32 return std::make_unique<QASymm8Encoder>(
33 static_cast<uint8_t*
>(data),
34 info.GetQuantizationScale(),
35 info.GetQuantizationOffset());
39 if (
info.HasPerAxisQuantization())
42 return std::make_unique<QSymm8PerAxisEncoder>(
43 static_cast<int8_t*
>(data),
49 return std::make_unique<QSymmS8Encoder>(
50 static_cast<int8_t*
>(data),
51 info.GetQuantizationScale(),
52 info.GetQuantizationOffset());
57 if (
info.HasPerAxisQuantization())
59 unsigned int axis =
info.GetQuantizationDim().value();
60 auto axisDimensionality =
info.GetShape()[axis];
62 return std::make_unique<QSymm16PerAxisEncoder>(
63 static_cast<int16_t*
>(data),
70 return std::make_unique<QSymm16Encoder>(
71 static_cast<int16_t *
>(data),
72 info.GetQuantizationScale(),
73 info.GetQuantizationOffset());
78 return std::make_unique<Int32Encoder>(
static_cast<int32_t*
>(data));
82 return std::make_unique<Float16Encoder>(
static_cast<Half*
>(data));
86 return std::make_unique<Float32Encoder>(
static_cast<float*
>(data));
98 inline std::unique_ptr<Encoder<double_t>>
MakeEncoder(
const TensorInfo& info,
void* data)
100 switch(info.GetDataType())
104 return std::make_unique<Int64Encoder>(
static_cast<int64_t*
>(data));
108 throw InvalidArgumentException(
"Cannot encode from double. Unsupported target Data Type!");
116 inline std::unique_ptr<Encoder<bool>>
MakeEncoder(
const TensorInfo& info,
void* data)
118 switch(
info.GetDataType())
122 return std::make_unique<BooleanEncoder>(
static_cast<uint8_t*
>(data));
126 throw InvalidArgumentException(
"Cannot encode from boolean. Unsupported target Data Type!");
134 inline std::unique_ptr<Encoder<int32_t>>
MakeEncoder(
const TensorInfo& info,
void* data)
136 switch(
info.GetDataType())
140 return std::make_unique<Int32ToInt32tEncoder>(
static_cast<int32_t*
>(data));
144 throw InvalidArgumentException(
"Cannot encode from int32. Unsupported Data Type!");