Skip to content

Commit 1143d86

Browse files
Scoped Struct Added for Ops API extensions
1 parent 2bb4976 commit 1143d86

File tree

14 files changed

+193
-2
lines changed

14 files changed

+193
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework.Models
6+
{
7+
class ScopedTFFunction
8+
{
9+
}
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework.Models
6+
{
7+
public class ScopedTFGraph : Graph
8+
{
9+
public ScopedTFGraph() : base()
10+
{
11+
12+
}
13+
14+
~ScopedTFGraph()
15+
{
16+
base.Dispose();
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework.Models
6+
{
7+
public class ScopedTFImportGraphDefOptions : ImportGraphDefOptions
8+
{
9+
public ScopedTFImportGraphDefOptions() : base()
10+
{
11+
12+
}
13+
14+
~ScopedTFImportGraphDefOptions()
15+
{
16+
base.Dispose();
17+
}
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework.Models
6+
{
7+
public class ScopedTFImportGraphDefResults : ImportGraphDefOptions
8+
{
9+
public ScopedTFImportGraphDefResults() : base()
10+
{
11+
12+
}
13+
14+
public ScopedTFImportGraphDefResults(IntPtr results) : base(results)
15+
{
16+
17+
}
18+
19+
~ScopedTFImportGraphDefResults()
20+
{
21+
base.Dispose();
22+
}
23+
}
24+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework.Models
6+
{
7+
public class ScopedTFStatus : Status
8+
{
9+
public ScopedTFStatus() : base()
10+
{
11+
}
12+
13+
~ScopedTFStatus()
14+
{
15+
base.Dispose();
16+
}
17+
}
18+
}

src/TensorFlowNET.Core/Functions/Function.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ namespace Tensorflow
66
{
77
public class Function
88
{
9+
private IntPtr _handle;
910

11+
public Function()
12+
{
13+
14+
}
1015
}
1116
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Runtime.InteropServices;
4+
using System.Text;
5+
6+
namespace Tensorflow.Functions
7+
{
8+
[StructLayout(LayoutKind.Sequential)]
9+
public struct TF_Function
10+
{
11+
FunctionDef fdef;
12+
}
13+
}

src/TensorFlowNET.Core/Functions/c_api.function.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ public partial class c_api
1818
/// <param name="status"></param>
1919
[DllImport(TensorFlowLibName)]
2020
public static extern void TF_FunctionToFunctionDef(IntPtr func, IntPtr output_func_def, IntPtr status);
21+
22+
2123
}
2224
}

src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Tensorflow
77
public class ImportGraphDefOptions : IDisposable
88
{
99
private IntPtr _handle;
10+
1011
public int NumReturnOutputs => c_api.TF_ImportGraphDefOptionsNumReturnOutputs(_handle);
1112

1213
public ImportGraphDefOptions()
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow
6+
{
7+
public class StringOrFunction
8+
{
9+
private object variable;
10+
11+
private StringOrFunction(object val)
12+
{
13+
variable = val;
14+
}
15+
16+
public static implicit operator StringOrFunction(string val)
17+
{
18+
return new StringOrFunction(val);
19+
}
20+
21+
public static implicit operator StringOrFunction(Function val)
22+
{
23+
return new StringOrFunction(val);
24+
}
25+
26+
public bool IsFunction
27+
{
28+
get
29+
{
30+
return variable is FunctionDef;
31+
}
32+
}
33+
34+
public override string ToString()
35+
{
36+
if (variable == null)
37+
return "";
38+
39+
if(!IsFunction)
40+
{
41+
return variable.ToString();
42+
}
43+
44+
return ((FunctionDef)variable).ToString();
45+
}
46+
}
47+
48+
public class _UserDeviceSpec
49+
{
50+
private StringOrFunction _device_name_or_function;
51+
private string display_name;
52+
private FunctionDef function;
53+
private string raw_string;
54+
55+
public _UserDeviceSpec(StringOrFunction device_name_or_function)
56+
{
57+
58+
_device_name_or_function = device_name_or_function;
59+
display_name = device_name_or_function.ToString();
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)