| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,14 +59,28 @@ public Operation[] ReturnOperations(IntPtr results) | |||
| 59 | 59 | return return_opers; | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 62 | + /// <summary> | ||
| 63 | + /// Get operation with given <paramref name="operName"/> | ||
| 64 | + /// </summary> | ||
| 65 | + /// <exception cref="ValueError">When <paramref name="operName"/> is not found current graph.</exception> | ||
| 66 | + /// <exception cref="RuntimeError">When tf.get_default_graph() is not current graph.</exception> | ||
| 67 | + /// <example> | ||
| 68 | + /// graph.GetOperationByName("CustomInputName"); | ||
| 69 | + /// </example> | ||
| 62 | 70 | public Operation OperationByName(string operName) | |
| 63 | 71 | { | |
| 72 | + if (operName == null) | ||
| 73 | + throw new ArgumentNullException(nameof(operName)); | ||
| 74 | + | ||
| 64 | 75 | var handle = c_api.TF_GraphOperationByName(_handle, operName); | |
| 76 | + if (handle == IntPtr.Zero) | ||
| 77 | + throw new ValueError($"Could not find operation \"{operName}\" inside graph \"{_graph_key}\"."); | ||
| 78 | + | ||
| 65 | 79 | var defaultKey = tf.get_default_graph().graph_key; | |
| 66 | 80 | if (graph_key != defaultKey) | |
| 67 | 81 | { | |
| 68 | 82 | //Console.WriteLine($"Current graph is not default graph."); | |
| 69 | - throw new ValueError($"Current graph is not default graph. Default Graph Key: {defaultKey}, Current Graph Key: {graph_key}"); | ||
| 83 | + throw new RuntimeError($"Current graph is not default graph. Default Graph Key: {defaultKey}, Current Graph Key: {graph_key}"); | ||
| 70 | 84 | } | |
| 71 | 85 | ||
| 72 | 86 | return new Operation(handle, g: this); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments