diff --git a/TensorFlow.NET.sln.DotSettings b/TensorFlow.NET.sln.DotSettings
new file mode 100644
index 00000000..aba8725c
--- /dev/null
+++ b/TensorFlow.NET.sln.DotSettings
@@ -0,0 +1,2 @@
+
+ True
\ No newline at end of file
diff --git a/src/TensorFlowNET.Core/APIs/c_api.cs b/src/TensorFlowNET.Core/APIs/c_api.cs
index adf0b86f..56672173 100644
--- a/src/TensorFlowNET.Core/APIs/c_api.cs
+++ b/src/TensorFlowNET.Core/APIs/c_api.cs
@@ -54,6 +54,15 @@ namespace Tensorflow
public struct DeallocatorArgs
{
+ internal static unsafe c_api.DeallocatorArgs* EmptyPtr;
+ internal static unsafe IntPtr Empty;
+
+ static unsafe DeallocatorArgs()
+ {
+ Empty = new IntPtr(EmptyPtr = (DeallocatorArgs*) Marshal.AllocHGlobal(Marshal.SizeOf()));
+ *EmptyPtr = new DeallocatorArgs() {gc_handle = IntPtr.Zero, deallocator_called = false};
+ }
+
public bool deallocator_called;
public IntPtr gc_handle;
}
diff --git a/src/TensorFlowNET.Core/APIs/tf.graph.cs b/src/TensorFlowNET.Core/APIs/tf.graph.cs
index cee941ed..1648cb70 100644
--- a/src/TensorFlowNET.Core/APIs/tf.graph.cs
+++ b/src/TensorFlowNET.Core/APIs/tf.graph.cs
@@ -29,7 +29,19 @@ namespace Tensorflow
return ops.get_default_graph();
}
- public Graph Graph()
+ ///
+ /// Equivalent to but does not create a new graph if it there is none.
+ ///
+ public Graph peak_default_graph()
+ {
+ return ops.default_graph_stack.peak_controller();
+ }
+
+ ///
+ /// Creates a new graph.
+ ///
+ ///Has no interaction with graph defaulting. Equivalent to new Graph();
+ public Graph Graph()
=> new Graph();
}
-}
+}
\ No newline at end of file
diff --git a/src/TensorFlowNET.Core/Gradients/gradients_util.cs b/src/TensorFlowNET.Core/Gradients/gradients_util.cs
index 3b6d0eea..5aa0d044 100644
--- a/src/TensorFlowNET.Core/Gradients/gradients_util.cs
+++ b/src/TensorFlowNET.Core/Gradients/gradients_util.cs
@@ -61,7 +61,7 @@ namespace Tensorflow
string grad_scope = scope;
// Get a uid for this call to gradients that can be used to help
// cluster ops for compilation.
- var gradient_uid = ops.get_default_graph().unique_name("uid");
+ var gradient_uid = curr_graph.unique_name("uid");
ys = ops.convert_n_to_tensor_or_indexed_slices(ys, name: "y");
xs = ops.internal_convert_n_to_tensor_or_indexed_slices(xs, name: "x", as_ref: true);
grad_ys = _DefaultGradYs(grad_ys, ys, colocate_gradients_with_ops, gradient_uid);
@@ -80,7 +80,7 @@ namespace Tensorflow
var to_ops = ys.Select(x => x.op).ToList();
var from_ops = xs.Select(x => x.op).ToList();
var stop_gradient_ops = stop_gradients.Select(x => x.op).ToList();
- (var reachable_to_ops, var pending_count, var loop_state) = _PendingCount(to_ops, from_ops, colocate_gradients_with_ops, new List