2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 namespace Tizen.MachineLearning.Train
23 /// Constructs the neural network model
26 /// Use this function to create neural network model.
27 /// The Model class provides interfaces to construct, complle, run, adding layer
28 /// and etc with neural networks.
29 /// If you want to access only internal storage by using this function,
30 /// you should add privilege %http://tizen.org/privilege/mediastorage. Or, if you
31 /// want to access only external storage by using this function, you should add
32 /// privilege %http://tizen.org/privilege/externalstorage. If you want to access
33 /// both storage, you must add all the privileges.
35 /// <since_tizen> 10 </since_tizen>
36 public class Model: IDisposable
38 private IntPtr _handle = IntPtr.Zero;
39 private bool _disposed = false;
42 /// Create a new Model instance.
44 /// <since_tizen> 10 </since_tizen>
47 NNTrainerError ret = Interop.Model.Construct(out _handle);
48 NNTrainer.CheckException(ret, "Failed to create model instance");
52 /// Destructor of Model
54 /// <since_tizen> 10 </since_tizen>
61 /// Releases any unmanaged resources used by this object.
63 /// <since_tizen> 10 </since_tizen>
67 GC.SuppressFinalize(this);
71 /// Releases any unmanaged resources used by this object including opened handle.
73 /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
74 /// <since_tizen> 10 </since_tizen>
75 protected virtual void Dispose(bool disposing)
81 // release managed object
84 // release unmanaged object
85 if (_handle != IntPtr.Zero)
87 // Destroy the neural network model.
88 NNTrainerError ret = Interop.Model.Destroy(_handle);
89 NNTrainer.CheckException(ret, "Failed to destroy model instance");
91 _handle = IntPtr.Zero;