File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -451,28 +451,26 @@ def convert_shape(shape: Shape) -> Optional[WeakShape]:
451
451
return None
452
452
if isinstance (shape , int ) or (isinstance (size , TensorVariable ) and shape .ndim == 0 ):
453
453
shape = (shape ,)
454
- if isinstance (shape , TensorVariable ) and shape .ndim == 1 :
454
+ elif isinstance (shape , TensorVariable ) and shape .ndim == 1 :
455
455
shape = tuple (shape )
456
456
elif isinstance (shape , (list , tuple )):
457
457
shape = tuple (shape )
458
458
else :
459
459
raise ValueError (
460
460
f"The `shape` parameter must be a tuple, TensorVariable, int or list. Actual: { type (shape )} "
461
461
)
462
-
463
462
if isinstance (shape , tuple ) and any (s == Ellipsis for s in shape [:- 1 ]):
464
463
raise ValueError (
465
464
f"Ellipsis in `shape` may only appear in the last position. Actual: { shape } "
466
465
)
467
-
468
466
return shape
469
467
470
468
471
469
def convert_size (size : Size ) -> Optional [StrongSize ]:
472
470
"""Process a user-provided size variable into None or a valid size object."""
473
471
if size is None :
474
472
return None
475
- if isinstance (size , int ) or (isinstance (size , TensorVariable ) and size .ndim == 0 ):
473
+ elif isinstance (size , int ) or (isinstance (size , TensorVariable ) and size .ndim == 0 ):
476
474
size = (size ,)
477
475
elif isinstance (size , TensorVariable ) and size .ndim == 1 :
478
476
size = tuple (size )
You can’t perform that action at this time.
0 commit comments