"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "b242d0f297aa87a0c8d99657a53691ece2dfe492"
Unverified Commit d984b103 authored by Tavin Turner's avatar Tavin Turner Committed by GitHub
Browse files

Add 'with torch.no_grad()' to BEiT integration test forward passes (#14961)

* Add 'with torch.no_grad()' to BEiT integration test forward pass

* Fix inconsistent use of tabs and spaces in indentation
parent 09f9d072
...@@ -435,7 +435,8 @@ class BeitModelIntegrationTest(unittest.TestCase): ...@@ -435,7 +435,8 @@ class BeitModelIntegrationTest(unittest.TestCase):
bool_masked_pos = torch.ones((1, 196), dtype=torch.bool).to(torch_device) bool_masked_pos = torch.ones((1, 196), dtype=torch.bool).to(torch_device)
# forward pass # forward pass
outputs = model(pixel_values=pixel_values, bool_masked_pos=bool_masked_pos) with torch.no_grad():
outputs = model(pixel_values=pixel_values, bool_masked_pos=bool_masked_pos)
logits = outputs.logits logits = outputs.logits
# verify the logits # verify the logits
...@@ -457,7 +458,8 @@ class BeitModelIntegrationTest(unittest.TestCase): ...@@ -457,7 +458,8 @@ class BeitModelIntegrationTest(unittest.TestCase):
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device) inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)
# forward pass # forward pass
outputs = model(**inputs) with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits logits = outputs.logits
# verify the logits # verify the logits
...@@ -482,7 +484,8 @@ class BeitModelIntegrationTest(unittest.TestCase): ...@@ -482,7 +484,8 @@ class BeitModelIntegrationTest(unittest.TestCase):
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device) inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)
# forward pass # forward pass
outputs = model(**inputs) with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits logits = outputs.logits
# verify the logits # verify the logits
...@@ -508,7 +511,8 @@ class BeitModelIntegrationTest(unittest.TestCase): ...@@ -508,7 +511,8 @@ class BeitModelIntegrationTest(unittest.TestCase):
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device) inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)
# forward pass # forward pass
outputs = model(**inputs) with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits logits = outputs.logits
# verify the logits # verify the logits
......
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