Commit 259c0a48 authored by Nishant Patel's avatar Nishant Patel Committed by Scott Cyphers

Fix signed conv op (#2287)

* Fix signedconv op

* Add assert and change the dynamic scale test case

* Change assert

* Update quantized_conv_bias.cpp

* Update quantized_conv_bias.cpp
parent 8e1922be
......@@ -19,6 +19,7 @@
#include "ngraph/builder/make_constant.hpp"
#include "ngraph/builder/quantization.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/convert.hpp"
#include "quantization_util.hpp"
using namespace std;
......@@ -337,18 +338,19 @@ namespace ngraph
bias = make_shared<op::Quantize>(
bias, bias_scale, zero, element::i32, quantization_axes, round_mode);
}
return make_shared<op::QuantizedConvolutionBiasSignedAdd>(input,
filters,
bias,
sum_input,
window_movement_strides,
window_dilation_strides,
padding_below,
padding_above,
data_dilation_strides,
requantization_scale,
sum_scale,
with_relu);
auto qconv = make_shared<op::QuantizedConvolutionBiasSignedAdd>(input,
filters,
bias,
sum_input,
window_movement_strides,
window_dilation_strides,
padding_below,
padding_above,
data_dilation_strides,
requantization_scale,
sum_scale,
with_relu);
return make_shared<op::Convert>(qconv, element::u8);
}
}
}
......@@ -192,9 +192,10 @@ op::QuantizedConvolutionBiasSignedAdd::QuantizedConvolutionBiasSignedAdd(
// TODO: call ngraph util
// util::validate_convbias_shapes(data_batch_shape, filters_shape, bias->get_shape());
auto output_et = with_relu ? element::u8 : element::i8;
// TODO (nbpatel): Remove with_relu arg from the API
NGRAPH_ASSERT(with_relu == true) << "with_relu must be true";
set_output_type(0,
output_et,
element::i8,
util::infer_convolution_output_shape(this,
data_batch_shape,
filters_shape,
......
......@@ -675,7 +675,7 @@ TEST(builder, scaled_QC_with_bias_signed_add_and_relu)
auto result = backend->create_tensor(element::u8, shape_r);
auto handle = backend->compile(f);
backend->call_with_validate(handle, {result}, {a, b, c, d});
EXPECT_EQ((vector<uint8_t>{76, 110, 99, 105, 122, 218, 255, 136, 110, 165, 142, 133}),
EXPECT_EQ((vector<uint8_t>{74, 106, 93, 97, 112, 127, 127, 127, 110, 127, 127, 127}),
read_vector<uint8_t>(result));
}
......@@ -750,7 +750,7 @@ TEST(builder, dynamic_scaled_QC_with_bias_signed_add_and_relu)
auto result = backend->create_tensor(element::u8, shape_r);
auto handle = backend->compile(f);
backend->call_with_validate(handle, {result}, {a, b, c, d, e, e_a, g, h, i, j, k, l});
EXPECT_EQ((vector<uint8_t>{76, 110, 99, 105, 122, 218, 255, 136, 110, 165, 142, 133}),
EXPECT_EQ((vector<uint8_t>{74, 106, 93, 97, 112, 127, 127, 127, 110, 127, 127, 127}),
read_vector<uint8_t>(result));
}
......
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