Skip to content

Commit 6fc9add

Browse files
committed
Fixed Node 57, but node 61 still error. SciSharp#226
1 parent bc23079 commit 6fc9add

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public override Tensor AddValue(Tensor val)
7373
// Use the real value if it comes from outer context. This is needed in
7474
// particular for nested conds.
7575
if (_external_values.ContainsKey(val.name))
76-
result = _external_values[val.name];
77-
else
78-
result = val;
76+
result = _external_values[val.name];
77+
78+
result = result == null ? val : result;
7979
}
8080
else
8181
{
@@ -89,6 +89,11 @@ public override Tensor AddValue(Tensor val)
8989
_external_values[result.name] = result;
9090
}
9191

92+
// for debug purpose
93+
if(ops.get_default_graph()._nodes_by_name.Count > 60)
94+
{
95+
}
96+
9297
with(ops.control_dependencies(null), ctrl =>
9398
{
9499
var (r0, r1) = control_flow_ops._SwitchRefOrTensor(result, _pred);

src/TensorFlowNET.Core/Operations/Operation.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,13 @@ public override bool Equals(object obj)
279279
/// <param name="tensor"> the Tensor to be used as the input at the given index.</param>
280280
public void _update_input(int index, Tensor tensor)
281281
{
282+
_assert_same_graph(tensor);
283+
282284
var input = _tf_input(index);
283-
var output = tensor._as_tf_output();
284-
_assert_same_graph( tensor);
285-
// Reset cached inputs.
286-
_inputs=new InputList(new Tensor[]{ tensor }); // is this right? original code: self._inputs_val=None
285+
var output = tensor._as_tf_output();
286+
287+
// Reset cached inputs.
288+
_inputs = null;// new InputList(new Tensor[] { tensor }); // is this right? original code: self._inputs_val=None
287289
// TODO: implement below code dependencies
288290
//c_api.UpdateEdge(_graph._c_graph, output, input);
289291
}

0 commit comments

Comments
 (0)