[DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_destroy")]
public static extern NNTrainerError Destroy(IntPtr modelHandle);
- /* int ml_train_model_construct_with_conf(const char *model_conf, ml_train_model_h *model)*/
+ /* int ml_train_model_construct_with_conf(const char *model_conf, ml_train_model_h *model) */
[DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_construct_with_conf")]
public static extern NNTrainerError ConstructWithConf(string modelConf, out IntPtr modelHandle);
[DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_add_layer")]
public static extern NNTrainerError AddLayer(IntPtr modelHandle, IntPtr layerHandle);
+ /* int ml_train_model_get_layer(ml_train_model_h model, const char *layer_name, ml_train_layer_h *layer) */
+ [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_get_layer")]
+ public static extern NNTrainerError GetLayer(IntPtr modelHandle, string layerName, out IntPtr layer);
+
}
}
NNTrainer.CheckException(NNTrainerError.InvalidParameter, "layer instance is null");
NNTrainerError ret = Interop.Model.AddLayer(handle, layer.GetHandle());
NNTrainer.CheckException(ret, "Failed to compile model");
+ Log.Info("MLT", $"AddLayer:\n{layer.GetHandle()}");
+ }
+
+ /// <summary>
+ /// Gets neural network layer from the model with the given name.
+ /// </summary>
+ /// <remarks>
+ /// Use this function to get already created Neural Network Layer.
+ /// The returned layer must not be deleted as it is owned by the model.
+ /// </remarks>
+ /// <param name="layerName"> Name of the already created layer.</param>
+ /// <param name="layerHandle"> layer handle from the given description.</param>
+ /// <since_tizen> 10 </since_tizen>
+ public void GetLayer(string layerName, out IntPtr layerHandle)
+ {
+ if (string.IsNullOrEmpty(layerName))
+ NNTrainer.CheckException(NNTrainerError.InvalidParameter, "layerName is null");
+ /* FiX_ME : how to handle layerHandle */
+ NNTrainerError ret = Interop.Model.GetLayer(handle, layerName, out layerHandle);
+ NNTrainer.CheckException(ret, "Failed to get layer");
}
}
}