| @@ -62,7 +62,8 @@ namespace Tensorflow.Eager | |||||
| GarbageCollector.Decrease(tfe_tensor_handle); | GarbageCollector.Decrease(tfe_tensor_handle); | ||||
| GarbageCollector.Decrease(EagerTensorHandle); | GarbageCollector.Decrease(EagerTensorHandle); | ||||
| /*c_api.TF_DeleteTensor(_handle); | |||||
| /*print($"deleting DeleteTensorHandle {Id} {_handle.ToString("x16")}"); | |||||
| c_api.TF_DeleteTensor(_handle); | |||||
| print($"deleting DeleteTensorHandle {Id} {tfe_tensor_handle.ToString("x16")}"); | print($"deleting DeleteTensorHandle {Id} {tfe_tensor_handle.ToString("x16")}"); | ||||
| c_api.TFE_DeleteTensorHandle(tfe_tensor_handle); | c_api.TFE_DeleteTensorHandle(tfe_tensor_handle); | ||||
| print($"deleting DeleteEagerTensor {Id} {EagerTensorHandle.ToString("x16")}"); | print($"deleting DeleteEagerTensor {Id} {EagerTensorHandle.ToString("x16")}"); | ||||
| @@ -56,7 +56,6 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (tf.context.executing_eagerly()) | if (tf.context.executing_eagerly()) | ||||
| { | { | ||||
| var results = new[] { new EagerTensor() }; | |||||
| Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name, | Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name, | ||||
| "AssignAddVariableOp", name, | "AssignAddVariableOp", name, | ||||
| new IntPtr[] | new IntPtr[] | ||||
| @@ -64,9 +63,9 @@ namespace Tensorflow | |||||
| resource as EagerTensor, | resource as EagerTensor, | ||||
| value as EagerTensor | value as EagerTensor | ||||
| }, 2, null, | }, 2, null, | ||||
| results.Select(x => x.EagerTensorHandle).ToArray(), results.Length); | |||||
| null, 0); | |||||
| status.Check(true); | status.Check(true); | ||||
| return results[0].Resolve(); | |||||
| return null; | |||||
| } | } | ||||
| return null; | return null; | ||||
| @@ -76,7 +75,6 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (tf.context.executing_eagerly()) | if (tf.context.executing_eagerly()) | ||||
| { | { | ||||
| var results = new EagerTensor[0]; | |||||
| Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name, | Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name, | ||||
| "AssignVariableOp", name, | "AssignVariableOp", name, | ||||
| new IntPtr[] | new IntPtr[] | ||||
| @@ -84,7 +82,7 @@ namespace Tensorflow | |||||
| resource as EagerTensor, | resource as EagerTensor, | ||||
| value as EagerTensor | value as EagerTensor | ||||
| }, 2, null, | }, 2, null, | ||||
| results.Select(x => x.EagerTensorHandle).ToArray(), results.Length); | |||||
| null, 0); | |||||
| status.Check(true); | status.Check(true); | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -29,6 +29,9 @@ namespace Tensorflow | |||||
| public static void Increase(IntPtr handle, GCItemType type) | public static void Increase(IntPtr handle, GCItemType type) | ||||
| { | { | ||||
| if (handle == IntPtr.Zero) | |||||
| return; | |||||
| if (container.ContainsKey(handle)) | if (container.ContainsKey(handle)) | ||||
| { | { | ||||
| container[handle].RefCounter++; | container[handle].RefCounter++; | ||||
| @@ -51,11 +54,8 @@ namespace Tensorflow | |||||
| public static void Decrease(IntPtr handle) | public static void Decrease(IntPtr handle) | ||||
| { | { | ||||
| lock (locker) | |||||
| { | |||||
| if (container.ContainsKey(handle)) | |||||
| container[handle].RefCounter--; | |||||
| } | |||||
| if (handle != IntPtr.Zero && container.ContainsKey(handle)) | |||||
| container[handle].RefCounter--; | |||||
| } | } | ||||
| private static void Recycle() | private static void Recycle() | ||||
| @@ -65,7 +65,6 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (tf.context.executing_eagerly()) | if (tf.context.executing_eagerly()) | ||||
| { | { | ||||
| var results = new[] { new EagerTensor() }; | |||||
| Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name, | Status status = c_api.TFE_FastPathExecute(tf.context, tf.context.device_name, | ||||
| "ResourceApplyGradientDescent", name, new IntPtr[] | "ResourceApplyGradientDescent", name, new IntPtr[] | ||||
| { | { | ||||
| @@ -74,9 +73,9 @@ namespace Tensorflow | |||||
| delta | delta | ||||
| }, 3, | }, 3, | ||||
| op => wrap_tfe_src.SetOpAttrs(op, "use_locking", use_locking), | op => wrap_tfe_src.SetOpAttrs(op, "use_locking", use_locking), | ||||
| results.Select(x => x.EagerTensorHandle).ToArray(), results.Length); | |||||
| null, 0); | |||||
| status.Check(true); | status.Check(true); | ||||
| return results[0].Resolve(); | |||||
| return null; | |||||
| } | } | ||||
| var _op = _op_def_lib._apply_op_helper("ResourceApplyGradientDescent", name, new | var _op = _op_def_lib._apply_op_helper("ResourceApplyGradientDescent", name, new | ||||