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())
41 return std::make_unique<QSymm8PerAxisEncoder>(
static_cast<int8_t*
>(data),
info);
45 return std::make_unique<QSymmS8Encoder>(
46 static_cast<int8_t*
>(data),
47 info.GetQuantizationScale(),
48 info.GetQuantizationOffset());
53 if (
info.HasPerAxisQuantization())
55 unsigned int axis =
info.GetQuantizationDim().value();
56 auto axisDimensionality =
info.GetShape()[axis];
58 return std::make_unique<QSymm16PerAxisEncoder>(
59 static_cast<int16_t*
>(data),
66 return std::make_unique<QSymm16Encoder>(
67 static_cast<int16_t *
>(data),
68 info.GetQuantizationScale(),
69 info.GetQuantizationOffset());
74 return std::make_unique<Int32Encoder>(
static_cast<int32_t*
>(data));
78 return std::make_unique<Float16Encoder>(
static_cast<Half*
>(data));
82 return std::make_unique<Float32Encoder>(
static_cast<float*
>(data));
94 inline std::unique_ptr<Encoder<double_t>>
MakeEncoder(
const TensorInfo& info,
void* data)
96 switch(info.GetDataType())
100 return std::make_unique<Int64Encoder>(
static_cast<int64_t*
>(data));
104 throw InvalidArgumentException(
"Cannot encode from double. Unsupported target Data Type!");
112 inline std::unique_ptr<Encoder<bool>>
MakeEncoder(
const TensorInfo& info,
void* data)
114 switch(
info.GetDataType())
118 return std::make_unique<BooleanEncoder>(
static_cast<uint8_t*
>(data));
122 throw InvalidArgumentException(
"Cannot encode from boolean. Unsupported target Data Type!");
130 inline std::unique_ptr<Encoder<int32_t>>
MakeEncoder(
const TensorInfo& info,
void* data)
132 switch(
info.GetDataType())
136 return std::make_unique<Int32ToInt32tEncoder>(
static_cast<int32_t*
>(data));
140 throw InvalidArgumentException(
"Cannot encode from int32. Unsupported Data Type!");