#ifndef DEEPVIEW_RT_H
#define DEEPVIEW_RT_H
#ifndef DEEPVIEW_RT_NO_INCLUDES
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#endif
#define NN_VERSION_ENCODE(major, minor, revision) \
(((major) *1000000) + ((minor) *1000) + (revision))
#define NN_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
#define NN_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
#define NN_VERSION_DECODE_REVISION(version) ((version) % 1000)
#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
#define NN_GNUC_VERSION \
NN_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#elif defined(__GNUC__)
#define NN_GNUC_VERSION NN_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
#endif
#if defined(NN_GNUC_VERSION)
#define NN_GNUC_VERSION_CHECK(major, minor, patch) \
(NN_GNUC_VERSION >= NN_VERSION_ENCODE(major, minor, patch))
#else
#define NN_GNUC_VERSION_CHECK(major, minor, patch) (0)
#endif
#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
#define NN_ARM_VERSION \
NN_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, \
(__ARMCOMPILER_VERSION % 1000000) / 10000, \
(__ARMCOMPILER_VERSION % 10000) / 100)
#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
#define NN_ARM_VERSION \
NN_VERSION_ENCODE(__ARMCC_VERSION / 1000000, \
(__ARMCC_VERSION % 1000000) / 10000, \
(__ARMCC_VERSION % 10000) / 100)
#endif
#if defined(NN_ARM_VERSION)
#define NN_ARM_VERSION_CHECK(major, minor, patch) \
(NN_ARM_VERSION >= NN_VERSION_ENCODE(major, minor, patch))
#else
#define NN_ARM_VERSION_CHECK(major, minor, patch) (0)
#endif
#if defined(__IAR_SYSTEMS_ICC__)
#if __VER__ > 1000
#define NN_IAR_VERSION \
NN_VERSION_ENCODE((__VER__ / 1000000), \
((__VER__ / 1000) % 1000), \
(__VER__ % 1000))
#else
#define NN_IAR_VERSION NN_VERSION_ENCODE(VER / 100, __VER__ % 100, 0)
#endif
#endif
#if defined(NN_IAR_VERSION)
#define NN_IAR_VERSION_CHECK(major, minor, patch) \
(NN_IAR_VERSION >= NN_VERSION_ENCODE(major, minor, patch))
#else
#define NN_IAR_VERSION_CHECK(major, minor, patch) (0)
#endif
#if defined(NN_GNUC_VERSION) && !defined(__clang) && !defined(NN_ARM_VERSION)
#define NN_GCC_VERSION NN_GNUC_VERSION
#endif
#if defined(NN_GCC_VERSION)
#define NN_GCC_VERSION_CHECK(major, minor, patch) \
(NN_GCC_VERSION >= NN_VERSION_ENCODE(major, minor, patch))
#else
#define NN_GCC_VERSION_CHECK(major, minor, patch) (0)
#endif
#if defined(__cplusplus) && (__cplusplus >= 201402L)
#define NN_DEPRECATED(since) [[deprecated("Since " #since)]]
#elif _MSC_VER >= 1400
#define NN_DEPRECATED(since) __declspec(deprecated("Since " #since))
#elif _MSC_VER >= 1310
#define NN_DEPRECATED(since) _declspec(deprecated)
#elif NN_IAR_VERSION_CHECK(8, 0, 0)
#define NN_DEPRECATED(since) _Pragma("deprecated")
#elif defined(_GHS_MULTI)
#define NN_DEPRECATED(since)
#else
#define NN_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
#endif
#if NN_GCC_VERSION_CHECK(4, 3, 0)
#define NN_UNAVAILABLE(available_since) \
__attribute__((__warning__("Not available until " #available_since)))
#else
#define NN_UNAVAILABLE(available_since)
#endif
#if defined(__cplusplus) && (__cplusplus >= 201703L)
#define NN_WARN_UNUSED_RESULT [[nodiscard]]
#elif defined(_Check_return_)
#define NN_WARN_UNUSED_RESULT _Check_return_
#elif !defined(__IAR_SYSTEMS_ICC__)
#define NN_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#else
#define NN_WARN_UNUSED_RESULT
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
#define NN_PRIVATE
#define NN_PUBLIC __declspec(dllexport)
#define NN_IMPORT __declspec(dllimport)
#else
#define NN_PRIVATE __attribute__((__visibility__("hidden")))
#define NN_PUBLIC __attribute__((__visibility__("default")))
#define NN_IMPORT extern
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
!defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \
!defined(NN_PGI_VERSION) && !defined(NN_TINYC_VERSION)
#define NN_ARRAY_PARAM(name) static(name)
#else
#define NN_ARRAY_PARAM(name)
#endif
#if !defined(__cplusplus) && \
((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
defined(_Static_assert))
#define NN_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
#elif (defined(__cplusplus) && (__cplusplus >= 201703L)) || (_MSC_VER >= 1600)
#define NN_STATIC_ASSERT(expr, message) static_assert(expr, message)
#elif defined(__cplusplus) && (__cplusplus >= 201103L)
#define NN_STATIC_ASSERT(expr, message) static_assert(expr)
#else
#define NN_STATIC_ASSERT(expr, message)
#endif
#ifdef NN_API_STATIC
#define NN_API
#else
#ifdef NN_API_EXPORT
#define NN_API NN_PUBLIC
#else
#define NN_API NN_IMPORT
#endif
#endif
#define NN_VERSION_2_0 NN_VERSION_ENCODE(2, 0, 0)
#define NN_VERSION_2_1 NN_VERSION_ENCODE(2, 1, 0)
#define NN_VERSION_2_2 NN_VERSION_ENCODE(2, 2, 0)
#define NN_VERSION_2_3 NN_VERSION_ENCODE(2, 3, 0)
#define NN_VERSION_2_4 NN_VERSION_ENCODE(2, 4, 0)
#define NN_VERSION_2_4_18 NN_VERSION_ENCODE(2, 4, 18)
#define NN_VERSION_2_4_25 NN_VERSION_ENCODE(2, 4, 25)
#define NN_VERSION_2_4_28 NN_VERSION_ENCODE(2, 4, 28)
#define NN_VERSION_2_4_30 NN_VERSION_ENCODE(2, 4, 30)
#define NN_VERSION_2_4_32 NN_VERSION_ENCODE(2, 4, 32)
#define NN_VERSION_2_4_42 NN_VERSION_ENCODE(2, 4, 42)
#define NN_VERSION_2_4_73 NN_VERSION_ENCODE(2, 4, 73)
#ifndef NN_TARGET_VERSION
#define NN_TARGET_VERSION NN_VERSION_2_4_73
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 0, 0)
#define NN_AVAILABLE_SINCE_2_0 NN_UNAVAILABLE(2.0)
#define NN_DEPRECATED_SINCE_2_0
#else
#define NN_AVAILABLE_SINCE_2_0
#define NN_DEPRECATED_SINCE_2_0 NN_DEPRECATED(2.0)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 1, 0)
#define NN_AVAILABLE_SINCE_2_1 NN_UNAVAILABLE(2.1)
#define NN_DEPRECATED_SINCE_2_1
#else
#define NN_AVAILABLE_SINCE_2_1
#define NN_DEPRECATED_SINCE_2_1 NN_DEPRECATED(2.1)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 2, 0)
#define NN_AVAILABLE_SINCE_2_2 NN_UNAVAILABLE(2.2)
#define NN_DEPRECATED_SINCE_2_2
#else
#define NN_AVAILABLE_SINCE_2_2
#define NN_DEPRECATED_SINCE_2_2 NN_DEPRECATED(2.2)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 3, 0)
#define NN_AVAILABLE_SINCE_2_3 NN_UNAVAILABLE(2.3)
#define NN_DEPRECATED_SINCE_2_3
#else
#define NN_AVAILABLE_SINCE_2_3
#define NN_DEPRECATED_SINCE_2_3 NN_DEPRECATED(2.3)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 0)
#define NN_AVAILABLE_SINCE_2_4 NN_UNAVAILABLE(2.4)
#define NN_DEPRECATED_SINCE_2_4
#else
#define NN_AVAILABLE_SINCE_2_4
#define NN_DEPRECATED_SINCE_2_4 NN_DEPRECATED(2.4)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 18)
#define NN_AVAILABLE_SINCE_2_4_18 NN_UNAVAILABLE(2.4.18)
#define NN_DEPRECATED_SINCE_2_4_18
#else
#define NN_AVAILABLE_SINCE_2_4_18
#define NN_DEPRECATED_SINCE_2_4_18 NN_DEPRECATED(2.4.18)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 25)
#define NN_AVAILABLE_SINCE_2_4_25 NN_UNAVAILABLE(2.4.25)
#define NN_DEPRECATED_SINCE_2_4_25
#else
#define NN_AVAILABLE_SINCE_2_4_25
#define NN_DEPRECATED_SINCE_2_4_25 NN_DEPRECATED(2.4.25)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 28)
#define NN_AVAILABLE_SINCE_2_4_28 NN_UNAVAILABLE(2.4.28)
#define NN_DEPRECATED_SINCE_2_4_28
#else
#define NN_AVAILABLE_SINCE_2_4_28
#define NN_DEPRECATED_SINCE_2_4_28 NN_DEPRECATED(2.4.28)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 30)
#define NN_AVAILABLE_SINCE_2_4_30 NN_UNAVAILABLE(2.4.30)
#define NN_DEPRECATED_SINCE_2_4_30
#else
#define NN_AVAILABLE_SINCE_2_4_30
#define NN_DEPRECATED_SINCE_2_4_30 NN_DEPRECATED(2.4.30)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 32)
#define NN_AVAILABLE_SINCE_2_4_32 NN_UNAVAILABLE(2.4.32)
#define NN_DEPRECATED_SINCE_2_4_32
#else
#define NN_AVAILABLE_SINCE_2_4_32
#define NN_DEPRECATED_SINCE_2_4_32 NN_DEPRECATED(2.4.32)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 42)
#define NN_AVAILABLE_SINCE_2_4_42 NN_UNAVAILABLE(2.4.42)
#define NN_DEPRECATED_SINCE_2_4_42
#else
#define NN_AVAILABLE_SINCE_2_4_42
#define NN_DEPRECATED_SINCE_2_4_42 NN_DEPRECATED(2.4.42)
#endif
#if NN_TARGET_VERSION < NN_VERSION_ENCODE(2, 4, 73)
#define NN_AVAILABLE_SINCE_2_4_73 NN_UNAVAILABLE(2.4.73)
#define NN_DEPRECATED_SINCE_2_4_73
#else
#define NN_AVAILABLE_SINCE_2_4_73
#define NN_DEPRECATED_SINCE_2_4_73 NN_DEPRECATED(2.4.73)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define NN_IMAGE_PROC_UNSIGNED_NORM 0x0001
#define NN_IMAGE_PROC_WHITENING 0x0002
#define NN_IMAGE_PROC_SIGNED_NORM 0x0004
#define NN_IMAGE_PROC_IMAGENET 0x0008
#define NN_IMAGE_PROC_MIRROR 0x1000
#define NN_IMAGE_PROC_FLIP 0x2000
#define NN_ENGINE_SIZEOF 1024
#define NN_TENSOR_SIZEOF 160
#define NN_CONTEXT_SIZEOF 512
typedef enum {
NN_SUCCESS = 0,
NN_ERROR_INTERNAL,
NN_ERROR_INVALID_HANDLE,
NN_ERROR_OUT_OF_MEMORY,
NN_ERROR_OUT_OF_RESOURCES,
NN_ERROR_NOT_IMPLEMENTED,
NN_ERROR_INVALID_PARAMETER,
NN_ERROR_TYPE_MISMATCH,
NN_ERROR_SHAPE_MISMATCH,
NN_ERROR_INVALID_SHAPE,
NN_ERROR_INVALID_ORDER,
NN_ERROR_INVALID_AXIS,
NN_ERROR_MISSING_RESOURCE,
NN_ERROR_INVALID_ENGINE,
NN_ERROR_TENSOR_NO_DATA,
NN_ERROR_KERNEL_MISSING,
NN_ERROR_TENSOR_TYPE_UNSUPPORTED,
NN_ERROR_TOO_MANY_INPUTS,
NN_ERROR_SYSTEM_ERROR,
NN_ERROR_INVALID_LAYER,
NN_ERROR_MODEL_INVALID,
NN_ERROR_MODEL_MISSING,
NN_ERROR_STRING_TOO_LARGE,
NN_ERROR_INVALID_QUANT,
NN_ERROR_MODEL_GRAPH_FAILED,
NN_ERROR_GRAPH_VERIFY_FAILED,
} NNError;
typedef enum {
NNTensorType_RAW = 0,
NNTensorType_STR = 1,
NNTensorType_I8 = 2,
NNTensorType_U8 = 3,
NNTensorType_I16 = 4,
NNTensorType_U16 = 5,
NNTensorType_I32 = 6,
NNTensorType_U32 = 7,
NNTensorType_I64 = 8,
NNTensorType_U64 = 9,
NNTensorType_F16 = 10,
NNTensorType_F32 = 11,
NNTensorType_F64 = 12
} NNTensorType;
typedef enum {
NNQuantizationType_None = 0,
NNQuantizationType_Affine_PerTensor = 1,
NNQuantizationType_Affine_PerChannel = 2,
NNQuantizationType_DFP = 3,
} NNQuantizationType;
typedef intptr_t NNOptions;
typedef struct nn_engine NNEngine;
typedef struct nn_tensor NNTensor;
typedef struct nn_quant_param NNQuantParam;
typedef void NNModel;
typedef void NNModelResource;
typedef void NNModelParameter;
typedef struct nn_context NNContext;
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_version();
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_strerror(NNError error);
NN_AVAILABLE_SINCE_2_4
NN_API
NN_WARN_UNUSED_RESULT
NNError
nn_init(const NNOptions* options);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_engine_sizeof();
NN_AVAILABLE_SINCE_2_0
NN_API
NNEngine*
nn_engine_init(void* memory);
NN_AVAILABLE_SINCE_2_4
NN_API
void*
nn_engine_native_handle(NNEngine* engine);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_engine_release(NNEngine* engine);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_engine_load(NNEngine* engine, const char* plugin);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_engine_unload(NNEngine* engine);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_engine_name(NNEngine* engine);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_engine_version(NNEngine* engine);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_tensor_sizeof();
NN_AVAILABLE_SINCE_2_0
NN_API
NNTensor*
nn_tensor_init(void* memory, NNEngine* engine);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_tensor_release(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
NNEngine*
nn_tensor_engine(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
void*
nn_tensor_native_handle(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_tensor_set_native_handle(NNTensor* tensor, void* handle);
typedef void(nn_aux_object_free)(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_1
NN_API
void
nn_tensor_set_aux_object(NNTensor* tensor,
void* aux_object,
nn_aux_object_free* aux_object_free);
NN_AVAILABLE_SINCE_2_1
NN_API
void*
nn_tensor_aux_object(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_3
NN_API
nn_aux_object_free*
nn_tensor_aux_free(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_4
NN_API
void
nn_tensor_set_aux_object_by_name(NNTensor* tensor,
const char* name,
void* aux_object,
nn_aux_object_free* aux_object_free,
bool buffer_ownership,
bool name_ownership);
NN_AVAILABLE_SINCE_2_4
NN_API
void*
nn_tensor_aux_object_by_name(NNTensor* tensor, const char* name);
nn_aux_object_free*
nn_tensor_aux_free_by_name(NNTensor* tensor, const char* name);
NN_AVAILABLE_SINCE_2_4
NN_API
int
nn_tensor_panel_size(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_4
NN_API
void
nn_tensor_set_panel_size(NNTensor* tensor, int panel_size);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_sync(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
int64_t
nn_tensor_time(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_1
NN_API
int64_t
nn_tensor_io_time(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_tensor_printf(NNTensor* tensor, bool data, FILE* out);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_assign(NNTensor* tensor,
NNTensorType type,
int32_t n_dims,
const int32_t shape[NN_ARRAY_PARAM(n_dims)],
void* data);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_view(NNTensor* tensor,
NNTensorType type,
int32_t n_dims,
const int32_t shape[NN_ARRAY_PARAM(n_dims)],
NNTensor* parent,
int32_t offset);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_alloc(NNTensor* tensor,
NNTensorType type,
int32_t n_dims,
const int32_t shape[NN_ARRAY_PARAM(n_dims)]);
NN_AVAILABLE_SINCE_2_0
NN_API
const int32_t*
nn_tensor_shape(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
const int32_t*
nn_tensor_strides(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
int32_t
nn_tensor_dims(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
const void*
nn_tensor_mapro(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
void*
nn_tensor_maprw(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
void*
nn_tensor_mapwo(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
int
nn_tensor_mapped(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_tensor_unmap(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
NNTensorType
nn_tensor_type(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_4
NN_API
NNError
nn_tensor_set_type(NNTensor* tensor, NNTensorType type);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_tensor_element_size(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
int32_t
nn_tensor_volume(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_API
int32_t
nn_tensor_size(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_4
NN_API
char
nn_tensor_axis(const NNTensor* tensor);
NN_AVAILABLE_SINCE_2_4
NN_API
const int32_t*
nn_tensor_zeros(const NNTensor* tensor, size_t* n_zeros);
NN_AVAILABLE_SINCE_2_4
NN_API
void
nn_tensor_set_zeros(NNTensor* tensor,
size_t n_zeros,
const int32_t* zeros,
int own);
NN_AVAILABLE_SINCE_2_4
NN_API
void
nn_tensor_set_axis(NNTensor* tensor, int32_t axis);
NN_AVAILABLE_SINCE_2_4
NN_API
const float*
nn_tensor_scales(const NNTensor* tensor, size_t* n_scales);
NN_AVAILABLE_SINCE_2_4
NN_API
void
nn_tensor_quant_params(const NNTensor* tensor, NNQuantParam* quant_params);
NN_AVAILABLE_SINCE_2_4
NN_API
void
nn_tensor_set_scales(NNTensor* tensor,
size_t n_scales,
const float* scales,
int own);
NN_AVAILABLE_SINCE_2_4_32
NN_API
NNQuantizationType
nn_tensor_quantization_type(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_DEPRECATED_SINCE_2_3
NN_API
bool
nn_tensor_shape_equal(const int32_t left[4], const int32_t right[4]);
NN_AVAILABLE_SINCE_2_0
NN_DEPRECATED_SINCE_2_3
NN_API
void
nn_tensor_shape_copy(int32_t dst[4], const int32_t src[4]);
NN_AVAILABLE_SINCE_2_0
NN_API
int
nn_tensor_offset(const NNTensor* tensor,
int32_t n_dims,
const int32_t shape[NN_ARRAY_PARAM(n_dims)]);
NN_AVAILABLE_SINCE_2_0
NN_API
int
nn_tensor_offsetv(const NNTensor* tensor, int32_t n_dims, ...);
NN_AVAILABLE_SINCE_2_0
NN_DEPRECATED_SINCE_2_3
NN_API
int
nn_tensor_compare(NNTensor* left, NNTensor* right, double tolerance);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_reshape(NNTensor* tensor,
int32_t n_dims,
const int32_t shape[NN_ARRAY_PARAM(n_dims)]);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_shuffle(NNTensor* output,
NNTensor* input,
int32_t n_dims,
const int32_t order[NN_ARRAY_PARAM(n_dims)]);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_fill(NNTensor* tensor, double constant);
NN_AVAILABLE_SINCE_2_0
NN_DEPRECATED_SINCE_2_3
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_randomize(NNTensor* tensor);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_copy(NNTensor* dest, NNTensor* source);
NN_AVAILABLE_SINCE_2_4
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_copy_buffer(NNTensor* tensor, const void* buffer, size_t bufsize);
NN_AVAILABLE_SINCE_2_4
NN_API
NNError
nn_tensor_requantize(NNTensor* dest, NNTensor* source);
NN_AVAILABLE_SINCE_2_4
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_quantize(NNTensor* dest, NNTensor* source, int axis);
NN_AVAILABLE_SINCE_2_4
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_quantize_buffer(NNTensor* dest,
size_t buffer_length,
const float* buffer,
int axis);
NN_AVAILABLE_SINCE_2_4
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_dequantize(NNTensor* dest, NNTensor* source);
NN_AVAILABLE_SINCE_2_4
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_dequantize_buffer(NNTensor* source,
size_t buffer_length,
float* buffer);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_concat(NNTensor* output,
int32_t n_inputs,
NNTensor* inputs[NN_ARRAY_PARAM(n_inputs)],
int32_t axis);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_slice(NNTensor* output,
NNTensor* input,
int32_t n_axes,
const int32_t axes[NN_ARRAY_PARAM(n_axes)],
const int32_t head[NN_ARRAY_PARAM(n_axes)],
const int32_t tail[NN_ARRAY_PARAM(n_axes)]);
NN_AVAILABLE_SINCE_2_4_42
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_strided_slice(NNTensor* output,
NNTensor* input,
int32_t n_axes,
const int32_t axes[NN_ARRAY_PARAM(n_axes)],
const int32_t head_[NN_ARRAY_PARAM(n_axes)],
const int32_t tail_[NN_ARRAY_PARAM(n_axes)],
const int32_t strides_[NN_ARRAY_PARAM(n_axes)]);
NN_AVAILABLE_SINCE_2_3
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_padding(NNTensor* tensor,
const char* padtype,
const int32_t* window,
const int32_t* stride,
const int32_t* dilation,
int32_t* padded_shape,
int32_t* paddings);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_pad(NNTensor* output,
NNTensor* input,
const int32_t head[4],
const int32_t tail[4],
double constant);
NN_AVAILABLE_SINCE_2_2
NN_DEPRECATED_SINCE_2_3
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_load_file(NNTensor* tensor, const char* filename);
NN_AVAILABLE_SINCE_2_2
NN_DEPRECATED_SINCE_2_3
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_load_file_ex(NNTensor* tensor, const char* filename, uint32_t proc);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_load_image(NNTensor* tensor, const void* image, size_t image_size);
NN_AVAILABLE_SINCE_2_1
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_tensor_load_image_ex(NNTensor* tensor,
const void* image,
size_t image_size,
uint32_t proc);
NN_AVAILABLE_SINCE_2_0
NN_API
int
nn_model_validate(const NNModel* memory, size_t size);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_validate_error(int err);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_name(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_uuid(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
uint32_t
nn_model_serial(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
int
nn_model_label_count(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_label(const NNModel* model, int index);
NN_AVAILABLE_SINCE_2_0
NN_API
const uint8_t*
nn_model_label_icon(const NNModel* model, int index, size_t* size);
NN_AVAILABLE_SINCE_2_4
NN_API
const uint32_t*
nn_model_inputs(const NNModel* model, size_t* n_inputs);
NN_AVAILABLE_SINCE_2_4
NN_API
const uint32_t*
nn_model_outputs(const NNModel* model, size_t* n_outputs);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_model_layer_count(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_layer_name(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_0
NN_API
int
nn_model_layer_lookup(const NNModel* model, const char* name);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_layer_type(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_4
NN_API
int16_t
nn_model_layer_type_id(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_0
NN_API
const char*
nn_model_layer_datatype(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_0
NN_API
NNTensorType
nn_model_layer_datatype_id(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_4
NN_API
const int32_t*
nn_model_layer_zeros(const NNModel* model, size_t index, size_t* n_zeros);
NN_AVAILABLE_SINCE_2_4
NN_API
const float*
nn_model_layer_scales(const NNModel* model, size_t index, size_t* n_scales);
NN_AVAILABLE_SINCE_2_4
NN_API
int
nn_model_layer_axis(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_0
NN_API
const int32_t*
nn_model_layer_shape(const NNModel* model, size_t index, size_t* n_dims);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_model_layer_inputs(const NNModel* model,
size_t index,
const uint32_t** inputs);
NN_AVAILABLE_SINCE_2_4
NN_API
const NNModelParameter*
nn_model_layer_parameter(const NNModel* model, size_t layer, const char* key);
NN_AVAILABLE_SINCE_2_4
NN_API
const int32_t*
nn_model_layer_parameter_shape(const NNModel* model,
size_t layer,
const char* key,
size_t* n_dims);
NN_AVAILABLE_SINCE_2_4
NN_API
const float*
nn_model_layer_parameter_data_f32(const NNModel* model,
size_t layer,
const char* key,
size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const int16_t*
nn_model_layer_parameter_data_i16(const NNModel* model,
size_t layer,
const char* key,
size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const uint8_t*
nn_model_layer_parameter_data_raw(const NNModel* model,
size_t layer,
const char* key,
size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const char*
nn_model_layer_parameter_data_str(const NNModel* model,
size_t layer,
const char* key,
size_t index);
NN_AVAILABLE_SINCE_2_4
NN_API
size_t
nn_model_layer_parameter_data_str_len(const NNModel* model,
size_t layer,
const char* key);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_model_memory_size(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_model_cache_minimum_size(const NNModel* model);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_model_cache_optimum_size(const NNModel* model);
NN_AVAILABLE_SINCE_2_4
NN_API
size_t
nn_model_resource_count(const NNModel* model);
NN_AVAILABLE_SINCE_2_4
NN_API
const NNModelResource*
nn_model_resource_at(const NNModel* model, size_t index);
NN_AVAILABLE_SINCE_2_4
NN_API
const NNModelResource*
nn_model_resource(const NNModel* model, const char* name);
NN_AVAILABLE_SINCE_2_4
NN_API
const int32_t*
nn_model_parameter_shape(const NNModelParameter* parameter, size_t* n_dims);
NN_AVAILABLE_SINCE_2_4
NN_API
const float*
nn_model_parameter_data_f32(const NNModelParameter* parameter, size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const int32_t*
nn_model_parameter_data_i32(const NNModelParameter* parameter, size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const int16_t*
nn_model_parameter_data_i16(const NNModelParameter* parameter, size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const int8_t*
nn_model_parameter_data_i8(const NNModelParameter* parameter, size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const uint8_t*
nn_model_parameter_data_raw(const NNModelParameter* parameter, size_t* length);
NN_AVAILABLE_SINCE_2_4
NN_API
const char*
nn_model_parameter_data_str(const NNModelParameter* parameter, size_t index);
NN_AVAILABLE_SINCE_2_4
NN_API
size_t
nn_model_parameter_data_str_len(const NNModelParameter* parameter);
NN_AVAILABLE_SINCE_2_4
NN_API
const char*
nn_model_resource_name(const NNModelResource* resource);
NN_AVAILABLE_SINCE_2_4
NN_API
const char*
nn_model_resource_meta(const NNModelResource* resource);
NN_AVAILABLE_SINCE_2_4
NN_API
const char*
nn_model_resource_mime(const NNModelResource* resource);
NN_AVAILABLE_SINCE_2_4
NN_API
const uint8_t*
nn_model_resource_data(const NNModelResource* resource, size_t* data_size);
NN_AVAILABLE_SINCE_2_0
NN_API
size_t
nn_context_sizeof();
NN_AVAILABLE_SINCE_2_0
NN_API
NNContext*
nn_context_init(NNEngine* engine,
size_t memory_size,
void* memory,
size_t cache_size,
void* cache);
NN_API
NNContext*
nn_context_init_ex(void* context_memory,
NNEngine* engine,
size_t memory_size,
void* memory,
size_t cache_size,
void* cache);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_context_release(NNContext* context);
typedef NNError(nn_user_ops)(NNContext* context,
const char* opname,
size_t index);
NN_AVAILABLE_SINCE_2_4
NN_API
NNError
nn_context_user_ops_register(NNContext* context, nn_user_ops* callback);
NN_AVAILABLE_SINCE_2_4
NN_API
nn_user_ops*
nn_context_user_ops(NNContext* context);
NN_AVAILABLE_SINCE_2_2
NN_API
NNTensor*
nn_context_cache(NNContext* context);
NN_AVAILABLE_SINCE_2_2
NN_API
NNTensor*
nn_context_mempool(NNContext* context);
NN_AVAILABLE_SINCE_2_0
NN_API
NNEngine*
nn_context_engine(NNContext* context);
NN_AVAILABLE_SINCE_2_0
NN_API
const NNModel*
nn_context_model(NNContext* context);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_context_model_load(NNContext* context,
size_t memory_size,
const void* memory);
NN_AVAILABLE_SINCE_2_0
NN_API
void
nn_context_model_unload(NNContext* context);
NN_AVAILABLE_SINCE_2_0
NN_API
NNTensor*
nn_context_tensor(NNContext* context, const char* name);
NN_AVAILABLE_SINCE_2_0
NN_API
NNTensor*
nn_context_tensor_index(NNContext* context, size_t index);
NN_AVAILABLE_SINCE_2_0
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_context_run(NNContext* context);
NN_AVAILABLE_SINCE_2_3
NN_WARN_UNUSED_RESULT
NN_API
NNError
nn_context_step(NNContext* context, size_t index);
NN_API
void
nn_free(void* ptr);
NN_API
void*
nn_malloc(size_t size);
#ifdef __cplusplus
}
#endif
#endif