Commit 9e1809d9 authored by Sergey Shalnov's avatar Sergey Shalnov Committed by Scott Cyphers

IntelGPU backend: ReluBackprop operation fix for datatypes (#2605)

parent a2df5c7c
......@@ -1156,13 +1156,29 @@ shared_ptr<runtime::Executable>
{
arguments_check(op, 2, 1);
const cldnn_activation_additional_params& param = {0.f, 0.f};
const cldnn::activation_grad cldnn_activ_grad(get_output_name(op),
get_input_name(op, 1),
get_input_name(op, 0),
activation_grad_relu,
param);
topology.add(cldnn_activ_grad);
if (get_input_type(op) != element::f32 || get_input_type(op, 1) != element::f32 ||
get_output_type(op) != element::f32 || get_output_shape(op).size() > 4)
{
do_relu_backprop(topology,
get_input_name(op, 0),
get_input_shape(op, 0),
get_input_type(op, 0),
get_input_name(op, 1),
get_input_shape(op, 1),
get_output_name(op),
get_output_shape(op),
get_output_type(op));
}
else
{
const cldnn_activation_additional_params& param = {0.f, 0.f};
const cldnn::activation_grad cldnn_activ_grad(get_output_name(op),
get_input_name(op, 1),
get_input_name(op, 0),
activation_grad_relu,
param);
topology.add(cldnn_activ_grad);
}
break;
}
case OP_TYPEID::Abs:
......
......@@ -1383,6 +1383,58 @@ void runtime::intelgpu::do_eltwise_kernel(cldnn::topology& topology,
topology.add(op_eltwise);
}
void runtime::intelgpu::do_relu_backprop(cldnn::topology& topology,
const string& input0_name,
const Shape& input0_shape,
const element::Type& input0_type,
const string& input1_name,
const Shape& input1_shape,
const string& output_name,
const Shape& output_shape,
const element::Type& output_type)
{
const cldnn::layout layout = IntelGPULayout::create_cldnn_layout(output_type, output_shape);
const string entry_point_name = "relubackprop_" + output_name;
const string input0_type_name = get_opencl_type_name(input0_type);
const string output_type_name = get_opencl_type_name(output_type);
const string zero_input0_const = "convert_" + input0_type_name + "(0)";
const string zero_output_const = "convert_" + output_type_name + "(0)";
CodeWriter writer;
vector<size_t> gws;
gen_func_def(writer,
entry_point_name,
{2, input0_type_name},
{input0_shape, input1_shape},
output_type_name,
output_shape);
writer.block_begin();
{
// Main loops
gws = generate_loops(writer, output_shape, true);
writer << "output" << access_dims(output_shape) << " = (input0" << access_dims(input0_shape)
<< " > " << zero_input0_const << ") ? input1" << access_dims(input1_shape) << " : "
<< zero_output_const << ";\n";
// Closing brackets for main loops
generate_loops(writer, output_shape, false);
}
writer.block_end();
const cldnn::custom_gpu_primitive op_reluback(output_name,
{input0_name, input1_name},
{writer.get_code()},
entry_point_name,
get_kernel_args(2, 1),
"",
layout,
gws);
topology.add(op_reluback);
}
void runtime::intelgpu::do_reverse_operation(cldnn::topology& topology,
const string& input_name,
const Shape& input_shape,
......
......@@ -144,6 +144,16 @@ namespace ngraph
const std::string& operation,
bool function_operation);
void do_relu_backprop(cldnn::topology& topology,
const std::string& input0_name,
const Shape& input0_shape,
const element::Type& input0_type,
const std::string& input1_name,
const Shape& input1_shape,
const std::string& output_name,
const Shape& output_shape,
const element::Type& output_type);
void do_reverse_operation(cldnn::topology& topology,
const std::string& input_name,
const Shape& input_shape,
......
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