Skip to content

Commit 784b1eb

Browse files
committed
remove output for assign_add_variable_op.
1 parent e3034fa commit 784b1eb

4 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ protected override void DisposeUnmanagedResources(IntPtr handle)
6262
GarbageCollector.Decrease(tfe_tensor_handle);
6363
GarbageCollector.Decrease(EagerTensorHandle);
6464

65-
/*c_api.TF_DeleteTensor(_handle);
65+
/*print($"deleting DeleteTensorHandle {Id} {_handle.ToString("x16")}");
66+
c_api.TF_DeleteTensor(_handle);
6667
print($"deleting DeleteTensorHandle {Id} {tfe_tensor_handle.ToString("x16")}");
6768
c_api.TFE_DeleteTensorHandle(tfe_tensor_handle);
6869
print($"deleting DeleteEagerTensor {Id} {EagerTensorHandle.ToString("x16")}");

src/TensorFlowNET.Core/Operations/gen_resource_variable_ops.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ public static Operation assign_add_variable_op(Tensor resource, Tensor value, st
5656
{
5757
if (tf.context.executing_eagerly())
5858
{
59-
var results = new[] { new EagerTensor() };
6059
Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name,
6160
"AssignAddVariableOp", name,
6261
new IntPtr[]
6362
{
6463
resource as EagerTensor,
6564
value as EagerTensor
6665
}, 2, null,
67-
results.Select(x => x.EagerTensorHandle).ToArray(), results.Length);
66+
null, 0);
6867
status.Check(true);
69-
return results[0].Resolve();
68+
return null;
7069
}
7170

7271
return null;
@@ -76,15 +75,14 @@ public static Operation assign_variable_op(Tensor resource, Tensor value, string
7675
{
7776
if (tf.context.executing_eagerly())
7877
{
79-
var results = new EagerTensor[0];
8078
Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name,
8179
"AssignVariableOp", name,
8280
new IntPtr[]
8381
{
8482
resource as EagerTensor,
8583
value as EagerTensor
8684
}, 2, null,
87-
results.Select(x => x.EagerTensorHandle).ToArray(), results.Length);
85+
null, 0);
8886
status.Check(true);
8987
return null;
9088
}

src/TensorFlowNET.Core/System/GarbageCollector.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public static void Init()
2929

3030
public static void Increase(IntPtr handle, GCItemType type)
3131
{
32+
if (handle == IntPtr.Zero)
33+
return;
34+
3235
if (container.ContainsKey(handle))
3336
{
3437
container[handle].RefCounter++;
@@ -51,11 +54,8 @@ public static void Increase(IntPtr handle, GCItemType type)
5154

5255
public static void Decrease(IntPtr handle)
5356
{
54-
lock (locker)
55-
{
56-
if (container.ContainsKey(handle))
57-
container[handle].RefCounter--;
58-
}
57+
if (handle != IntPtr.Zero && container.ContainsKey(handle))
58+
container[handle].RefCounter--;
5959
}
6060

6161
private static void Recycle()

src/TensorFlowNET.Core/Training/gen_training_ops.py.cs renamed to src/TensorFlowNET.Core/Training/gen_training_ops.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public static Operation resource_apply_gradient_descent(EagerTensor var, EagerTe
6565
{
6666
if (tf.context.executing_eagerly())
6767
{
68-
var results = new[] { new EagerTensor() };
6968
Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name,
7069
"ResourceApplyGradientDescent", name, new IntPtr[]
7170
{
@@ -74,9 +73,9 @@ public static Operation resource_apply_gradient_descent(EagerTensor var, EagerTe
7473
delta
7574
}, 3,
7675
op => wrap_tfe_src.SetOpAttrs(op, "use_locking", use_locking),
77-
results.Select(x => x.EagerTensorHandle).ToArray(), results.Length);
76+
null, 0);
7877
status.Check(true);
79-
return results[0].Resolve();
78+
return null;
8079
}
8180

8281
var _op = _op_def_lib._apply_op_helper("ResourceApplyGradientDescent", name, new

0 commit comments

Comments
 (0)