[MachineLearning.Inference] Change interop (#4168)
[platform/core/csapi/tizenfx.git] / src / Tizen.MachineLearning.Inference / Interop / Interop.Nnstreamer.cs
1 /*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. 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;
18 using System.Runtime.InteropServices;
19 using Tizen.MachineLearning.Inference;
20
21 internal static partial class Interop
22 {
23     internal static partial class Libraries
24     {
25         public const string Nnstreamer = "libcapi-nnstreamer.so.1";
26         public const string MlCommon = "libcapi-ml-common.so.1";
27         public const string MlSingle = "libcapi-ml-inference-single.so.1";
28     }
29
30     internal static partial class Pipeline
31     {
32         /* typedef void (*ml_pipeline_state_cb) (ml_pipeline_state_e state, void *user_data); */
33         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34         internal delegate void StateChangedCallback(PipelineState state, IntPtr user_data);
35
36         /* typedef void (*ml_pipeline_sink_cb) (const ml_tensors_data_h data, const ml_tensors_info_h info, void *user_data); */
37         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38         internal delegate void NewDataCallback(IntPtr data, IntPtr info, IntPtr user_data);
39
40         /* typedef int (*ml_custom_easy_invoke_cb) (const ml_tensors_data_h in, ml_tensors_data_h out, void *user_data); */
41         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
42         internal delegate void CustomEasyInvokeCallback(IntPtr in_data, IntPtr out_data, IntPtr user_data);
43
44         /* int ml_pipeline_construct (const char *pipeline_description, ml_pipeline_state_cb cb, void *user_data, ml_pipeline_h *pipe); */
45         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_construct", CallingConvention = CallingConvention.Cdecl)]
46         internal static extern NNStreamerError Construct(string pipeline_description, StateChangedCallback callback, IntPtr user_data, out IntPtr pipeline_handle);
47
48         /* int ml_pipeline_destroy (ml_pipeline_h pipe); */
49         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_destroy", CallingConvention = CallingConvention.Cdecl)]
50         internal static extern NNStreamerError Destroy(IntPtr pipeline_handle);
51
52         /* int ml_pipeline_get_state (ml_pipeline_h pipe, ml_pipeline_state_e *state) */
53         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_get_state", CallingConvention = CallingConvention.Cdecl)]
54         internal static extern NNStreamerError GetState(IntPtr pipeline_handle, out int state);
55
56         /* int ml_pipeline_start (ml_pipeline_h pipe); */
57         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_start", CallingConvention = CallingConvention.Cdecl)]
58         internal static extern NNStreamerError Start(IntPtr pipeline_handle);
59
60         /* int ml_pipeline_stop (ml_pipeline_h pipe); */
61         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_stop", CallingConvention = CallingConvention.Cdecl)]
62         internal static extern NNStreamerError Stop(IntPtr pipeline_handle);
63
64         /* int ml_pipeline_sink_register (ml_pipeline_h pipe, const char *sink_name, ml_pipeline_sink_cb cb, void *user_data, ml_pipeline_sink_h *sink_handle); */
65         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_sink_register", CallingConvention = CallingConvention.Cdecl)]
66         internal static extern NNStreamerError RegisterSinkCallback(IntPtr pipeline_handle, string sink_name, NewDataCallback callback, IntPtr user_data, out IntPtr sink_handle);
67
68         /* int ml_pipeline_sink_unregister (ml_pipeline_sink_h sink_handle); */
69         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_sink_unregister", CallingConvention = CallingConvention.Cdecl)]
70         internal static extern NNStreamerError UnregisterSinkCallback(IntPtr sink_handle);
71
72         /* int ml_pipeline_src_get_handle (ml_pipeline_h pipe, const char *src_name, ml_pipeline_src_h *src_handle); */
73         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_src_get_handle", CallingConvention = CallingConvention.Cdecl)]
74         internal static extern NNStreamerError GetSrcHandle(IntPtr pipeline_handle, string src_name, out IntPtr src_handle);
75
76         /* int ml_pipeline_src_release_handle (ml_pipeline_src_h src_handle); */
77         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_src_release_handle", CallingConvention = CallingConvention.Cdecl)]
78         internal static extern NNStreamerError ReleaseSrcHandle(IntPtr src_handle);
79
80         /* int ml_pipeline_src_input_data (ml_pipeline_src_h src_handle, ml_tensors_data_h data, ml_pipeline_buf_policy_e policy); */
81         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_src_input_data", CallingConvention = CallingConvention.Cdecl)]
82         internal static extern NNStreamerError InputSrcData(IntPtr src_handle, IntPtr data_handle, PipelineBufferPolicy policy);
83
84         /* int ml_pipeline_valve_get_handle (ml_pipeline_h pipe, const char *valve_name, ml_pipeline_valve_h *valve_handle); */
85         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_valve_get_handle", CallingConvention = CallingConvention.Cdecl)]
86         internal static extern NNStreamerError GetValveHandle(IntPtr pipeline_handle, string valve_name, out IntPtr valve_handle);
87
88         /* int ml_pipeline_valve_release_handle (ml_pipeline_valve_h valve_handle); */
89         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_valve_release_handle", CallingConvention = CallingConvention.Cdecl)]
90         internal static extern NNStreamerError ReleaseValveHandle(IntPtr valve_handle);
91
92         /* int ml_pipeline_valve_set_open (ml_pipeline_valve_h valve_handle, bool open); */
93         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_valve_set_open", CallingConvention = CallingConvention.Cdecl)]
94         internal static extern NNStreamerError OpenValve(IntPtr valve_handle, bool open);
95
96         /* int ml_pipeline_switch_get_handle (ml_pipeline_h pipe, const char *switch_name, ml_pipeline_switch_e *switch_type, ml_pipeline_switch_h *switch_handle); */
97         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_switch_get_handle", CallingConvention = CallingConvention.Cdecl)]
98         internal static extern NNStreamerError GetSwitchHandle(IntPtr pipeline_handle, string switch_name, out SwitchType switch_type, out IntPtr switch_handle);
99
100         /* int ml_pipeline_switch_release_handle (ml_pipeline_switch_h switch_handle); */
101         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_switch_release_handle", CallingConvention = CallingConvention.Cdecl)]
102         internal static extern NNStreamerError ReleaseSwitchHandle(IntPtr switch_handle);
103
104         /* int ml_pipeline_switch_select (ml_pipeline_switch_h switch_handle, const char *pad_name); */
105         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_switch_select", CallingConvention = CallingConvention.Cdecl)]
106         internal static extern NNStreamerError SelectSwitchPad(IntPtr switch_handle, string pad_name);
107
108         /* int ml_pipeline_custom_easy_filter_register (const char *name, const ml_tensors_info_h in, const ml_tensors_info_h out, ml_custom_easy_invoke_cb cb, void *user_data, ml_custom_easy_filter_h *custom); */
109         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_custom_easy_filter_register", CallingConvention = CallingConvention.Cdecl)]
110         internal static extern NNStreamerError RegisterCustomFilter(string name, IntPtr input_info, IntPtr output_info, CustomEasyInvokeCallback callback, IntPtr user_data, out IntPtr custom_handle);
111
112         /* int ml_pipeline_custom_easy_filter_unregister (ml_custom_easy_filter_h custom); */
113         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_custom_easy_filter_unregister", CallingConvention = CallingConvention.Cdecl)]
114         internal static extern NNStreamerError UnregisterCustomFilter(IntPtr custom_handle);
115
116         /* int ml_pipeline_element_get_handle (ml_pipeline_h pipe, const char *element_name, ml_pipeline_element_h *elem_h); */
117         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_handle", CallingConvention = CallingConvention.Cdecl)]
118         internal static extern NNStreamerError GetElementHandle(IntPtr pipeline_handle, string element_name, out IntPtr element_handle);
119
120         /* int ml_pipeline_element_release_handle (ml_pipeline_element_h elem_h); */
121         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_release_handle", CallingConvention = CallingConvention.Cdecl)]
122         internal static extern NNStreamerError ReleaseElementHandle(IntPtr element_handle);
123
124         /* int ml_pipeline_element_set_property_bool (ml_pipeline_element_h elem_h, const char *property_name, const int32_t value); */
125         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_bool", CallingConvention = CallingConvention.Cdecl)]
126         internal static extern NNStreamerError SetPropertyBool(IntPtr element_handle, string property_name, int value);
127
128         /* int ml_pipeline_element_set_property_string (ml_pipeline_element_h elem_h, const char *property_name, const char *value); */
129         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_string", CallingConvention = CallingConvention.Cdecl)]
130         internal static extern NNStreamerError SetPropertyString(IntPtr element_handle, string property_name, string value);
131
132         /* int ml_pipeline_element_set_property_int32 (ml_pipeline_element_h elem_h, const char *property_name, const int32_t value); */
133         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_int32", CallingConvention = CallingConvention.Cdecl)]
134         internal static extern NNStreamerError SetPropertyInt32(IntPtr element_handle, string property_name, int value);
135
136         /* int ml_pipeline_element_set_property_int64 (ml_pipeline_element_h elem_h, const char *property_name, const int64_t value); */
137         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_int64", CallingConvention = CallingConvention.Cdecl)]
138         internal static extern NNStreamerError SetPropertyInt64(IntPtr element_handle, string property_name, long value);
139
140         /* int ml_pipeline_element_set_property_uint32 (ml_pipeline_element_h elem_h, const char *property_name, const uint32_t value); */
141         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_uint32", CallingConvention = CallingConvention.Cdecl)]
142         internal static extern NNStreamerError SetPropertyUInt32(IntPtr element_handle, string property_name, uint value);
143
144         /* int ml_pipeline_element_set_property_uint64 (ml_pipeline_element_h elem_h, const char *property_name, const uint64_t value); */
145         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_uint64", CallingConvention = CallingConvention.Cdecl)]
146         internal static extern NNStreamerError SetPropertyUInt64(IntPtr element_handle, string property_name, ulong value);
147
148         /* int ml_pipeline_element_set_property_double (ml_pipeline_element_h elem_h, const char *property_name, const double value); */
149         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_double", CallingConvention = CallingConvention.Cdecl)]
150         internal static extern NNStreamerError SetPropertyDouble(IntPtr element_handle, string property_name, double value);
151
152         /* int ml_pipeline_element_set_property_enum (ml_pipeline_element_h elem_h, const char *property_name, const uint32_t value); */
153         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_enum", CallingConvention = CallingConvention.Cdecl)]
154         internal static extern NNStreamerError SetPropertyEnum(IntPtr element_handle, string property_name, uint value);
155
156         /* int ml_pipeline_element_get_property_bool (ml_pipeline_element_h elem_h, const char *property_name, int32_t *value); */
157         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_bool", CallingConvention = CallingConvention.Cdecl)]
158         internal static extern NNStreamerError GetPropertyBool(IntPtr element_handle, string property_name, out int value);
159
160         /* int ml_pipeline_element_get_property_string (ml_pipeline_element_h elem_h, const char *property_name, char **value); */
161         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_string", CallingConvention = CallingConvention.Cdecl)]
162         internal static extern NNStreamerError GetPropertyString(IntPtr element_handle, string property_name, out string value);
163
164         /* int ml_pipeline_element_get_property_int32 (ml_pipeline_element_h elem_h, const char *property_name, int32_t *value); */
165         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_int32", CallingConvention = CallingConvention.Cdecl)]
166         internal static extern NNStreamerError GetPropertyInt32(IntPtr element_handle, string property_name, out int value);
167
168         /* int ml_pipeline_element_get_property_int64 (ml_pipeline_element_h elem_h, const char *property_name, int64_t *value); */
169         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_int64", CallingConvention = CallingConvention.Cdecl)]
170         internal static extern NNStreamerError GetPropertyInt64(IntPtr element_handle, string property_name, out long value);
171
172         /* int ml_pipeline_element_get_property_uint32 (ml_pipeline_element_h elem_h, const char *property_name, uint32_t *value); */
173         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_uint32", CallingConvention = CallingConvention.Cdecl)]
174         internal static extern NNStreamerError GetPropertyUInt32(IntPtr element_handle, string property_name, out uint value);
175
176         /* int ml_pipeline_element_get_property_uint64 (ml_pipeline_element_h elem_h, const char *property_name, uint64_t *value); */
177         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_uint64", CallingConvention = CallingConvention.Cdecl)]
178         internal static extern NNStreamerError GetPropertyUInt64(IntPtr element_handle, string property_name, out ulong value);
179
180         /* int ml_pipeline_element_get_property_double (ml_pipeline_element_h elem_h, const char *property_name, double *value); */
181         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_double", CallingConvention = CallingConvention.Cdecl)]
182         internal static extern NNStreamerError GetPropertyDouble(IntPtr element_handle, string property_name, out double value);
183
184         /* int ml_pipeline_element_get_property_enum (ml_pipeline_element_h elem_h, const char *property_name, uint32_t *value); */
185         [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_enum", CallingConvention = CallingConvention.Cdecl)]
186         internal static extern NNStreamerError GetPropertyEnum(IntPtr element_handle, string property_name, out uint value);
187     }
188
189     internal static partial class SingleShot
190     {
191         /* int ml_single_open (ml_single_h *single, const char *model, const ml_tensors_info_h input_info, const ml_tensors_info_h output_info, ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw) */
192         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_open", CallingConvention = CallingConvention.Cdecl)]
193         internal static extern NNStreamerError OpenSingle(out IntPtr single_handle, string model_path, IntPtr input_info, IntPtr output_info, NNFWType nn_type, HWType hw_type);
194
195         /* int ml_single_close (ml_single_h single) */
196         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_close", CallingConvention = CallingConvention.Cdecl)]
197         internal static extern NNStreamerError CloseSingle(IntPtr single_handle);
198
199         /* int ml_single_invoke (ml_single_h single, const ml_tensors_data_h input, ml_tensors_data_h *output) */
200         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_invoke", CallingConvention = CallingConvention.Cdecl)]
201         internal static extern NNStreamerError InvokeSingle(IntPtr single_handle, IntPtr input_data, out IntPtr output_data);
202
203         /* int ml_single_invoke_dynamic (ml_single_h single, const ml_tensors_data_h input, const ml_tensors_info_h in_info, ml_tensors_data_h * output, ml_tensors_info_h * out_info) */
204         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_invoke_dynamic", CallingConvention = CallingConvention.Cdecl)]
205         internal static extern NNStreamerError InvokeSingleDynamic(IntPtr single_handle, IntPtr input_data, IntPtr input_info, out IntPtr output_data, out IntPtr output_info);
206
207         /* int ml_single_get_input_info (ml_single_h single, ml_tensors_info_h *info) */
208         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_get_input_info", CallingConvention = CallingConvention.Cdecl)]
209         internal static extern NNStreamerError GetInputTensorsInfo(IntPtr single_handle, out IntPtr input_info);
210
211         /* int ml_single_get_output_info (ml_single_h single, ml_tensors_info_h *info) */
212         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_get_output_info", CallingConvention = CallingConvention.Cdecl)]
213         internal static extern NNStreamerError GetOutputTensorsInfo(IntPtr single_handle, out IntPtr output_info);
214
215         /* int ml_single_set_input_info (ml_single_h single, const ml_tensors_info_h info) */
216         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_set_input_info", CallingConvention = CallingConvention.Cdecl)]
217         internal static extern NNStreamerError SetInputInfo(IntPtr single_handle, IntPtr in_handle);
218
219         /* int ml_single_set_timeout (ml_single_h single, unsigned int timeout)*/
220         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_set_timeout", CallingConvention = CallingConvention.Cdecl)]
221         internal static extern NNStreamerError SetTimeout(IntPtr single_handle, int time_ms);
222
223         /* int ml_single_set_property (ml_single_h single, const char *name, const char *value) */
224         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_set_property", CallingConvention = CallingConvention.Cdecl)]
225         internal static extern NNStreamerError SetValue(IntPtr single_handle, string name, string value);
226
227         /* int ml_single_get_property (ml_single_h single, const char *name, char **value) */
228         [DllImport(Libraries.MlSingle, EntryPoint = "ml_single_get_property", CallingConvention = CallingConvention.Cdecl)]
229         internal static extern NNStreamerError GetValue(IntPtr single_handle, string name, out IntPtr value);
230     }
231
232     internal static partial class Util
233     {
234         /* int ml_tensors_info_create (ml_tensors_info_h *info) */
235         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_create", CallingConvention = CallingConvention.Cdecl)]
236         internal static extern NNStreamerError CreateTensorsInfo(out IntPtr info);
237
238         /* int ml_tensors_info_destroy (ml_tensors_info_h info) */
239         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_destroy", CallingConvention = CallingConvention.Cdecl)]
240         internal static extern NNStreamerError DestroyTensorsInfo(IntPtr info);
241
242         /* int ml_tensors_info_set_count (ml_tensors_info_h info, unsigned int count) */
243         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_set_count", CallingConvention = CallingConvention.Cdecl)]
244         internal static extern NNStreamerError SetTensorsCount(IntPtr info, int count);
245
246         /* int ml_tensors_info_get_count (ml_tensors_info_h info, unsigned int *count) */
247         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_get_count", CallingConvention = CallingConvention.Cdecl)]
248         internal static extern NNStreamerError GetTensorsCount(IntPtr info, out int count);
249
250         /* int ml_tensors_info_set_tensor_name (ml_tensors_info_h info, unsigned int index, const char *name) */
251         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_set_tensor_name", CallingConvention = CallingConvention.Cdecl)]
252         internal static extern NNStreamerError SetTensorName(IntPtr info, int index, string name);
253
254         /* int ml_tensors_info_get_tensor_name (ml_tensors_info_h info, unsigned int index, char **name) */
255         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_get_tensor_name", CallingConvention = CallingConvention.Cdecl)]
256         internal static extern NNStreamerError GetTensorName(IntPtr info, int index, out string name);
257
258         /* int ml_tensors_info_set_tensor_type (ml_tensors_info_h info, unsigned int index, const ml_tensor_type_e type) */
259         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_set_tensor_type", CallingConvention = CallingConvention.Cdecl)]
260         internal static extern NNStreamerError SetTensorType(IntPtr info, int index, TensorType type);
261
262         /* int ml_tensors_info_get_tensor_type (ml_tensors_info_h info, unsigned int index, ml_tensor_type_e *type) */
263         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_get_tensor_type", CallingConvention = CallingConvention.Cdecl)]
264         internal static extern NNStreamerError GetTensorType(IntPtr info, int index, out TensorType type);
265
266         /* int ml_tensors_info_set_tensor_dimension (ml_tensors_info_h info, unsigned int index, const ml_tensor_dimension dimension) */
267         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_set_tensor_dimension", CallingConvention = CallingConvention.Cdecl)]
268         internal static extern NNStreamerError SetTensorDimension(IntPtr info, int index, int[] dimension);
269
270         /* int ml_tensors_info_get_tensor_dimension (ml_tensors_info_h info, unsigned int index, ml_tensor_dimension dimension) */
271         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_info_get_tensor_dimension", CallingConvention = CallingConvention.Cdecl)]
272         internal static extern NNStreamerError GetTensorDimension(IntPtr info, int index, [In, Out] uint[] dimension);
273
274         /* int ml_tensors_data_create (const ml_tensors_info_h info, ml_tensors_data_h *data) */
275         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_data_create", CallingConvention = CallingConvention.Cdecl)]
276         internal static extern NNStreamerError CreateTensorsData(IntPtr info, out IntPtr data);
277
278         /* int ml_tensors_data_destroy (ml_tensors_data_h data) */
279         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_data_destroy", CallingConvention = CallingConvention.Cdecl)]
280         internal static extern NNStreamerError DestroyTensorsData(IntPtr data);
281
282         /* int ml_tensors_data_get_tensor_data (ml_tensors_data_h data, unsigned int index, void **raw_data, size_t *data_size) */
283         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_data_get_tensor_data", CallingConvention = CallingConvention.Cdecl)]
284         internal static extern NNStreamerError GetTensorData(IntPtr data, int index, out IntPtr raw_data, out int data_size);
285
286         /* int ml_tensors_data_set_tensor_data (ml_tensors_data_h data, unsigned int index, const void *raw_data, const size_t data_size) */
287         [DllImport(Libraries.MlCommon, EntryPoint = "ml_tensors_data_set_tensor_data", CallingConvention = CallingConvention.Cdecl)]
288         internal static extern NNStreamerError SetTensorData(IntPtr data, int index, byte[] raw_data, int data_size);
289
290         /* int ml_check_nnfw_availability (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, bool *available); */
291         [DllImport(Libraries.MlSingle, EntryPoint = "ml_check_nnfw_availability", CallingConvention = CallingConvention.Cdecl)]
292         internal static extern NNStreamerError CheckNNFWAvailability(NNFWType nnfw, HWType hw, out bool available);
293
294         internal static byte[] IntPtrToByteArray(IntPtr unmanagedByteArray, int size)
295         {
296             byte[] retByte = new byte[size];
297             Marshal.Copy(unmanagedByteArray, retByte, 0, size);
298             return retByte;
299         }
300
301         internal static string IntPtrToString(IntPtr val)
302         {
303             return (val != IntPtr.Zero) ? Marshal.PtrToStringAnsi(val) : string.Empty;
304         }
305     }
306 }