@@ -638,6 +638,14 @@ public static Tensor floor_div(Tensor x, Tensor y, string name = null)
638638 /// <returns></returns>
639639 public static Tensor mat_mul ( Tensor a , Tensor b , bool transpose_a = false , bool transpose_b = false , string name = null )
640640 {
641+ if ( tf . context . executing_eagerly ( ) )
642+ {
643+ var _result = wrap_tfe_src . TFE_Py_FastPathExecute ( tf . context , tf . context . device_name ,
644+ "MatMul" , name , null ,
645+ a , b , "transpose_a" , transpose_a , "transpose_b" , transpose_b ) ;
646+ return _result ;
647+ }
648+
641649 var _op = _op_def_lib . _apply_op_helper ( "MatMul" , name , args : new { a , b , transpose_a , transpose_b } ) ;
642650
643651 return _op . output ;
@@ -738,17 +746,37 @@ public static Tensor _sum<Tx, Ty>(Tx input, Ty axis = default, bool keep_dims =
738746 {
739747 if ( tf . context . executing_eagerly ( ) )
740748 {
741- var _result = wrap_tfe_src . TFE_Py_FastPathExecute ( tf . context , tf . context . device_name ,
742- "Sum" , name , null ,
743- input , axis , "keep_dims" , keep_dims ) ;
744- return _result ;
749+ try
750+ {
751+ var _result = wrap_tfe_src . TFE_Py_FastPathExecute ( tf . context , tf . context . device_name ,
752+ "Sum" , name , null ,
753+ input , axis , "keep_dims" , keep_dims ) ;
754+ return _result ;
755+ }
756+ catch ( Exception )
757+ {
758+ return _sum_eager_fallback ( input as Tensor [ ] , axis as Tensor ,
759+ keep_dims : keep_dims , name : name , ctx : tf . context ) ;
760+ }
745761 }
746762
747763 var _op = _op_def_lib . _apply_op_helper ( "Sum" , name , args : new { input , reduction_indices = axis , keep_dims } ) ;
748764
749765 return _op . outputs [ 0 ] ;
750766 }
751767
768+ private static Tensor _sum_eager_fallback ( Tensor [ ] inputs , Tensor axis , bool keep_dims = false , string name = null , Context ctx = null )
769+ {
770+ var ( _attr_T , input ) = _execute . args_to_matching_eager ( inputs , ctx ) ;
771+ var ( _attr_Tidx , axis1 ) = _execute . args_to_matching_eager ( new [ ] { axis } , ctx , TF_DataType . TF_INT32 ) ;
772+ var _inputs_flat = new Tensor [ ] { input , axis1 } ;
773+
774+ var _attrs = new object [ ] { "keep_dims" , keep_dims , "T" , _attr_T , "Tidx" , _attr_Tidx } ;
775+
776+ var _result = _execute . execute ( ctx , "Sum" , _inputs_flat , _attrs , name : name ) ;
777+ return _result ;
778+ }
779+
752780 /// <summary>
753781 /// Creates a sequence of numbers.
754782 /// </summary>
0 commit comments