| @@ -0,0 +1,13 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static partial class c_api | |||||
| { | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern string TF_GetBuffer(IntPtr buffer); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static partial class c_api | |||||
| { | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern void TF_GraphGetOpDef(IntPtr graph, string op_name, IntPtr output_op_def, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern IntPtr TF_NewGraph(); | |||||
| } | |||||
| } | |||||
| @@ -1,16 +0,0 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public sealed class MonoPInvokeCallbackAttribute : Attribute | |||||
| { | |||||
| /// <summary> | |||||
| /// Use this constructor to annotate the type of the callback function that | |||||
| /// will be invoked from unmanaged code. | |||||
| /// </summary> | |||||
| /// <param name="t">T.</param> | |||||
| public MonoPInvokeCallbackAttribute(Type t) { } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,36 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static partial class c_api | |||||
| { | |||||
| /// <summary> | |||||
| /// For inputs that take a single tensor. | |||||
| /// </summary> | |||||
| /// <param name="desc"></param> | |||||
| /// <param name="input"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_AddInput(TF_OperationDescription desc, TF_Output input); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern IntPtr TF_FinishOperation(TF_OperationDescription desc, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern TF_OperationDescription TF_NewOperation(IntPtr graph, string opType, string oper_name); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe int TF_OperationNumOutputs(IntPtr oper); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SetAttrValueProto(TF_OperationDescription desc, string attr_name, IntPtr proto, UIntPtr proto_len, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SetAttrTensor(TF_OperationDescription desc, string attr_name, IntPtr value, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SetAttrType(TF_OperationDescription desc, string attr_name, TF_DataType value); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,59 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static partial class c_api | |||||
| { | |||||
| /// <summary> | |||||
| /// Destroy an options object. | |||||
| /// </summary> | |||||
| /// <param name="opts"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_DeleteSessionOptions(IntPtr opts); | |||||
| /// <summary> | |||||
| /// Return a new execution session with the associated graph, or NULL on | |||||
| /// error. Does not take ownership of any input parameters. | |||||
| /// </summary> | |||||
| /// <param name="graph"></param> | |||||
| /// <param name="opts"></param> | |||||
| /// <param name="status"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern IntPtr TF_NewSession(IntPtr graph, IntPtr opts, IntPtr status); | |||||
| /// <summary> | |||||
| /// Return a new options object. | |||||
| /// </summary> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern IntPtr TF_NewSessionOptions(); | |||||
| /// <summary> | |||||
| /// Run the graph associated with the session starting with the supplied inputs | |||||
| /// (inputs[0,ninputs-1] with corresponding values in input_values[0,ninputs-1]). | |||||
| /// </summary> | |||||
| /// <param name="session"></param> | |||||
| /// <param name="run_options"></param> | |||||
| /// <param name="inputs"></param> | |||||
| /// <param name="input_values"></param> | |||||
| /// <param name="ninputs"></param> | |||||
| /// <param name="outputs"></param> | |||||
| /// <param name="output_values"></param> | |||||
| /// <param name="noutputs"></param> | |||||
| /// <param name="target_opers"></param> | |||||
| /// <param name="ntargets"></param> | |||||
| /// <param name="run_metadata"></param> | |||||
| /// <param name="status"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SessionRun(IntPtr session, IntPtr run_options, | |||||
| TF_Output[] inputs, IntPtr[] input_values, int ninputs, | |||||
| TF_Output[] outputs, IntPtr[] output_values, int noutputs, | |||||
| IntPtr[] target_opers, int ntargets, | |||||
| IntPtr run_metadata, | |||||
| IntPtr status); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static partial class c_api | |||||
| { | |||||
| /// <summary> | |||||
| /// Delete a previously created status object. | |||||
| /// </summary> | |||||
| /// <param name="s"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_DeleteStatus(IntPtr s); | |||||
| /// <summary> | |||||
| /// Return the code record in *s. | |||||
| /// </summary> | |||||
| /// <param name="s"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe TF_Code TF_GetCode(IntPtr s); | |||||
| /// <summary> | |||||
| /// Return a pointer to the (null-terminated) error message in *s. | |||||
| /// The return value points to memory that is only usable until the next | |||||
| /// mutation to *s. Always returns an empty string if TF_GetCode(s) is TF_OK. | |||||
| /// </summary> | |||||
| /// <param name="s"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe string TF_Message(IntPtr s); | |||||
| /// <summary> | |||||
| /// Return a new status object. | |||||
| /// </summary> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern IntPtr TF_NewStatus(); | |||||
| /// <summary> | |||||
| /// Record <code, msg> in *s. Any previous information is lost. | |||||
| /// A common use is to clear a status: TF_SetStatus(s, TF_OK, ""); | |||||
| /// </summary> | |||||
| /// <param name="s"></param> | |||||
| /// <param name="code"></param> | |||||
| /// <param name="msg"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern void TF_SetStatus(IntPtr s, TF_Code code, string msg); | |||||
| } | |||||
| } | |||||
| @@ -12,7 +12,7 @@ | |||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| <None Remove="Tensorflow\README.md" /> | |||||
| <None Remove="Protobuf\README.md" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| @@ -27,10 +27,10 @@ | |||||
| <None Update="tensorflow.dll"> | <None Update="tensorflow.dll"> | ||||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
| </None> | </None> | ||||
| <None Update="Tensorflow\op_list_proto_array.bin"> | |||||
| <None Update="Protobuf\op_list_proto_array.bin"> | |||||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
| </None> | </None> | ||||
| <None Update="Tensorflow\op_list_proto_math.bin"> | |||||
| <None Update="Protobuf\op_list_proto_math.bin"> | |||||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
| </None> | </None> | ||||
| </ItemGroup> | </ItemGroup> | ||||
| @@ -0,0 +1,81 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static partial class c_api | |||||
| { | |||||
| /// <summary> | |||||
| /// returns the sizeof() for the underlying type corresponding to the given TF_DataType enum value. | |||||
| /// </summary> | |||||
| /// <param name="dt"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern ulong TF_DataTypeSize(TF_DataType dt); | |||||
| /// <summary> | |||||
| /// Destroy a tensor. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_DeleteTensor(IntPtr tensor); | |||||
| /// <summary> | |||||
| /// Return the length of the tensor in the "dim_index" dimension. | |||||
| /// REQUIRES: 0 <= dim_index < TF_NumDims(tensor) | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <param name="dim_index"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe long TF_Dim(IntPtr tensor, int dim_index); | |||||
| /// <summary> | |||||
| /// Return a new tensor that holds the bytes data[0,len-1] | |||||
| /// </summary> | |||||
| /// <param name="dataType"></param> | |||||
| /// <param name="dims"></param> | |||||
| /// <param name="num_dims"></param> | |||||
| /// <param name="data"></param> | |||||
| /// <param name="len">num_bytes, ex: 6 * sizeof(float)</param> | |||||
| /// <param name="deallocator"></param> | |||||
| /// <param name="deallocator_arg"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe IntPtr TF_NewTensor(TF_DataType dataType, long[] dims, int num_dims, IntPtr data, UIntPtr len, Deallocator deallocator, ref bool deallocator_arg); | |||||
| /// <summary> | |||||
| /// Return the number of dimensions that the tensor has. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe int TF_NumDims(IntPtr tensor); | |||||
| /// <summary> | |||||
| /// Return the size of the underlying data in bytes. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe ulong TF_TensorByteSize(IntPtr tensor); | |||||
| /// <summary> | |||||
| /// Return a pointer to the underlying data buffer. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe IntPtr TF_TensorData(IntPtr tensor); | |||||
| /// <summary> | |||||
| /// Return the type of a tensor element. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe TF_DataType TF_TensorType(IntPtr tensor); | |||||
| } | |||||
| } | |||||
| @@ -5,156 +5,18 @@ using System.Text; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public static class c_api | |||||
| /// <summary> | |||||
| /// C API for TensorFlow. | |||||
| /// | |||||
| /// The API leans towards simplicity and uniformity instead of convenience | |||||
| /// since most usage will be by language specific wrappers. | |||||
| /// </summary> | |||||
| public static partial class c_api | |||||
| { | { | ||||
| public const string TensorFlowLibName = "tensorflow"; | public const string TensorFlowLibName = "tensorflow"; | ||||
| /// <summary> | |||||
| /// For inputs that take a single tensor. | |||||
| /// </summary> | |||||
| /// <param name="desc"></param> | |||||
| /// <param name="input"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_AddInput(TF_OperationDescription desc, TF_Output input); | |||||
| /// <summary> | |||||
| /// returns the sizeof() for the underlying type corresponding to the given TF_DataType enum value. | |||||
| /// </summary> | |||||
| /// <param name="dt"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern ulong TF_DataTypeSize(TF_DataType dt); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_DeleteSessionOptions(IntPtr opts); | |||||
| /// <summary> | |||||
| /// Delete a previously created status object. | |||||
| /// </summary> | |||||
| /// <param name="s"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_DeleteStatus(IntPtr s); | |||||
| /// <summary> | |||||
| /// Destroy a tensor. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern void TF_DeleteTensor(IntPtr tensor); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe long TF_Dim(IntPtr tensor, int dim_index); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern IntPtr TF_FinishOperation(TF_OperationDescription desc, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern string TF_GetBuffer(IntPtr buffer); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe TF_Code TF_GetCode(IntPtr s); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern void TF_GraphGetOpDef(IntPtr graph, string op_name, IntPtr output_op_def, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe string TF_Message(IntPtr s); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern IntPtr TF_NewGraph(); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern TF_OperationDescription TF_NewOperation(IntPtr graph, string opType, string oper_name); | |||||
| /// <summary> | |||||
| /// Return a new status object. | |||||
| /// </summary> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static unsafe extern IntPtr TF_NewStatus(); | |||||
| /// <summary> | |||||
| /// Return a new tensor that holds the bytes data[0,len-1] | |||||
| /// </summary> | |||||
| /// <param name="dataType"></param> | |||||
| /// <param name="dims"></param> | |||||
| /// <param name="num_dims"></param> | |||||
| /// <param name="data"></param> | |||||
| /// <param name="len">num_bytes, ex: 6 * sizeof(float)</param> | |||||
| /// <param name="deallocator"></param> | |||||
| /// <param name="deallocator_arg"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe IntPtr TF_NewTensor(TF_DataType dataType, long[] dims, int num_dims, IntPtr data, UIntPtr len, Deallocator deallocator, ref bool deallocator_arg); | |||||
| public delegate void Deallocator(IntPtr data, IntPtr size, ref bool deallocatorData); | public delegate void Deallocator(IntPtr data, IntPtr size, ref bool deallocatorData); | ||||
| /// <summary> | |||||
| /// Return the number of dimensions that the tensor has. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe int TF_NumDims(IntPtr tensor); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe int TF_OperationNumOutputs(IntPtr oper); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SetAttrValueProto(TF_OperationDescription desc, string attr_name, IntPtr proto, UIntPtr proto_len, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SetAttrTensor(TF_OperationDescription desc, string attr_name, IntPtr value, IntPtr status); | |||||
| /// <summary> | |||||
| /// | |||||
| /// </summary> | |||||
| /// <param name="session"></param> | |||||
| /// <param name="run_options"></param> | |||||
| /// <param name="inputs"></param> | |||||
| /// <param name="input_values"></param> | |||||
| /// <param name="ninputs"></param> | |||||
| /// <param name="outputs"></param> | |||||
| /// <param name="output_values"></param> | |||||
| /// <param name="noutputs"></param> | |||||
| /// <param name="target_opers"></param> | |||||
| /// <param name="ntargets"></param> | |||||
| /// <param name="run_metadata"></param> | |||||
| /// <param name="status"></param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SessionRun(IntPtr session, IntPtr run_options, | |||||
| TF_Output[] inputs, IntPtr[] input_values, int ninputs, | |||||
| TF_Output[] outputs, IntPtr[] output_values, int noutputs, | |||||
| IntPtr[] target_opers, int ntargets, | |||||
| IntPtr run_metadata, | |||||
| IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe void TF_SetAttrType(TF_OperationDescription desc, string attr_name, TF_DataType value); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern void TF_SetStatus(IntPtr s, TF_Code code, string msg); | |||||
| /// <summary> | |||||
| /// Return the size of the underlying data in bytes. | |||||
| /// </summary> | |||||
| /// <param name="tensor"></param> | |||||
| /// <returns></returns> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe ulong TF_TensorByteSize(IntPtr tensor); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe IntPtr TF_TensorData(IntPtr tensor); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern unsafe TF_DataType TF_TensorType(IntPtr tensor); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern IntPtr TF_NewSession(IntPtr graph, IntPtr opts, IntPtr status); | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern IntPtr TF_NewSessionOptions(); | |||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static unsafe extern IntPtr TF_Version(); | public static unsafe extern IntPtr TF_Version(); | ||||
| } | } | ||||