@@ -42,25 +42,15 @@ def _check_instance(x, x_name, types=(int, float)):
4242 format (types , x_name , type (x )))
4343
4444
45- def _check_value_limitation (x , x_name , min_limit = 1e-3 , max_limit = None ):
46- def _check_value (x , x_name , min_limit = 1e-3 , max_limit = None ):
45+ def _check_value_limitation (x , x_name , min_limit = 1e-3 ):
46+ def _check_value (x , x_name , min_limit = 1e-3 ):
4747 if isinstance (x , int ) and min_limit is not None and x < min_limit :
4848 raise ValueError (
4949 "Excepted the input {} to be greater than {} but received x: {}. " .
5050 format (x_name , min_limit , x ))
51- if isinstance (x , int ) and max_limit is not None and x > max_limit :
52- raise ValueError (
53- "Excepted the input {} to be less than {} but received x: {}. " .
54- format (x_name , max_limit , x ))
55-
56- if isinstance (x , (list , tuple )):
57- for ele in x :
58- _check_value (ele , x_name )
59- elif isinstance (x , (int , float )):
60- _check_value (x , x_name )
61- else :
62- raise ValueError ("Excepted {} type for {} but received type: {}. " .
63- format ((int , list , tuple ), x_name , type (x )))
51+
52+ for ele in x :
53+ _check_value (ele , x_name )
6454
6555
6656def _zero_padding_in_batch_and_channel (padding , channel_last ):
@@ -232,9 +222,8 @@ def avg_pool1d(x,
232222 stride = utils .convert_to_list (stride , 1 , 'pool_stride' )
233223 stride = [1 ] + stride
234224
235- _check_value_limitation (
236- kernel_size , "kernel_size" , min_limit = 1e-3 , max_limit = None )
237- _check_value_limitation (stride , "stride" , min_limit = 1e-3 , max_limit = None )
225+ _check_value_limitation (kernel_size , "kernel_size" , min_limit = 1e-3 )
226+ _check_value_limitation (stride , "stride" , min_limit = 1e-3 )
238227
239228 channel_last = _channel_last ("NCL" , 1 )
240229 padding , padding_algorithm = _update_padding_nd (
@@ -350,9 +339,8 @@ def avg_pool2d(x,
350339 else :
351340 stride = utils .convert_to_list (stride , 2 , 'pool_stride' )
352341
353- _check_value_limitation (
354- kernel_size , "kernel_size" , min_limit = 1e-3 , max_limit = None )
355- _check_value_limitation (stride , "stride" , min_limit = 1e-3 , max_limit = None )
342+ _check_value_limitation (kernel_size , "kernel_size" , min_limit = 1e-3 )
343+ _check_value_limitation (stride , "stride" , min_limit = 1e-3 )
356344
357345 channel_last = _channel_last (data_format , 2 )
358346 padding , padding_algorithm = _update_padding_nd (
@@ -477,9 +465,8 @@ def avg_pool3d(x,
477465 padding , padding_algorithm = _update_padding_nd (
478466 padding , 3 , channel_last = channel_last , ceil_mode = ceil_mode )
479467
480- _check_value_limitation (
481- kernel_size , "kernel_size" , min_limit = 1e-3 , max_limit = None )
482- _check_value_limitation (stride , "stride" , min_limit = 1e-3 , max_limit = None )
468+ _check_value_limitation (kernel_size , "kernel_size" , min_limit = 1e-3 )
469+ _check_value_limitation (stride , "stride" , min_limit = 1e-3 )
483470
484471 if in_dygraph_mode ():
485472 output = _C_ops .pool3d (
0 commit comments