FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/TensorFlowNET.Core/Device/c_api.device.cs at master · feelsyt/TensorFlow.NET · GitHub
feelsyt
/
TensorFlow.NET
Public
forked from
SciSharp/TensorFlow.NET
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
Device
/
c_api.device.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
96 lines (85 loc) · 4.08 KB
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
Device
/
c_api.device.cs
Copy path
File metadata and controls
96 lines (85 loc) · 4.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
92
93
94
95
96
/*****************************************************************************
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
using
System
;
using
System
.
Runtime
.
InteropServices
;
using
Tensorflow
.
Device
;
using
Tensorflow
.
Eager
;
using
Tensorflow
.
Util
;
namespace
Tensorflow
{
public
partial
class
c_api
{
/// <summary>
/// Specify the device for `desc`. Defaults to empty, meaning unconstrained.
/// </summary>
/// <param name="desc"></param>
/// <param name="device"></param>
[
DllImport
(
TensorFlowLibName
)
]
public
static
extern
void
TF_SetDevice
(
IntPtr
desc
,
string
device
)
;
/// <summary>
/// Counts the number of elements in the device list.
/// </summary>
/// <param name="list">TF_DeviceList*</param>
/// <returns></returns>
[
DllImport
(
TensorFlowLibName
)
]
public
static
extern
int
TF_DeviceListCount
(
SafeDeviceListHandle
list
)
;
/// <summary>
/// Retrieves the type of the device at the given index.
/// </summary>
/// <param name="list">TF_DeviceList*</param>
/// <param name="index">int</param>
/// <param name="status">TF_Status*</param>
/// <returns></returns>
[
DllImport
(
TensorFlowLibName
)
]
public
static
extern
IntPtr
TF_DeviceListType
(
SafeDeviceListHandle
list
,
int
index
,
SafeStatusHandle
status
)
;
/// <summary>
/// Deallocates the device list.
/// </summary>
/// <param name="list">TF_DeviceList*</param>
[
DllImport
(
TensorFlowLibName
)
]
public
static
extern
void
TF_DeleteDeviceList
(
IntPtr
list
)
;
/// <summary>
/// Create a new TFE_TensorHandle with the same contents as 'h' but placed
/// in the memory of the device name 'device_name'.
/// </summary>
/// <param name="h">TFE_TensorHandle*</param>
/// <param name="ctx">TFE_Context*</param>
/// <param name="device_name">char*</param>
/// <param name="status">TF_Status*</param>
/// <returns>TFE_TensorHandle*</returns>
[
DllImport
(
TensorFlowLibName
)
]
public
static
extern
SafeEagerTensorHandle
TFE_TensorHandleCopyToDevice
(
SafeEagerTensorHandle
h
,
SafeContextHandle
ctx
,
string
device_name
,
SafeStatusHandle
status
)
;
/// <summary>
/// Retrieves the full name of the device (e.g. /job:worker/replica:0/...)
/// </summary>
/// <param name="list">TF_DeviceList*</param>
/// <param name="index"></param>
/// <param name="status">TF_Status*</param>
public
static
string
TF_DeviceListName
(
SafeDeviceListHandle
list
,
int
index
,
SafeStatusHandle
status
)
{
using
var
_
=
list
.
Lease
(
)
;
return
StringPiece
(
TF_DeviceListNameImpl
(
list
,
index
,
status
)
)
;
}
/// <summary>
/// Retrieves the full name of the device (e.g. /job:worker/replica:0/...)
/// The return value will be a pointer to a null terminated string. The caller
/// must not modify or delete the string. It will be deallocated upon a call to
/// TF_DeleteDeviceList.
/// </summary>
/// <param name="list">TF_DeviceList*</param>
/// <param name="index"></param>
/// <param name="status">TF_Status*</param>
[
DllImport
(
TensorFlowLibName
,
EntryPoint
=
"TF_DeviceListName"
)
]
private
static
extern
IntPtr
TF_DeviceListNameImpl
(
SafeDeviceListHandle
list
,
int
index
,
SafeStatusHandle
status
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL