Browse Source

reorganize file structure

tags/v0.1.0-Tensor
Oceania2018 6 years ago
parent
commit
b084ae6dbf
38 changed files with 267 additions and 164 deletions
  1. +0
    -0
      src/TensorFlowNET.Core/Buffers/Buffer.cs
  2. +0
    -0
      src/TensorFlowNET.Core/Buffers/TF_Buffer.cs
  3. +13
    -0
      src/TensorFlowNET.Core/Buffers/c_api.buffer.cs
  4. +0
    -0
      src/TensorFlowNET.Core/Graphs/Graph.cs
  5. +0
    -0
      src/TensorFlowNET.Core/Graphs/TF_Input.cs
  6. +0
    -0
      src/TensorFlowNET.Core/Graphs/TF_Output.cs
  7. +16
    -0
      src/TensorFlowNET.Core/Graphs/c_api.graph.cs
  8. +0
    -16
      src/TensorFlowNET.Core/MonoPInvokeCallbackAttribute.cs
  9. +0
    -0
      src/TensorFlowNET.Core/Operations/OpDefLibrary.cs
  10. +0
    -0
      src/TensorFlowNET.Core/Operations/Operation.cs
  11. +0
    -0
      src/TensorFlowNET.Core/Operations/TF_OperationDescription.cs
  12. +36
    -0
      src/TensorFlowNET.Core/Operations/c_api.ops.cs
  13. +0
    -0
      src/TensorFlowNET.Core/Operations/gen_array_ops.cs
  14. +0
    -0
      src/TensorFlowNET.Core/Operations/gen_math_ops.cs
  15. +0
    -0
      src/TensorFlowNET.Core/Operations/ops.cs
  16. +0
    -0
      src/TensorFlowNET.Core/Protobuf/AttrValue.cs
  17. +0
    -0
      src/TensorFlowNET.Core/Protobuf/NodeDef.cs
  18. +0
    -0
      src/TensorFlowNET.Core/Protobuf/OpDef.cs
  19. +0
    -0
      src/TensorFlowNET.Core/Protobuf/README.md
  20. +0
    -0
      src/TensorFlowNET.Core/Protobuf/ResourceHandle.cs
  21. +0
    -0
      src/TensorFlowNET.Core/Protobuf/Tensor.cs
  22. +0
    -0
      src/TensorFlowNET.Core/Protobuf/TensorShape.cs
  23. +0
    -0
      src/TensorFlowNET.Core/Protobuf/Types.cs
  24. +0
    -0
      src/TensorFlowNET.Core/Protobuf/op_list_proto_array.bin
  25. +0
    -0
      src/TensorFlowNET.Core/Protobuf/op_list_proto_math.bin
  26. +0
    -0
      src/TensorFlowNET.Core/Sessions/BaseSession.cs
  27. +0
    -0
      src/TensorFlowNET.Core/Sessions/Session.cs
  28. +0
    -0
      src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs
  29. +0
    -0
      src/TensorFlowNET.Core/Sessions/_FetchHandler.cs
  30. +0
    -0
      src/TensorFlowNET.Core/Sessions/_FetchMapper.cs
  31. +59
    -0
      src/TensorFlowNET.Core/Sessions/c_api.session.cs
  32. +0
    -0
      src/TensorFlowNET.Core/Status/Status.cs
  33. +0
    -0
      src/TensorFlowNET.Core/Status/TF_Code.cs
  34. +52
    -0
      src/TensorFlowNET.Core/Status/c_api.status.cs
  35. +3
    -3
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
  36. +0
    -0
      src/TensorFlowNET.Core/Tensors/TensorShape.cs
  37. +81
    -0
      src/TensorFlowNET.Core/Tensors/c_api.tensor.cs
  38. +7
    -145
      src/TensorFlowNET.Core/c_api.cs

src/TensorFlowNET.Core/Buffer.cs → src/TensorFlowNET.Core/Buffers/Buffer.cs View File


src/TensorFlowNET.Core/Tensorflow/TF_Buffer.cs → src/TensorFlowNET.Core/Buffers/TF_Buffer.cs View File


+ 13
- 0
src/TensorFlowNET.Core/Buffers/c_api.buffer.cs View File

@@ -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);
}
}

src/TensorFlowNET.Core/Graph.cs → src/TensorFlowNET.Core/Graphs/Graph.cs View File


src/TensorFlowNET.Core/Tensorflow/TF_Input.cs → src/TensorFlowNET.Core/Graphs/TF_Input.cs View File


src/TensorFlowNET.Core/Tensorflow/TF_Output.cs → src/TensorFlowNET.Core/Graphs/TF_Output.cs View File


+ 16
- 0
src/TensorFlowNET.Core/Graphs/c_api.graph.cs View File

@@ -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();
}
}

