You need to sign in or sign up before continuing.
Commit ea6cc1da authored by Christian Clauss's avatar Christian Clauss Committed by Facebook Github Bot
Browse files

Use ==/!= to compare str, bytes, and int literals (#948)

Summary:
Identity is not the same thing as equality in Python.
Pull Request resolved: https://github.com/pytorch/fairseq/pull/948

Differential Revision: D16608269

Pulled By: myleott

fbshipit-source-id: be203d62e7824c96c59400d1b342196adb89a839
parent 45f23f66
...@@ -35,7 +35,7 @@ class SparseMultiheadAttention(MultiheadAttention): ...@@ -35,7 +35,7 @@ class SparseMultiheadAttention(MultiheadAttention):
# Used for Ai(2) calculations - beginning of [l-c, l] range # Used for Ai(2) calculations - beginning of [l-c, l] range
def compute_checkpoint(self, word_index): def compute_checkpoint(self, word_index):
if word_index % self.stride == 0 and word_index is not 0: if word_index % self.stride == 0 and word_index != 0:
checkpoint_index = word_index - self.expressivity checkpoint_index = word_index - self.expressivity
else: else:
checkpoint_index = ( checkpoint_index = (
...@@ -66,7 +66,7 @@ class SparseMultiheadAttention(MultiheadAttention): ...@@ -66,7 +66,7 @@ class SparseMultiheadAttention(MultiheadAttention):
# Subset 1 - whole window # Subset 1 - whole window
rounded_index = math.floor((word_index + self.stride) / self.stride) * self.stride rounded_index = math.floor((word_index + self.stride) / self.stride) * self.stride
if word_index % self.stride == 0 and word_index is not 0: if word_index % self.stride == 0 and word_index != 0:
subset_one = set(range(word_index-self.stride, min(absolute_max, word_index+1))) subset_one = set(range(word_index-self.stride, min(absolute_max, word_index+1)))
else: else:
subset_one = set(range(max(0, rounded_index - self.stride), min( subset_one = set(range(max(0, rounded_index - self.stride), min(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment