Browse Source

_ControlDependenciesController: fixed a bug related to stack order

tags/v0.9
Meinrad Recheis 6 years ago
parent
commit
e27bf7bb83
3 changed files with 6 additions and 17 deletions
  1. +4
    -14
      src/TensorFlowNET.Core/Graphs/Graph.Control.cs
  2. +2
    -2
      src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs
  3. +0
    -1
      test/TensorFlowNET.UnitTest/ControlDependenciesTest.cs

+ 4
- 14
src/TensorFlowNET.Core/Graphs/Graph.Control.cs View File

@@ -10,18 +10,8 @@ namespace Tensorflow
{
public IControlFlowContext _control_flow_context;

private Queue<_ControlDependenciesController> _graph_control_dependencies_stack = new Queue<_ControlDependenciesController>();
public Queue<_ControlDependenciesController> _control_dependencies_stack
{
get
{
return _graph_control_dependencies_stack;
}
set
{
_graph_control_dependencies_stack = value;
}
}
// represents the nested with(...) statements
public List<_ControlDependenciesController> _control_dependencies_stack { get; set; } = new List<_ControlDependenciesController>();

/// <summary>
/// For an op that takes `input_ops` as inputs, compute control inputs.
@@ -122,12 +112,12 @@ namespace Tensorflow

public void _push_control_dependencies_controller(_ControlDependenciesController controller)
{
_control_dependencies_stack.Enqueue(controller);
_control_dependencies_stack.Add(controller);
}

public void _pop_control_dependencies_controller(_ControlDependenciesController controller)
{
_control_dependencies_stack.Dequeue();
_control_dependencies_stack.RemoveAt(_control_dependencies_stack.Count-1);
}

/// <summary>


+ 2
- 2
src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs View File

@@ -13,7 +13,7 @@ namespace Tensorflow
private Graph _graph;
private List<ITensorOrOperation> _control_inputs_val;
private List<ITensorOrOperation> _seen_nodes;
private Queue<_ControlDependenciesController> _old_stack;
private List<_ControlDependenciesController> _old_stack;
private bool _new_stack;
private IControlFlowContext _old_control_flow_context;

@@ -73,7 +73,7 @@ namespace Tensorflow
{
// Clear the control_dependencies graph.
_old_stack = _graph._control_dependencies_stack;
_graph._control_dependencies_stack = new Queue<_ControlDependenciesController>();
_graph._control_dependencies_stack = new List<_ControlDependenciesController>();

// Clear the control_flow_context too.
_old_control_flow_context = _graph._get_control_flow_context();


+ 0
- 1
test/TensorFlowNET.UnitTest/ControlDependenciesTest.cs View File

@@ -161,7 +161,6 @@ namespace TensorFlowNET.UnitTest
AssertItemsEqual(b_1.op.control_inputs, b_2.op.control_inputs);
}
[Ignore("Fails")]
[TestMethod]
public void TestClear()
{


Loading…
Cancel
Save