diff --git a/src/TensorFlowNET.Core/APIs/tf.io.cs b/src/TensorFlowNET.Core/APIs/tf.io.cs index 6d1f7d17..40da04b1 100644 --- a/src/TensorFlowNET.Core/APIs/tf.io.cs +++ b/src/TensorFlowNET.Core/APIs/tf.io.cs @@ -23,6 +23,7 @@ namespace Tensorflow { public GFile gfile = new GFile(); public Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name); + public Tensor read_file(Tensor filename, string name = null) => gen_io_ops.read_file(filename, name); public ITensorOrOperation[] import_graph_def(GraphDef graph_def, Dictionary input_map = null, diff --git a/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs b/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs index 5bc74351..381ff744 100644 --- a/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs +++ b/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; +using Google.Protobuf; namespace Tensorflow { @@ -15,17 +17,30 @@ namespace Tensorflow /// the model outputs /// transform names and parameters /// - public GraphDef TransformGraph(GraphDef input_graph_def, - string[] inputs, - string[] outputs, + public GraphDef TransformGraph(GraphDef input_graph_def, + string[] inputs, + string[] outputs, string[] transforms) { - var input_graph_def_string = input_graph_def.ToString(); + var input_graph_def_string = input_graph_def.ToByteArray(); var inputs_string = string.Join(",", inputs); var outputs_string = string.Join(",", outputs); - var transforms_string = string.Join(",", transforms); + var transforms_string = string.Join(" ", transforms); + using (var status = new Status()) + { + var buffer = new Buffer(); + var len = c_api.TransformGraphWithStringInputs(input_graph_def_string, + input_graph_def_string.Length, + inputs_string, + outputs_string, + transforms_string, + buffer, + status); - throw new NotImplementedException(""); + status.Check(false); + var bytes = buffer.ToArray(); + return GraphDef.Parser.ParseFrom(bytes); + } } } } diff --git a/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs b/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs new file mode 100644 index 00000000..8390d74e --- /dev/null +++ b/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs @@ -0,0 +1,33 @@ +/***************************************************************************** + Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +******************************************************************************/ + +using System; +using System.Runtime.InteropServices; + +namespace Tensorflow +{ + public partial class c_api + { + [DllImport(TensorFlowLibName)] + public static extern int TransformGraphWithStringInputs(byte[] graph_def_string, + int graph_def_string_len, + string inputs_string, + string outputs_string, + string transforms_string, + IntPtr output_buffer, + IntPtr status); + } +} diff --git a/src/TensorFlowNET.Core/Operations/gen_io_ops.cs b/src/TensorFlowNET.Core/Operations/gen_io_ops.cs index 2a921d93..13408452 100644 --- a/src/TensorFlowNET.Core/Operations/gen_io_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_io_ops.cs @@ -34,7 +34,7 @@ namespace Tensorflow return _op.outputs; } - public static Tensor read_file(string filename, string name = null) + public static Tensor read_file(T filename, string name = null) { var _op = _op_def_lib._apply_op_helper("ReadFile", name: name, args: new { filename }); diff --git a/src/TensorFlowNET.Core/TensorFlow.Binding.csproj b/src/TensorFlowNET.Core/TensorFlow.Binding.csproj index cd5a5c90..ea93f37d 100644 --- a/src/TensorFlowNET.Core/TensorFlow.Binding.csproj +++ b/src/TensorFlowNET.Core/TensorFlow.Binding.csproj @@ -5,7 +5,7 @@ TensorFlow.NET Tensorflow 1.14.1 - 0.14.0 + 0.15.0 Haiping Chen, Meinrad Recheis, Eli Belash SciSharp STACK true @@ -18,15 +18,11 @@ Google's TensorFlow full binding in .NET Standard. Building, training and infering deep learning models. https://tensorflownet.readthedocs.io - 0.14.0.0 - Changes since v0.13.0: -1: Upgrade NumSharp to v0.20.5 -2: Return byte[] for TF_String -3: Fix return_tensors for import_graph_def -4: Add tf.nn.ctc_greedy_decoder -5: Fix calling RegisterGradientFunction too early + 0.15.0.0 + Changes since v0.14.0: +1: Add TransformGraphWithStringInputs. 7.3 - 0.14.0.0 + 0.15.0.0 LICENSE true true