Browse Source

Scoped Struct Added for Ops API extensions

tags/v0.9
Deepak Battini 6 years ago
parent
commit
1143d866d6
14 changed files with 193 additions and 2 deletions
  1. +10
    -0
      src/TensorFlowNET.Core/Framework/Models/ScopedTFFunction.cs
  2. +19
    -0
      src/TensorFlowNET.Core/Framework/Models/ScopedTFGraph.cs
  3. +19
    -0
      src/TensorFlowNET.Core/Framework/Models/ScopedTFImportGraphDefOptions.cs
  4. +24
    -0
      src/TensorFlowNET.Core/Framework/Models/ScopedTFImportGraphDefResults.cs
  5. +18
    -0
      src/TensorFlowNET.Core/Framework/Models/ScopedTFStatus.cs
  6. +5
    -0
      src/TensorFlowNET.Core/Functions/Function.cs
  7. +13
    -0
      src/TensorFlowNET.Core/Functions/TF_Function.cs
  8. +2
    -0
      src/TensorFlowNET.Core/Functions/c_api.function.cs
  9. +1
    -0
      src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs
  10. +62
    -0
      src/TensorFlowNET.Core/Operations/_UserDeviceSpec.cs
  11. +13
    -0
      src/TensorFlowNET.Core/Sessions/TF_DeprecatedSession.cs
  12. +1
    -1
      src/TensorFlowNET.Core/Sessions/TF_SessionOptions.cs
  13. +1
    -1
      src/TensorFlowNET.Core/Status/Status.cs
  14. +5
    -0
      src/TensorFlowNET.Core/ops.py.cs

+ 10
- 0
src/TensorFlowNET.Core/Framework/Models/ScopedTFFunction.cs View File

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

namespace Tensorflow.Framework.Models
{
class ScopedTFFunction
{
}
}

+ 19
- 0
src/TensorFlowNET.Core/Framework/Models/ScopedTFGraph.cs View File

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

namespace Tensorflow.Framework.Models
{
public class ScopedTFGraph : Graph
{
public ScopedTFGraph() : base()
{

}

~ScopedTFGraph()
{
base.Dispose();
}
}
}

+ 19
- 0
src/TensorFlowNET.Core/Framework/Models/ScopedTFImportGraphDefOptions.cs View File

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

namespace Tensorflow.Framework.Models
{
public class ScopedTFImportGraphDefOptions : ImportGraphDefOptions
{
public ScopedTFImportGraphDefOptions() : base()
{

}

~ScopedTFImportGraphDefOptions()
{
base.Dispose();
}
}
}

+ 24
- 0
src/TensorFlowNET.Core/Framework/Models/ScopedTFImportGraphDefResults.cs View File

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

namespace Tensorflow.Framework.Models
{
public class ScopedTFImportGraphDefResults : ImportGraphDefOptions
{
public ScopedTFImportGraphDefResults() : base()
{
}

public ScopedTFImportGraphDefResults(IntPtr results) : base(results)
{

}

~ScopedTFImportGraphDefResults()
{
base.Dispose();
}
}
}

+ 18
- 0
src/TensorFlowNET.Core/Framework/Models/ScopedTFStatus.cs View File

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

namespace Tensorflow.Framework.Models
{
public class ScopedTFStatus : Status
{
public ScopedTFStatus() : base()
{
}

~ScopedTFStatus()
{
base.Dispose();
}
}
}

+ 5
- 0
src/TensorFlowNET.Core/Functions/Function.cs View File

@@ -6,6 +6,11 @@ namespace Tensorflow
{
public class Function
{
private IntPtr _handle;

public Function()
{

}
}
}

+ 13
- 0
src/TensorFlowNET.Core/Functions/TF_Function.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Tensorflow.Functions
{
[StructLayout(LayoutKind.Sequential)]
public struct TF_Function
{
FunctionDef fdef;
}
}

+ 2
- 0
src/TensorFlowNET.Core/Functions/c_api.function.cs View File

@@ -18,5 +18,7 @@ namespace Tensorflow
/// <param name="status"></param>
[DllImport(TensorFlowLibName)]
public static extern void TF_FunctionToFunctionDef(IntPtr func, IntPtr output_func_def, IntPtr status);


}
}

+ 1
- 0
src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs View File

@@ -7,6 +7,7 @@ namespace Tensorflow
public class ImportGraphDefOptions : IDisposable
{
private IntPtr _handle;

public int NumReturnOutputs => c_api.TF_ImportGraphDefOptionsNumReturnOutputs(_handle);

public ImportGraphDefOptions()


+ 62
- 0
src/TensorFlowNET.Core/Operations/_UserDeviceSpec.cs View File

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

namespace Tensorflow
{
public class StringOrFunction
{
private object variable;

private StringOrFunction(object val)
{
variable = val;
}

public static implicit operator StringOrFunction(string val)
{
return new StringOrFunction(val);
}

public static implicit operator StringOrFunction(Function val)
{
return new StringOrFunction(val);
}

public bool IsFunction
{
get
{
return variable is FunctionDef;
}
}

public override string ToString()
{
if (variable == null)
return "";

if(!IsFunction)
{
return variable.ToString();
}

return ((FunctionDef)variable).ToString();
}
}

public class _UserDeviceSpec
{
private StringOrFunction _device_name_or_function;
private string display_name;
private FunctionDef function;
private string raw_string;

public _UserDeviceSpec(StringOrFunction device_name_or_function)
{
_device_name_or_function = device_name_or_function;
display_name = device_name_or_function.ToString();
}
}
}

+ 13
- 0
src/TensorFlowNET.Core/Sessions/TF_DeprecatedSession.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Tensorflow.Sessions
{
[StructLayout(LayoutKind.Sequential)]
public struct TF_DeprecatedSession
{
Session session;
}
}

+ 1
- 1
src/TensorFlowNET.Core/Sessions/TF_SessionOptions.cs View File

@@ -8,6 +8,6 @@ namespace Tensorflow
[StructLayout(LayoutKind.Sequential)]
public struct TF_SessionOptions
{
public IntPtr options;
public SessionOptions options;
}
}

+ 1
- 1
src/TensorFlowNET.Core/Status/Status.cs View File

@@ -10,7 +10,7 @@ namespace Tensorflow
/// </summary>
public class Status : IDisposable
{
private readonly IntPtr _handle;
protected readonly IntPtr _handle;

/// <summary>
/// Error message


+ 5
- 0
src/TensorFlowNET.Core/ops.py.cs View File

@@ -14,6 +14,11 @@ namespace Tensorflow
{
public partial class ops
{
public static int tensor_id(Tensor tensor)
{
return tensor.Id;
}

public static void add_to_collection<T>(string name, T value)
{
var graph = tf.get_default_graph();


Loading…
Cancel
Save