-
Notifications
You must be signed in to change notification settings - Fork 295
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
Simplified memory bank for Emformer #440
Merged
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9c39d8b
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei 70634d5
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei ecfb3e9
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei bcef517
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei c9d84ae
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei fbbc24f
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei 5453166
Merge remote-tracking branch 'origin/master'
yaozengwei bb7ea31
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei 2a5a70e
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei ec8646d
Merge remote-tracking branch 'k2-fsa/master'
yaozengwei 1c067e7
init files
yaozengwei 193b44e
use average value as memory vector for each chunk
yaozengwei 5d877ef
change tail padding length from right_context_length to chunk_length
yaozengwei c27bb1c
correct the files, ln -> cp
yaozengwei 208bbb6
fix bug in conv_emformer_transducer_stateless2/emformer.py
yaozengwei 5b19011
fix doc in conv_emformer_transducer_stateless/emformer.py
yaozengwei 42e3e88
refactor init states for stream
yaozengwei 9c37c16
modify .flake8
yaozengwei 10662c5
fix bug about memory mask when memory_size==0
yaozengwei dbea9a9
Merge remote-tracking branch 'k2-fsa/master' into emformer_conv_simpl…
yaozengwei 1f6c822
add @torch.jit.export for init_states function
yaozengwei 61794d8
update RESULTS.md
yaozengwei 69a3ef3
minor change
yaozengwei f9c6014
update README.md
yaozengwei 12c176c
modify doc
yaozengwei 5cfdbd3
replace torch.div() with <<
yaozengwei 2057124
fix bug, >> -> <<
yaozengwei e3e8b19
use i&i-1 to judge if it is a power of 2
yaozengwei ad68987
minor fix
yaozengwei 1a44724
fix error in RESULTS.md
yaozengwei 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1252,6 +1252,10 @@ def __init__( | |
): | ||
super().__init__() | ||
|
||
assert int(math.log(chunk_length, 2)) == math.log( | ||
chunk_length, 2 | ||
), "chunk_length should be a power of 2." | ||
|
||
self.use_memory = memory_size > 0 | ||
self.init_memory_op = nn.AvgPool1d( | ||
kernel_size=chunk_length, | ||
|
@@ -1580,10 +1584,8 @@ def infer( | |
chunk_mask = make_pad_mask(output_lengths).to(x.device) | ||
memory_mask = ( | ||
( | ||
torch.div( | ||
num_processed_frames, | ||
self.chunk_length, | ||
rounding_mode="floor", | ||
( | ||
num_processed_frames << int(math.log(self.chunk_length, 2)) | ||
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. Please cache the result of |
||
).view(x.size(1), 1) | ||
<= torch.arange(self.memory_size, device=x.device).expand( | ||
x.size(1), self.memory_size | ||
|
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
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.