Skip to content
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

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add 'with torch.no_grad()' to BEiT integration test forward pass
  • Loading branch information
itsTurner committed Dec 28, 2021
commit e41e93526f80ffaa3e79197b57af1900815b20ac
12 changes: 8 additions & 4 deletions tests/test_modeling_beit.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ def test_inference_masked_image_modeling_head(self):
bool_masked_pos = torch.ones((1, 196), dtype=torch.bool).to(torch_device)

# 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

# verify the logits
Expand All @@ -457,7 +458,8 @@ def test_inference_image_classification_head_imagenet_1k(self):
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)

# forward pass
outputs = model(**inputs)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits

# verify the logits
Expand All @@ -482,7 +484,8 @@ def test_inference_image_classification_head_imagenet_22k(self):
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)

# forward pass
outputs = model(**inputs)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits

# verify the logits
Expand All @@ -508,7 +511,8 @@ def test_inference_semantic_segmentation(self):
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)

# forward pass
outputs = model(**inputs)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits

# verify the logits
Expand Down