FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/TensorFlowNET.Core/ops.threading.cs at master · AhmedZero/TensorFlow.NET · GitHub
AhmedZero
/
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
/
ops.threading.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (85 loc) · 3.87 KB
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
ops.threading.cs
Copy path
File metadata and controls
94 lines (85 loc) · 3.87 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
using
System
;
using
System
.
Threading
;
using
static
Tensorflow
.
Binding
;
namespace
Tensorflow
{
public
partial
class
ops
{
[
ThreadStatic
]
static
DefaultGraphStack
default_graph_stack
=
new
DefaultGraphStack
(
)
;
[
ThreadStatic
]
static
Session
defaultSession
;
/// <summary>
/// Returns the default session for the current thread.
/// </summary>
/// <returns>The default `Session` being used in the current thread.</returns>
public
static
Session
get_default_session
(
)
{
if
(
defaultSession
==
null
)
defaultSession
=
new
Session
(
tf
.
get_default_graph
(
)
)
;
return
defaultSession
;
}
/// <summary>
/// Returns the default session for the current thread.
/// </summary>
/// <returns>The default `Session` being used in the current thread.</returns>
public
static
Session
set_default_session
(
Session
sess
)
{
defaultSession
=
sess
;
return
sess
;
}
/// <summary>
/// Returns the default graph for the current thread.
///
/// The returned graph will be the innermost graph on which a
/// `Graph.as_default()` context has been entered, or a global default
/// graph if none has been explicitly created.
///
/// NOTE: The default graph is a property of the current thread.If you
/// create a new thread, and wish to use the default graph in that
/// thread, you must explicitly add a `with g.as_default():` in that
/// thread's function.
/// </summary>
/// <returns></returns>
public
static
Graph
get_default_graph
(
)
{
if
(
default_graph_stack
==
null
)
default_graph_stack
=
new
DefaultGraphStack
(
)
;
return
default_graph_stack
.
get_default
(
)
;
}
public
static
Graph
set_default_graph
(
Graph
g
)
{
if
(
default_graph_stack
==
null
)
default_graph_stack
=
new
DefaultGraphStack
(
)
;
return
default_graph_stack
.
get_controller
(
g
)
;
}
/// <summary>
/// Clears the default graph stack and resets the global default graph.
///
/// NOTE: The default graph is a property of the current thread.This
/// function applies only to the current thread.Calling this function while
/// a `tf.Session` or `tf.InteractiveSession` is active will result in undefined
/// behavior. Using any previously created `tf.Operation` or `tf.Tensor` objects
/// after calling this function will result in undefined behavior.
/// </summary>
/// <returns></returns>
public
static
void
reset_default_graph
(
)
{
if
(
default_graph_stack
==
null
)
return
;
//if (!_default_graph_stack.is_cleared())
// throw new InvalidOperationException("Do not use tf.reset_default_graph() to clear " +
// "nested graphs. If you need a cleared graph, " +
// "exit the nesting and create a new graph.");
default_graph_stack
.
reset
(
)
;
}
public
static
Graph
peak_default_graph
(
)
{
if
(
default_graph_stack
==
null
)
default_graph_stack
=
new
DefaultGraphStack
(
)
;
return
default_graph_stack
.
peak_controller
(
)
;
}
public
static
void
pop_graph
(
)
=>
default_graph_stack
.
pop
(
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL