|
1 | 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; |
2 | 2 | using System; |
3 | 3 | using Tensorflow; |
| 4 | +using Tensorflow.Device; |
4 | 5 | using Tensorflow.Eager; |
5 | 6 | using Buffer = System.Buffer; |
6 | 7 |
|
7 | 8 | namespace TensorFlowNET.UnitTest |
8 | 9 | { |
9 | 10 | public class CApiTest |
10 | 11 | { |
11 | | - protected TF_Code TF_OK = TF_Code.TF_OK; |
12 | | - protected TF_DataType TF_FLOAT = TF_DataType.TF_FLOAT; |
13 | | - protected TF_DataType TF_BOOL = TF_DataType.TF_BOOL; |
| 12 | + protected static readonly TF_Code TF_OK = TF_Code.TF_OK; |
| 13 | + protected static readonly TF_DataType TF_FLOAT = TF_DataType.TF_FLOAT; |
| 14 | + protected static readonly TF_DataType TF_BOOL = TF_DataType.TF_BOOL; |
14 | 15 |
|
15 | 16 | protected void EXPECT_TRUE(bool expected, string msg = "") |
16 | 17 | => Assert.IsTrue(expected, msg); |
17 | 18 |
|
18 | | - protected void EXPECT_EQ(object expected, object actual, string msg = "") |
| 19 | + protected static void EXPECT_EQ(object expected, object actual, string msg = "") |
19 | 20 | => Assert.AreEqual(expected, actual, msg); |
20 | 21 |
|
21 | 22 | protected void CHECK_EQ(object expected, object actual, string msg = "") |
@@ -63,10 +64,10 @@ protected int TFE_TensorHandleNumDims(IntPtr h, SafeStatusHandle status) |
63 | 64 | protected TF_Code TF_GetCode(Status s) |
64 | 65 | => s.Code; |
65 | 66 |
|
66 | | - protected TF_Code TF_GetCode(SafeStatusHandle s) |
| 67 | + protected static TF_Code TF_GetCode(SafeStatusHandle s) |
67 | 68 | => c_api.TF_GetCode(s); |
68 | 69 |
|
69 | | - protected string TF_Message(SafeStatusHandle s) |
| 70 | + protected static string TF_Message(SafeStatusHandle s) |
70 | 71 | => c_api.StringPiece(c_api.TF_Message(s)); |
71 | 72 |
|
72 | 73 | protected SafeStatusHandle TF_NewStatus() |
@@ -141,21 +142,18 @@ protected string TFE_TensorHandleDeviceName(IntPtr h, SafeStatusHandle status) |
141 | 142 | protected string TFE_TensorHandleBackingDeviceName(IntPtr h, SafeStatusHandle status) |
142 | 143 | => c_api.StringPiece(c_api.TFE_TensorHandleBackingDeviceName(h, status)); |
143 | 144 |
|
144 | | - protected IntPtr TFE_ContextListDevices(SafeContextHandle ctx, SafeStatusHandle status) |
| 145 | + protected SafeDeviceListHandle TFE_ContextListDevices(SafeContextHandle ctx, SafeStatusHandle status) |
145 | 146 | => c_api.TFE_ContextListDevices(ctx, status); |
146 | 147 |
|
147 | | - protected int TF_DeviceListCount(IntPtr list) |
| 148 | + protected int TF_DeviceListCount(SafeDeviceListHandle list) |
148 | 149 | => c_api.TF_DeviceListCount(list); |
149 | 150 |
|
150 | | - protected string TF_DeviceListType(IntPtr list, int index, SafeStatusHandle status) |
| 151 | + protected string TF_DeviceListType(SafeDeviceListHandle list, int index, SafeStatusHandle status) |
151 | 152 | => c_api.StringPiece(c_api.TF_DeviceListType(list, index, status)); |
152 | 153 |
|
153 | | - protected string TF_DeviceListName(IntPtr list, int index, SafeStatusHandle status) |
| 154 | + protected string TF_DeviceListName(SafeDeviceListHandle list, int index, SafeStatusHandle status) |
154 | 155 | => c_api.StringPiece(c_api.TF_DeviceListName(list, index, status)); |
155 | 156 |
|
156 | | - protected void TF_DeleteDeviceList(IntPtr list) |
157 | | - => c_api.TF_DeleteDeviceList(list); |
158 | | - |
159 | 157 | protected IntPtr TFE_TensorHandleCopyToDevice(IntPtr h, SafeContextHandle ctx, string device_name, SafeStatusHandle status) |
160 | 158 | => c_api.TFE_TensorHandleCopyToDevice(h, ctx, device_name, status); |
161 | 159 |
|
|
0 commit comments