/// Forces the library to ignore different thread accessing.
/// </summary>
/// <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>
publicstaticvoidenforce_singlethreading()
{
isSingleThreaded=true;
}
/// <summary>
/// Forces the library to provide a separate <see cref="Session"/> and <see cref="Graph"/> to every different thread accessing.
/// </summary>
/// <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>
publicstaticvoidenforce_multithreading()
{
isSingleThreaded=false;
}
/// <summary>
/// Returns the default session for the current thread.
/// </summary>
/// <returns>The default `Session` being used in the current thread.</returns>
publicstaticSessionget_default_session()
{
if(!isSingleThreaded)
returntf.defaultSession;
if(_singleSesson==null)
{
lock(_threadingLock)
{
if(_singleSesson==null)
_singleSesson=newSession();
}
}
return_singleSesson;
}
/// <summary>
/// Returns the default session for the current thread.
/// </summary>
/// <returns>The default `Session` being used in the current thread.</returns>