Commit 2ece2d9c authored by Sergey Shalnov's avatar Sergey Shalnov Committed by Scott Cyphers

IntelGPU backend: Convert operation fix to be friendly with CPU float… (#2485)

* IntelGPU backend: Convert operation fix to be friendly with CPU floating point conversion

* PR2485. Exclude tests from GPU backend

* PR2485. Apply new tests changes

* Make this PR INTELGPU specific only

* Remove new tests from the list

* Update intelgpu_op_custom_kernels.cpp

* Update intelgpu_op_custom_kernels.cpp

* Update intelgpu_op_custom_kernels.cpp

* Update intelgpu_op_custom_kernels.cpp
parent ab7341d7
......@@ -61,6 +61,7 @@ string runtime::intelgpu::get_opencl_type_min_max_value(const element::Type& ngr
case element::Type_t::u16: return is_min ? "0" : "USHRT_MAX";
case element::Type_t::i8: return is_min ? "CHAR_MIN" : "CHAR_MAX";
case element::Type_t::u8: return is_min ? "0" : "UCHAR_MAX";
case element::Type_t::boolean: return is_min ? "0" : "1";
}
throw ngraph_error("Unsupported type '" + ngraph_type.c_type_string() +
......@@ -1694,8 +1695,42 @@ void runtime::intelgpu::do_convert_operation(cldnn::topology& topology,
{
gws = generate_loops(writer, output_shape, true);
writer << "output" << access_dims(output_shape) << " = convert_" << output_type_name
<< "(input0" << access_dims(output_shape) << ");\n";
if (((input_type.get_type_enum() == element::Type_t::f64) ||
(input_type.get_type_enum() == element::Type_t::f32)) &&
(output_type.get_type_enum() != element::Type_t::boolean))
{
// this is the workaround for OpenCL to be same as with CPU floating point operations
writer << input_type_name << " input_var = input0" << access_dims(output_shape) << ";\n"
<< output_type_name << " output_var = 0;\n";
writer << "if (input_var > " << get_opencl_type_min_max_value(output_type, false);
if (!output_type.is_real())
{
writer << " || isnan(input_var)";
}
writer << ")\n";
writer.block_begin();
{
writer << "output_var = " << get_opencl_type_min_max_value(output_type, true)
<< ";\n";
}
writer.block_end();
writer << "else\n";
writer.block_begin();
{
writer << "output_var = convert_" << output_type_name << "(input_var);\n";
}
writer.block_end();
writer << "output" << access_dims(output_shape) << " = output_var;\n";
}
else
{
writer << "output" << access_dims(output_shape) << " = convert_" << output_type_name
<< "(input0" << access_dims(output_shape) << ");\n";
}
generate_loops(writer, output_shape, false);
}
......
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