diff --git a/inference-engine/src/gna_plugin/backend/make_pwl.cpp b/inference-engine/src/gna_plugin/backend/make_pwl.cpp index 6c3c3433b08e21..29522b63dffe93 100644 --- a/inference-engine/src/gna_plugin/backend/make_pwl.cpp +++ b/inference-engine/src/gna_plugin/backend/make_pwl.cpp @@ -282,10 +282,10 @@ void make_gna_pwl(const DnnActivation fun, int16_t y_lower = y_min; int16_t y_upper = y_max; if (fun.fqParams.set) { - x_lower = FLOAT_TO_INT32(*fun.fqParams.input_low * 1.25 * in_scale); - x_upper = FLOAT_TO_INT32(*fun.fqParams.input_high * 1.25 * in_scale); - y_lower = FLOAT_TO_INT16(*fun.fqParams.input_low * 1.25 * out_scale); - y_upper = FLOAT_TO_INT16(*fun.fqParams.input_high * 1.25 * out_scale); + x_lower = std::max(FLOAT_TO_INT64(*fun.fqParams.input_low * 1.25 * in_scale), static_cast(x_lower)); + x_upper = std::min(FLOAT_TO_INT64(*fun.fqParams.input_high * 1.25 * in_scale), static_cast(x_upper)); + y_lower = std::max(FLOAT_TO_INT32(*fun.fqParams.input_low * 1.25 * out_scale), static_cast(y_lower)); + y_upper = std::min(FLOAT_TO_INT32(*fun.fqParams.input_high * 1.25 * out_scale), static_cast(y_upper)); } else { if (x_lower < y_lower * in_scale / out_scale) x_lower = FLOAT_TO_INT32(y_lower * in_scale / out_scale); if (y_lower < x_lower * out_scale / in_scale) y_lower = FLOAT_TO_INT16(x_lower * out_scale / in_scale); @@ -365,10 +365,10 @@ void make_gna_pwl(const DnnActivation fun, int16_t y_lower = y_min; int16_t y_upper = y_max; if (fun == kActFakeQuantize && fun.fqParams.set) { - x_lower = *fun.fqParams.input_low * in_scale; - x_upper = *fun.fqParams.input_high * in_scale; - y_lower = *fun.fqParams.input_low * out_scale; - y_upper = *fun.fqParams.input_high * out_scale; + x_lower = std::max(static_cast(*fun.fqParams.input_low * in_scale), static_cast(x_lower)); + x_upper = std::min(static_cast(*fun.fqParams.input_high * in_scale), static_cast(x_upper)); + y_lower = std::max(static_cast(*fun.fqParams.input_low * out_scale), static_cast(y_lower)); + y_upper = std::min(static_cast(*fun.fqParams.input_high * out_scale), static_cast(y_upper)); } auto n_segments = 2; if (fun == kActKaldiLstmClipping) { diff --git a/inference-engine/src/gna_plugin/round_float_define.hpp b/inference-engine/src/gna_plugin/round_float_define.hpp index 584d14ecc1ac3f..2fd4b1422be4f5 100644 --- a/inference-engine/src/gna_plugin/round_float_define.hpp +++ b/inference-engine/src/gna_plugin/round_float_define.hpp @@ -10,3 +10,4 @@ #define FLOAT_TO_INT8(a) static_cast(((a) < 0)?((a) - 0.5f):((a) + 0.5f)) #define FLOAT_TO_INT16(a) static_cast(((a) < 0)?((a) - 0.5f):((a) + 0.5f)) #define FLOAT_TO_INT32(a) static_cast(((a) < 0)?((a)-0.5f):((a)+0.5f)) +#define FLOAT_TO_INT64(a) static_cast(((a) < 0)?((a)-0.5f):((a)+0.5f)) \ No newline at end of file