forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc_api.cs
More file actions
89 lines (67 loc) · 3.58 KB
/
c_api.cs
File metadata and controls
89 lines (67 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using size_t = System.UIntPtr;
using TF_Graph = System.IntPtr;
using TF_Operation = System.IntPtr;
using TF_Status = System.IntPtr;
using TF_Tensor = System.IntPtr;
using TF_Session = System.IntPtr;
using TF_SessionOptions = System.IntPtr;
using TF_DataType = Tensorflow.DataType;
namespace Tensorflow
{
public static 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);
[DllImport(TensorFlowLibName)]
public static unsafe extern void TF_DeleteSessionOptions(TF_SessionOptions opts);
[DllImport(TensorFlowLibName)]
public static unsafe extern TF_Operation TF_FinishOperation(TF_OperationDescription desc, TF_Status status);
[DllImport(TensorFlowLibName)]
public static extern string TF_GetBuffer(IntPtr buffer);
[DllImport(TensorFlowLibName)]
public static extern unsafe TF_Code TF_GetCode(TF_Status s);
[DllImport(TensorFlowLibName)]
public static extern void TF_GraphGetOpDef(TF_Graph graph, string op_name, IntPtr output_op_def, TF_Status status);
[DllImport(TensorFlowLibName)]
public static extern unsafe string TF_Message(TF_Status s);
[DllImport(TensorFlowLibName)]
public static unsafe extern TF_Graph TF_NewGraph();
[DllImport(TensorFlowLibName)]
public static unsafe extern TF_OperationDescription TF_NewOperation(TF_Graph graph, string opType, string oper_name);
[DllImport(TensorFlowLibName)]
public static unsafe extern TF_Status TF_NewStatus();
[DllImport(TensorFlowLibName)]
public static extern unsafe TF_Tensor TF_NewTensor(TF_DataType dataType, Int64 dims, int num_dims, IntPtr data, size_t len, tf.Deallocator deallocator, IntPtr deallocator_arg);
[DllImport(TensorFlowLibName)]
public static extern unsafe int TF_OperationNumOutputs(TF_Operation oper);
[DllImport(TensorFlowLibName)]
public static extern unsafe void TF_SetAttrValueProto(TF_OperationDescription desc, string attr_name, IntPtr proto, size_t proto_len, TF_Status status);
[DllImport(TensorFlowLibName)]
public static extern unsafe void TF_SetAttrTensor(TF_OperationDescription desc, string attr_name, TF_Tensor value, TF_Status status);
[DllImport(TensorFlowLibName)]
public static extern unsafe void TF_SessionRun(TF_Session session, IntPtr run_options,
TF_Output[] inputs, TF_Tensor[] input_values, int ninputs,
TF_Output[] outputs, TF_Tensor[] output_values, int noutputs,
TF_Operation[] target_opers, int ntargets,
IntPtr run_metadata,
TF_Status status);
[DllImport(TensorFlowLibName)]
public static extern unsafe void TF_SetAttrType(TF_OperationDescription desc, string attr_name, TF_DataType value);
[DllImport(TensorFlowLibName)]
public static extern TF_Session TF_NewSession(TF_Graph graph, TF_SessionOptions opts, TF_Status status);
[DllImport(TensorFlowLibName)]
public static extern TF_SessionOptions TF_NewSessionOptions();
[DllImport(TensorFlowLibName)]
public static unsafe extern IntPtr TF_Version();
}
}