@@ -18,6 +18,7 @@ limitations under the License.
1818using System . Runtime . InteropServices ;
1919using Tensorflow . Device ;
2020using Tensorflow . Eager ;
21+ using Tensorflow . Util ;
2122
2223namespace Tensorflow
2324{
@@ -68,6 +69,18 @@ public partial class c_api
6869 [ DllImport ( TensorFlowLibName ) ]
6970 public static extern IntPtr TFE_TensorHandleCopyToDevice ( IntPtr h , SafeContextHandle ctx , string device_name , SafeStatusHandle status ) ;
7071
72+ /// <summary>
73+ /// Retrieves the full name of the device (e.g. /job:worker/replica:0/...)
74+ /// </summary>
75+ /// <param name="list">TF_DeviceList*</param>
76+ /// <param name="index"></param>
77+ /// <param name="status">TF_Status*</param>
78+ public static string TF_DeviceListName ( SafeDeviceListHandle list , int index , SafeStatusHandle status )
79+ {
80+ using var _ = list . Lease ( ) ;
81+ return StringPiece ( TF_DeviceListNameImpl ( list , index , status ) ) ;
82+ }
83+
7184 /// <summary>
7285 /// Retrieves the full name of the device (e.g. /job:worker/replica:0/...)
7386 /// The return value will be a pointer to a null terminated string. The caller
@@ -77,7 +90,7 @@ public partial class c_api
7790 /// <param name="list">TF_DeviceList*</param>
7891 /// <param name="index"></param>
7992 /// <param name="status">TF_Status*</param>
80- [ DllImport ( TensorFlowLibName ) ]
81- public static extern IntPtr TF_DeviceListName ( SafeDeviceListHandle list , int index , SafeStatusHandle status ) ;
93+ [ DllImport ( TensorFlowLibName , EntryPoint = "TF_DeviceListName" ) ]
94+ private static extern IntPtr TF_DeviceListNameImpl ( SafeDeviceListHandle list , int index , SafeStatusHandle status ) ;
8295 }
8396}
0 commit comments