@@ -542,45 +542,49 @@ public static Tensor crop_to_bounding_box(Tensor image, int offset_height, int o
542542 image_shape ) ) ;
543543 }
544544
545- var assert_ops = _CheckAtLeast3DImage ( image , require_static : false ) ;
545+ var assert_ops = _CheckAtLeast3DImage ( image , require_static : false ) . ToList ( ) ;
546546
547547 // batch: [0], height: [1], width: [2], depth: [3]
548548 var bhwd = _ImageDimensions ( image , rank : 4 ) ;
549549
550- assert_ops [ assert_ops . Length ] = _assert ( check_ops . assert_greater_equal ( tf . constant ( offset_height ) ,
550+ assert_ops . Add ( _assert ( check_ops . assert_greater_equal ( tf . constant ( offset_height ) ,
551551 tf . constant ( 0 ) ) , typeof ( ValueError ) ,
552- "offset_height must be >= 0." ) ;
553- assert_ops [ assert_ops . Length ] = _assert ( check_ops . assert_greater_equal ( tf . constant ( offset_width ) ,
552+ "offset_height must be >= 0." ) ) ;
553+ assert_ops . Add ( _assert ( check_ops . assert_greater_equal ( tf . constant ( offset_width ) ,
554554 tf . constant ( 0 ) ) , typeof ( ValueError ) ,
555- "offset_width must be >= 0." ) ;
556- assert_ops [ assert_ops . Length ] = _assert ( check_ops . assert_less ( tf . constant ( 0 ) ,
555+ "offset_width must be >= 0." ) ) ;
556+ assert_ops . Add ( _assert ( check_ops . assert_less ( tf . constant ( 0 ) ,
557557 tf . constant ( target_width ) ) , typeof ( ValueError ) ,
558- "target_width must be > 0." ) ;
559- assert_ops [ assert_ops . Length ] = _assert ( check_ops . assert_less ( tf . constant ( 0 ) ,
558+ "target_width must be > 0." ) ) ;
559+ assert_ops . Add ( _assert ( check_ops . assert_less ( tf . constant ( 0 ) ,
560560 tf . constant ( target_height ) ) , typeof ( ValueError ) ,
561- "target_height must be > 0." ) ;
562- assert_ops [ assert_ops . Length ] = _assert ( check_ops . assert_greater_equal ( tf . constant ( bhwd [ 2 ] ) ,
561+ "target_height must be > 0." ) ) ;
562+ assert_ops . Add ( _assert ( check_ops . assert_greater_equal ( tf . constant ( bhwd [ 2 ] ) ,
563563 tf . constant ( target_width + offset_width ) ) ,
564564 typeof ( ValueError ) ,
565- "width must be >= target + offset." ) ;
566- assert_ops [ assert_ops . Length ] = _assert ( check_ops . assert_greater_equal ( tf . constant ( bhwd [ 1 ] ) ,
565+ "width must be >= target + offset." ) ) ;
566+ assert_ops . Add ( _assert ( check_ops . assert_greater_equal ( tf . constant ( bhwd [ 1 ] ) ,
567567 tf . constant ( target_height + offset_height ) ) ,
568568 typeof ( ValueError ) ,
569- "height must be >= target + offset." ) ;
570- image = control_flow_ops . with_dependencies ( assert_ops , image ) ;
569+ "height must be >= target + offset." ) ) ;
570+ image = control_flow_ops . with_dependencies ( assert_ops . ToArray ( ) , image ) ;
571571
572572 var cropped = array_ops . slice (
573573 image , array_ops . stack ( new [ ] { 0 , offset_height , offset_width , 0 } ) ,
574574 array_ops . stack ( new [ ] { - 1 , target_height , target_width , - 1 } ) ) ;
575575
576576 Shape cropped_shape_result ( )
577577 {
578- long [ ] i_remnants = { } ;
578+ long [ ] i_remnants = new long [ 4 ] ;
579+ int idx = 0 ;
579580 foreach ( var i in new [ ] { bhwd [ 0 ] , target_height , target_width , bhwd [ 3 ] } )
581+ {
580582 if ( _is_tensor ( i ) )
581- return null ;
583+ i_remnants [ idx ] = - 1 ;
582584 else
583- i_remnants [ i_remnants . Length ] = i ;
585+ i_remnants [ idx ] = i ;
586+ idx ++ ;
587+ }
584588 return new Shape ( i_remnants ) ;
585589 } ;
586590 var cropped_shape = cropped_shape_result ( ) ;
0 commit comments