Commit 73ba71a8 authored by Adam Straw's avatar Adam Straw Committed by Robert Kimball

remove TensorFlow rounding mode HALF_AWAY_FROM_ZERO (#2047)

parent 2cf9e4b2
...@@ -37,7 +37,6 @@ namespace ngraph ...@@ -37,7 +37,6 @@ namespace ngraph
// 2.5 -> 3 // 2.5 -> 3
// -3.5 -> -4 // -3.5 -> -4
ROUND_NEAREST_TOWARD_INFINITY, ROUND_NEAREST_TOWARD_INFINITY,
HALF_AWAY_FROM_ZERO, // TF mode for backward compatability
// round to nearest integer // round to nearest integer
// in case of two equidistant integers round toward zero e.g. // in case of two equidistant integers round toward zero e.g.
......
...@@ -567,7 +567,7 @@ void ngraph::pass::ConstantFolding::construct_constant_quantize() ...@@ -567,7 +567,7 @@ void ngraph::pass::ConstantFolding::construct_constant_quantize()
make_shared<pattern::op::Label>(element::f32, Shape{2}, pattern::has_class<op::Constant>()); make_shared<pattern::op::Label>(element::f32, Shape{2}, pattern::has_class<op::Constant>());
auto q_scale = op::Constant::create(element::f32, Shape{}, {1}); auto q_scale = op::Constant::create(element::f32, Shape{}, {1});
auto q_offset = op::Constant::create(element::i8, Shape{}, {0}); auto q_offset = op::Constant::create(element::i8, Shape{}, {0});
auto mode = op::Quantize::RoundMode::HALF_AWAY_FROM_ZERO; auto mode = op::Quantize::RoundMode::ROUND_NEAREST_TOWARD_INFINITY;
auto quant_op = auto quant_op =
make_shared<op::Quantize>(constant_label, q_scale, q_offset, element::i8, AxisSet{}, mode); make_shared<op::Quantize>(constant_label, q_scale, q_offset, element::i8, AxisSet{}, mode);
auto quant = make_shared<pattern::op::Label>(quant_op, nullptr, NodeVector{quant_op}); auto quant = make_shared<pattern::op::Label>(quant_op, nullptr, NodeVector{quant_op});
...@@ -592,11 +592,6 @@ void ngraph::pass::ConstantFolding::construct_constant_quantize() ...@@ -592,11 +592,6 @@ void ngraph::pass::ConstantFolding::construct_constant_quantize()
return false; return false;
} }
if (quantize_op->get_round_mode() != op::Quantize::RoundMode::HALF_AWAY_FROM_ZERO)
{
return false;
}
if (type == element::u8) if (type == element::u8)
{ {
replace_node( replace_node(
......
...@@ -47,8 +47,7 @@ namespace ngraph ...@@ -47,8 +47,7 @@ namespace ngraph
scale[scale_offset_transform.index(scale_offset_coord)]; scale[scale_offset_transform.index(scale_offset_coord)];
// round // round
if (round_mode == op::Quantize::RoundMode::ROUND_NEAREST_TOWARD_INFINITY || if (round_mode == op::Quantize::RoundMode::ROUND_NEAREST_TOWARD_INFINITY)
round_mode == op::Quantize::RoundMode::HALF_AWAY_FROM_ZERO)
{ {
auto abs_qvalue = std::fabs(qvalue); auto abs_qvalue = std::fabs(qvalue);
auto abs_qvalue_toward_inf = std::floor(abs_qvalue + 0.5); auto abs_qvalue_toward_inf = std::floor(abs_qvalue + 0.5);
......
...@@ -265,7 +265,7 @@ TEST(constant_folding, const_quantize) ...@@ -265,7 +265,7 @@ TEST(constant_folding, const_quantize)
auto constant = op::Constant::create(element::f32, input_shape, values_in); auto constant = op::Constant::create(element::f32, input_shape, values_in);
auto scale = op::Constant::create(element::f32, scale_offset_shape, {2}); auto scale = op::Constant::create(element::f32, scale_offset_shape, {2});
auto offset = op::Constant::create(quant_type, scale_offset_shape, {1}); auto offset = op::Constant::create(quant_type, scale_offset_shape, {1});
auto mode = op::Quantize::RoundMode::HALF_AWAY_FROM_ZERO; auto mode = op::Quantize::RoundMode::ROUND_NEAREST_TOWARD_INFINITY;
auto quantize = auto quantize =
make_shared<op::Quantize>(constant, scale, offset, output_type, quantization_axes, mode); make_shared<op::Quantize>(constant, scale, offset, output_type, quantization_axes, mode);
auto f = make_shared<Function>(quantize, op::ParameterVector{}); auto f = make_shared<Function>(quantize, op::ParameterVector{});
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment