Nux C API  0.0.1
C API of NPU Engine
nux.h
Go to the documentation of this file.
1 #ifndef furiosa_libnux_bindings_h
2 #define furiosa_libnux_bindings_h
3 
4 /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
5 
6 #include <stdarg.h>
7 #include <stdbool.h>
8 #include <stdint.h>
9 #include <stdlib.h>
10 
11 typedef enum Axis {
14  /**
15  * For convolution weights, this axis is also known as an input channel.
16  */
18  /**
19  * For convolution weights, this axis is also known as an output channel or feature map.
20  */
27 } Axis;
28 
29 /**
30  * \brief Represent tensor data type
31  */
32 typedef enum TensorDataType {
41 
42 /**
43  * \brief Represent a return status of a function that can fail.
44  */
45 typedef enum nux_error_t {
46  /**
47  * When a function call is successful
48  */
50  /**
51  * When #create_nux fails to initialize
52  */
54  /**
55  * When deploying a model to an executor fails.
56  * See also #nux_create_sync_model, #nux_create_task_model for more details.
57  */
59  /**
60  * When running an inference task fails.
61  * See also #model_run, #task_execute for more details.
62  */
64  /**
65  * When the given index of an input tensor is invalid. See also #model_input_tensor
66  * for more details.
67  */
69  /**
70  * When the given index of an output tensor is invalid. See also #model_output_tensor
71  * for more details.
72  */
74  /**
75  * When a data buffer is invalid. See #tensor_set_buffer for more details.
76  */
78  /**
79  * When the input tensors are invalid
80  */
82  /**
83  * When the output tensors are invalid
84  */
86  /**
87  * When #task_model_get_task or #task_model_try_get_task fails to return an available
88  * task slot. This error code can have different meanings in both functions.
89  * Please see #task_model_get_task and #task_model_try_get_task for more details.
90  */
92  /**
93  * reserved
94  */
96  /**
97  * When waiting for completion queue is timed out
98  */
100  /**
101  * When there's no data in completion queue
102  */
104  /**
105  * When loading a model image fails
106  */
108  /**
109  * When the compiler fails to transform a given model image to a binary for NPU
110  */
112  /**
113  * Internal error
114  */
116  /**
117  * Invalid yaml syntax
118  */
120  /**
121  * incompatible api client error
122  */
124  /**
125  * when api client fails to initialize
126  */
128  /**
129  * No API Key
130  */
132  /**
133  * Null pointer exception
134  */
136  /**
137  * Invalid session option
138  */
140  /**
141  * Session termination
142  */
144  /**
145  * NPU device is busy
146  */
148  /**
149  * Tensor name not found in a given model
150  */
152  /**
153  * Unsupported feature
154  */
156 } nux_error_t;
157 
158 typedef enum nux_log_level_t {
164 
166 
168 
169 typedef struct Model Model;
170 
171 typedef struct Nux Nux;
172 
173 typedef struct NuxModel NuxModel;
174 
175 typedef struct OpaqueTensor OpaqueTensor;
176 
178 
180 
181 typedef struct Task Task;
182 
183 typedef struct TaskModel TaskModel;
184 
185 typedef struct TensorArray TensorArray;
186 
187 typedef struct TensorDesc TensorDesc;
188 
189 /**
190  * \brief Nux handle
191  *
192  * #create_nux initializes an instance of #nux_handle_t.
193  */
194 typedef struct Nux *nux_handle_t;
195 
196 /**
197  * \brief Byte length of a data buffer
198  */
199 typedef uintptr_t nux_buffer_len_t;
200 
201 /**
202  * \brief Handle of a synchronous model
203  *
204  * #nux_create_sync_model initializes an instance of #nux_sync_model_t.
205  */
206 typedef struct Model *nux_sync_model_t;
207 
208 /**
209  * \brief Handle of tensor
210  *
211  * #model_input_tensor or #model_output_tensor returns an instance of #nux_tensor_t.
212  */
213 typedef struct OpaqueTensor *nux_tensor_t;
214 
215 /**
216  * \brief Pointer to a data buffer.
217  *
218  * In Nux, it is commonly used to contain any kind of binary data like ENF binary,
219  * or a data buffer of input/output tensors.
220  */
221 typedef uint8_t *nux_buffer_t;
222 
223 typedef uintptr_t RequestId;
224 
225 /**
226  * \brief Identifier to distinguish tasks in a task model
227  */
229 
230 typedef uint32_t OutputIndex;
231 
232 /**
233  * \brief Index of an output tensor, used in task model
234  */
236 
237 /**
238  * \brief Callback function called per tensor output
239  * when a task of a task model is completed.
240  *
241  * For example, if one model has 2 output tensors,
242  * this function will be called 2 times upon each task's completion.
243  */
245 
246 /**
247  * \brief Callback function called when a task fails to complete.
248  */
250 
251 /**
252  * \brief Callback function which is finally called when a task is completed.
253  *
254  * Unlike #nux_output_callback_t, this callback function is called only once
255  * after #nux_output_callback_t is called for all output tensors.
256  */
258 
259 /**
260  * \brief Handle of a task model
261  *
262  * #nux_create_task_model creates an instance of #nux_task_model_t.
263  */
264 typedef struct TaskModel *nux_task_model_t;
265 
266 /**
267  * \brief Handle of a task of a task model
268  *
269  * #task_model_get_task or #task_model_try_get_task returns an instance of #nux_task_t.
270  */
271 typedef struct Task *nux_task_t;
272 
273 typedef uint32_t InputIndex;
274 
275 /**
276  * \brief Index of an input tensor, used in task model
277  */
279 
280 /**
281  * \brief Session option
282  */
284 
285 /**
286  * \brief Session
287  */
288 typedef const struct BlockingSession *nux_session_t;
289 
290 /**
291  * \brief Model
292  */
293 typedef const struct NuxModel *nux_model_t;
294 
296 
297 /**
298  * \brief Async Session
299  */
301 
303 
304 /**
305  * \brief Context pointer
306  */
307 typedef void *nux_context_t;
308 
309 typedef const struct TensorDesc *nux_tensor_desc_t;
310 
311 /**
312  * \brief A null-terminated C string
313  */
314 typedef char *nux_string_t;
315 
316 /**
317  * \brief Represent a data type of tensor
318  */
320 
321 typedef const Config *npu_config_t;
322 
323 typedef CompilerOptions *compiler_options_t;
324 
325 #ifdef __cplusplus
326 extern "C" {
327 #endif // __cplusplus
328 
329 /**
330  * \brief Return a version of Nux native library
331  */
332 const char *version(void);
333 
334 /**
335  * \brief Return a short Git hash of Nux native library
336  */
337 const char *git_short_hash(void);
338 
339 /**
340  * \brief Return a build timestamp of Nux native library
341  */
342 const char *build_timestamp(void);
343 
344 /**
345  * \brief Enable a logger with a specific log level
346  * @param log_level Log level (off, error, warn, info)
347  */
348 void enable_logging(enum nux_log_level_t _log_level);
349 
350 /**
351  * \brief Register Ctrl-C signal handler to exit process.
352  */
353 void register_signal_handler(void);
354 
355 /**
356  * \brief Creates a new nux handle.
357  *
358  * @param[out] nux Mutable pointer to receive a created Nux handle
359  * @return #nux_error_t_success if successful, or
360  * it will return #nux_error_t_nux_creation_failed.
361  */
363 
364 /**
365  * \brief Destroy the Nux handle and release its resources.
366  *
367  * @param nux Nux handle to be destroyed. It must not be NULL.
368  */
369 void destroy_nux(nux_handle_t nux);
370 
371 /**
372  * \brief Create an instance of a synchronous model.
373  *
374  * It creates a synchronous model to execute a compiled ENF binary.
375  * The synchronous model provides APIs to run a single inference task
376  * with one input batch at a time.
377  *
378  * @param nux Nux handle
379  * @param buffer Byte buffer containing ENF binary
380  * @param len Byte length of `buffer`
381  * @param[out] model Mutable pointer to receive the handle of a created sync model
382  */
384  const uint8_t *buffer,
385  nux_buffer_len_t len,
386  nux_sync_model_t *model);
387 
388 /**
389  * \brief Destroy the sync model and release its resources.
390  *
391  * @param model Sync model to be destroyed, and it must not be NULL.
392  */
394 
395 /**
396  * \brief Return the number of input tensors of a given sync model.
397  *
398  * A model can have more than one input tensor.
399  * This function returns how many input tensors this model has.
400  *
401  * @param model Sync model
402  * @return Output tensors of this model
403  */
404 uint32_t model_count_inputs(nux_sync_model_t model);
405 
406 /**
407  * \brief Return the number of output tensors of a given sync model.
408  *
409  * A model can have more than one output tensor.
410  * This function returns how many output tensors this model has.
411  *
412  * @param model Sync model
413  * @return Output tensors of this model
414  */
415 uint32_t model_count_outputs(nux_sync_model_t model);
416 
417 /**
418  * \brief Get the handle of a specified input tensor from a given sync model.
419  *
420  * \remark An input tensor handle will be valid
421  * until #destroy_sync_model with this `model` is called.
422  *
423  * @param model Sync model
424  * @param index Input tensor index
425  * @param[out] tensor Mutable pointer to receive the handle of a specified input tensor
426  */
427 enum nux_error_t model_input_tensor(nux_sync_model_t model, uint32_t index, nux_tensor_t *tensor);
428 
429 /**
430  * \brief Get the handle of a specified output tensor from a given sync model.
431  *
432  * \remark Output tensor handle will be valid
433  * until #destroy_sync_model with this `model` is called.
434  *
435  * @param model Sync model
436  * @param index Output tensor index
437  * @param[out] tensor Mutable pointer to receive a specified output tensor handle
438  */
439 enum nux_error_t model_output_tensor(nux_sync_model_t model, uint32_t index, nux_tensor_t *tensor);
440 
441 /**
442  * \brief Run a single inference task
443  *
444  * Before calling this function, you must fill input tensors with proper data.
445  * Please refer to #model_input_tensor and #tensor_set_buffer
446  * to learn how to fill input tensors with data.
447  */
449 
450 /**
451  * \brief Get a pointer to the data buffer of a given tensor.
452  *
453  * Once #model_run is called, the inference result will be written into output tensors.
454  * This function returns a pointer to the data buffer of a specified output tensor.
455  *
456  * \remark the buffers of output tensors are valid until #destroy_sync_model is called.
457  *
458  * @param tensor Tensor from which you want to get a pointer of the data buffer
459  * @param[out] buffer Mutable pointer to receive the pointer to the data buffer
460  * @param[out] len Byte length of `buffer`
461  * @return nux_error_t_success if successful
462  */
464 
465 /**
466  * \brief Copy data into the data buffer of a specified input tensor.
467  *
468  * To execute #model_run, you first need to fill input tensors with data.
469  * #tensor_fill_buffer copies the data into the data buffer of a specified input tensor.
470  *
471  * @param tensor Tensor handle into which you want to copy input data
472  * @param buffer Pointer to the data buffer
473  * @param len Byte length of `buffer`
474  * @return nux_error_t_success if successful,
475  * or nux_error_t_invalid_buffer if `buffer` is invalid.
476  */
478 
479 /**
480  * \brief Specify a pointer to a data buffer to a specified input tensor.
481  *
482  * This function is almost same to #tensor_fill_buffer.
483  * However, `tensor` takes the ownership of the buffer with `free` function
484  * to deallocate the buffer. Ensure that nothing else uses the pointer after calling this function.
485  *
486  * if `free` is `null`, `tensor` will not deallocate the buffer.
487  * It can be useful when you want to reuse the buffer or buffer is on a stack area of a function.
488  * Please ensure that the buffer must be deallocated manually by users
489  * in order to prevent the memory leak.
490  *
491  * @param tensor Tensor handle into which you want to copy input data
492  * @param buffer Pointer to the data buffer
493  * @param len Byte length of `buffer`
494  * @param free a function pointer to deallocate a buffer. If `free` is `null`,
495  * `tensor` will not deallocate the data.
496  * @return nux_error_t_success if successful,
497  * or nux_error_t_invalid_buffer if `buffer` is invalid.
498  */
500  nux_buffer_t buffer,
501  nux_buffer_len_t len,
502  void (*free)(uint8_t*, uintptr_t));
503 
504 /**
505  * \brief Create an instance of a task model.
506  *
507  * It allows users to run multiple inference tasks asynchronously and simultaneously.
508  * When each task is completed or failed, corresponding callback functions will be called
509  * with #nux_request_id_t, an identifier of a task request.
510  * See also #task_execute for more details.
511  *
512  * @param nux Nux handle
513  * @param buffer Byte buffer containing ENF binary
514  * @param len Byte length of `buffer`
515  * @param max_batch Number of concurrent running tasks
516  * It can be limited according to internal configurations and HW capacity.
517  * @param output_callback Callback function invoked when a task is completed.
518  * It will be called per output tensor. Please see #nux_output_callback_t for more details.
519  * @param error_callback Callback function invoked when a task is failed.
520  * @param finish_callback Callback function which will be called finally
521  * after the output_callback is called after all output tensors.
522  * @param task_model Mutable pointer to receive the handle of a created task model
523  */
525  const uint8_t *buffer,
526  nux_buffer_len_t len,
527  uint32_t max_batch,
528  nux_output_callback_t output_callback,
529  nux_error_callback_t error_callback,
530  nux_finish_callback_t finish_callback,
531  nux_task_model_t *task_model);
532 
533 /**
534  * \brief Destroy the task model and release its resources.
535  *
536  * @param task_model Task model to be destroyed
537  */
538 void destroy_task_model(nux_task_model_t task_model);
539 
540 /**
541  * \brief Return `true` if there's no running tasks, or `false` if any task is still running.
542  *
543  * @param task_model Task handle
544  */
546 
547 /**
548  * \brief Get a task handle from a specified task model.
549  *
550  * When there's no available task in a given task model,
551  * it will block until new task is available.
552  *
553  * @param task_model Handle of a task model
554  * @param[out] task Mutable pointer to receive the handle of a created task
555  */
557 
558 /**
559  * \brief (non-blocking) Get a task handle from the specified task model.
560  *
561  * It's the non-blocking version of #task_model_get_task.
562  * This function returns an available task, or
563  * it will return immediately #nux_error_t_get_task_failed
564  * if there's no available task in a given task model.
565  *
566  * @param task_model Handle of a task model
567  * @param[out] task Mutable pointer to receive the handle of a created task
568  */
570 
571 /**
572  * \brief Destroy the task and release its resources.
573  *
574  * \remark Once you call #task_execute with a `task`,
575  * the `task` will get destroyed automatically. Please do not call #destroy_task with
576  * the `task` which is already passed to #task_execute.
577  *
578  * @param task Task to be destroyed
579  */
580 void destroy_task(nux_task_t task);
581 
582 /**
583  * \brief Request one asynchronous inference task.
584  *
585  * #task_execute submits a request for an inference task identified by `task`.
586  * Once a task is completed, `output_callback` function passed to #nux_create_task_model
587  * will be called with a distinct output index per output tensor.
588  * `finish_callback` function will be also called
589  * after `output_callback` function is called for all output tensors.
590  *
591  * \remark Once you call #task_execute with a `task`,
592  * the `task` will get destroyed automatically. Please do not call #destroy_task with
593  * the `task` which is already passed to #task_execute.
594  *
595  * @param task Task handle obtained from calling #task_model_get_task
596  * or #task_model_try_get_task.
597  * @param request_id An positive integer to distinguish task requests.
598  * The behavior of #task_execute doesn't rely on a `request_id` value at all.
599  * `request_id` will be just passed to callback functions.
600  * @return #nux_error_t_success if successful.
601  * or #nux_error_t_model_execution_failed if failed.
602  */
603 enum nux_error_t task_execute(nux_task_t task, nux_request_id_t request_id);
604 
605 /**
606  * \brief Return a mutable pointer to the buffer of the specified input tensor.
607  *
608  * @param task Task handle
609  * @param index Index of the input tensor
610  * @return A mutable pointer to the data buffer of the given input tensor
611  */
613 
614 /**
615  * \brief Return the buffer length in bytes of the specified input tensor.
616  *
617  * @param task Task handle
618  * @param index Index of the input tensor
619  */
621 
622 /**
623  * \brief Create a session option
624  *
625  * It allows to specify more options for a session.
626  *
627  * @return Session option
628  */
630 
631 /**
632  * \brief Set a NPU device to the given session option
633  *
634  * If NPU device is not set, Session will use the default NPU device `npu0pe0`.
635  *
636  * @param option Session option
637  * @param devname A NPU device name (e.g., npu0pe0, npu1pe0)
638  */
639 void nux_session_option_set_device(nux_session_option_t builder, const char *devname);
640 
641 /**
642  * \brief Set the number of workers to the given session option
643  *
644  * The number of workers means how many workers handle the inference requests.
645  * By default, the number of workers is 1.
646  *
647  * @param option Session option
648  * @param num The number of workers, and it must be a positive integer.
649  */
650 void nux_session_option_set_worker_num(nux_session_option_t builder, uintptr_t num);
651 
652 /**
653  * \brief Set the file path to which the compiler save log messages.
654  *
655  * @param option Session option
656  * @param path Log path
657  */
658 void nux_session_option_set_compiler_log_path(nux_session_option_t builder, const char *path);
659 
660 /**
661  * \brief Set the input queue size of async session
662  *
663  * async session has both input and output queues.
664  * The input queue keeps inference requests until the async session handles them.
665  * If it is not set, async session will have the unlimited input queue size by default.
666  * An unlimited input queue will keep the requests as much as your system's memory allow.
667  *
668  * When a input queue length is specified and the queue is full,
669  * the caller of async session will be blocked until async session digests the requests.
670  * It's useful especially when you want backpressure.
671  *
672  * @param option Session option
673  * @param num The input queue size, and it must be > 0 and < 2^31.
674  */
676 
677 /**
678  * \brief Set the output queue size of async session
679  *
680  * async session has both input and output queues.
681  * The output queue keeps inference results until the consumer drains the results.
682  * If it is not set, async session will have the unlimited output queue size by default.
683  * An unlimited output queue will keep the responses as much as your system's memory allow.
684  *
685  * When a output queue length is specified and the queue is full,
686  * async session will be blocked until consumers drain the results.
687  * It's useful especially when you want to prevent the out of memory issue.
688  *
689  * @param option Session option
690  * @param num The output queue size, and it must be be > 0 and < 2^31.
691  */
693 
694 /**
695  * \brief Set a compiler config to the given session option
696  *
697  * If compiler config is not set, Session will use a default compiler config.
698  *
699  * @param option Session option
700  * @param yaml A yaml formatted string of compiler option
701  * @return #nux_error_t_success if successful.
702  * or #nux_error_t_invalid_yaml if `yaml` is not a valid yaml document.
703  */
705 
706 /**
707  * \brief Destroy a session option
708  */
710 
711 /**
712  * \brief Create a session
713  *
714  * Session provides simple and synchronous APIs to run inference tasks from a loaded model.
715  *
716  * @param model_binary Buffer which contains a model binary
717  * @param model_binary_len Length of `model_binary`
718  * @param option Session option. If it is null, the default option will be used.
719  * @param[out] sess Mutable pointer to receive a created Nux handle
720  * @return #nux_error_t_success if successful.
721  * or it will return other error value.
722  */
724  nux_buffer_len_t model_binary_len,
725  nux_session_option_t option,
726  nux_session_t *out_sess);
727 
728 /**
729  * \brief Get the pointer of the Model of a given session
730  *
731  * @param sess Handle of session instance. It must not be `NULL`.
732  * @return Pointer of the Model of a given session
733  */
735 
736 /**
737  * \brief Run an inference task
738  *
739  * @param sess Handle of Session instance. It must not be `NULL`.
740  * @param inputs Input tensors
741  * @param outputs Output tensors
742  * @return #nux_error_t_success if successful.
743  * or it will return other error value.
744  */
746 
747 /**
748  * \brief Run an inference task with tensor names
749  * The number of input/output tensors and its corresponding names must be the same.
750  *
751  * @param sess Handle of Session instance. It must not be `NULL`.
752  * @param input_names An array of input tensor names
753  * @param input_len Number of input tensor names
754  * @param output_names An array of output tensor names
755  * @param output_len Number of output tensor names
756  * @param inputs Input tensors
757  * @param outputs Output tensors
758  * @return #nux_error_t_success if successful.
759  * or it will return other error value.
760  */
762  const char *const *input_names,
763  uintptr_t input_len,
764  const char *const *output_names,
765  uintptr_t output_len,
766  nux_tensor_array_t inputs,
767  nux_tensor_array_t outputs);
768 
769 /**
770  * \brief Destroy a session
771  * @param sess Handle of Session instance to be destroyed. It must not be `NULL`.
772  */
774 
775 /**
776  * \brief Create an asynchronous session and a queue to receive the results.
777  *
778  * #nux_async_session_t allows users to submit inference tasks.
779  * #nux_completion_queue_t is an iterator to receive the result in the asynchronous way.
780  * See also #nux_async_session_run and #nux_completion_queue_next.
781  *
782  * @param model_binary Buffer which contains a model binary
783  * @param model_binary_len Length of `model_binary`
784  * @param option Session option. If it is null, the default option will be used.
785  * @param[out] out_sess Mutable pointer to an instance of async session
786  * @param[out] out_queue Mutable pointer to an instance of async completion queue
787  */
789  nux_buffer_len_t model_binary_len,
790  nux_session_option_t option,
791  nux_async_session_t *out_sess,
792  nux_completion_queue_t *out_queue);
793 
794 /**
795  * \brief Submit an inference task asynchronously. It returns immediately.
796  *
797  * You can receive the completed inference results through #nux_completion_queue_t.
798  * please refer to #nux_completion_queue_next to know how to receive the completed results.
799  *
800  * @param sess Handle of asynchronous session
801  * @param `context` is a void pointer, so you can pass any data to context.
802  * Generally, `context` can be used to identify what's the completion event.
803  * Also, sophisticated data structure can be used to to do more as soon as
804  * you receive the completion event. You must make sure the pointer must be valid as
805  * long as you want to use a passed context even after you receive the completion event.
806  * @param inputs an array of tensors
807  */
809 
810 /**
811  * \brief Wait until it receives any completion event, which can be success or fail.
812  *
813  * @param queue Async completion queue
814  * @param[out] context A pointer of the context value that you passed to `nux_async_session_run`
815  * @param[out] outputs Output tensors
816  * @param[out] error #nux_error_t_success if successful,
817  * #nux_error_t_session_terminated if the async session
818  * is terminated, or it will return other error value.
819  * @return True if async_session is still alive, or False.
820  */
822  nux_context_t *context,
823  nux_tensor_array_t *outputs,
824  enum nux_error_t *error);
825 
826 /**
827  * \brief It's almost the same as #nux_completion_queue_next.
828  * However, this call immediately returns even if it hasn't received any result event
829  * after the last call. In the case, it will set `error` to #nux_error_t_queue_no_data.
830  *
831  * @param queue Async completion queue
832  * @param[out] context A pointer of the context value that you passed to `nux_async_session_run`
833  * @param[out] outputs Output tensors
834  * @param[out] error #nux_error_t_success if successful,
835  * #nux_error_t_session_terminated if the async session
836  * is terminated, #nux_error_t_queue_no_data if no result is received,
837  * or it will return other error value.
838  * @return True if async_session is still alive, or False.
839  */
841  nux_context_t *context,
842  nux_tensor_array_t *outputs,
843  enum nux_error_t *error);
844 
845 /**
846  * \brief It's almost the same as #nux_completion_queue_next.
847  * However, this call will be blocked only until a timeout occurs even if it hasn't received
848  * any result. In this case, it will set #nux_error_t_queue_wait_timeout to `error`.
849  *
850  * @param queue Async completion queue
851  * @param timeout_ms How long to wait before giving up, and its time unit is milliseconds.
852  * @param[out] context A pointer of the context value that you passed to `nux_async_session_run`
853  * @param[out] outputs Output tensors
854  * @param[out] error #nux_error_t_success if successful,
855  * #nux_error_t_session_terminated if the async session
856  * is terminated, #queue_wait_timeout if no data is received until the timeout,
857  * or it will return other error value.
858  * @return True if async_session is still alive, or False.
859  */
861  uint64_t timeout_ms,
862  nux_context_t *context,
863  nux_tensor_array_t *outputs,
864  enum nux_error_t *error);
865 
866 /**
867  * \brief Get the pointer of the Model of a given asynchronous session
868  *
869  * @param sess Handle of asynchronous session instance. It must not be `NULL`.
870  * @return Pointer of the Model of a given asynchronous session
871  */
873 
874 /**
875  * \brief Destroy an asynchronous session
876  */
878 
879 /**
880  * \brief Destroy a completion queue
881  */
883 
884 /**
885  * \brief Return the number of input tensors of the given model
886  */
887 uintptr_t nux_input_num(nux_model_t model);
888 
889 /**
890  * \brief Return the number of output tensors of the given model
891  */
892 uintptr_t nux_output_num(nux_model_t model);
893 
894 /**
895  * \brief Return the description of the tensor matched to the given name
896  * @return the tensor descriptor if there exists Tensor matched to a given name, or null.
897  */
898 nux_tensor_desc_t nux_tensor_desc_by_name(nux_model_t model, const char *name);
899 
900 /**
901  * \brief Return the description of i-th input tensor of the given model
902  */
903 nux_tensor_desc_t nux_input_desc(nux_model_t model, uintptr_t index);
904 
905 /**
906  * \brief Return the description of i-th output tensor of the given model
907  */
908 nux_tensor_desc_t nux_output_desc(nux_model_t model, uintptr_t index);
909 
910 /**
911  * \brief Return the tensor name and transfers its ownership to the caller.
912  * To destroy #nux_string_t, please call #nux_string_destroy.
913  *
914  * @param Tensor descriptor
915  * @return Tensor name if the specific tensor has its name, or null.
916  */
918 
919 /**
920  * \brief Return the number of dimensions of the given tensor
921  */
922 uintptr_t nux_tensor_dim_num(nux_tensor_desc_t tensor);
923 
924 /**
925  * \brief Return the dimension size of the dimension index
926  */
927 uintptr_t nux_tensor_dim(nux_tensor_desc_t tensor, uintptr_t index);
928 
929 /**
930  * \brief Return the axis type of i-th dimension (e.g., Width, Height, Channel)
931  */
932 enum Axis nux_tensor_axis(nux_tensor_desc_t tensor, uintptr_t idx);
933 
934 /**
935  * \brief Return the tensor data type
936  */
938 
939 /**
940  * \brief Return the total number of all elements
941  */
942 uintptr_t nux_tensor_len(nux_tensor_desc_t tensor);
943 
944 /**
945  * \brief Return the byte size of tensor
946  *
947  * It will be useful when you have to fill the tensor buffer with data.
948  */
949 uintptr_t nux_tensor_size(nux_tensor_desc_t tensor);
950 
951 /**
952  * \brief Create a tensor according to a given tensor description
953  *
954  * You have to call `nux_tensor_destroy` to release the resource of a create tensor.
955  */
957 
958 /**
959  * \brief Create a tensor with an exiting buffer. It doesn't copy the data.
960  */
962  nux_buffer_t buffer,
963  nux_buffer_len_t len,
964  void (*free)(uint8_t*, uintptr_t));
965 
966 /**
967  * \brief Destroy a tensor
968  */
969 void nux_tensor_destroy(nux_tensor_t tensor);
970 
971 /**
972  * \brief Return the pointer to the buffer of this tensor
973  */
974 uint8_t *nux_tensor_buffer(nux_tensor_t tensor);
975 
976 /**
977  * \brief Return the size of tensor buffer
978  */
979 uintptr_t nux_tensor_buffer_size(nux_tensor_t tensor);
980 
981 /**
982  * \brief Return an array of tensors corresponding to the names with allocated buffers
983  */
984 nux_tensor_array_t nux_tensor_array_allocate_by_names(nux_model_t model, const char *const *names, uintptr_t len);
985 
986 /**
987  * \brief Return an array of tensors corresponding to the names without allocated buffers
988  */
989 nux_tensor_array_t nux_tensor_array_create_by_names(nux_model_t model, const char *const *names, uintptr_t len);
990 
991 /**
992  * \brief Return an array of input tensors with allocated buffers
993  *
994  * This function is generally used with #tensor_fill_buffer.
995  */
997 
998 /**
999  * \brief Return an array of input tensors without allocated buffers
1000  *
1001  * This function is generally used with #tensor_set_buffer.
1002  */
1004 
1005 /**
1006  * \brief Return an array of output tensors with allocated buffers
1007  */
1009 
1010 /**
1011  * \brief Return an array of output tensors without allocated buffers
1012  */
1014 
1015 /**
1016  * \brief Return a tensor from the given tensor array
1017  */
1018 nux_tensor_t nux_tensor_array_get(nux_tensor_array_t array, uintptr_t index);
1019 
1020 /**
1021  * \brief Return the number of tensors in the given tensor array
1022  */
1023 uintptr_t nux_tensor_array_len(nux_tensor_array_t array);
1024 
1025 /**
1026  * \brief Destroy a tensor array
1027  */
1029 
1030 /**
1031  * \brief Destroy a buffer
1032  * @param buffer Byte buffer to be destroyed. It must not be `NULL`.
1033  * @param len Byte length of `buffer`
1034  */
1035 void nux_buffer_destroy(uint8_t *buf, nux_buffer_len_t len);
1036 
1037 /**
1038  * \brief Destroy a buffer
1039  * @param buffer Byte buffer to be destroyed. It must not be `NULL`.
1040  * @param len Byte length of `buffer`
1041  */
1043 
1044 /**
1045  * \brief Get NPU specification by NPUID.
1046  * @param npuid NPUID, indicating a specific NPU configuration with a certain NPU chip.
1047  * Currently, available NPUIDs are WARBOY and WARBOY-2PE.
1048  * @return A reference of the a specific NPU specification.
1049  * The ownership is not transferred to the caller.
1050  */
1051 npu_config_t get_npu_spec(const char *npuid);
1052 
1053 /**
1054  * \brief Run compiler
1055  */
1057 
1058 /**
1059  * \brief Create a compiler options
1060  */
1062 
1063 /**
1064  * \brief Destroy the compiler options
1065  */
1067 
1068 /**
1069  * \brief Set an input path
1070  */
1071 void compiler_options_input(compiler_options_t options, const char *path);
1072 
1073 /**
1074  * \brief Set an output path
1075  */
1076 void compiler_options_output(compiler_options_t options, const char *path);
1077 
1078 /**
1079  * \brief Set a target ir (one of dfg, ldfg, cdfg, gir, sir, lir, enf)
1080  */
1081 void compiler_options_target_ir(compiler_options_t options, const char *target_ir);
1082 
1083 /**
1084  * \brief Set a path to which a dot graph file is saved
1085  */
1086 void compiler_options_dot_graph(compiler_options_t options, const char *path);
1087 
1088 /**
1089  * \brief Set a path to which a memory analysis in HTML is saved
1090  */
1091 void compiler_options_memory_analysis(compiler_options_t options, const char *path);
1092 
1093 /**
1094  * \brief Set an inference batch size
1095  */
1096 void compiler_options_batch_size(compiler_options_t options, uintptr_t batch_size);
1097 
1098 /**
1099  * \brief Enable the automatic batch size optimizer
1100  */
1101 void compiler_options_auto_batch_size(compiler_options_t options, bool enabled);
1102 
1103 /**
1104  * \brief Enable the split after lower
1105  */
1106 void compiler_options_split_after_lower(compiler_options_t options, bool split_after_lower);
1107 
1108 /**
1109  * \brief Enable target NPU (available NPUs: warboy, warboy-2pe)
1110  */
1111 void compiler_options_target_npu(compiler_options_t options, const char *target_npu);
1112 
1113 /**
1114  * \brief Enable the optimization based on the genetic algorithm
1115  */
1116 void compiler_options_ga_optimization(compiler_options_t options, bool enabled);
1117 
1118 void compiler_options_ga_population_size(compiler_options_t options, uintptr_t population_size);
1119 
1120 void compiler_options_ga_generation_limit(compiler_options_t options, uint64_t generation_limit);
1121 
1122 void compiler_options_ga_max_prefetch_size(compiler_options_t options, uintptr_t max_prefetch_size);
1123 
1124 void compiler_options_ga_nondeterministic(compiler_options_t options, bool nondeterministic);
1125 
1126 void compiler_options_ga_pin_tensors(compiler_options_t options, bool pin_tensors);
1127 
1128 /**
1129  * \brief Set the initial tactic of genetic algorithm (available tactics: heuristic or random)
1130  */
1131 void compiler_options_ga_init_tactic(compiler_options_t options, const char *tactic);
1132 
1133 #ifdef __cplusplus
1134 } // extern "C"
1135 #endif // __cplusplus
1136 
1137 #endif /* furiosa_libnux_bindings_h */
nux_error_t_internal_error
@ nux_error_t_internal_error
Definition: nux.h:115
nux_session_option_set_compiler_log_path
void nux_session_option_set_compiler_log_path(nux_session_option_t builder, const char *path)
Set the file path to which the compiler save log messages.
create_nux
enum nux_error_t create_nux(nux_handle_t *nux)
Creates a new nux handle.
tensor_data_type_uint8
@ tensor_data_type_uint8
Definition: nux.h:34
nux_output_callback_t
void(* nux_output_callback_t)(nux_request_id_t, nux_output_index_t, nux_buffer_t, nux_buffer_len_t)
Callback function called per tensor output when a task of a task model is completed.
Definition: nux.h:244
nux_tensor_axis
enum Axis nux_tensor_axis(nux_tensor_desc_t tensor, uintptr_t idx)
Return the axis type of i-th dimension (e.g., Width, Height, Channel)
nux_tensor_size
uintptr_t nux_tensor_size(nux_tensor_desc_t tensor)
Return the byte size of tensor.
nux_session_run
enum nux_error_t nux_session_run(nux_session_t sess, nux_tensor_array_t inputs, nux_tensor_array_t outputs)
Run an inference task.
nux_session_option_create
nux_session_option_t nux_session_option_create(void)
Create a session option.
compiler_options_memory_analysis
void compiler_options_memory_analysis(compiler_options_t options, const char *path)
Set a path to which a memory analysis in HTML is saved.
compiler_options_input
void compiler_options_input(compiler_options_t options, const char *path)
Set an input path.
TensorArray
struct TensorArray TensorArray
Definition: nux.h:185
nux_error_t_unsupported_feature
@ nux_error_t_unsupported_feature
Definition: nux.h:155
nux_error_t_queue_wait_timeout
@ nux_error_t_queue_wait_timeout
Definition: nux.h:99
Model
struct Model Model
Definition: nux.h:169
nux_log_level_t_warn
@ nux_log_level_t_warn
Definition: nux.h:161
Nux
struct Nux Nux
Definition: nux.h:171
nux_log_level_t_info
@ nux_log_level_t_info
Definition: nux.h:162
nux_session_create
enum nux_error_t nux_session_create(nux_buffer_t model_binary, nux_buffer_len_t model_binary_len, nux_session_option_t option, nux_session_t *out_sess)
Create a session.
task_input_size
nux_buffer_len_t task_input_size(nux_task_t task, nux_input_index_t index)
Return the buffer length in bytes of the specified input tensor.
destroy_sync_model
void destroy_sync_model(nux_sync_model_t model)
Destroy the sync model and release its resources.
nux_error_t
nux_error_t
Represent a return status of a function that can fail.
Definition: nux.h:45
compiler_options_split_after_lower
void compiler_options_split_after_lower(compiler_options_t options, bool split_after_lower)
Enable the split after lower.
nux_input_index_t
InputIndex nux_input_index_t
Index of an input tensor, used in task model.
Definition: nux.h:278
axis_width_outer
@ axis_width_outer
Definition: nux.h:22
nux_async_session_run
enum nux_error_t nux_async_session_run(nux_async_session_t sess, nux_context_t context, nux_tensor_array_t inputs)
Submit an inference task asynchronously. It returns immediately.
destroy_task_model
void destroy_task_model(nux_task_model_t task_model)
Destroy the task model and release its resources.
compiler_options_target_npu
void compiler_options_target_npu(compiler_options_t options, const char *target_npu)
Enable target NPU (available NPUs: warboy, warboy-2pe)
compiler_options_t
CompilerOptions * compiler_options_t
Definition: nux.h:323
nux_session_option_t
struct SessionOptions * nux_session_option_t
Session option.
Definition: nux.h:283
nux_string_t
char * nux_string_t
A null-terminated C string.
Definition: nux.h:314
nux_input_desc
nux_tensor_desc_t nux_input_desc(nux_model_t model, uintptr_t index)
Return the description of i-th input tensor of the given model.
compiler_options_target_ir
void compiler_options_target_ir(compiler_options_t options, const char *target_ir)
Set a target ir (one of dfg, ldfg, cdfg, gir, sir, lir, enf)
nux_model_t
const struct NuxModel * nux_model_t
Model.
Definition: nux.h:293
tensor_data_type_int64
@ tensor_data_type_int64
Definition: nux.h:37
OpaqueTensor
struct OpaqueTensor OpaqueTensor
Definition: nux.h:175
tensor_set_buffer
enum nux_error_t tensor_set_buffer(nux_tensor_t tensor, nux_buffer_t buffer, nux_buffer_len_t len, void(*free)(uint8_t *, uintptr_t))
Specify a pointer to a data buffer to a specified input tensor.
nux_session_option_set_input_queue_size
void nux_session_option_set_input_queue_size(nux_session_option_t builder, uintptr_t len)
Set the input queue size of async session.
nux_error_t_incompatible_api_client_error
@ nux_error_t_incompatible_api_client_error
Definition: nux.h:123
nux_completion_queue_try_next
bool nux_completion_queue_try_next(nux_completion_queue_t queue, nux_context_t *context, nux_tensor_array_t *outputs, enum nux_error_t *error)
It's almost the same as nux_completion_queue_next. However, this call immediately returns even if it ...
nux_error_t_no_api_key
@ nux_error_t_no_api_key
Definition: nux.h:131
get_npu_spec
npu_config_t get_npu_spec(const char *npuid)
Get NPU specification by NPUID.
nux_create_sync_model
enum nux_error_t nux_create_sync_model(nux_handle_t nux, const uint8_t *buffer, nux_buffer_len_t len, nux_sync_model_t *model)
Create an instance of a synchronous model.
SessionOptions
struct SessionOptions SessionOptions
Definition: nux.h:177
tensor_get_buffer
enum nux_error_t tensor_get_buffer(nux_tensor_t tensor, nux_buffer_t *buffer, nux_buffer_len_t *len)
Get a pointer to the data buffer of a given tensor.
nux_tensor_array_create_outputs
nux_tensor_array_t nux_tensor_array_create_outputs(nux_model_t model)
Return an array of output tensors without allocated buffers.
compiler_options_batch_size
void compiler_options_batch_size(compiler_options_t options, uintptr_t batch_size)
Set an inference batch size.
nux_error_t_invalid_yaml
@ nux_error_t_invalid_yaml
Definition: nux.h:119
nux_error_t_nux_creation_failed
@ nux_error_t_nux_creation_failed
Definition: nux.h:53
axis_channel_outer
@ axis_channel_outer
Definition: nux.h:24
axis_batch_outer
@ axis_batch_outer
Definition: nux.h:25
tensor_data_type_int8
@ tensor_data_type_int8
Definition: nux.h:35
nux_tensor_array_create_by_names
nux_tensor_array_t nux_tensor_array_create_by_names(nux_model_t model, const char *const *names, uintptr_t len)
Return an array of tensors corresponding to the names without allocated buffers.
nux_error_t_invalid_outputs
@ nux_error_t_invalid_outputs
Definition: nux.h:85
BlockingSession
struct BlockingSession BlockingSession
Definition: nux.h:165
nux_session_option_destroy
void nux_session_option_destroy(nux_session_option_t option)
Destroy a session option.
nux_create_task_model
enum nux_error_t nux_create_task_model(nux_handle_t nux, const uint8_t *buffer, nux_buffer_len_t len, uint32_t max_batch, nux_output_callback_t output_callback, nux_error_callback_t error_callback, nux_finish_callback_t finish_callback, nux_task_model_t *task_model)
Create an instance of a task model.
nux_session_get_model
nux_model_t nux_session_get_model(nux_session_t sess)
Get the pointer of the Model of a given session.
compiler_options_auto_batch_size
void compiler_options_auto_batch_size(compiler_options_t options, bool enabled)
Enable the automatic batch size optimizer.
nux_error_t_compilation_failed
@ nux_error_t_compilation_failed
Definition: nux.h:111
register_signal_handler
void register_signal_handler(void)
Register Ctrl-C signal handler to exit process.
nux_session_destroy
void nux_session_destroy(nux_session_t sess)
Destroy a session.
nux_task_t
struct Task * nux_task_t
Handle of a task of a task model.
Definition: nux.h:271
nux_error_callback_t
void(* nux_error_callback_t)(nux_request_id_t, enum nux_error_t)
Callback function called when a task fails to complete.
Definition: nux.h:249
nux_session_option_set_worker_num
void nux_session_option_set_worker_num(nux_session_option_t builder, uintptr_t num)
Set the number of workers to the given session option.
nux_buffer_len_t
uintptr_t nux_buffer_len_t
Byte length of a data buffer.
Definition: nux.h:199
nux_buffer_destroy
void nux_buffer_destroy(uint8_t *buf, nux_buffer_len_t len)
Destroy a buffer.
RequestId
uintptr_t RequestId
Definition: nux.h:223
nux_error_t_session_terminated
@ nux_error_t_session_terminated
Definition: nux.h:143
task_execute
enum nux_error_t task_execute(nux_task_t task, nux_request_id_t request_id)
Request one asynchronous inference task.
nux_log_level_t
nux_log_level_t
Definition: nux.h:158
tensor_data_type_bfloat16
@ tensor_data_type_bfloat16
Definition: nux.h:38
npu_config_t
const typedef Config * npu_config_t
Definition: nux.h:321
Axis
Axis
Definition: nux.h:11
TaskModel
struct TaskModel TaskModel
Definition: nux.h:183
nux_tensor_destroy
void nux_tensor_destroy(nux_tensor_t tensor)
Destroy a tensor.
nux_error_t_device_busy
@ nux_error_t_device_busy
Definition: nux.h:147
compiler_options_ga_generation_limit
void compiler_options_ga_generation_limit(compiler_options_t options, uint64_t generation_limit)
nux_error_t_dump_profile_failed
@ nux_error_t_dump_profile_failed
Definition: nux.h:95
nux_error_t_invalid_input_index
@ nux_error_t_invalid_input_index
Definition: nux.h:68
nux_error_t_null_pointer_exception
@ nux_error_t_null_pointer_exception
Definition: nux.h:135
nux_tensor_dim_num
uintptr_t nux_tensor_dim_num(nux_tensor_desc_t tensor)
Return the number of dimensions of the given tensor.
compiler_options_dot_graph
void compiler_options_dot_graph(compiler_options_t options, const char *path)
Set a path to which a dot graph file is saved.
nux_error_t_invalid_buffer
@ nux_error_t_invalid_buffer
Definition: nux.h:77
task_model_is_all_task_done
bool task_model_is_all_task_done(nux_task_model_t task_model)
Return true if there's no running tasks, or false if any task is still running.
nux_input_num
uintptr_t nux_input_num(nux_model_t model)
Return the number of input tensors of the given model.
nux_error_t_model_deploy_failed
@ nux_error_t_model_deploy_failed
Definition: nux.h:58
nux_tensor_array_destroy
void nux_tensor_array_destroy(nux_tensor_array_t array)
Destroy a tensor array.
nux_tensor_buffer
uint8_t * nux_tensor_buffer(nux_tensor_t tensor)
Return the pointer to the buffer of this tensor.
nux_tensor_create_with_buffer
nux_tensor_t nux_tensor_create_with_buffer(nux_tensor_desc_t desc, nux_buffer_t buffer, nux_buffer_len_t len, void(*free)(uint8_t *, uintptr_t))
Create a tensor with an exiting buffer. It doesn't copy the data.
compiler_options_ga_optimization
void compiler_options_ga_optimization(compiler_options_t options, bool enabled)
Enable the optimization based on the genetic algorithm.
model_output_tensor
enum nux_error_t model_output_tensor(nux_sync_model_t model, uint32_t index, nux_tensor_t *tensor)
Get the handle of a specified output tensor from a given sync model.
nux_buffer_t
uint8_t * nux_buffer_t
Pointer to a data buffer.
Definition: nux.h:221
version
const char * version(void)
Return a version of Nux native library.
task_model_get_task
enum nux_error_t task_model_get_task(nux_task_model_t task_model, nux_task_t *task)
Get a task handle from a specified task model.
git_short_hash
const char * git_short_hash(void)
Return a short Git hash of Nux native library.
nux_handle_t
struct Nux * nux_handle_t
Nux handle.
Definition: nux.h:194
tensor_data_type_int32
@ tensor_data_type_int32
Definition: nux.h:36
destroy_nux
void destroy_nux(nux_handle_t nux)
Destroy the Nux handle and release its resources.
nux_tensor_array_len
uintptr_t nux_tensor_array_len(nux_tensor_array_t array)
Return the number of tensors in the given tensor array.
nux_tensor_desc_by_name
nux_tensor_desc_t nux_tensor_desc_by_name(nux_model_t model, const char *name)
Return the description of the tensor matched to the given name.
nux_error_t_model_execution_failed
@ nux_error_t_model_execution_failed
Definition: nux.h:63
axis_height_outer
@ axis_height_outer
Definition: nux.h:23
axis_channel
@ axis_channel
Definition: nux.h:17
nux_log_level_t_error
@ nux_log_level_t_error
Definition: nux.h:160
nux_log_level_t_off
@ nux_log_level_t_off
Definition: nux.h:159
nux_tensor_array_allocate_inputs
nux_tensor_array_t nux_tensor_array_allocate_inputs(nux_model_t model)
Return an array of input tensors with allocated buffers.
TensorDataType
TensorDataType
Represent tensor data type.
Definition: nux.h:32
nux_tensor_create
nux_tensor_t nux_tensor_create(nux_tensor_desc_t desc)
Create a tensor according to a given tensor description.
nux_error_t_invalid_output_index
@ nux_error_t_invalid_output_index
Definition: nux.h:73
nux_tensor_name
nux_string_t nux_tensor_name(nux_tensor_desc_t tensor)
Return the tensor name and transfers its ownership to the caller. To destroy nux_string_t,...
nux_tensor_array_allocate_by_names
nux_tensor_array_t nux_tensor_array_allocate_by_names(nux_model_t model, const char *const *names, uintptr_t len)
Return an array of tensors corresponding to the names with allocated buffers.
nux_async_session_t
struct Submitter_ContextPtr * nux_async_session_t
Async Session.
Definition: nux.h:300
axis_height
@ axis_height
Definition: nux.h:13
nux_tensor_dtype_t
enum TensorDataType nux_tensor_dtype_t
Represent a data type of tensor.
Definition: nux.h:319
nux_string_destroy
void nux_string_destroy(nux_string_t str)
Destroy a buffer.
nux_tensor_array_create_inputs
nux_tensor_array_t nux_tensor_array_create_inputs(nux_model_t model)
Return an array of input tensors without allocated buffers.
nux_error_t_incompatible_model
@ nux_error_t_incompatible_model
Definition: nux.h:107
nux_error_t_success
@ nux_error_t_success
Definition: nux.h:49
nux_finish_callback_t
void(* nux_finish_callback_t)(nux_request_id_t)
Callback function which is finally called when a task is completed.
Definition: nux.h:257
axis_batch
@ axis_batch
Definition: nux.h:21
Task
struct Task Task
Definition: nux.h:181
build_timestamp
const char * build_timestamp(void)
Return a build timestamp of Nux native library.
compiler_options_ga_init_tactic
void compiler_options_ga_init_tactic(compiler_options_t options, const char *tactic)
Set the initial tactic of genetic algorithm (available tactics: heuristic or random)
nux_tensor_array_allocate_outputs
nux_tensor_array_t nux_tensor_array_allocate_outputs(nux_model_t model)
Return an array of output tensors with allocated buffers.
NuxModel
struct NuxModel NuxModel
Definition: nux.h:173
nux_async_session_destroy
void nux_async_session_destroy(nux_async_session_t sess)
Destroy an asynchronous session.
nux_error_t_queue_no_data
@ nux_error_t_queue_no_data
Definition: nux.h:103
tensor_fill_buffer
enum nux_error_t tensor_fill_buffer(nux_tensor_t tensor, nux_buffer_t buffer, nux_buffer_len_t len)
Copy data into the data buffer of a specified input tensor.
compiler_options_ga_max_prefetch_size
void compiler_options_ga_max_prefetch_size(compiler_options_t options, uintptr_t max_prefetch_size)
nux_async_session_create
enum nux_error_t nux_async_session_create(nux_buffer_t model_binary, nux_buffer_len_t model_binary_len, nux_session_option_t option, nux_async_session_t *out_sess, nux_completion_queue_t *out_queue)
Create an asynchronous session and a queue to receive the results.
Submitter_ContextPtr
struct Submitter_ContextPtr Submitter_ContextPtr
Definition: nux.h:179
model_input_tensor
enum nux_error_t model_input_tensor(nux_sync_model_t model, uint32_t index, nux_tensor_t *tensor)
Get the handle of a specified input tensor from a given sync model.
compiler_options_create
compiler_options_t compiler_options_create(void)
Create a compiler options.
nux_sync_model_t
struct Model * nux_sync_model_t
Handle of a synchronous model.
Definition: nux.h:206
nux_error_t_invalid_session_options
@ nux_error_t_invalid_session_options
Definition: nux.h:139
nux_tensor_desc_t
const struct TensorDesc * nux_tensor_desc_t
Definition: nux.h:309
nux_tensor_array_t
struct TensorArray * nux_tensor_array_t
Definition: nux.h:295
nux_session_run_with
enum nux_error_t nux_session_run_with(nux_session_t sess, const char *const *input_names, uintptr_t input_len, const char *const *output_names, uintptr_t output_len, nux_tensor_array_t inputs, nux_tensor_array_t outputs)
Run an inference task with tensor names The number of input/output tensors and its corresponding name...
nux_tensor_dtype
nux_tensor_dtype_t nux_tensor_dtype(nux_tensor_desc_t tensor)
Return the tensor data type.
model_count_outputs
uint32_t model_count_outputs(nux_sync_model_t model)
Return the number of output tensors of a given sync model.
enable_logging
void enable_logging(enum nux_log_level_t _log_level)
Enable a logger with a specific log level.
nux_session_option_set_device
void nux_session_option_set_device(nux_session_option_t builder, const char *devname)
Set a NPU device to the given session option.
nux_completion_queue_next_timeout
bool nux_completion_queue_next_timeout(nux_completion_queue_t queue, uint64_t timeout_ms, nux_context_t *context, nux_tensor_array_t *outputs, enum nux_error_t *error)
It's almost the same as nux_completion_queue_next. However, this call will be blocked only until a ti...
compiler_options_ga_pin_tensors
void compiler_options_ga_pin_tensors(compiler_options_t options, bool pin_tensors)
nux_error_t_tensor_name_not_found
@ nux_error_t_tensor_name_not_found
Definition: nux.h:151
nux_session_t
const struct BlockingSession * nux_session_t
Session.
Definition: nux.h:288
CompletionQueue_ContextPtr
struct CompletionQueue_ContextPtr CompletionQueue_ContextPtr
Definition: nux.h:167
nux_context_t
void * nux_context_t
Context pointer.
Definition: nux.h:307
compiler_options_destroy
void compiler_options_destroy(compiler_options_t options)
Destroy the compiler options.
nux_tensor_array_get
nux_tensor_t nux_tensor_array_get(nux_tensor_array_t array, uintptr_t index)
Return a tensor from the given tensor array.
nux_completion_queue_next
bool nux_completion_queue_next(nux_completion_queue_t queue, nux_context_t *context, nux_tensor_array_t *outputs, enum nux_error_t *error)
Wait until it receives any completion event, which can be success or fail.
destroy_task
void destroy_task(nux_task_t task)
Destroy the task and release its resources.
nux_tensor_dim
uintptr_t nux_tensor_dim(nux_tensor_desc_t tensor, uintptr_t index)
Return the dimension size of the dimension index.
nux_tensor_t
struct OpaqueTensor * nux_tensor_t
Handle of tensor.
Definition: nux.h:213
compiler_options_output
void compiler_options_output(compiler_options_t options, const char *path)
Set an output path.
compiler_run
enum nux_error_t compiler_run(compiler_options_t options)
Run compiler.
axis_width
@ axis_width
Definition: nux.h:12
model_run
enum nux_error_t model_run(nux_sync_model_t model)
Run a single inference task.
nux_completion_queue_destroy
void nux_completion_queue_destroy(nux_completion_queue_t queue)
Destroy a completion queue.
nux_output_index_t
OutputIndex nux_output_index_t
Index of an output tensor, used in task model.
Definition: nux.h:235
nux_session_option_set_output_queue_size
void nux_session_option_set_output_queue_size(nux_session_option_t builder, uintptr_t len)
Set the output queue size of async session.
nux_request_id_t
RequestId nux_request_id_t
Identifier to distinguish tasks in a task model.
Definition: nux.h:228
tensor_data_type_bool
@ tensor_data_type_bool
Definition: nux.h:39
nux_error_t_invalid_inputs
@ nux_error_t_invalid_inputs
Definition: nux.h:81
task_model_try_get_task
enum nux_error_t task_model_try_get_task(nux_task_model_t task_model, nux_task_t *task)
(non-blocking) Get a task handle from the specified task model.
compiler_options_ga_population_size
void compiler_options_ga_population_size(compiler_options_t options, uintptr_t population_size)
axis_unknown
@ axis_unknown
Definition: nux.h:26
OutputIndex
uint32_t OutputIndex
Definition: nux.h:230
InputIndex
uint32_t InputIndex
Definition: nux.h:273
nux_tensor_buffer_size
uintptr_t nux_tensor_buffer_size(nux_tensor_t tensor)
Return the size of tensor buffer.
nux_async_session_get_model
nux_model_t nux_async_session_get_model(nux_async_session_t sess)
Get the pointer of the Model of a given asynchronous session.
model_count_inputs
uint32_t model_count_inputs(nux_sync_model_t model)
Return the number of input tensors of a given sync model.
task_input
nux_buffer_t task_input(nux_task_t task, nux_input_index_t index)
Return a mutable pointer to the buffer of the specified input tensor.
nux_output_desc
nux_tensor_desc_t nux_output_desc(nux_model_t model, uintptr_t index)
Return the description of i-th output tensor of the given model.
tensor_data_type_float32
@ tensor_data_type_float32
Definition: nux.h:33
nux_task_model_t
struct TaskModel * nux_task_model_t
Handle of a task model.
Definition: nux.h:264
nux_output_num
uintptr_t nux_output_num(nux_model_t model)
Return the number of output tensors of the given model.
nux_completion_queue_t
struct CompletionQueue_ContextPtr * nux_completion_queue_t
Definition: nux.h:302
compiler_options_ga_nondeterministic
void compiler_options_ga_nondeterministic(compiler_options_t options, bool nondeterministic)
nux_error_t_get_task_failed
@ nux_error_t_get_task_failed
Definition: nux.h:91
nux_error_t_api_client_init_failed
@ nux_error_t_api_client_init_failed
Definition: nux.h:127
TensorDesc
struct TensorDesc TensorDesc
Definition: nux.h:187
nux_tensor_len
uintptr_t nux_tensor_len(nux_tensor_desc_t tensor)
Return the total number of all elements.
nux_session_option_set_compiler_config
enum nux_error_t nux_session_option_set_compiler_config(nux_session_option_t option, const char *yaml)
Set a compiler config to the given session option.