use i&i-1 to judge if it is a power of 2

This commit is contained in:
yaozengwei 2022-07-08 17:16:10 +08:00
parent 2057124004
commit e3e8b1990c
2 changed files with 4 additions and 4 deletions

View File

@ -1252,8 +1252,8 @@ class EmformerEncoder(nn.Module):
):
super().__init__()
assert int(math.log(chunk_length, 2)) == math.log(
chunk_length, 2
assert (
chunk_length - 1 & chunk_length == 0
), "chunk_length should be a power of 2."
self.use_memory = memory_size > 0

View File

@ -1188,8 +1188,8 @@ class EmformerEncoder(nn.Module):
):
super().__init__()
assert int(math.log(chunk_length, 2)) == math.log(
chunk_length, 2
assert (
chunk_length - 1 & chunk_length == 0
), "chunk_length should be a power of 2."
self.use_memory = memory_size > 0