@@ -411,7 +411,10 @@ def forward(self, x: Tensor) -> Tensor:
411411 prepare_program = inject_subbyte_tensors ,
412412 )
413413
414- async def test_per_channel_negative_axis_numerical (self ) -> None :
414+ # (2, 4, 4): equal dims keep a wrong axis silent (a value mismatch).
415+ # (2, 3, 4): distinct dims show -1 is the last dim (a wrong axis is a reshape error).
416+ @pytest .mark .parametrize ("x" , [torch .randn (2 , 4 , 4 ), torch .randn (2 , 3 , 4 )])
417+ async def test_per_channel_negative_axis_numerical (self , x : Tensor ) -> None :
415418 """quantize with a per-channel scale on a negative axis matches eager."""
416419
417420 class Model (nn .Module ):
@@ -428,7 +431,6 @@ def forward(self, x: Tensor) -> Tensor:
428431 )
429432
430433 model = Model ()
431- x = torch .randn (2 , 4 , 4 )
432434 await validate_numerical_output (
433435 model = model , x = x , prepare_program = inject_subbyte_tensors
434436 )
@@ -562,7 +564,16 @@ def forward(self, x: Tensor) -> Tensor:
562564 prepare_program = inject_subbyte_tensors ,
563565 )
564566
565- async def test_per_channel_negative_axis_numerical (self ) -> None :
567+ # (2, 4, 4): equal dims keep a wrong axis silent (a value mismatch).
568+ # (2, 3, 4): distinct dims show -1 is the last dim (a wrong axis is a reshape error).
569+ @pytest .mark .parametrize (
570+ "x" ,
571+ [
572+ torch .randint (- 128 , 127 , (2 , 4 , 4 ), dtype = torch .int8 ),
573+ torch .randint (- 128 , 127 , (2 , 3 , 4 ), dtype = torch .int8 ),
574+ ],
575+ )
576+ async def test_per_channel_negative_axis_numerical (self , x : Tensor ) -> None :
566577 """dequantize with a per-channel scale on a negative axis matches eager."""
567578
568579 class Model (nn .Module ):
@@ -579,7 +590,6 @@ def forward(self, x: Tensor) -> Tensor:
579590 )
580591
581592 model = Model ()
582- x = torch .randint (- 128 , 127 , (2 , 4 , 4 ), dtype = torch .int8 )
583593 await validate_numerical_output (
584594 model = model , x = x , prepare_program = inject_subbyte_tensors
585595 )
0 commit comments