@@ -173,6 +173,62 @@ def conv_depthwise2d_input_fn(shape, dtype, device):
173173 bench .run ()
174174
175175
176+ class CudnnConvolutionBenchmark (GenericBenchmark ):
177+ def set_more_shapes (self ):
178+ return [
179+ (1 , 2 , 5 , 5 , 1 , 3 , 3 , 1 , 0 , 1 , 1 ),
180+ (2 , 3 , 9 , 9 , 1 , 3 , 3 , 1 , 1 , 1 , 1 ),
181+ (32 , 8 , 8 , 8 , 32 , 2 , 2 , 1 , 0 , 1 , 1 ),
182+ (32 , 64 , 128 , 128 , 32 , 3 , 3 , 1 , 2 , 1 , 1 ),
183+ (32 , 64 , 210 , 210 , 16 , 5 , 5 , 2 , 1 , 1 , 1 ),
184+ (16 , 32 , 24 , 24 , 24 , 3 , 3 , 2 , 2 , 2 , 2 ),
185+ ]
186+
187+
188+ @pytest .mark .cudnn_convolution
189+ def test_perf_cudnn_convolution ():
190+ def cudnn_conv_input_fn (shape , dtype , device ):
191+ (
192+ batch ,
193+ input_c ,
194+ input_h ,
195+ input_w ,
196+ out_c ,
197+ kernel_h ,
198+ kernel_w ,
199+ stride ,
200+ padding ,
201+ groups ,
202+ dilation ,
203+ ) = shape
204+ input_shape = (batch , input_c , input_h , input_w )
205+ weight_shape = (out_c , input_c // groups , kernel_h , kernel_w )
206+ input = torch .randn (size = input_shape , device = device , dtype = dtype )
207+ weight = torch .randn (size = weight_shape , device = device , dtype = dtype )
208+
209+ yield {
210+ "input" : input ,
211+ "weight" : weight ,
212+ "padding" : [padding , padding ],
213+ "stride" : [stride , stride ],
214+ "dilation" : [dilation , dilation ],
215+ "groups" : groups ,
216+ "benchmark" : False ,
217+ "deterministic" : False ,
218+ "allow_tf32" : False ,
219+ },
220+
221+ torch .backends .cudnn .allow_tf32 = False
222+ bench = CudnnConvolutionBenchmark (
223+ input_fn = cudnn_conv_input_fn ,
224+ op_name = "cudnn_convolution" ,
225+ torch_op = torch .cudnn_convolution ,
226+ dtypes = [torch .float16 , torch .float32 ],
227+ )
228+ bench .set_gems (flag_gems .cudnn_convolution )
229+ bench .run ()
230+
231+
176232class Conv3DBenchmark (GenericBenchmark ):
177233 def set_more_shapes (self ):
178234 return None
0 commit comments