21 inline std::unique_ptr<Decoder<float>> MakeSigned32PerAxisDecoder(
const TensorInfo& info,
const void* data)
23 return std::make_unique<ScaledInt32PerAxisDecoder>(
static_cast<const int32_t*
>(data), info);
26 inline std::unique_ptr<Decoder<float>> MakeSigned32Decoder(
const TensorInfo& info,
const void* data)
28 if(
info.HasMultipleQuantizationScales())
32 return MakeSigned32PerAxisDecoder(info, data);
36 if (
info.GetQuantizationDim().has_value())
41 return MakeSigned32PerAxisDecoder(info, data);
44 const float scale =
info.GetQuantizationScale();
50 return std::make_unique<Int32Decoder>(
static_cast<const int32_t*
>(data));
56 return std::make_unique<ScaledInt32Decoder>(
static_cast<const int32_t*
>(data), scale);
63 inline std::unique_ptr<Decoder<T>>
MakeDecoder(
const TensorInfo& info,
const void* data =
nullptr);
68 switch(
info.GetDataType())
72 return std::make_unique<QASymmS8Decoder>(
73 static_cast<const int8_t*
>(data),
74 info.GetQuantizationScale(),
75 info.GetQuantizationOffset());
79 return std::make_unique<QASymm8Decoder>(
80 static_cast<const uint8_t*
>(data),
81 info.GetQuantizationScale(),
82 info.GetQuantizationOffset());
86 return std::make_unique<QSymm16Decoder>(
87 static_cast<const int16_t*
>(data),
88 info.GetQuantizationScale(),
89 info.GetQuantizationOffset());
93 return std::make_unique<Float16Decoder>(
static_cast<const Half*
>(data));
97 return std::make_unique<Float32Decoder>(
static_cast<const float*
>(data));
101 return MakeSigned32Decoder(
info, data);
105 if (
info.HasPerAxisQuantization())
108 return std::make_unique<QSymm8PerAxisDecoder>(
static_cast<const int8_t*
>(data),
info);
112 return std::make_unique<QSymmS8Decoder>(
113 static_cast<const int8_t*
>(data),
114 info.GetQuantizationScale(),
115 info.GetQuantizationOffset());
120 return std::make_unique<BooleanDecoder>(
static_cast<const uint8_t*
>(data));
132 inline std::unique_ptr<Decoder<bool>>
MakeDecoder(
const TensorInfo& info,
const void* data)
134 switch(info.GetDataType())
138 return std::make_unique<BooleanDecoderBool>(
static_cast<const uint8_t*
>(data));
150 inline std::unique_ptr<Decoder<int32_t>>
MakeDecoder(
const TensorInfo& info,
const void* data)
152 switch(
info.GetDataType())
156 return std::make_unique<Int32ToInt32tDecoder>(
static_cast<const int32_t*
>(data));