Skip to content

Commit 72f0cf4

Browse files
teekenlyiliu30
authored andcommitted
Add more test scenario for tensor schema (vllm-project#22733)
Signed-off-by: teekenl <[email protected]>
1 parent 0bafb59 commit 72f0cf4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/utils_/test_tensor_schema.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,31 @@ def test_tensor_schema_constant_dim_failure():
3333
)
3434

3535

36+
def test_tensor_schema_invalid_types_in_list():
37+
with pytest.raises(ValueError, match="is not a torch.Tensor"):
38+
Phi3VImagePixelInputs(
39+
data=[
40+
torch.randn(64, 3, 32, 32),
41+
"not_a_tensor",
42+
torch.randn(64, 3, 32, 32),
43+
],
44+
image_sizes=torch.randint(0, 256, (3, 2)),
45+
)
46+
47+
48+
def test_tensor_schema_rank_mismatch():
49+
with pytest.raises(ValueError, match="has rank 3 but expected 5"):
50+
Phi3VImagePixelInputs(
51+
data=torch.randn(16, 64, 3),
52+
image_sizes=torch.randint(0, 256, (16, 2)),
53+
)
54+
55+
56+
def test_tensor_schema_missing_required_field():
57+
with pytest.raises(ValueError, match="Required field 'data' is missing"):
58+
Phi3VImagePixelInputs(image_sizes=torch.randint(0, 256, (16, 2)), )
59+
60+
3661
def test_tensor_schema_symbolic_dim_mismatch():
3762
with pytest.raises(ValueError, match="expected 'bn'=12, got 16"):
3863
Phi3VImagePixelInputs(

0 commit comments

Comments
 (0)