@@ -44,13 +44,13 @@ public static Tensor add_n(Tensor[] inputs, string name = null)
4444 if ( tf . context . executing_eagerly ( ) )
4545 {
4646 using var status = new Status ( ) ;
47- var _result = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
47+ EagerTensorHandle _result = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
4848 "AddN" , name ,
4949 inputs . Select ( x => ( x as EagerTensor ) . EagerTensorHandle ) . ToArray ( ) , inputs . Length ,
5050 null ,
5151 status ) ;
5252 status . Check ( true ) ;
53- return new EagerTensor ( _result ) ;
53+ return _result ;
5454 }
5555
5656 var _op = _op_def_lib . _apply_op_helper ( "AddN" , name , args : new { inputs } ) ;
@@ -132,17 +132,17 @@ public static Tensor mean<T1, T2>(T1 input, T2 axis, bool keep_dims= false, stri
132132 if ( tf . context . executing_eagerly ( ) )
133133 {
134134 using var status = new Status ( ) ;
135- var tensor = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
135+ EagerTensorHandle tensor = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
136136 "Mean" , name ,
137137 new IntPtr [ ]
138138 {
139139 input as EagerTensor ,
140140 axis as EagerTensor
141141 } , 2 ,
142- op => wrap_tfe_src . SetOpAttrs ( tf . context , op , new object [ ] { "keep_dims" , keep_dims } , status ) ,
142+ op => wrap_tfe_src . SetOpAttrs ( op , "keep_dims" , keep_dims ) ,
143143 status ) ;
144144 status . Check ( true ) ;
145- return new EagerTensor ( tensor ) ;
145+ return tensor ;
146146 }
147147
148148 var _op = _op_def_lib . _apply_op_helper ( "Mean" , name , args : new { input , reduction_indices = axis , keep_dims = keep_dims } ) ;
@@ -185,10 +185,7 @@ public static Tensor prod<T1, T2>(T1 input, T2 axis, bool keep_dims = false, str
185185 input as EagerTensor ,
186186 axis as EagerTensor
187187 } , 2 ,
188- op => wrap_tfe_src . SetOpAttrs ( tf . context , op , new object [ ]
189- {
190- "keep_dims" , keep_dims
191- } , status ) ,
188+ op => wrap_tfe_src . SetOpAttrs ( op , "keep_dims" , keep_dims ) ,
192189 status ) ;
193190 status . Check ( true ) ;
194191 return tensor ;
@@ -232,14 +229,14 @@ public static Tensor add(Tensor x, Tensor y, string name = null)
232229 if ( tf . context . executing_eagerly ( ) )
233230 {
234231 using var status = new Status ( ) ;
235- var _result = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
232+ EagerTensorHandle _result = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
236233 "Add" , name , new IntPtr [ ]
237234 {
238235 x as EagerTensor ,
239236 y as EagerTensor
240237 } , 2 , null , status ) ;
241238 status . Check ( true ) ;
242- return new EagerTensor ( _result ) ;
239+ return _result ;
243240 }
244241
245242 var _op = _op_def_lib . _apply_op_helper ( "Add" , name , args : new { x , y } ) ;
@@ -273,14 +270,14 @@ public static Tensor add_v2<Tx, Ty>(Tx x, Ty y, string name = null)
273270 if ( tf . context . executing_eagerly ( ) )
274271 {
275272 using var status = new Status ( ) ;
276- var tensor = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
273+ EagerTensorHandle tensor = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
277274 "AddV2" , name , new IntPtr [ ]
278275 {
279276 x as EagerTensor ,
280277 y as EagerTensor
281278 } , 2 , null , status ) ;
282279 status . Check ( true ) ;
283- return new EagerTensor ( tensor ) ;
280+ return tensor ;
284281 }
285282
286283 var _op = _op_def_lib . _apply_op_helper ( "AddV2" , name , args : new { x , y } ) ;
@@ -574,6 +571,18 @@ public static Tensor squared_difference(Tensor x, Tensor y, string name = null)
574571 /// <returns> A `Tensor`. Has the same type as `x`.</returns>
575572 public static Tensor square ( Tensor x , string name = null )
576573 {
574+ if ( tf . context . executing_eagerly ( ) )
575+ {
576+ using var status = new Status ( ) ;
577+ EagerTensorHandle tensor = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
578+ "Square" , name , new IntPtr [ ]
579+ {
580+ x as EagerTensor ,
581+ } , 1 , null , status ) ;
582+ status . Check ( true ) ;
583+ return tensor ;
584+ }
585+
577586 var _op = _op_def_lib . _apply_op_helper ( "Square" , name , args : new { x } ) ;
578587
579588 return _op . outputs [ 0 ] ;
@@ -633,7 +642,7 @@ public static Tensor cast(Tensor x, TF_DataType DstT, bool Truncate= false, stri
633642 var tensor = c_api . TFE_FastPathExecute ( tf . context , tf . context . device_name ,
634643 "Cast" , name ,
635644 new IntPtr [ ] { x as EagerTensor } , 1 ,
636- op => wrap_tfe_src . SetOpAttrs ( tf . context , op , new object [ ] { "DstT" , DstT , "Truncate" , Truncate } , status ) ,
645+ op => wrap_tfe_src . SetOpAttrs ( op , "DstT" , DstT , "Truncate" , Truncate ) ,
637646 status ) ;
638647 status . Check ( true ) ;
639648 return new EagerTensor ( tensor ) ;
@@ -918,11 +927,9 @@ public static Tensor mat_mul(Tensor a, Tensor b, bool transpose_a = false, bool
918927 a as EagerTensor ,
919928 b as EagerTensor
920929 } , 2 ,
921- op => wrap_tfe_src . SetOpAttrs ( tf . context , op , new object [ ]
922- {
930+ op => wrap_tfe_src . SetOpAttrs ( op ,
923931 "transpose_a" , transpose_a ,
924- "transpose_b" , transpose_b
925- } , status ) ,
932+ "transpose_b" , transpose_b ) ,
926933 status ) ;
927934 status . Check ( true ) ;
928935 return new EagerTensor ( tensor ) ;
@@ -1049,7 +1056,7 @@ public static Tensor _sum<Tx, Ty>(Tx input, Ty axis = default, bool keep_dims =
10491056 input as EagerTensor ,
10501057 axis as EagerTensor
10511058 } , 2 ,
1052- op => wrap_tfe_src . SetOpAttrs ( tf . context , op , new object [ ] { "keep_dims" , keep_dims } , status ) ,
1059+ op => wrap_tfe_src . SetOpAttrs ( op , "keep_dims" , keep_dims ) ,
10531060 status ) ;
10541061 status . Check ( true ) ;
10551062 return new EagerTensor ( tensor ) ;
0 commit comments