-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cker] Fix min-max calculation in MaxPool2D #14133
Conversation
This PR fixes min-max calculation in MaxPool2D kernel. ONE-DCO-1.0-Signed-off-by: seunghui youn <[email protected]>
out_mat.cwiseMin(params.float_activation_min).cwiseMax(params.float_activation_max); | ||
out_mat = out_mat.cwiseMin(params.float_activation_max).cwiseMax(params.float_activation_min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note) This line is a main change in this PR
// with min, max params | ||
{ | ||
nnfw::cker::PoolParams op_param; | ||
{ | ||
op_param.stride_height = 1; | ||
op_param.stride_width = 1; | ||
op_param.filter_height = 2; | ||
op_param.filter_width = 2; | ||
op_param.padding_values.height = 0; | ||
op_param.padding_values.width = 0; | ||
op_param.float_activation_min = 0.0; | ||
op_param.float_activation_max = 6.0; | ||
} | ||
nnfw::cker::Shape in = {1, 3, 3, 1}; | ||
nnfw::cker::Shape out = {1, 2, 2, 1}; | ||
|
||
MaxPoolOpVerifier<float> verifier(op_param, in, out); | ||
|
||
/** | ||
* input(index) : output(arg-index): | ||
* | ||
* 1(0) 2(1) 3(2) | ||
* 4(3) 5(4) 6(5) - (forward) -> 5(4) 6(5) | ||
* 7(6) 8(7) 9(8) 6(7) 6(8) | ||
*/ | ||
|
||
std::vector<float> input = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | ||
std::vector<float> expected_output = {5, 6, 6, 6}; | ||
verifier.verifyForward(input, expected_output); | ||
|
||
/** | ||
* output_deriv: input_deriv: | ||
* (randomly filled) | ||
* | ||
* 0.1 0.2 0 0 0 | ||
* 0.3 0.4 - (backward) -> 0 0.1 0.2 | ||
* 0 0.3 0.4 | ||
*/ | ||
|
||
std::vector<float> output_deriv = {0.1, 0.2, 0.3, 0.4}; | ||
std::vector<float> expected_input_deriv = {0, 0, 0, 0, 0.1, 0.2, 0, 0.3, 0.4}; | ||
verifier.verifyBackward(output_deriv, expected_input_deriv); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note) This is a newly added test - to check that min/max works as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Jang Jiseob <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Beyond this PR: I've found several typos during reading MaxPool.test.cc
:
- calcuated_grad → calculated_grad
- cacluated_output → calculated_output
This PR fixes min-max calculation in MaxPool2D kernel.
ONE-DCO-1.0-Signed-off-by: seunghui youn [email protected]