33import pytest
44import torch
55
6- from benchmark .attri_util import FLOAT_DTYPES , BenchLevel
7- from benchmark .performance_utils import Config , GenericBenchmark , generate_tensor_input
6+ from . import base , consts , utils
87
98
109def avg_pool3d_input_fn (shape , dtype , device ):
11- inp = generate_tensor_input (shape , dtype , device )
10+ inp = utils . generate_tensor_input (shape , dtype , device )
1211 # Common case
1312 yield inp , {
1413 "kernel_size" : 3 ,
@@ -18,7 +17,7 @@ def avg_pool3d_input_fn(shape, dtype, device):
1817 "count_include_pad" : True ,
1918 "divisor_override" : None ,
2019 }
21- if Config .bench_level == BenchLevel .COMPREHENSIVE :
20+ if base . Config .bench_level == consts . BenchLevel .COMPREHENSIVE :
2221 # With count_include_pad=False
2322 yield inp , {
2423 "kernel_size" : 3 ,
@@ -49,8 +48,8 @@ def avg_pool3d_input_fn(shape, dtype, device):
4948 }
5049
5150
52- class AvgPool3dBenchmark (GenericBenchmark ):
53- def get_input_iter (self , cur_dtype ) -> Generator :
51+ class AvgPool3dBenchmark (base . GenericBenchmark ):
52+ def get_input_iter (self , dtype ) -> Generator :
5453 shapes_5d = [
5554 (4 , 3 , 16 , 56 , 56 ),
5655 (8 , 64 , 8 , 28 , 28 ),
@@ -59,7 +58,7 @@ def get_input_iter(self, cur_dtype) -> Generator:
5958 ]
6059
6160 for shape in shapes_5d :
62- yield from self .input_fn (shape , cur_dtype , self .device )
61+ yield from self .input_fn (shape , dtype , self .device )
6362
6463
6564@pytest .mark .avg_pool3d
@@ -68,18 +67,18 @@ def test_perf_avg_pool3d():
6867 input_fn = avg_pool3d_input_fn ,
6968 op_name = "avg_pool3d" ,
7069 torch_op = torch .ops .aten .avg_pool3d ,
71- dtypes = FLOAT_DTYPES ,
70+ dtypes = consts . FLOAT_DTYPES ,
7271 )
7372 bench .run ()
7473
7574
76- @pytest .mark .avg_pool3d
75+ @pytest .mark .avg_pool3d_backward
7776def test_perf_avg_pool3d_backward ():
7877 bench = AvgPool3dBenchmark (
7978 input_fn = avg_pool3d_input_fn ,
8079 op_name = "avg_pool3d" ,
8180 torch_op = torch .ops .aten .avg_pool3d ,
82- dtypes = FLOAT_DTYPES ,
81+ dtypes = consts . FLOAT_DTYPES ,
8382 is_backward = True ,
8483 )
8584 bench .run ()
0 commit comments