|
|
|
@@ -2,6 +2,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Threading; |
|
|
|
using static Tensorflow.Binding; |
|
|
|
|
|
|
|
namespace Tensorflow.NumPy |
|
|
|
@@ -10,9 +11,12 @@ namespace Tensorflow.NumPy |
|
|
|
public sealed class AutoNumPyAttribute : OnMethodBoundaryAspect |
|
|
|
{ |
|
|
|
bool _changedMode = false; |
|
|
|
|
|
|
|
bool _locked = false; |
|
|
|
static object locker = new Object(); |
|
|
|
public override void OnEntry(MethodExecutionArgs args) |
|
|
|
{ |
|
|
|
Monitor.Enter(locker, ref _locked); |
|
|
|
|
|
|
|
if (!tf.executing_eagerly()) |
|
|
|
{ |
|
|
|
tf.Context.eager_mode(); |
|
|
|
@@ -24,6 +28,9 @@ namespace Tensorflow.NumPy |
|
|
|
{ |
|
|
|
if (_changedMode) |
|
|
|
tf.Context.restore_mode(); |
|
|
|
|
|
|
|
if (_locked) |
|
|
|
Monitor.Exit(locker); |
|
|
|
} |
|
|
|
} |
|
|
|
} |