File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
pytensor/tensor/rewriting Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -413,7 +413,10 @@ def local_replace_slice(fgraph, node):
413
413
idx_flag = True
414
414
start = None
415
415
416
- if extract_constant (stop , only_process_constants = True ) == x .type .shape [dim ]:
416
+ if (
417
+ x .type .shape [dim ] is not None
418
+ and extract_constant (stop , only_process_constants = True ) == x .type .shape [dim ]
419
+ ):
417
420
idx_flag = True
418
421
stop = None
419
422
@@ -423,8 +426,13 @@ def local_replace_slice(fgraph, node):
423
426
424
427
new_idxs [dim ] = slice (start , stop , step )
425
428
426
- assert node .outputs [0 ].type == x [tuple (new_idxs )].type
427
429
if idx_flag is True :
430
+ try :
431
+ assert node .outputs [0 ].type == x [tuple (new_idxs )].type
432
+ except AssertionError :
433
+ raise AssertionError (
434
+ f"The type of the returned variable { x [tuple (new_idxs )].type } did not match with the type of the original variable { node .outputs [0 ].type } "
435
+ )
428
436
return [x [tuple (new_idxs )]]
429
437
430
438
You can’t perform that action at this time.
0 commit comments