Browse Source

remove op_list_proto_array and op_list_proto_math

instead of g.GetOpDef()
tags/v0.1.0-Tensor
estherhu2012@gmail.com 6 years ago
parent
commit
560fcf1b87
3 changed files with 3 additions and 40 deletions
  1. +1
    -17
      src/TensorFlowNET.Core/Operations/OpDefLibrary.cs
  2. +1
    -11
      src/TensorFlowNET.Core/Operations/gen_array_ops.cs
  3. +1
    -12
      src/TensorFlowNET.Core/Operations/gen_math_ops.cs

+ 1
- 17
src/TensorFlowNET.Core/Operations/OpDefLibrary.cs View File

@@ -9,26 +9,10 @@ namespace Tensorflow
{ {
public class OpDefLibrary public class OpDefLibrary
{ {
public Dictionary<string, OpDef> _ops = new Dictionary<string, OpDef>();

public void add_op_list(OpList op_list)
{
foreach(var op_def in op_list.Op)
{
add_op(op_def);
}
}

public void add_op(OpDef op_def)
{
_ops[op_def.Name] = op_def;
}

public unsafe Operation _apply_op_helper(string op_type_name, string name = "", Dictionary<string, object> keywords = null) public unsafe Operation _apply_op_helper(string op_type_name, string name = "", Dictionary<string, object> keywords = null)
{ {
var op_def = _ops[op_type_name];

var g = ops.get_default_graph(); var g = ops.get_default_graph();
var op_def = g.GetOpDef(op_type_name);


if (String.IsNullOrEmpty(name)) if (String.IsNullOrEmpty(name))
{ {


+ 1
- 11
src/TensorFlowNET.Core/Operations/gen_array_ops.cs View File

@@ -8,7 +8,7 @@ namespace Tensorflow
{ {
public static class gen_array_ops public static class gen_array_ops
{ {
public static OpDefLibrary _op_def_lib = _InitOpDefLibrary();
public static OpDefLibrary _op_def_lib = new OpDefLibrary();


public static Tensor placeholder(TF_DataType dtype, TensorShape shape = null) public static Tensor placeholder(TF_DataType dtype, TensorShape shape = null)
{ {
@@ -34,15 +34,5 @@ namespace Tensorflow
var tensor = new Tensor(_op, 0, dtype); var tensor = new Tensor(_op, 0, dtype);
return tensor; return tensor;
} }

private static OpDefLibrary _InitOpDefLibrary()
{
var bytes = File.ReadAllBytes("Operations/op_list_proto_array.bin");
var op_list = OpList.Parser.ParseFrom(bytes);
var op_def_lib = new OpDefLibrary();
op_def_lib.add_op_list(op_list);

return op_def_lib;
}
} }
} }

+ 1
- 12
src/TensorFlowNET.Core/Operations/gen_math_ops.cs View File

@@ -7,7 +7,7 @@ namespace Tensorflow
{ {
public static class gen_math_ops public static class gen_math_ops
{ {
public static OpDefLibrary _op_def_lib = _InitOpDefLibrary();
public static OpDefLibrary _op_def_lib = new OpDefLibrary();


public static Tensor add(Tensor a, Tensor b) public static Tensor add(Tensor a, Tensor b)
{ {
@@ -19,16 +19,5 @@ namespace Tensorflow


return new Tensor(_op, 0, _op.OutputType(0)); return new Tensor(_op, 0, _op.OutputType(0));
} }

private static OpDefLibrary _InitOpDefLibrary()
{
// c_api.TF_GraphGetOpDef(g.Handle, op_type_name, buffer.Handle, status.Handle);
var bytes = File.ReadAllBytes("Operations/op_list_proto_math.bin");
var op_list = OpList.Parser.ParseFrom(bytes);
var op_def_lib = new OpDefLibrary();
op_def_lib.add_op_list(op_list);

return op_def_lib;
}
} }
} }

Loading…
Cancel
Save