From 45213fb1204fe04dcfe26d34dabe0d321b48fddd Mon Sep 17 00:00:00 2001 From: ydshieh Date: Fri, 1 Dec 2023 17:30:52 +0100 Subject: [PATCH 1/3] fix --- tests/models/tvp/test_modeling_tvp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/models/tvp/test_modeling_tvp.py b/tests/models/tvp/test_modeling_tvp.py index ebdd4fb0b7694b..be0cfbd398ad5c 100644 --- a/tests/models/tvp/test_modeling_tvp.py +++ b/tests/models/tvp/test_modeling_tvp.py @@ -230,10 +230,10 @@ def test_inference_no_head(self): image_processor = self.default_image_processor image = prepare_img() - encoding = image_processor(images=image, return_tensors="pt").to(torch_device) + encoding = image_processor(images=image, return_tensors="pt") input_ids = torch.tensor([[1, 2]]) attention_mask = torch.tensor([[1, 1]]) - encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}) + encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}).to(torch_device) with torch.no_grad(): outputs = model(**encoding) @@ -250,10 +250,10 @@ def test_inference_with_head(self): image_processor = self.default_image_processor image = prepare_img() - encoding = image_processor(images=image, return_tensors="pt").to(torch_device) + encoding = image_processor(images=image, return_tensors="pt") input_ids = torch.tensor([[1, 2]]) attention_mask = torch.tensor([[1, 1]]) - encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}) + encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}).to(torch_device) with torch.no_grad(): outputs = model(**encoding) From 0a30bf518870f8f731675e5e130bc18812aba895 Mon Sep 17 00:00:00 2001 From: ydshieh Date: Fri, 1 Dec 2023 17:32:54 +0100 Subject: [PATCH 2/3] fix --- tests/models/tvp/test_modeling_tvp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/models/tvp/test_modeling_tvp.py b/tests/models/tvp/test_modeling_tvp.py index be0cfbd398ad5c..15c4938e2c526f 100644 --- a/tests/models/tvp/test_modeling_tvp.py +++ b/tests/models/tvp/test_modeling_tvp.py @@ -233,7 +233,8 @@ def test_inference_no_head(self): encoding = image_processor(images=image, return_tensors="pt") input_ids = torch.tensor([[1, 2]]) attention_mask = torch.tensor([[1, 1]]) - encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}).to(torch_device) + encoding.update({"input_ids": input_ids, "attention_mask": attention_mask})\ + encoding.to(torch_device) with torch.no_grad(): outputs = model(**encoding) @@ -253,7 +254,8 @@ def test_inference_with_head(self): encoding = image_processor(images=image, return_tensors="pt") input_ids = torch.tensor([[1, 2]]) attention_mask = torch.tensor([[1, 1]]) - encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}).to(torch_device) + encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}) + encoding.to(torch_device) with torch.no_grad(): outputs = model(**encoding) From 56c15ce24f93a40c4a917b849e05c2c75348a5ea Mon Sep 17 00:00:00 2001 From: ydshieh Date: Fri, 1 Dec 2023 17:33:44 +0100 Subject: [PATCH 3/3] fix --- tests/models/tvp/test_modeling_tvp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/models/tvp/test_modeling_tvp.py b/tests/models/tvp/test_modeling_tvp.py index 15c4938e2c526f..14ec02ed6fd9a9 100644 --- a/tests/models/tvp/test_modeling_tvp.py +++ b/tests/models/tvp/test_modeling_tvp.py @@ -233,7 +233,7 @@ def test_inference_no_head(self): encoding = image_processor(images=image, return_tensors="pt") input_ids = torch.tensor([[1, 2]]) attention_mask = torch.tensor([[1, 1]]) - encoding.update({"input_ids": input_ids, "attention_mask": attention_mask})\ + encoding.update({"input_ids": input_ids, "attention_mask": attention_mask}) encoding.to(torch_device) with torch.no_grad():