-
Notifications
You must be signed in to change notification settings - Fork 314
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
fma relu combination for convolution-output #31
Conversation
Thanks Keren. Looks good, but needs few changes:
|
@@ -509,6 +514,8 @@ def inverse_vfft(reg_t0, reg_t8, reg_t_stride, data_in, reg_row_start=None, reg_ | |||
elif reg_row_end: | |||
CMP(reg_row_end, row_lo) | |||
JBE(store_data.end) | |||
if relu: | |||
VBLENDVPS(ymm_data_lo, ymm_data_lo, ymm_zero, ymm_data_lo) |
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.
It is preferable to use VMAXPS(ymm_data_lo, ymm_data_lo, ymm_zero)
for performance reasons (VBLENDPS
may generate multiple microoperations)
@@ -499,6 +500,10 @@ def inverse_vfft(reg_t0, reg_t8, reg_t_stride, data_in, reg_row_start=None, reg_ | |||
negate_b=fft8_negate_b.get(id(data_hi), False), | |||
writeback=False) | |||
|
|||
if relu: | |||
ymm_zero = YMMRegister() | |||
VMOVAPS(ymm_zero, Constant.uint32x8(0)) |
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.
Please use negative signed zero, i.e. Constant.float32x8(-0.0)
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.
Could you please tell me the reason for using negative signed zero? Or propose a simple example?
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.
This is for the backward pass. The backward pass needs to know which values were positive/negative before we applied ReLU. Using negative zero ensures that the sign of the convolution results doesn't change after we apply ReLU. See discussion in #24 for why its important.
Sorry that I set I have changed the format, and it looks just fine. I will fix other functions later. Regarding the |
You don't need a Mac to test |
Hi, @Maratyszcza ! Please view my latest commits to see whether the structures and format meet your requirement. A problem about testing is proposed in the issues. |
@@ -94,7 +94,9 @@ double benchmark_vgg( | |||
for (size_t layer_index = 0; layer_index < layers_count; layer_index++) { | |||
switch (layers[layer_index].type) { | |||
case layer_type_convolutional: | |||
status = nnp_convolution_output(nnp_convolution_algorithm_auto, | |||
status = nnp_convolution_output( | |||
nnp_activation_identity, |
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.
Is the order correct? In include/nnpack.h
activation is the second argument
output_transform_function = nnp_hwinfo.transforms.ifft8x8_with_bias; | ||
break; | ||
default: | ||
goto cleanup; |
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.
nnp_convolution_output
should return an error code if activation
has unknown value. I suggest to check activation inside validate_convolution_arguments
. Then in these switch statements you write NNP_UNREACHABLE;
to indicate that this case never happens. Compiler will use it for optimization.
Looks good. Once the tests are working I will merge. |
Hi, @Maratyszcza , all tests are working! I am sorry that my former commit logs are not in correct format. I used [-0.1, 1] uniform distribution for convolution tests. |
Any news? |
@bhack This PR is ready to merge, but first NNPACK is moving to a new configuration system. |
Anything I can help? @Maratyszcza |
Manually rebased, merged, and committed as 4dbf75d |
Thanks for your review!