| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,19 @@ public Graph get_default_graph() | |||
| 29 | 29 | return ops.get_default_graph(); | |
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | - public Graph Graph() | ||
| 32 | + /// <summary> | ||
| 33 | + /// Equivalent to <see cref="get_default_graph"/> but does not create a new graph if it there is none. | ||
| 34 | + /// </summary> | ||
| 35 | + public Graph peak_default_graph() | ||
| 36 | + { | ||
| 37 | + return ops.default_graph_stack.peak_controller(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /// <summary> | ||
| 41 | + /// Creates a new graph. | ||
| 42 | + /// </summary> | ||
| 43 | + ///<remarks>Has no interaction with graph defaulting. Equivalent to new Graph();</remarks> | ||
| 44 | + public Graph Graph() | ||
| 33 | 45 | => new Graph(); | |
| 34 | 46 | } | |
| 35 | - } | ||
| 47 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,11 +21,10 @@ limitations under the License. | |||
| 21 | 21 | ||
| 22 | 22 | namespace Tensorflow | |
| 23 | 23 | { | |
| 24 | - | ||
| 25 | 24 | /// <summary> | |
| 26 | 25 | /// Serves as a stack for determining current default graph. | |
| 27 | 26 | /// </summary> | |
| 28 | - public class DefaultGraphStack | ||
| 27 | + public class DefaultGraphStack | ||
| 29 | 28 | { | |
| 30 | 29 | private readonly List<StackModel> _stack = new List<StackModel>(); | |
| 31 | 30 | ||
@@ -52,6 +51,20 @@ public Graph get_controller() | |||
| 52 | 51 | throw new TensorflowException("Unable to find a default graph"); | |
| 53 | 52 | } | |
| 54 | 53 | ||
| 54 | + public Graph peak_controller() | ||
| 55 | + { | ||
| 56 | + if (_stack.Count == 0 || _stack.Count(x => x.IsDefault) == 0) | ||
| 57 | + return null; | ||
| 58 | + for (var i = _stack.Count - 1; i >= 0; i--) | ||
| 59 | + { | ||
| 60 | + var x = _stack[i]; | ||
| 61 | + if (x.IsDefault) | ||
| 62 | + return x.Graph; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + return null; | ||
| 66 | + } | ||
| 67 | + | ||
| 55 | 68 | public bool remove(Graph g) | |
| 56 | 69 | { | |
| 57 | 70 | if (_stack.Count == 0) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments