@@ -253,7 +253,7 @@ def to_jit(self, *values, **kwargs):
253
253
"""
254
254
self .info ("+" , "to_jit" , args = values , kwargs = kwargs )
255
255
annotations = self .f .__annotations__
256
- if len ( annotations ) > 0 :
256
+ if annotations :
257
257
input_to_kwargs = {}
258
258
kwargs_to_input = {}
259
259
names = list (annotations .keys ())
@@ -352,10 +352,10 @@ def to_jit(self, *values, **kwargs):
352
352
if iname in constraints
353
353
]
354
354
names = [i .name for i in inputs ]
355
- if len ( new_kwargs ) > 0 :
355
+ if new_kwargs :
356
356
# An attribute is not named in the numpy API
357
357
# but is the ONNX definition.
358
- if len ( kwargs ) == 0 :
358
+ if not kwargs :
359
359
kwargs = new_kwargs
360
360
else :
361
361
kwargs = kwargs .copy ()
@@ -375,13 +375,13 @@ def to_jit(self, *values, **kwargs):
375
375
target_opsets = self .target_opsets ,
376
376
ir_version = self .ir_version ,
377
377
)
378
- if len ( values ) > 0 and len ( values [0 ].shape ) == 0 :
378
+ if values and not values [0 ].shape :
379
379
inps = onx .graph .input [0 ]
380
380
shape = []
381
381
for d in inps .type .tensor_type .shape .dim :
382
382
v = d .dim_value if d .dim_value > 0 else d .dim_param
383
383
shape .append (v )
384
- if len ( shape ) != 0 :
384
+ if shape :
385
385
raise RuntimeError (
386
386
f"Shape mismatch, values[0]={ values [0 ]} "
387
387
f"and inputs={ onx .graph .input } ."
@@ -441,7 +441,7 @@ def move_input_to_kwargs(
441
441
f"self.input_to_kwargs_ is not initialized for function { self .f } "
442
442
f"from module { self .f .__module__ !r} ."
443
443
)
444
- if len ( self .input_to_kwargs_ ) == 0 :
444
+ if not self .input_to_kwargs_ :
445
445
return values , kwargs
446
446
new_values = []
447
447
new_kwargs = kwargs .copy ()
0 commit comments