Browse Source

change CondContext to IControlFlowContext in Operation and Graph.

tags/v0.8.0
Oceania2018 6 years ago
parent
commit
54427278aa
5 changed files with 16 additions and 12 deletions
  1. +2
    -1
      src/TensorFlowNET.Core/Gradients/control_flow_grad.py.cs
  2. +3
    -3
      src/TensorFlowNET.Core/Operations/Operation.Control.cs
  3. +5
    -1
      src/TensorFlowNET.Core/Operations/Operation.cs
  4. +1
    -1
      src/TensorFlowNET.Core/Operations/control_flow_util.py.cs
  5. +5
    -6
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj

+ 2
- 1
src/TensorFlowNET.Core/Gradients/control_flow_grad.py.cs View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Operations;

namespace Tensorflow.Gradients
{
@@ -13,7 +14,7 @@ namespace Tensorflow.Gradients
var input_op = op.inputs[0].op;
var graph = ops.get_default_graph();
var op_ctxt = control_flow_util.GetOutputContext(input_op);
var pred = op_ctxt.pred;
var pred = (op_ctxt as CondContext).pred;

var results = control_flow_ops._SwitchRefOrTensor(grad, pred, name: "cond_grad");
return new Tensor[] { results.Item1, results.Item2 };


+ 3
- 3
src/TensorFlowNET.Core/Operations/Operation.Control.cs View File

@@ -7,7 +7,7 @@ namespace Tensorflow
{
public partial class Operation
{
private CondContext _control_flow_context;
private IControlFlowContext _control_flow_context;

/// <summary>
/// Add this op to its control flow context.
@@ -28,12 +28,12 @@ namespace Tensorflow
}
}

public void _set_control_flow_context(CondContext ctx)
public void _set_control_flow_context(IControlFlowContext ctx)
{
_control_flow_context = ctx;
}

public CondContext _get_control_flow_context()
public IControlFlowContext _get_control_flow_context()
{
return _control_flow_context;
}


+ 5
- 1
src/TensorFlowNET.Core/Operations/Operation.cs View File

@@ -102,8 +102,12 @@ namespace Tensorflow
}
}

// Dict mapping op name to file and line information for op colocation
// context managers.
_control_flow_context = graph._get_control_flow_context();

// This will be set by self.inputs.
if(op_def == null)
if (op_def == null)
op_def = g.GetOpDef(node_def.Op);

var grouped_inputs = _reconstruct_sequence_inputs(op_def, inputs, node_def.Attr);


+ 1
- 1
src/TensorFlowNET.Core/Operations/control_flow_util.py.cs View File

@@ -27,7 +27,7 @@ namespace Tensorflow
return op.type == "Switch" || op.type == "RefSwitch";
}

public static CondContext GetOutputContext(Operation op)
public static IControlFlowContext GetOutputContext(Operation op)
{
var ctxt = op._get_control_flow_context();



+ 5
- 6
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>TensorFlow.NET</AssemblyName>
<RootNamespace>Tensorflow</RootNamespace>
<Version>0.4.2</Version>
<Version>0.5.0</Version>
<Authors>Haiping Chen</Authors>
<Company>SciSharp STACK</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -13,14 +13,13 @@
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/SciSharp</PackageProjectUrl>
<PackageIconUrl>https://avatars3.githubusercontent.com/u/44989469?s=200&amp;v=4</PackageIconUrl>
<PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET</PackageTags>
<PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags>
<Description>Google's TensorFlow binding in .NET Standard.
Docs: https://tensorflownet.readthedocs.io</Description>
<AssemblyVersion>0.4.2.0</AssemblyVersion>
<PackageReleaseNotes>Added ConfigProto to control CPU and GPU resource.
Fixed import name scope issue.</PackageReleaseNotes>
<AssemblyVersion>0.5.0.0</AssemblyVersion>
<PackageReleaseNotes>Add a lot of APIs to build neural networks model</PackageReleaseNotes>
<LangVersion>7.2</LangVersion>
<FileVersion>0.4.2.0</FileVersion>
<FileVersion>0.5.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">


Loading…
Cancel
Save