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())
105 return std::make_unique<QSymm8PerAxisDecoder>(
static_cast<const int8_t*
>(data),
info);
109 return std::make_unique<QSymmS8Decoder>(
110 static_cast<const int8_t*
>(data),
111 info.GetQuantizationScale(),
112 info.GetQuantizationOffset());
117 return std::make_unique<BooleanDecoder>(
static_cast<const uint8_t*
>(data));
129 inline std::unique_ptr<Decoder<double_t>>
MakeDecoder(
const TensorInfo& info,
const void* data)
131 switch(info.GetDataType())
135 return std::make_unique<Int64Decoder>(
static_cast<const int64_t*
>(data));
139 throw InvalidArgumentException(
"Cannot decode to double. Unsupported origin Data Type!");
147 inline std::unique_ptr<Decoder<bool>>
MakeDecoder(
const TensorInfo& info,
const void* data)
149 switch(
info.GetDataType())
153 return std::make_unique<BooleanDecoderBool>(
static_cast<const uint8_t*
>(data));
157 throw InvalidArgumentException(
"Cannot decode to bool. Unsupported origin Data Type!");
165 inline std::unique_ptr<Decoder<int32_t>>
MakeDecoder(
const TensorInfo& info,
const void* data)
167 switch(
info.GetDataType())
171 return std::make_unique<Int32ToInt32tDecoder>(
static_cast<const int32_t*
>(data));
175 throw InvalidArgumentException(
"Cannot decode to int32. Unsupported origin Data Type!");