@@ -119,11 +119,43 @@ public static Tensor expand_dims(Tensor input, int axis, string name = null)
119119
120120 public static Tensor gather_v2 < T1 , T2 > ( T1 @params , T2 indices , int axis , string name = null )
121121 {
122+ if ( tf . Context . executing_eagerly ( ) )
123+ {
124+ try
125+ {
126+ var results = tf . Runner . TFE_FastPathExecute ( new FastPathOpExecInfo ( "GatherV2" , name , @params , indices , axis , "batch_dims" )
127+ {
128+ ctx = tf . Context ,
129+ device_name = tf . Context . DeviceName
130+ } ) ;
131+ return results [ 0 ] ;
132+ }
133+ catch ( Exception exc )
134+ {
135+ return gather_v2_eager_fallback ( @params , indices , axis , name , tf . Context ) ;
136+ }
137+ }
138+
122139 var _op = tf . OpDefLib . _apply_op_helper ( "GatherV2" , name : name , new { @params , indices , axis } ) ;
123140
124141 return _op . outputs [ 0 ] ;
125142 }
126143
144+ private static Tensor gather_v2_eager_fallback ( object @params , object indices , int axis , string name , Context ctx )
145+ {
146+ var ( _attr_T , param ) = tf . Runner . ArgsToMatchingEager ( ctx , args : new [ ] { @params } ) ;
147+ var ( _attr_Tindice , indice ) = tf . Runner . ArgsToMatchingEager ( ctx , default_dtype : tf . int32 , args : new [ ] { indices } ) ;
148+ var ( _attr_Taxis , axiss ) = tf . Runner . ArgsToMatchingEager ( ctx , default_dtype : tf . int32 , args : new object [ ] { axis } ) ;
149+ var _inputs_flat = param . concat ( indice ) . concat ( axiss ) ;
150+ var _attrs = new object [ ] { "batch_dims" , 0 , "Tparams" , _attr_T , "Tindices" , _attr_Tindice , "Taxis" , _attr_Taxis } ;
151+
152+ var results = tf . Runner . Execute ( ctx , "GatherV2" , 1 , _inputs_flat , _attrs , name : name ) ;
153+ if ( tf . Runner . MustRecordGradient ( ) )
154+ tf . Runner . RecordGradient ( "GatherV2" , _inputs_flat , _attrs , results ) ;
155+ return results [ 0 ] ;
156+ }
157+
158+
127159 public static Tensor pad ( Tensor input , Tensor paddings , string name = null )
128160 {
129161 if ( tf . Context . executing_eagerly ( ) )
0 commit comments