|
1 | | -using System; |
2 | | -using System.IO; |
| 1 | +/***************************************************************************** |
| 2 | + Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +******************************************************************************/ |
| 16 | + |
| 17 | +using System; |
3 | 18 |
|
4 | 19 | namespace Tensorflow.Eager |
5 | 20 | { |
6 | | - public class ContextOptions : DisposableObject |
| 21 | + public sealed class ContextOptions : IDisposable |
7 | 22 | { |
8 | | - public ContextOptions() : base(c_api.TFE_NewContextOptions()) |
9 | | - { } |
| 23 | + public SafeContextOptionsHandle Handle { get; } |
10 | 24 |
|
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); |
| 25 | + public ContextOptions() |
| 26 | + { |
| 27 | + Handle = c_api.TFE_NewContextOptions(); |
| 28 | + } |
16 | 29 |
|
17 | | - |
18 | | - public static implicit operator IntPtr(ContextOptions opts) |
19 | | - => opts._handle; |
20 | | - |
21 | | - public static implicit operator TFE_ContextOptions(ContextOptions opts) |
22 | | - => new TFE_ContextOptions(opts._handle); |
23 | | - |
| 30 | + public void Dispose() |
| 31 | + => Handle.Dispose(); |
24 | 32 | } |
25 | | - |
26 | 33 | } |
0 commit comments