-
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bdc4619
fma relu combination for convolution-output
Jokeren 267ae02
code sytle format
Jokeren cdeaac7
merge relu to activation struct
Jokeren 214a66f
relu inference
Jokeren 51922c5
bug fix and test pass
Jokeren 01f5e59
Test: use (-0.1, 1.0) uniform distribution from convolution inference…
Jokeren f68d944
Configure: fix vgg-a test name
Jokeren 2731511
Test: modify errorLimit of vgg-a to pass the test
Jokeren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,7 +290,7 @@ def forward_vfft(reg_t0, reg_t8, reg_t_stride, data_out, reg_row_start=None, reg | |
store_ymm_result(out_imag[5], ymm_two_w5_imag) | ||
|
||
|
||
def inverse_vfft(reg_t0, reg_t8, reg_t_stride, data_in, reg_row_start=None, reg_row_end=None, store_mask=None): | ||
def inverse_vfft(reg_t0, reg_t8, reg_t_stride, data_in, reg_row_start=None, reg_row_end=None, store_mask=None, relu=False): | ||
assert isinstance(reg_t0, GeneralPurposeRegister64) | ||
assert isinstance(reg_t8, GeneralPurposeRegister64) | ||
assert isinstance(reg_t_stride, GeneralPurposeRegister64) | ||
|
@@ -487,6 +487,7 @@ def inverse_vfft(reg_t0, reg_t8, reg_t_stride, data_in, reg_row_start=None, reg_ | |
if store_mask: | ||
VMOVAPS(ymm_store_mask, store_mask) | ||
|
||
|
||
# FFT8: butterfly | ||
with Block() as store_data: | ||
for i, (data_lo, data_hi) in enumerate(zip(data[0:8], data[8:16])): | ||
|
@@ -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)) | ||
|
||
with Block() as store_data_lo: | ||
if reg_row_start: | ||
CMP(reg_row_start, row_lo) | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. It is preferable to use |
||
if store_mask: | ||
VMASKMOVPS([reg_t0], ymm_store_mask, ymm_data_lo) | ||
else: | ||
|
@@ -523,6 +530,8 @@ def inverse_vfft(reg_t0, reg_t8, reg_t_stride, data_in, reg_row_start=None, reg_ | |
if reg_row_end: | ||
CMP(reg_row_end, row_hi) | ||
JBE(store_data_hi.end) | ||
if relu: | ||
VBLENDVPS(ymm_data_hi, ymm_data_hi, ymm_zero, ymm_data_hi) | ||
if store_mask: | ||
VMASKMOVPS([reg_t8], ymm_store_mask, ymm_data_hi) | ||
else: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.