@@ -39,6 +39,7 @@ def assert_delegated(
3939 model ,
4040 input_shape ,
4141 mocker ,
42+ request ,
4243 use_qat = False ,
4344 expected_delegated_ops : dict [Operator , int ] | None = None ,
4445 ):
@@ -58,6 +59,7 @@ def assert_delegated(
5859 model ,
5960 input_shape ,
6061 graph_verifier ,
62+ request ,
6163 dataset_creator ,
6264 use_qat = use_qat ,
6365 )
@@ -80,9 +82,9 @@ def assert_not_delegated(self, model, input_shape):
8082 ],
8183 ids = lambda s : f"input_shape = { s } " ,
8284 )
83- def test__from_addmm (self , mocker , use_qat , input_shape : tuple [int , ...]):
85+ def test__from_addmm (self , mocker , request , use_qat , input_shape : tuple [int , ...]):
8486 model = AddmmModule (input_shape [- 1 ])
85- self .assert_delegated (model , input_shape , mocker , use_qat = use_qat )
87+ self .assert_delegated (model , input_shape , mocker , request , use_qat = use_qat )
8688
8789 def test__from_addmm__unsupported_alpha (self ):
8890 input_shape = (1 , 8 )
@@ -99,20 +101,20 @@ def test__from_addmm__unsupported_beta(self):
99101 [1 , 1.0 ],
100102 ids = lambda a : f"alpha = { a } " ,
101103 )
102- def test__from_addmm__supported_alpha (self , mocker , use_qat , alpha ):
104+ def test__from_addmm__supported_alpha (self , mocker , request , use_qat , alpha ):
103105 input_shape = (1 , 8 )
104106 model = AddmmModule (input_shape [- 1 ], alpha = alpha )
105- self .assert_delegated (model , input_shape , mocker , use_qat )
107+ self .assert_delegated (model , input_shape , mocker , request , use_qat )
106108
107109 @pytest .mark .parametrize (
108110 "beta" ,
109111 [1 , 1.0 ],
110112 ids = lambda b : f"beta = { b } " ,
111113 )
112- def test__from_addmm__supported_beta (self , mocker , use_qat , beta ):
114+ def test__from_addmm__supported_beta (self , mocker , request , use_qat , beta ):
113115 input_shape = (1 , 8 )
114116 model = AddmmModule (input_shape [- 1 ], beta = beta )
115- self .assert_delegated (model , input_shape , mocker , use_qat )
117+ self .assert_delegated (model , input_shape , mocker , request , use_qat )
116118
117119 @pytest .mark .parametrize (
118120 "input_shape" ,
@@ -123,13 +125,14 @@ def test__from_addmm__supported_beta(self, mocker, use_qat, beta):
123125 ids = lambda s : f"input_shape = { s } " ,
124126 )
125127 def test__from_linear_with_bias__2d (
126- self , mocker , use_qat , input_shape : tuple [int , ...]
128+ self , mocker , request , use_qat , input_shape : tuple [int , ...]
127129 ):
128130 model = LinearModule (bias = True , in_features = input_shape [- 1 ], out_features = 7 )
129131 self .assert_delegated (
130132 model ,
131133 input_shape ,
132134 mocker ,
135+ request ,
133136 use_qat = use_qat ,
134137 expected_delegated_ops = {AddMM : 1 , PermuteCopy : 1 },
135138 )
@@ -144,7 +147,7 @@ def test__from_linear_with_bias__2d(
144147 ids = lambda s : f"input_shape = { s } " ,
145148 )
146149 def test__from_linear_with_bias__higher_ranks (
147- self , mocker , use_qat , input_shape : tuple [int , ...]
150+ self , mocker , request , use_qat , input_shape : tuple [int , ...]
148151 ):
149152 # More than 2D cases get reshaped to 2D, so two extra view_copy nodes are delegated.
150153
@@ -153,6 +156,7 @@ def test__from_linear_with_bias__higher_ranks(
153156 model ,
154157 input_shape ,
155158 mocker ,
159+ request ,
156160 use_qat = use_qat ,
157161 expected_delegated_ops = {AddMM : 1 , PermuteCopy : 1 , ViewCopy : 2 },
158162 )
0 commit comments