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