Repository navigation
Expand file tree
/
Copy pathc_api.tensor.cs
More file actions
81 lines (73 loc) · 2.96 KB
/
Copy pathc_api.tensor.cs
File metadata and controls
81 lines (73 loc) · 2.96 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
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);
}
}