| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,12 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | 3 | namespace Tensorflow.Eager | |
| 4 | 4 | { | |
| 5 | - public class Context : IDisposable | ||
| 5 | + public class Context : DisposableObject | ||
| 6 | 6 | { | |
| 7 | - private IntPtr _handle; | ||
| 8 | - | ||
| 9 | - public static int GRAPH_MODE = 0; | ||
| 10 | - public static int EAGER_MODE = 1; | ||
| 7 | + public const int GRAPH_MODE = 0; | ||
| 8 | + public const int EAGER_MODE = 1; | ||
| 11 | 9 | ||
| 12 | 10 | public int default_execution_mode; | |
| 13 | 11 | ||
@@ -17,19 +15,16 @@ public Context(ContextOptions opts, Status status) | |||
| 17 | 15 | status.Check(true); | |
| 18 | 16 | } | |
| 19 | 17 | ||
| 20 | - public void Dispose() | ||
| 21 | - { | ||
| 22 | - c_api.TFE_DeleteContext(_handle); | ||
| 23 | - } | ||
| 18 | + /// <summary> | ||
| 19 | + /// Dispose any unmanaged resources related to given <paramref name="handle"/>. | ||
| 20 | + /// </summary> | ||
| 21 | + protected sealed override void DisposeUnmanagedResources(IntPtr handle) | ||
| 22 | + => c_api.TFE_DeleteContext(_handle); | ||
| 24 | 23 | ||
| 25 | - public bool executing_eagerly() | ||
| 26 | - { | ||
| 27 | - return false; | ||
| 28 | - } | ||
| 29 | 24 | ||
| 30 | - public static implicit operator IntPtr(Context ctx) | ||
| 31 | - { | ||
| 32 | - return ctx._handle; | ||
| 33 | - } | ||
| 25 | + public bool executing_eagerly() => false; | ||
| 26 | + | ||
| 27 | + public static implicit operator IntPtr(Context ctx) | ||
| 28 | + => ctx._handle; | ||
| 34 | 29 | } | |
| 35 | 30 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,23 +3,20 @@ | |||
| 3 | 3 | ||
| 4 | 4 | namespace Tensorflow.Eager | |
| 5 | 5 | { | |
| 6 | - public class ContextOptions : IDisposable //TODO! Eli: Shouldn't this inherieting DisposableObject? | ||
| 6 | + public class ContextOptions : DisposableObject | ||
| 7 | 7 | { | |
| 8 | - private IntPtr _handle; | ||
| 8 | + public ContextOptions() : base(c_api.TFE_NewContextOptions()) | ||
| 9 | + { } | ||
| 9 | 10 | ||
| 10 | - public ContextOptions() | ||
| 11 | - { | ||
| 12 | - _handle = c_api.TFE_NewContextOptions(); | ||
| 13 | - } | ||
| 11 | + /// <summary> | ||
| 12 | + /// Dispose any unmanaged resources related to given <paramref name="handle"/>. | ||
| 13 | + /// </summary> | ||
| 14 | + protected sealed override void DisposeUnmanagedResources(IntPtr handle) | ||
| 15 | + => c_api.TFE_DeleteContextOptions(_handle); | ||
| 14 | 16 | ||
| 15 | - public void Dispose() | ||
| 16 | - { | ||
| 17 | - c_api.TFE_DeleteContextOptions(_handle); | ||
| 18 | - } | ||
| 19 | 17 | ||
| 20 | - public static implicit operator IntPtr(ContextOptions opts) | ||
| 21 | - { | ||
| 22 | - return opts._handle; | ||
| 23 | - } | ||
| 18 | + public static implicit operator IntPtr(ContextOptions opts) | ||
| 19 | + => opts._handle; | ||
| 24 | 20 | } | |
| 21 | + | ||
| 25 | 22 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments