Browse Source

AddControlInput and UpdateEdge works..

tags/v0.9
Deepak Kumar 6 years ago
parent
commit
c62d9ee520
4 changed files with 52 additions and 72 deletions
  1. +0
    -20
      src/TensorFlowNET.Core/Graphs/python_api.graph.cs
  2. +50
    -50
      src/TensorFlowNET.Core/Operations/Operation.Control.cs
  3. +2
    -0
      src/TensorFlowNET.Core/Operations/array_ops.py.cs
  4. +0
    -2
      src/TensorFlowNET.Core/Operations/nn_impl.py.cs

+ 0
- 20
src/TensorFlowNET.Core/Graphs/python_api.graph.cs View File

@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Graphs
{
/// <summary>
/// Lots of other functions required for Operation control flow like AddControlInput, UpdateEdge, RemoveAllControlInputs etc are not exposed via C_API and there is a C implementation of it.
/// https://github.com/tensorflow/tensorflow/blob/r1.14/tensorflow/c/python_api.h
/// https://github.com/tensorflow/tensorflow/blob/r1.14/tensorflow/c/python_api.cc
///
/// </summary>
public class python_api
{
public static void UpdateEdge(Graph graph, TF_Output new_src, TF_Input dst, Status status)
{
}
}
}

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

@@ -1,52 +1,52 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Operations;
namespace Tensorflow
{
public partial class Operation
{
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Operations;
namespace Tensorflow
{
public partial class Operation
{
private ControlFlowContext _control_flow_context;
/// <summary>
/// Add this op to its control flow context.
///
/// This may add new ops and change this op's inputs. self.inputs must be
/// available before calling this method.
/// </summary>
public void _control_flow_post_processing()
{
foreach(var input_tensor in inputs)
{
//TODO: implement below code dependency
//control_flow_util.CheckInputFromValidContext(this, input_tensor.op);
}
if (_control_flow_context != null)
_control_flow_context.AddOp(this);
}
public void _add_control_input(Operation op)
{
//c_api.TF_AddControlInput(_operDesc, op);
c_api.AddControlInput(graph, _handle, op);
}
public void _add_control_inputs(Operation[] ops)
{
foreach (var op in ops)
_add_control_input(op);
}
public void _set_control_flow_context(ControlFlowContext ctx)
{
_control_flow_context = ctx;
}
public ControlFlowContext _get_control_flow_context()
{
return _control_flow_context;
}
}
}
/// <summary>
/// Add this op to its control flow context.
///
/// This may add new ops and change this op's inputs. self.inputs must be
/// available before calling this method.
/// </summary>
public void _control_flow_post_processing()
{
foreach(var input_tensor in inputs)
{
//TODO: implement below code dependency
//control_flow_util.CheckInputFromValidContext(this, input_tensor.op);
}
if (_control_flow_context != null)
_control_flow_context.AddOp(this);
}
public void _add_control_input(Operation op)
{
//c_api.TF_AddControlInput(_operDesc, op);
c_api.AddControlInput(graph, _handle, op);
}
public void _add_control_inputs(Operation[] ops)
{
foreach (var op in ops)
_add_control_input(op);
}
public void _set_control_flow_context(ControlFlowContext ctx)
{
_control_flow_context = ctx;
}
public ControlFlowContext _get_control_flow_context()
{
return _control_flow_context;
}
}
}

+ 2
- 0
src/TensorFlowNET.Core/Operations/array_ops.py.cs View File

@@ -30,6 +30,8 @@ namespace Tensorflow
return _constant_if_small(0.0F, shape, dtype, name);
case TF_DataType.TF_INT32:
return _constant_if_small(0, shape, dtype, name);
case TF_DataType.TF_INT8:
return _constant_if_small<byte>(0, shape, dtype, name);
default:
throw new TypeError("can't find type for zeros");
}


+ 0
- 2
src/TensorFlowNET.Core/Operations/nn_impl.py.cs View File

@@ -129,10 +129,8 @@ namespace Tensorflow
{
return with(ops.name_scope(name, "zero_fraction", new { value }), scope =>
{

value = ops.convert_to_tensor(value, name: "value");
Tensor size = array_ops.size(value, out_type: dtypes.int64);
Func<ITensorOrOperation> fu_true = () => math_ops.cast(_count_nonzero(value, dtype: dtypes.int32));
Tensor zero_fraction_float32 = null;

size = gen_math_ops.less_equal(size, dtypes.int32.max());


Loading…
Cancel
Save