Skip to content
Snippets Groups Projects
Commit 95243d20 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Fixed Clip gradient on edge cases

parent 88db4fe8
No related branches found
No related tags found
1 merge request!175Fix backward for MaxPool and Clip
Pipeline #75581 passed
......@@ -46,9 +46,11 @@ void ClipImpl_cpu_backward_kernel(
const I* input = static_cast<const I*>(input_);
const GO* grad_output = static_cast<const GO*>(grad_output_);
GI* grad_input = static_cast<GI*>(grad_input_);
I minCasted = static_cast<I>(min_);
I maxCasted = static_cast<I>(max_);
for (std::size_t i = 0; i < length; ++i) {
grad_input[i] += ((input[i] > min_) && (input[i] < max_)) ? grad_output[i] : 0;
grad_input[i] += ((input[i] >= minCasted) && (input[i] <= maxCasted)) ? grad_output[i] : 0;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment