|
10 | 10 | namespace Tensorflow |
11 | 11 | { |
12 | 12 |
|
13 | | - /// <summary> |
14 | | - /// Represents a graph node that performs computation on tensors. |
15 | | - /// |
16 | | - /// An `Operation` is a node in a TensorFlow `Graph` that takes zero or |
17 | | - /// more `Tensor` objects as input, and produces zero or more `Tensor` |
18 | | - /// objects as output. Objects of type `Operation` are created by |
19 | | - /// calling an op constructor(such as `tf.matmul`) |
20 | | - /// or `tf.Graph.create_op`. |
21 | | - /// |
22 | | - /// For example `c = tf.matmul(a, b)` creates an `Operation` of type |
23 | | - /// "MatMul" that takes tensors `a` and `b` as input, and produces `c` |
24 | | - /// as output. |
25 | | - /// |
26 | | - /// After the graph has been launched in a session, an `Operation` can |
27 | | - /// be executed by passing it to |
28 | | - /// `tf.Session.run`. |
| 13 | + /// <summary> |
| 14 | + /// Represents a graph node that performs computation on tensors. |
| 15 | + /// |
| 16 | + /// An `Operation` is a node in a TensorFlow `Graph` that takes zero or |
| 17 | + /// more `Tensor` objects as input, and produces zero or more `Tensor` |
| 18 | + /// objects as output. Objects of type `Operation` are created by |
| 19 | + /// calling an op constructor(such as `tf.matmul`) |
| 20 | + /// or `tf.Graph.create_op`. |
| 21 | + /// |
| 22 | + /// For example `c = tf.matmul(a, b)` creates an `Operation` of type |
| 23 | + /// "MatMul" that takes tensors `a` and `b` as input, and produces `c` |
| 24 | + /// as output. |
| 25 | + /// |
| 26 | + /// After the graph has been launched in a session, an `Operation` can |
| 27 | + /// be executed by passing it to |
| 28 | + /// `tf.Session.run`. |
29 | 29 | /// `op.run()` is a shortcut for calling `tf.get_default_session().run(op)`. |
30 | 30 | /// </summary> |
31 | 31 | public partial class Operation : ITensorOrOperation |
@@ -271,47 +271,49 @@ public override bool Equals(object obj) |
271 | 271 | return base.Equals(obj); |
272 | 272 | } |
273 | 273 |
|
274 | | - /// <summary> |
275 | | - /// Update the input to this operation at the given index. |
276 | | - /// |
277 | | - /// NOTE: This is for TF internal use only.Please don't use it. |
278 | | - /// </summary> |
279 | | - /// <param name="index">the index of the input to update.</param> |
280 | | - /// <param name="tensor"> the Tensor to be used as the input at the given index.</param> |
281 | | - public void _update_input(int index, Tensor tensor) |
282 | | - { |
283 | | - _assert_same_graph(tensor); |
284 | | - |
285 | | - var input = _tf_input(index); |
| 274 | + /// <summary> |
| 275 | + /// Update the input to this operation at the given index. |
| 276 | + /// |
| 277 | + /// NOTE: This is for TF internal use only.Please don't use it. |
| 278 | + /// </summary> |
| 279 | + /// <param name="index">the index of the input to update.</param> |
| 280 | + /// <param name="tensor"> the Tensor to be used as the input at the given index.</param> |
| 281 | + public void _update_input(int index, Tensor tensor) |
| 282 | + { |
| 283 | + _assert_same_graph(tensor); |
| 284 | + |
| 285 | + var input = _tf_input(index); |
286 | 286 | var output = tensor._as_tf_output(); |
287 | 287 |
|
288 | 288 | // Reset cached inputs. |
289 | | - _inputs = null;// new InputList(new Tensor[] { tensor }); // is this right? original code: self._inputs_val=None |
290 | | - // TODO: implement below code dependencies |
291 | | - c_api.TF_UpdateEdge(graph, output, input, status); |
292 | | - } |
293 | | - |
294 | | - private void _assert_same_graph(Tensor tensor) |
295 | | - { |
296 | | - //TODO: implement |
297 | | - } |
298 | | - |
299 | | - /// <summary> |
300 | | - /// Create and return a new TF_Output for output_idx'th output of this op. |
301 | | - /// </summary> |
302 | | - public TF_Output _tf_output(int output_idx) |
303 | | - { |
304 | | - var tf_output = new TF_Output(op, output_idx); |
305 | | - return tf_output; |
306 | | - } |
307 | | - |
308 | | - /// <summary> |
309 | | - /// Create and return a new TF_Input for input_idx'th input of this op. |
310 | | - /// </summary> |
311 | | - public TF_Input _tf_input(int input_idx) |
312 | | - { |
313 | | - var tf_input = new TF_Input(op, input_idx); |
314 | | - return tf_input; |
315 | | - } |
316 | | - } |
317 | | -} |
| 289 | + _inputs = null; |
| 290 | + // after the c_api call next time _inputs is accessed |
| 291 | + // the updated inputs are reloaded from the c_api |
| 292 | + c_api.TF_UpdateEdge(_graph, output, input, status); |
| 293 | + //var updated_inputs = inputs; |
| 294 | + } |
| 295 | + |
| 296 | + private void _assert_same_graph(Tensor tensor) |
| 297 | + { |
| 298 | + //TODO: implement |
| 299 | + } |
| 300 | + |
| 301 | + /// <summary> |
| 302 | + /// Create and return a new TF_Output for output_idx'th output of this op. |
| 303 | + /// </summary> |
| 304 | + public TF_Output _tf_output(int output_idx) |
| 305 | + { |
| 306 | + var tf_output = new TF_Output(op, output_idx); |
| 307 | + return tf_output; |
| 308 | + } |
| 309 | + |
| 310 | + /// <summary> |
| 311 | + /// Create and return a new TF_Input for input_idx'th input of this op. |
| 312 | + /// </summary> |
| 313 | + public TF_Input _tf_input(int input_idx) |
| 314 | + { |
| 315 | + var tf_input = new TF_Input(op, input_idx); |
| 316 | + return tf_input; |
| 317 | + } |
| 318 | + } |
| 319 | +} |
0 commit comments