From 7ce21269f9d60d61a4c59bb157a33534f4e4632b Mon Sep 17 00:00:00 2001 From: xu-gaopeng Date: Thu, 13 Jun 2024 20:12:04 +0800 Subject: [PATCH] Update subsampling.py (#2554) The StackNFramesSubsampling module was missing the pos_enc attribute, which caused an AttributeError when pos_enc.position_encoding was called in the forward_chunk. --- wenet/transformer/subsampling.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wenet/transformer/subsampling.py b/wenet/transformer/subsampling.py index 1d252b940..7432e8119 100644 --- a/wenet/transformer/subsampling.py +++ b/wenet/transformer/subsampling.py @@ -388,3 +388,7 @@ def forward( x = self.norm(x) x = self.out(x) return x, pos_emb, new_mask.unsqueeze(1) + + def position_encoding(self, offset: Union[int, torch.Tensor], + size: int) -> torch.Tensor: + return self.pos_enc_class.position_encoding(offset, size)