File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,10 @@ public static string StringPiece(IntPtr handle)
5353
5454 public unsafe static byte [ ] ByteStringPiece ( Buffer ? handle )
5555 {
56- if ( handle is null ) {
56+ if ( handle is null )
57+ {
5758 return new byte [ 0 ] ;
59+ }
5860 var data = handle . ToArray ( ) ;
5961 return data ;
6062 }
Original file line number Diff line number Diff line change @@ -576,8 +576,14 @@ public static bool inside_function()
576576 public static HandleData get_resource_handle_data ( Tensor graph_op )
577577 {
578578 var handle_data = c_api . TFC_GetHandleShapeAndType ( graph_op . graph . c_graph , graph_op . _as_tf_output ( ) ) ;
579- var handle_str = c_api . ByteStringPiece ( handle_data . DangerousGetHandle ( ) == IntPtr . Zero ? null : new Buffer ( handle_data ) ) ;
580- return HandleData . Parser . ParseFrom ( handle_str ) ;
579+ try {
580+ var handle_str = c_api . ByteStringPiece ( handle_data . DangerousGetHandle ( ) == IntPtr . Zero ? null : new Buffer ( handle_data ) ) ;
581+ return HandleData . Parser . ParseFrom ( handle_str ) ;
582+ }
583+ catch ( Exception ) {
584+ var handle_str = c_api . ByteStringPieceFromNativeString ( handle_data . DangerousGetHandle ( ) ) ;
585+ return HandleData . Parser . ParseFrom ( handle_str ) ;
586+ }
581587 }
582588
583589 public static void dismantle_graph ( Graph graph )
You can’t perform that action at this time.
0 commit comments