else
{
assert(out_type == loco::DataType::S16);
- compute_sym_scale_zp(min, max, scaling_factor, zp, nudged_min, nudged_max);
+ compute_sym_scale(min, max, scaling_factor, nudged_min, nudged_max);
}
auto quantparam = std::make_unique<CircleQuantParam>();
INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleFloor, x)
INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleFullyConnected, input)
INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleGather, params)
+ INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleGelu, features)
INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleInstanceNorm, input)
INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleLeakyRelu, features)
INSERT_QUANTIZE_TO_UNARY_OP(luci::CircleLocalResponseNormalization, input)
else
{
assert(user_given_dtype == loco::DataType::S16);
- compute_sym_scale_zp(min, max, scaling_factor, zp, nudged_min, nudged_max);
+ compute_sym_scale(min, max, scaling_factor, nudged_min, nudged_max);
}
input->quantparam()->scale[0] = scaling_factor;
input->quantparam()->zerop[0] = zp;
if (user_given_dtype == loco::DataType::FLOAT32)
{
auto dequant_op = create_dequantize(from);
- loco::replace(from).with(dequant_op);
dequant_op->input(from);
+ output->from(dequant_op);
}
else
{
// Insert Quantize Op for non-float32 output_type
auto quant_op = create_quantize_op(from, user_given_dtype);
- loco::replace(from).with(quant_op);
quant_op->input(from);
+ output->from(quant_op);
// TODO Set a proper origin (Quantize should have its own Origin)
luci::add_origin(quant_op, luci::get_origin(from));
for (auto node : loco::active_nodes(loco::output_nodes(g)))
{
auto circle_node = loco::must_cast<luci::CircleNode *>(node);
+
+ // At this point, all activations have to be quantized.
+ // Un-quantized nodes are not the quantization target (ex: int32 tensor),
+ // so we skip them
+ if (circle_node->quantparam() == nullptr)
+ continue;
+
QuantizeSpecialActivation qsa(_ctx->input_model_dtype, quantize_dtype(circle_node));
circle_node->accept(&qsa);
}