| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8f32e83 commit f3a5d19
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,7 +52,6 @@ public bool Import(byte[] bytes, string prefix = "") | |||
| 52 | 52 | using (var status = new Status()) | |
| 53 | 53 | using (var graph_def = new Buffer(bytes)) | |
| 54 | 54 | { | |
| 55 | - as_default(); | ||
| 56 | 55 | c_api.TF_ImportGraphDefOptionsSetPrefix(opts.Handle, prefix); | |
| 57 | 56 | c_api.TF_GraphImportGraphDef(_handle, graph_def.Handle, opts.Handle, status.Handle); | |
| 58 | 57 | status.Check(true); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | using System; | |
| 3 | 3 | using System.Collections.Generic; | |
| 4 | 4 | using System.Diagnostics; | |
| 5 | + using System.Threading; | ||
| 5 | 6 | using static Tensorflow.Binding; | |
| 6 | 7 | ||
| 7 | 8 | namespace Tensorflow.NumPy | |
@@ -10,9 +11,12 @@ namespace Tensorflow.NumPy | |||
| 10 | 11 | public sealed class AutoNumPyAttribute : OnMethodBoundaryAspect | |
| 11 | 12 | { | |
| 12 | 13 | bool _changedMode = false; | |
| 13 | - | ||
| 14 | + bool _locked = false; | ||
| 15 | + static object locker = new Object(); | ||
| 14 | 16 | public override void OnEntry(MethodExecutionArgs args) | |
| 15 | 17 | { | |
| 18 | + Monitor.Enter(locker, ref _locked); | ||
| 19 | + | ||
| 16 | 20 | if (!tf.executing_eagerly()) | |
| 17 | 21 | { | |
| 18 | 22 | tf.Context.eager_mode(); | |
@@ -24,6 +28,9 @@ public override void OnExit(MethodExecutionArgs args) | |||
| 24 | 28 | { | |
| 25 | 29 | if (_changedMode) | |
| 26 | 30 | tf.Context.restore_mode(); | |
| 31 | + | ||
| 32 | + if (_locked) | ||
| 33 | + Monitor.Exit(locker); | ||
| 27 | 34 | } | |
| 28 | 35 | } | |
| 29 | 36 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ public partial class NDArray : Tensor, IEnumerable<NDArray> | |||
| 30 | 30 | ||
| 31 | 31 | [AutoNumPy] | |
| 32 | 32 | public NDArray reshape(Shape newshape) => new NDArray(tf.reshape(this, newshape)); | |
| 33 | + [AutoNumPy] | ||
| 33 | 34 | public NDArray astype(TF_DataType dtype) => new NDArray(math_ops.cast(this, dtype)); | |
| 34 | 35 | public NDArray ravel() => throw new NotImplementedException(""); | |
| 35 | 36 | public void shuffle(NDArray nd) => np.random.shuffle(nd); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,7 +126,6 @@ public static Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, s | |||
| 126 | 126 | return tf_with(ops.name_scope(name, "Cast", new { x }), scope => | |
| 127 | 127 | { | |
| 128 | 128 | name = scope; | |
| 129 | - x = ops.convert_to_tensor(x, name: "x"); | ||
| 130 | 129 | if (x.dtype.as_base_dtype() != base_type) | |
| 131 | 130 | x = gen_math_ops.cast(x, base_type, name: name); | |
| 132 | 131 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,7 +101,7 @@ private static Tensor convert_to_eager_tensor(object value, Context ctx, TF_Data | |||
| 101 | 101 | value is NDArray nd && | |
| 102 | 102 | nd.dtype != dtype) | |
| 103 | 103 | { | |
| 104 | - value = nd.astype(dtype); | ||
| 104 | + value = math_ops.cast(nd, dtype); | ||
| 105 | 105 | } | |
| 106 | 106 | ||
| 107 | 107 | // non ascii char | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -197,13 +197,6 @@ public AndConstraint<NDArrayAssertions> BeScalar() | |||
| 197 | 197 | return new AndConstraint<NDArrayAssertions>(this); | |
| 198 | 198 | } | |
| 199 | 199 | ||
| 200 | - public AndConstraint<NDArrayAssertions> BeScalar(object value) | ||
| 201 | - { | ||
| 202 | - Subject.shape.IsScalar.Should().BeTrue(); | ||
| 203 | - Subject.GetValue().Should().Be(value); | ||
| 204 | - return new AndConstraint<NDArrayAssertions>(this); | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | 200 | public AndConstraint<NDArrayAssertions> BeOfType(Type typeCode) | |
| 208 | 201 | { | |
| 209 | 202 | Subject.dtype.Should().Be(typeCode); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments