19 inline std::unique_ptr<Decoder<float>> MakeSigned32PerAxisDecoder(
const TensorInfo& info,
const void* data)
21 return std::make_unique<ScaledInt32PerAxisDecoder>(
static_cast<const int32_t*
>(data), info);
24 inline std::unique_ptr<Decoder<float>> MakeSigned32Decoder(
const TensorInfo& info,
const void* data)
26 if(
info.HasMultipleQuantizationScales())
30 return MakeSigned32PerAxisDecoder(info, data);
34 if (
info.GetQuantizationDim().has_value())
39 return MakeSigned32PerAxisDecoder(info, data);
42 const float scale =
info.GetQuantizationScale();
48 return std::make_unique<Int32Decoder>(
static_cast<const int32_t*
>(data));
54 return std::make_unique<ScaledInt32Decoder>(
static_cast<const int32_t*
>(data), scale);
61 inline std::unique_ptr<Decoder<T>>
MakeDecoder(
const TensorInfo& info,
const void* data =
nullptr);
66 switch(
info.GetDataType())
70 return std::make_unique<QASymmS8Decoder>(
71 static_cast<const int8_t*
>(data),
72 info.GetQuantizationScale(),
73 info.GetQuantizationOffset());
77 return std::make_unique<QASymm8Decoder>(
78 static_cast<const uint8_t*
>(data),
79 info.GetQuantizationScale(),
80 info.GetQuantizationOffset());
84 return std::make_unique<QSymm16Decoder>(
85 static_cast<const int16_t*
>(data),
86 info.GetQuantizationScale(),
87 info.GetQuantizationOffset());
91 return std::make_unique<Float16Decoder>(
static_cast<const Half*
>(data));
95 return std::make_unique<Float32Decoder>(
static_cast<const float*
>(data));
99 return MakeSigned32Decoder(
info, data);
103 if (
info.HasPerAxisQuantization())
106 return std::make_unique<QSymm8PerAxisDecoder>(
static_cast<const int8_t*
>(data),
info);
110 return std::make_unique<QSymmS8Decoder>(
111 static_cast<const int8_t*
>(data),
112 info.GetQuantizationScale(),
113 info.GetQuantizationOffset());
118 return std::make_unique<BooleanDecoder>(
static_cast<const uint8_t*
>(data));
130 inline std::unique_ptr<Decoder<double_t>>
MakeDecoder(
const TensorInfo& info,
const void* data)
132 switch(info.GetDataType())
136 return std::make_unique<Int64Decoder>(
static_cast<const int64_t*
>(data));
140 throw InvalidArgumentException(
"Cannot decode to double. Unsupported origin Data Type!");
148 inline std::unique_ptr<Decoder<bool>>
MakeDecoder(
const TensorInfo& info,
const void* data)
150 switch(
info.GetDataType())
154 return std::make_unique<BooleanDecoderBool>(
static_cast<const uint8_t*
>(data));
158 throw InvalidArgumentException(
"Cannot decode to bool. Unsupported origin Data Type!");
166 inline std::unique_ptr<Decoder<int32_t>>
MakeDecoder(
const TensorInfo& info,
const void* data)
168 switch(
info.GetDataType())
172 return std::make_unique<Int32ToInt32tDecoder>(
static_cast<const int32_t*
>(data));
176 throw InvalidArgumentException(
"Cannot decode to int32. Unsupported origin Data Type!");