You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Forces the library to ignore different thread accessing.
54
+
/// </summary>
55
+
/// <remarks>https://github.com/SciSharp/TensorFlow.NET/wiki/Multithreading <br></br>Note that this discards any sessions and graphs used in a multithreaded manner</remarks>
56
+
publicstaticvoidenforce_singlethreading()
57
+
{
58
+
isSingleThreaded=true;
59
+
}
60
+
61
+
/// <summary>
62
+
/// Forces the library to provide a separate <see cref="Session"/> and <see cref="Graph"/> to every different thread accessing.
63
+
/// </summary>
64
+
/// <remarks>https://github.com/SciSharp/TensorFlow.NET/wiki/Multithreading <br></br>Note that this discards any sessions and graphs used in a singlethreaded manner</remarks>
65
+
publicstaticvoidenforce_multithreading()
66
+
{
67
+
isSingleThreaded=false;
68
+
}
69
+
70
+
/// <summary>
71
+
/// Returns the default session for the current thread.
72
+
/// </summary>
73
+
/// <returns>The default `Session` being used in the current thread.</returns>
74
+
publicstaticSessionget_default_session()
75
+
{
76
+
if(!isSingleThreaded)
77
+
returntf.defaultSession;
78
+
79
+
if(_singleSesson==null)
80
+
{
81
+
lock(_threadingLock)
82
+
{
83
+
if(_singleSesson==null)
84
+
_singleSesson=newSession();
85
+
}
86
+
}
87
+
88
+
return_singleSesson;
89
+
}
90
+
91
+
/// <summary>
92
+
/// Returns the default session for the current thread.
93
+
/// </summary>
94
+
/// <returns>The default `Session` being used in the current thread.</returns>
0 commit comments