@@ -61,7 +61,7 @@ public static Tensor[] _GradientsHelper(Tensor[] ys,
6161 string grad_scope = scope ;
6262 // Get a uid for this call to gradients that can be used to help
6363 // cluster ops for compilation.
64- var gradient_uid = ops . get_default_graph ( ) . unique_name ( "uid" ) ;
64+ var gradient_uid = curr_graph . unique_name ( "uid" ) ;
6565 ys = ops . convert_n_to_tensor_or_indexed_slices ( ys , name : "y" ) ;
6666 xs = ops . internal_convert_n_to_tensor_or_indexed_slices ( xs , name : "x" , as_ref : true ) ;
6767 grad_ys = _DefaultGradYs ( grad_ys , ys , colocate_gradients_with_ops , gradient_uid ) ;
@@ -80,7 +80,7 @@ public static Tensor[] _GradientsHelper(Tensor[] ys,
8080 var to_ops = ys . Select ( x => x . op ) . ToList ( ) ;
8181 var from_ops = xs . Select ( x => x . op ) . ToList ( ) ;
8282 var stop_gradient_ops = stop_gradients . Select ( x => x . op ) . ToList ( ) ;
83- ( var reachable_to_ops , var pending_count , var loop_state ) = _PendingCount ( to_ops , from_ops , colocate_gradients_with_ops , new List < object > ( ) , xs ) ;
83+ var ( reachable_to_ops , pending_count , loop_state ) = _PendingCount ( to_ops , from_ops , colocate_gradients_with_ops , new List < object > ( ) , xs ) ;
8484
8585 foreach ( var ( y , grad_y ) in zip ( ys , grad_ys ) )
8686 _SetGrad ( grads , y , grad_y ) ;
@@ -168,7 +168,7 @@ public static Tensor[] _GradientsHelper(Tensor[] ys,
168168 {
169169 if ( in_grad != null )
170170 {
171- if ( in_grad is Tensor &&
171+ if ( ! ( in_grad is null ) &&
172172 in_grad . Tag == null && // maybe a IndexedSlice
173173 t_in . dtype != TF_DataType . TF_RESOURCE )
174174 {
0 commit comments