+ 0
- 16
src/TensorFlowNET.Core/MonoPInvokeCallbackAttribute.cs View File

@@ -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) { }
}
}

src/TensorFlowNET.Core/OpDefLibrary.cs → src/TensorFlowNET.Core/Operations/OpDefLibrary.cs View File


src/TensorFlowNET.Core/Operation.cs → src/TensorFlowNET.Core/Operations/Operation.cs View File


src/TensorFlowNET.Core/Tensorflow/TF_OperationDescription.cs → src/TensorFlowNET.Core/Operations/TF_OperationDescription.cs View File


+ 36
- 0
src/TensorFlowNET.Core/Operations/c_api.ops.cs View File

@@ -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);
}
}

src/TensorFlowNET.Core/ops/gen_array_ops.cs → src/TensorFlowNET.Core/Operations/gen_array_ops.cs View File


src/TensorFlowNET.Core/ops/gen_math_ops.cs → src/TensorFlowNET.Core/Operations/gen_math_ops.cs View File


src/TensorFlowNET.Core/ops.cs → src/TensorFlowNET.Core/Operations/ops.cs View File


src/TensorFlowNET.Core/Tensorflow/AttrValue.cs → src/TensorFlowNET.Core/Protobuf/AttrValue.cs View File


src/TensorFlowNET.Core/Tensorflow/NodeDef.cs → src/TensorFlowNET.Core/Protobuf/NodeDef.cs View File


src/TensorFlowNET.Core/Tensorflow/OpDef.cs → src/TensorFlowNET.Core/Protobuf/OpDef.cs View File


src/TensorFlowNET.Core/Tensorflow/README.md → src/TensorFlowNET.Core/Protobuf/README.md View File


src/TensorFlowNET.Core/Tensorflow/ResourceHandle.cs → src/TensorFlowNET.Core/Protobuf/ResourceHandle.cs View File


src/TensorFlowNET.Core/Tensorflow/Tensor.cs → src/TensorFlowNET.Core/Protobuf/Tensor.cs View File


src/TensorFlowNET.Core/Tensorflow/TensorShape.cs → src/TensorFlowNET.Core/Protobuf/TensorShape.cs View File


src/TensorFlowNET.Core/Tensorflow/Types.cs → src/TensorFlowNET.Core/Protobuf/Types.cs View File


src/TensorFlowNET.Core/Tensorflow/op_list_proto_array.bin → src/TensorFlowNET.Core/Protobuf/op_list_proto_array.bin View File


src/TensorFlowNET.Core/Tensorflow/op_list_proto_math.bin → src/TensorFlowNET.Core/Protobuf/op_list_proto_math.bin View File


src/TensorFlowNET.Core/Session/BaseSession.cs → src/TensorFlowNET.Core/Sessions/BaseSession.cs View File


src/TensorFlowNET.Core/Session/Session.cs → src/TensorFlowNET.Core/Sessions/Session.cs View File


src/TensorFlowNET.Core/Session/_ElementFetchMapper.cs → src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs View File


src/TensorFlowNET.Core/Session/_FetchHandler.cs → src/TensorFlowNET.Core/Sessions/_FetchHandler.cs View File


src/TensorFlowNET.Core/Session/_FetchMapper.cs → src/TensorFlowNET.Core/Sessions/_FetchMapper.cs View File


+ 59
- 0
src/TensorFlowNET.Core/Sessions/c_api.session.cs View File

@@ -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);
}
}

src/TensorFlowNET.Core/Status.cs → src/TensorFlowNET.Core/Status/Status.cs View File


src/TensorFlowNET.Core/Tensorflow/TF_Code.cs → src/TensorFlowNET.Core/Status/TF_Code.cs View File


+ 52
- 0
src/TensorFlowNET.Core/Status/c_api.status.cs View File

@@ -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);
}
}

+ 3
- 3
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Tensorflow\README.md" />
<None Remove="Protobuf\README.md" />
</ItemGroup>

<ItemGroup>
@@ -27,10 +27,10 @@
<None Update="tensorflow.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Tensorflow\op_list_proto_array.bin">
<None Update="Protobuf\op_list_proto_array.bin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Tensorflow\op_list_proto_math.bin">
<None Update="Protobuf\op_list_proto_math.bin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


src/TensorFlowNET.Core/TensorShape.cs → src/TensorFlowNET.Core/Tensors/TensorShape.cs View File


+ 81
- 0
src/TensorFlowNET.Core/Tensors/c_api.tensor.cs View File

@@ -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);
}
}

+ 7
- 145
src/TensorFlowNET.Core/c_api.cs View File

@@ -5,156 +5,18 @@ using System.Text;

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";

/// <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);

/// <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)]
public static unsafe extern IntPtr TF_Version();
}


Loading…
Cancel
Save