forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc_api_lite.cs
More file actions
91 lines (65 loc) · 3.82 KB
/
c_api_lite.cs
File metadata and controls
91 lines (65 loc) · 3.82 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
90
91
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Tensorflow.Lite;
namespace Tensorflow
{
public class c_api_lite
{
public const string TensorFlowLibName = "tensorflowlite_c";
public static string StringPiece(IntPtr handle)
{
return handle == IntPtr.Zero ? String.Empty : Marshal.PtrToStringAnsi(handle);
}
[DllImport(TensorFlowLibName)]
public static extern IntPtr TfLiteVersion();
[DllImport(TensorFlowLibName)]
public static extern SafeTfLiteModelHandle TfLiteModelCreateFromFile(string model_path);
[DllImport(TensorFlowLibName)]
public static extern void TfLiteModelDelete(IntPtr model);
[DllImport(TensorFlowLibName)]
public static extern SafeTfLiteInterpreterOptionsHandle TfLiteInterpreterOptionsCreate();
[DllImport(TensorFlowLibName)]
public static extern void TfLiteInterpreterOptionsDelete(IntPtr options);
[DllImport(TensorFlowLibName)]
public static extern void TfLiteInterpreterOptionsSetNumThreads(SafeTfLiteInterpreterOptionsHandle options, int num_threads);
[DllImport(TensorFlowLibName)]
public static extern SafeTfLiteInterpreterHandle TfLiteInterpreterCreate(SafeTfLiteModelHandle model, SafeTfLiteInterpreterOptionsHandle optional_options);
[DllImport(TensorFlowLibName)]
public static extern void TfLiteInterpreterDelete(IntPtr interpreter);
[DllImport(TensorFlowLibName)]
public static extern TfLiteStatus TfLiteInterpreterAllocateTensors(SafeTfLiteInterpreterHandle interpreter);
[DllImport(TensorFlowLibName)]
public static extern int TfLiteInterpreterGetInputTensorCount(SafeTfLiteInterpreterHandle interpreter);
[DllImport(TensorFlowLibName)]
public static extern int TfLiteInterpreterGetOutputTensorCount(SafeTfLiteInterpreterHandle interpreter);
[DllImport(TensorFlowLibName)]
public static extern TfLiteStatus TfLiteInterpreterResizeInputTensor(SafeTfLiteInterpreterHandle interpreter,
int input_index, int[] input_dims, int input_dims_size);
[DllImport(TensorFlowLibName)]
public static extern TfLiteTensor TfLiteInterpreterGetInputTensor(SafeTfLiteInterpreterHandle interpreter, int input_index);
[DllImport(TensorFlowLibName)]
public static extern TfLiteDataType TfLiteTensorType(TfLiteTensor tensor);
[DllImport(TensorFlowLibName)]
public static extern int TfLiteTensorNumDims(TfLiteTensor tensor);
[DllImport(TensorFlowLibName)]
public static extern int TfLiteTensorDim(TfLiteTensor tensor, int dim_index);
[DllImport(TensorFlowLibName)]
public static extern int TfLiteTensorByteSize(TfLiteTensor tensor);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TfLiteTensorData(TfLiteTensor tensor);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TfLiteTensorName(TfLiteTensor tensor);
[DllImport(TensorFlowLibName)]
public static extern TfLiteQuantizationParams TfLiteTensorQuantizationParams(TfLiteTensor tensor);
[DllImport(TensorFlowLibName)]
public static extern TfLiteStatus TfLiteTensorCopyFromBuffer(TfLiteTensor tensor, IntPtr input_data, int input_data_size);
[DllImport(TensorFlowLibName)]
public static extern TfLiteStatus TfLiteInterpreterInvoke(SafeTfLiteInterpreterHandle interpreter);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TfLiteInterpreterGetOutputTensor(SafeTfLiteInterpreterHandle interpreter, int output_index);
[DllImport(TensorFlowLibName)]
public static extern TfLiteStatus TfLiteTensorCopyToBuffer(TfLiteTensor output_tensor, IntPtr output_data, int output_data_size);
}
}