Menoh
menoh.h
Go to the documentation of this file.
1 #ifndef MENOH_C_INTERFACE_H
2 #define MENOH_C_INTERFACE_H
3 
4 #include <stdint.h>
5 
6 #ifndef DOXYGEN_SHOULD_SKIP_THIS
7 
8 #if(defined(_WIN32) || defined(__WIN32__)) && !defined(__GNUC__)
9 #define MENOH_API __declspec(dllexport)
10 #else
11 #define MENOH_API
12 #endif
13 
14 #define MENOH_SUPPORTED_ONNX_OPSET_VERSION 8
15 
16 #ifndef MENOH_ERROR_MESSAGE_MAX_LENGTH
17 #define MENOH_ERROR_MESSAGE_MAX_LENGTH 1024
18 #endif
19 
20 #if MENOH_ERROR_MESSAGE_MAX_LENGTH < 1024
21 #undef MENOH_ERROR_MESSAGE_MAX_LENGTH
22 #define MENOH_ERROR_MESSAGE_MAX_LENGTH 1024
23 #endif
24 
25 #if defined(__cplusplus) && __cplusplus >= 201402L
26 #define MENOH_DEPRECATED_ATTRIBUTE(message) [[deprecated(message)]]
27 #elif(defined(_WIN32) || defined(__WIN32__)) && !defined(__GNUC__)
28 #define MENOH_DEPRECATED_ATTRIBUTE(message) __declspec(deprecated(message))
29 #elif defined(__GNUC__)
30 #define MENOH_DEPRECATED_ATTRIBUTE(message) __attribute__((deprecated(message)))
31 #else
32 #define MENOH_DEPRECATED_ATTRIBUTE(message)
33 #endif
34 
35 #endif // DOXYGEN_SHOULD_SKIP_THIS
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40 
48 };
51 typedef int32_t menoh_dtype;
52 
82 };
83 typedef int32_t menoh_error_code;
97 struct menoh_model_data;
111  const char* onnx_filename, menoh_model_data_handle* dst_handle);
118  const uint8_t* onnx_data, int32_t size, menoh_model_data_handle* dst_handle);
127  menoh_model_data_handle model_data, const char* parameter_name,
128  menoh_dtype dtype, int32_t dims_size, const int32_t* dims,
129  void* buffer_handle);
133  menoh_model_data_handle model_data, const char* op_type);
137  menoh_model_data_handle model_data, const char* input_name);
141  menoh_model_data_handle model_data, const char* output_name);
147  menoh_model_data_handle model_data, const char* attribute_name,
148  int32_t value);
154  menoh_model_data_handle model_data, const char* attribute_name, float value);
160  menoh_model_data_handle model_data, const char* attribute_name, int32_t size,
161  const int32_t* value);
168  menoh_model_data_handle model_data, const char* attribute_name, int32_t size,
169  const float* value);
187 
199 
207  menoh_variable_profile_table_builder_handle builder, const char* name,
208  menoh_dtype dtype, int32_t dims_size, const int32_t* dims);
209 
217  "please use menoh_variable_profile_table_builder_add_input_profile() instead")
220  menoh_variable_profile_table_builder_handle builder, const char* name,
221  menoh_dtype dtype, int32_t num, int32_t size);
222 
234  menoh_variable_profile_table_builder_handle builder, const char* name,
235  menoh_dtype dtype, int32_t num, int32_t channel, int32_t height,
236  int32_t width);
237 
244  menoh_variable_profile_table_builder_handle builder, const char* name);
245 
254  "dtype is totally ignored.")
257  menoh_variable_profile_table_builder_handle builder, const char* name,
258  menoh_dtype dtype);
259 
269 
274  const menoh_model_data_handle model_data,
282  menoh_variable_profile_table_handle variable_profile_table);
283 
289  const menoh_variable_profile_table_handle variable_profile_table,
290  const char* variable_name, menoh_dtype* dst_dtype);
291 
299  const menoh_variable_profile_table_handle variable_profile_table,
300  const char* variable_name, int32_t* dst_size);
301 
309  const menoh_variable_profile_table_handle variable_profile_table,
310  const char* variable_name, int32_t index, int32_t* dst_size);
311 
320  menoh_model_data_handle model_data,
321  const menoh_variable_profile_table_handle variable_profile_table);
322 
332 struct menoh_model_builder;
334 
338  const menoh_variable_profile_table_handle variable_profile_table,
339  menoh_model_builder_handle* dst_handle);
344 void MENOH_API
346 
358  menoh_model_builder_handle builder, const char* variable_name,
359  void* buffer_handle);
360 
366 struct menoh_model;
368 
375  const menoh_model_builder_handle builder,
376  const menoh_model_data_handle model_data, const char* backend_name,
377  const char* backend_config, menoh_model_handle* dst_model_handle);
383 
396  const menoh_model_handle model, const char* variable_name, void** dst_data);
397 
402  const menoh_model_handle model, const char* variable_name,
403  menoh_dtype* dst_dtype);
404 
411  const menoh_model_handle model, const char* variable_name, int32_t* dst_size);
412 
419  const menoh_model_handle model, const char* variable_name, int32_t index,
420  int32_t* dst_size);
421 
427 
432 #ifdef __cplusplus
433 }
434 #endif /* __cplusplus */
435 
436 #endif // MENOH_C_INTERFACE_H
menoh_model_builder is helper for creation of model.
menoh_error_code MENOH_API menoh_build_model(const menoh_model_builder_handle builder, const menoh_model_data_handle model_data, const char *backend_name, const char *backend_config, menoh_model_handle *dst_model_handle)
Factory function for menoh_model.
menoh_error_code MENOH_API menoh_model_data_add_output_name_to_current_node(menoh_model_data_handle model_data, const char *output_name)
Add a new output name to latest added node in model_data.
menoh_error_code MENOH_API menoh_make_model_data(menoh_model_data_handle *dst_handle)
Make empty model_data.
menoh_error_code MENOH_API menoh_variable_profile_table_get_dims_size(const menoh_variable_profile_table_handle variable_profile_table, const char *variable_name, int32_t *dst_size)
Accessor function for variable_profile_table.
menoh_error_code MENOH_API menoh_model_data_add_attribute_int_to_current_node(menoh_model_data_handle model_data, const char *attribute_name, int32_t value)
Add a new int attribute to latest added node in model_data.
menoh_error_code MENOH_API menoh_variable_profile_table_get_dims_at(const menoh_variable_profile_table_handle variable_profile_table, const char *variable_name, int32_t index, int32_t *dst_size)
Accessor function for variable_profile_table.
menoh_error_code MENOH_API menoh_variable_profile_table_builder_add_input_profile(menoh_variable_profile_table_builder_handle builder, const char *name, menoh_dtype dtype, int32_t dims_size, const int32_t *dims)
Add input profile.
menoh_error_code MENOH_API menoh_model_get_variable_buffer_handle(const menoh_model_handle model, const char *variable_name, void **dst_data)
Get a buffer handle attached to target variable.
menoh_error_code MENOH_API menoh_model_builder_attach_external_buffer(menoh_model_builder_handle builder, const char *variable_name, void *buffer_handle)
Attach a buffer which allocated by users.
menoh_error_code MENOH_API menoh_model_data_optimize(menoh_model_data_handle model_data, const menoh_variable_profile_table_handle variable_profile_table)
Optimize function for menoh_model_data.
menoh_model is the main component to execute model inference.
menoh_error_code_constant
Definition: menoh.h:59
menoh_error_code MENOH_API menoh_make_model_data_from_onnx(const char *onnx_filename, menoh_model_data_handle *dst_handle)
Load onnx file and make model_data.
deprecated menoh_error_code MENOH_API menoh_variable_profile_table_builder_add_input_profile_dims_4(menoh_variable_profile_table_builder_handle builder, const char *name, menoh_dtype dtype, int32_t num, int32_t channel, int32_t height, int32_t width)
Add 4D input profile.
menoh_error_code MENOH_API menoh_make_model_builder(const menoh_variable_profile_table_handle variable_profile_table, menoh_model_builder_handle *dst_handle)
Factory function for menoh_model_builder.
Definition: menoh.h:63
int32_t menoh_dtype
Definition: menoh.h:51
menoh_error_code MENOH_API menoh_model_data_add_input_name_to_current_node(menoh_model_data_handle model_data, const char *input_name)
Add a new input name to latest added node in model_data.
Definition: menoh.h:61
void MENOH_API menoh_delete_model_data(menoh_model_data_handle model_data)
Model_data delete function.
Definition: menoh.h:76
struct menoh_model_data * menoh_model_data_handle
Definition: menoh.h:98
menoh_dtype_constant
Definition: menoh.h:46
void MENOH_API menoh_delete_model(menoh_model_handle model)
Delete function for model.
menoh_error_code MENOH_API menoh_model_get_variable_dtype(const menoh_model_handle model, const char *variable_name, menoh_dtype *dst_dtype)
Get dtype of target variable.
MENOH_API const char * menoh_get_last_error_message()
Users can get detailed message about last error.
menoh_variable_profile_table_builder is the builder for creation of menoh_variable_profile_table.
menoh_error_code MENOH_API menoh_model_data_add_attribute_float_to_current_node(menoh_model_data_handle model_data, const char *attribute_name, float value)
Add a new float attribute to latest added node in model_data.
struct menoh_variable_profile_table_builder * menoh_variable_profile_table_builder_handle
Definition: menoh.h:185
menoh_error_code MENOH_API menoh_model_data_add_attribute_ints_to_current_node(menoh_model_data_handle model_data, const char *attribute_name, int32_t size, const int32_t *value)
Add a new int array attribute to latest added node in model_data.
menoh_error_code MENOH_API menoh_model_get_variable_dims_at(const menoh_model_handle model, const char *variable_name, int32_t index, int32_t *dst_size)
Get an element of dims of target variable specified by index.
Definition: menoh.h:72
menoh_error_code MENOH_API menoh_variable_profile_table_builder_add_output_name(menoh_variable_profile_table_builder_handle builder, const char *name)
Add output name.
Definition: menoh.h:60
void MENOH_API menoh_delete_variable_profile_table_builder(menoh_variable_profile_table_builder_handle builder)
Delete function for variable_profile_table_builder.
menoh_error_code MENOH_API menoh_model_data_add_attribute_floats_to_current_node(menoh_model_data_handle model_data, const char *attribute_name, int32_t size, const float *value)
Add a new float array attribute to latest added node in model_data.
void MENOH_API menoh_delete_model_builder(menoh_model_builder_handle model_builder)
Delete function for model_builder.
menoh_error_code MENOH_API menoh_make_model_data_from_onnx_data_on_memory(const uint8_t *onnx_data, int32_t size, menoh_model_data_handle *dst_handle)
make model_data from onnx binary data on memory
menoh_error_code MENOH_API menoh_variable_profile_table_get_dtype(const menoh_variable_profile_table_handle variable_profile_table, const char *variable_name, menoh_dtype *dst_dtype)
Accessor function for variable_profile_table.
Definition: menoh.h:62
int32_t menoh_error_code
Definition: menoh.h:83
#define MENOH_API
Definition: menoh.h:11
Definition: menoh.h:47
#define MENOH_DEPRECATED_ATTRIBUTE(message)
Definition: menoh.h:32
menoh_error_code MENOH_API menoh_build_variable_profile_table(const menoh_variable_profile_table_builder_handle builder, const menoh_model_data_handle model_data, menoh_variable_profile_table_handle *dst_handle)
Factory function for variable_profile_table.
Definition: menoh.h:66
menoh_variable_profile_table contains information of dims of variables.
menoh_error_code MENOH_API menoh_model_data_add_new_node(menoh_model_data_handle model_data, const char *op_type)
Add a new node to model_data.
menoh_error_code MENOH_API menoh_model_data_add_parameter(menoh_model_data_handle model_data, const char *parameter_name, menoh_dtype dtype, int32_t dims_size, const int32_t *dims, void *buffer_handle)
Add a new parameter in model_data.
void MENOH_API menoh_delete_variable_profile_table(menoh_variable_profile_table_handle variable_profile_table)
Delete function for variable_profile_table.
deprecated menoh_error_code MENOH_API menoh_variable_profile_table_builder_add_input_profile_dims_2(menoh_variable_profile_table_builder_handle builder, const char *name, menoh_dtype dtype, int32_t num, int32_t size)
Add 2D input profile.
menoh_model_data contains model parameters and computation graph structure.
Definition: menoh.h:65
menoh_error_code MENOH_API menoh_model_get_variable_dims_size(const menoh_model_handle model, const char *variable_name, int32_t *dst_size)
Get size of dims of target variable.
menoh_error_code MENOH_API menoh_make_variable_profile_table_builder(menoh_variable_profile_table_builder_handle *dst_handle)
Factory function for variable_profile_table_builder.
deprecated menoh_error_code MENOH_API menoh_variable_profile_table_builder_add_output_profile(menoh_variable_profile_table_builder_handle builder, const char *name, menoh_dtype dtype)
Add output profile.
menoh_error_code MENOH_API menoh_model_run(menoh_model_handle model)
Run model inference.