ailia
1.5.0.0
|
inference library More...
Go to the source code of this file.
Classes | |
struct | _AILIAShape |
struct | _AILIAEnvironment |
Typedefs | |
typedef struct _AILIAShape | AILIAShape |
typedef struct _AILIAEnvironment | AILIAEnvironment |
Functions | |
int AILIA_API | ailiaCreate (struct AILIANetwork **net, int env_id, int num_thread) |
Creates a network instance. More... | |
int AILIA_API | ailiaOpenStreamFileA (struct AILIANetwork *net, const char *path) |
Initializes the network instance. (Read from file) More... | |
int AILIA_API | ailiaOpenStreamFileW (struct AILIANetwork *net, const wchar_t *path) |
int AILIA_API | ailiaOpenStreamEx (struct AILIANetwork *net, const void *fopen_args, ailiaFileCallback callback, int version) |
Initializes the network instance. (User-defined file access callback) More... | |
int AILIA_API | ailiaOpenStreamMem (struct AILIANetwork *net, const void *buf, unsigned int buf_size) |
Initializes the network instance. (Read from memory) More... | |
int AILIA_API | ailiaOpenWeightFileA (struct AILIANetwork *net, const char *path) |
Reads weights into a network instance. (Read from file) More... | |
int AILIA_API | ailiaOpenWeightFileW (struct AILIANetwork *net, const wchar_t *path) |
int AILIA_API | ailiaOpenWeightEx (struct AILIANetwork *net, const void *fopen_args, ailiaFileCallback callback, int version) |
Reads weights into a network instance. (User-defined file access callback) More... | |
int AILIA_API | ailiaOpenWeightMem (struct AILIANetwork *net, const void *buf, unsigned int buf_size) |
Reads weights into a network instance. (Read from memory) More... | |
void AILIA_API | ailiaDestroy (struct AILIANetwork *net) |
It destroys the network instance. More... | |
int AILIA_API | ailiaSetInputShape (struct AILIANetwork *net, const AILIAShape *shape, unsigned int version) |
Changes the shape of the input data during inference. More... | |
int AILIA_API | ailiaSetInputShapeND (struct AILIANetwork *net, const unsigned int *shape, unsigned int dim) |
Changes the shape of the input data during inference. More... | |
int AILIA_API | ailiaGetInputShape (struct AILIANetwork *net, AILIAShape *shape, unsigned int version) |
Gets the shape of the input data during inference. More... | |
int AILIA_API | ailiaGetInputDim (struct AILIANetwork *net, unsigned int *dim) |
Gets the dimension of the input data during inference. More... | |
int AILIA_API | ailiaGetInputShapeND (struct AILIANetwork *net, unsigned int *shape, unsigned int dim) |
Gets the shape of the input data during inference. More... | |
int AILIA_API | ailiaGetOutputShape (struct AILIANetwork *net, AILIAShape *shape, unsigned int version) |
Gets the shape of the output data during inference. More... | |
int AILIA_API | ailiaGetOutputDim (struct AILIANetwork *net, unsigned int *dim) |
Gets the dimension of the output data during inference. More... | |
int AILIA_API | ailiaGetOutputShapeND (struct AILIANetwork *net, unsigned int *shape, unsigned int dim) |
Gets the shape of the output data during inference. More... | |
int AILIA_API | ailiaPredict (struct AILIANetwork *net, void *dest, unsigned int dest_size, const void *src, unsigned int src_size) |
Performs the inferences and provides the inference result. More... | |
int AILIA_API | ailiaGetBlobCount (struct AILIANetwork *net, unsigned int *blob_count) |
Gets the amount of internal data (blob) during inference. More... | |
int AILIA_API | ailiaGetBlobShape (struct AILIANetwork *net, AILIAShape *shape, unsigned int blob_idx, unsigned int version) |
Gets the shape of the internal data (blob) during inference. More... | |
int AILIA_API | ailiaGetBlobDim (struct AILIANetwork *net, unsigned int *dim, unsigned int blob_idx) |
Gets the dimension of the internal data (blob) during inference. More... | |
int AILIA_API | ailiaGetBlobShapeND (struct AILIANetwork *net, unsigned int *shape, unsigned int dim, unsigned int blob_idx) |
Gets the amount of internal data (blob) during inference. More... | |
int AILIA_API | ailiaGetBlobData (struct AILIANetwork *net, void *dest, unsigned int dest_size, unsigned int blob_idx) |
Gets the internal data (blob) during inference. More... | |
int AILIA_API | ailiaGetBlobDataType (struct AILIANetwork *net, int *type, unsigned int blob_idx) |
Get the type of Blob. More... | |
int AILIA_API | ailiaFindBlobIndexByName (struct AILIANetwork *net, unsigned int *blob_idx, const char *name) |
Searches by name for the index of the internal data (blob) during inference and returns it. More... | |
int AILIA_API | ailiaGetBlobNameLengthByIndex (struct AILIANetwork *net, const unsigned int blob_idx, unsigned int *buffer_size) |
Gets the size of the buffer needed for output of the name of the internal data (blob). More... | |
int AILIA_API | ailiaFindBlobNameByIndex (struct AILIANetwork *net, char *buffer, const unsigned int buffer_size, const unsigned int blob_idx) |
Searches by index for the name of the internal data (blob) during inference and returns it. More... | |
int AILIA_API | ailiaGetSummaryLength (struct AILIANetwork *net, unsigned int *buffer_size) |
Gets the size of the buffer needed for the network summary. More... | |
int AILIA_API | ailiaSummary (struct AILIANetwork *net, char *const buffer, const unsigned int buffer_size) |
Shows the name and shape of each blob. More... | |
int AILIA_API | ailiaGetInputBlobCount (struct AILIANetwork *net, unsigned int *input_blob_count) |
Get the number of input data blobs. More... | |
int AILIA_API | ailiaGetBlobIndexByInputIndex (struct AILIANetwork *net, unsigned int *blob_idx, unsigned int input_blob_idx) |
Get the blob index of the input data. More... | |
int AILIA_API | ailiaSetInputBlobData (struct AILIANetwork *net, const void *src, unsigned int src_size, unsigned int blob_idx) |
Provides the specified blob with the input data. More... | |
int AILIA_API | ailiaSetInputBlobShape (struct AILIANetwork *net, const AILIAShape *shape, unsigned int blob_idx, unsigned int version) |
Change the shape of the blob given by its index. More... | |
int AILIA_API | ailiaSetInputBlobShapeND (struct AILIANetwork *net, const unsigned *shape, const unsigned dim, unsigned int blob_idx) |
Change the shape of the blob given by its index. More... | |
int AILIA_API | ailiaCopyBlobData (struct AILIANetwork *dst_net, unsigned int dst_blob_idx, struct AILIANetwork *src_net, unsigned int src_blob_idx) |
Perform copies between blobs that specified. More... | |
int AILIA_API | ailiaUpdate (struct AILIANetwork *net) |
Makes inferences with the input data specified in advance. More... | |
int AILIA_API | ailiaGetOutputBlobCount (struct AILIANetwork *net, unsigned int *output_blob_count) |
Get the number of output data blobs. More... | |
int AILIA_API | ailiaGetBlobIndexByOutputIndex (struct AILIANetwork *net, unsigned int *blob_idx, unsigned int output_blob_idx) |
Get the blob index of the input data blob. More... | |
int AILIA_API | ailiaFinalize (void) |
Release GPU and other resources that have been globally allocated with ailia. More... | |
int AILIA_API | ailiaSetTemporaryCachePathA (const char *cache_dir) |
Specifies a temporary cache directory. More... | |
int AILIA_API | ailiaSetTemporaryCachePathW (const wchar_t *cache_dir) |
int AILIA_API | ailiaGetEnvironmentCount (unsigned int *env_count) |
Gets the number of available computational environments (CPU, GPU). More... | |
int AILIA_API | ailiaGetEnvironment (AILIAEnvironment **env, unsigned int env_idx, unsigned int version) |
Gets the list of computational environments. More... | |
int AILIA_API | ailiaGetSelectedEnvironment (struct AILIANetwork *net, AILIAEnvironment **env, unsigned int version) |
Gets the selected computational environment. More... | |
int AILIA_API | ailiaSetMemoryMode (struct AILIANetwork *net, unsigned int mode) |
Set the memory usage policy for inference. More... | |
int AILIA_API | ailiaDisableLayerFusion (struct AILIANetwork *net) |
Disalbe layer fusion optimaization for inference. More... | |
int AILIA_API | ailiaSetProfileMode (struct AILIANetwork *net, unsigned int mode) |
Set the profile mode. More... | |
const char *AILIA_API | ailiaGetStatusString (int status_code) |
Returns the string describing given status code. More... | |
const char *AILIA_API | ailiaGetErrorDetail (struct AILIANetwork *net) |
Returns the details of errors. More... | |
const char *AILIA_API | ailiaGetVersion (void) |
Get the version of the library. More... | |
inference library
#define AILIA_API __stdcall |
#define AILIA_DATATYPE_BFLOAT16 16 |
#define AILIA_DATATYPE_BOOL 9 |
#define AILIA_DATATYPE_DOUBLE 11 |
#define AILIA_DATATYPE_FLOAT 1 |
#define AILIA_DATATYPE_FLOAT16 10 |
#define AILIA_DATATYPE_INT16 5 |
#define AILIA_DATATYPE_INT32 6 |
#define AILIA_DATATYPE_INT64 7 |
#define AILIA_DATATYPE_INT8 3 |
#define AILIA_DATATYPE_UINT16 4 |
#define AILIA_DATATYPE_UINT32 12 |
#define AILIA_DATATYPE_UINT64 13 |
#define AILIA_DATATYPE_UINT8 2 |
#define AILIA_DATATYPE_UNDEFINED 0 |
#define AILIA_ENVIRONMENT_BACKEND_CUDA (2) |
#define AILIA_ENVIRONMENT_BACKEND_MPS (3) |
#define AILIA_ENVIRONMENT_BACKEND_NONE (0) |
#define AILIA_ENVIRONMENT_BACKEND_VULKAN (6) |
#define AILIA_ENVIRONMENT_ID_AUTO (-1) |
#define AILIA_ENVIRONMENT_PROPERTY_FP16 (2) |
Indicates that a FP16 mode
#define AILIA_ENVIRONMENT_PROPERTY_LOWPOWER (1) |
Indicates that a low-power GPU (e.g. integrated GPU) will be preferentially used. (for MPS)
#define AILIA_ENVIRONMENT_PROPERTY_NORMAL (0) |
#define AILIA_ENVIRONMENT_TYPE_BLAS (1) |
#define AILIA_ENVIRONMENT_TYPE_CPU (0) |
#define AILIA_ENVIRONMENT_TYPE_GPU (2) |
#define AILIA_ENVIRONMENT_TYPE_REMOTE (3) |
#define AILIA_ENVIRONMENT_VERSION (2) |
#define AILIA_MEMORY_NO_OPTIMIZATION (0) |
Do not release the intermediate buffer
#define AILIA_MEMORY_OPTIMAIZE_DEFAULT (AILIA_MEMORY_REDUCE_CONSTANT) |
#define AILIA_MEMORY_REDUCE_CONSTANT (1) |
Releases the intermediate buffer that is a constant such as weight
#define AILIA_MEMORY_REDUCE_CONSTANT_WITH_FILE_MAPPED (16) |
Infer with memory mapped file for weight due to reduce ram usage.
When need to convert weight, it will allocate temporary buffer and after infer, release buffer. It will apply when load from file, and environment that mmap available. It will create temporary file due to speedup mmap, so you should be call ailiaSetTemporaryCachePath. If do not call ailiaSetTemporaryCachePath and specify this, it will return error AILIA_STATUS_INVALID_STATE
when call ailiaOpenWeightXXX. AILIA_MEMORY_REDUCE_INTERSTAGE and AILIA_MEMORY_REUSE_INTERSTAGE can be used together.
#define AILIA_MEMORY_REDUCE_CONSTANT_WITH_INPUT_INITIALIZER (2) |
Disable the input specified initializer and release the intermediate buffer that becomes a constant such as weight.
#define AILIA_MEMORY_REDUCE_INTERSTAGE (4) |
Release intermediate buffer during inference
#define AILIA_MEMORY_REUSE_INTERSTAGE (8) |
Infer by sharing the intermediate buffer. When used with AILIA_MEMORY_REDUCE_INTERSTAGE , the sharable intermediate buffer is not opened.
#define AILIA_MULTITHREAD_AUTO (0) |
#define AILIA_PROFILE_AVERAGE (0x01) |
Measure the processing time for each layer. If you infer multiple times, the average value excluding the first execution is saved.
#define AILIA_PROFILE_DISABLE (0x00) |
Disable profile mode (Default)
#define AILIA_SHAPE_VERSION (1) |
#define AILIA_STATUS_BROKEN (-4) |
A corrupt file was passed.
#define AILIA_STATUS_DATA_HIDDEN (-19) |
The information was not available from the application.
#define AILIA_STATUS_DATA_REMOVED AILIA_STATUS_DATA_HIDDEN |
#define AILIA_STATUS_ERROR_FILE_API (-2) |
File access failed.
#define AILIA_STATUS_EXPIRED (-17) |
Model Expired.
#define AILIA_STATUS_GPU_ERROR (-14) |
Error during processing on the GPU.
#define AILIA_STATUS_GPU_UNSUPPORT_LAYER (-13) |
Please use AILIA_STATUS_GPU_UNSUPPORTED_LAYER. This macro has been deprecated. It will be removed in a future version.
#define AILIA_STATUS_GPU_UNSUPPORTED_LAYER (-13) |
A layer parameter not supported by the GPU was given.
#define AILIA_STATUS_INVALID_ARGUMENT (-1) |
Incorrect argument.
#define AILIA_STATUS_INVALID_LAYER (-10) |
Incorrect layer weight, parameter, or input or output shape.
#define AILIA_STATUS_INVALID_PARAMINFO (-11) |
The content of the parameter file is invalid.
#define AILIA_STATUS_INVALID_STATE (-7) |
The internal status of the ailia is incorrect.
#define AILIA_STATUS_INVALID_VERSION (-3) |
Incorrect struct version.
#define AILIA_STATUS_LICENSE_BROKEN (-21) |
License is broken.
#define AILIA_STATUS_LICENSE_EXPIRED (-22) |
License expired.
#define AILIA_STATUS_LICENSE_NOT_FOUND (-20) |
No valid license found.
#define AILIA_STATUS_MEMORY_INSUFFICIENT (-5) |
Insufficient memory.
#define AILIA_STATUS_NDIMENSION_SHAPE (-23) |
Dimension of shape is 5 or more.
#define AILIA_STATUS_NOT_FOUND (-12) |
The specified element was not found.
#define AILIA_STATUS_OTHER_ERROR (-128) |
Unknown error.
#define AILIA_STATUS_PERMISSION_DENIED (-16) |
Operation not allowed.
#define AILIA_STATUS_SUCCESS (0) |
Successful.
#define AILIA_STATUS_THREAD_ERROR (-6) |
Thread creation failed.
#define AILIA_STATUS_UNIMPLEMENTED (-15) |
Unimplemented error.
#define AILIA_STATUS_UNSETTLED_SHAPE (-18) |
The shape is not yet determined.
#define AILIA_STATUS_UNSUPPORT_NET (-9) |
Please use AILIA_STATUS_UNSUPPORTED_NET. This macro has been deprecated. It will be removed in a future version.
#define AILIA_STATUS_UNSUPPORTED_NET (-9) |
Unsupported network.
#define ailiaOpenStreamFile ailiaOpenStreamFileA |
#define ailiaOpenWeightFile ailiaOpenWeightFileA |
#define ailiaSetTemporaryCachePath ailiaSetTemporaryCachePathA |
typedef struct _AILIAEnvironment AILIAEnvironment |
typedef struct _AILIAShape AILIAShape |
int AILIA_API ailiaCopyBlobData | ( | struct AILIANetwork * | dst_net, |
unsigned int | dst_blob_idx, | ||
struct AILIANetwork * | src_net, | ||
unsigned int | src_blob_idx | ||
) |
Perform copies between blobs that specified.
dst_net | The network object pointer that contains destination blob |
dst_blob_idx | The index of destination blob |
src_net | The network object pointer that contains source blob |
src_blob_idx | The index of source blob |
Perform copy blobs between specified network. It accepts copy over different network. The src_blob_index must be specify blob index that inputs of src_net, and the dst_blob_index mut be specify blob index that outputs of dst_net. If specify index of other blob for dst_blob_idx , this function returns AILIA_STATUS_INVALID_ARGUMENT . This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaCreate | ( | struct AILIANetwork ** | net, |
int | env_id, | ||
int | num_thread | ||
) |
Creates a network instance.
net | A pointer to the network instance pointer |
env_id | The ID of the inference backend used for computation (obtained by ailiaGetEnvironment() ). It is selected automatically if AILIA_ENVIRONMENT_ID_AUTO is specified. |
num_thread | The upper limit on the number of threads (It is set automatically if AILIA_MULTITHREAD_AUTO is specified.) |
Creates a network instance. If the inference backend is set to automatic, CPU mode is used, while if BLAS is available, it uses BLAS. Note that if BLAS is used, num_thread may be ignored.
void AILIA_API ailiaDestroy | ( | struct AILIANetwork * | net | ) |
It destroys the network instance.
net | A network instance pointer |
int AILIA_API ailiaDisableLayerFusion | ( | struct AILIANetwork * | net | ) |
Disalbe layer fusion optimaization for inference.
net | A network instance pointer |
This api use to get blob that remove by layer fusion optimization. Must be specified immediately after ailiaCreate() . It cannot be changed after calling ailiaOpen. Note: When disable layer fusion optimization, inference speed may be down.
int AILIA_API ailiaFinalize | ( | void | ) |
Release GPU and other resources that have been globally allocated with ailia.
It must be called with all ailia instances created by ailiaCreate() released by ailiaDestroy(). Otherwise, #ref AILIA_STATUS_INVALID_STATE will be returned. Call this API from DllMain() on Windows OS, there is possibility of a deadlock.
int AILIA_API ailiaFindBlobIndexByName | ( | struct AILIANetwork * | net, |
unsigned int * | blob_idx, | ||
const char * | name | ||
) |
Searches by name for the index of the internal data (blob) during inference and returns it.
net | A network instance pointer |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
name | The name of the blob to search for |
This API can be call after call ailiaOpenStreamXXX(). In addition, when call this API before call ailiaOpenWeightXXX, can only find inputs and outputs blobs. If you want find intermediate blobs, please call ailiaOpenWeightXXX before.
int AILIA_API ailiaFindBlobNameByIndex | ( | struct AILIANetwork * | net, |
char * | buffer, | ||
const unsigned int | buffer_size, | ||
const unsigned int | blob_idx | ||
) |
Searches by index for the name of the internal data (blob) during inference and returns it.
net | A network instance pointer |
buffer | The output destination buffer for the blob name |
buffer_size | The size of the buffer (including the null terminator) |
blob_idx | The index of the blob to search for |
This API can be call after call ailiaOpenStreamXXX(). In addition, when call this API before call ailiaOpenWeightXXX, can only find inputs and outputs blobs. If you want find intermediate blobs, please call ailiaOpenWeightXXX before.
int AILIA_API ailiaGetBlobCount | ( | struct AILIANetwork * | net, |
unsigned int * | blob_count | ||
) |
Gets the amount of internal data (blob) during inference.
net | A network instance pointer |
blob_count | Storage location of the number of blobs |
This API can be call after call ailiaOpenStreamXXX(). In addition, this api returuns number of sum of inputs and outputs when after call ailiaOpenStreamXXX. And, when call ailiaOpenWeightXXX, enumerate and optimzie intermediate blobs. So, this api may return more count after call ailiaOpenWeightXXX.
int AILIA_API ailiaGetBlobData | ( | struct AILIANetwork * | net, |
void * | dest, | ||
unsigned int | dest_size, | ||
unsigned int | blob_idx | ||
) |
Gets the internal data (blob) during inference.
net | A network instance pointer |
dest | The result is stored in the inference result destination buffer as numeric type data in the order of X, Y, Z, and W. |
dest_size | The number of bytes for the inference result destination buffer |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
If ailiaPredict() or ailiaUpdate() is not run at all, the function returns AILIA_STATUS_INVALID_STATE .
int AILIA_API ailiaGetBlobDataType | ( | struct AILIANetwork * | net, |
int * | type, | ||
unsigned int | blob_idx | ||
) |
Get the type of Blob.
net | A network instance pointer |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
type | The type of blob is stored to it. Values are defined as AILIA_DATATYPE_XXX. |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetBlobDim | ( | struct AILIANetwork * | net, |
unsigned int * | dim, | ||
unsigned int | blob_idx | ||
) |
Gets the dimension of the internal data (blob) during inference.
net | A network instance pointer |
dim | The storage location of the dimension |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetBlobIndexByInputIndex | ( | struct AILIANetwork * | net, |
unsigned int * | blob_idx, | ||
unsigned int | input_blob_idx | ||
) |
Get the blob index of the input data.
net | A network instance pointer |
blob_idx | index of the blob (between 0 and ailiaGetBlobCount() -1) |
input_blob_idx | index among the input blobs (between 0 and ailiaGetInputBlobCount() -1) |
This API can be call after call ailiaOpenStreamXXX(). In addition, we guarantee that input_blob_idx and blob_idx which enumerate when call ailiaOpenStreamXXX are not changed when call ailiaOpneWeightXXX.
int AILIA_API ailiaGetBlobIndexByOutputIndex | ( | struct AILIANetwork * | net, |
unsigned int * | blob_idx, | ||
unsigned int | output_blob_idx | ||
) |
Get the blob index of the input data blob.
net | A network instance pointer |
blob_idx | blob index (between 0 and ailiaGetBlobCount() -1) |
output_blob_idx | index among output blobs (between 0 and ailiaGetOutputBlobCount() -1) |
This API can be call after call ailiaOpenStreamXXX().
int AILIA_API ailiaGetBlobNameLengthByIndex | ( | struct AILIANetwork * | net, |
const unsigned int | blob_idx, | ||
unsigned int * | buffer_size | ||
) |
Gets the size of the buffer needed for output of the name of the internal data (blob).
net | A network instance pointer |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
buffer_size | The size of the buffer needed for output of the blob name (including the null terminator) |
This API can be call after call ailiaOpenStreamXXX(). In addition, when call this API before call ailiaOpenWeightXXX, can only find inputs and outputs blobs. If you want find intermediate blobs, please call ailiaOpenWeightXXX before.
int AILIA_API ailiaGetBlobShape | ( | struct AILIANetwork * | net, |
AILIAShape * | shape, | ||
unsigned int | blob_idx, | ||
unsigned int | version | ||
) |
Gets the shape of the internal data (blob) during inference.
net | A network instance pointer |
shape | Storage location of the data shape information |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
version | AILIA_SHAPE_VERSION |
When dimension of shape is 5 or more, please use ailiaGetBlobDim() and ailiaGetBlobShapeND(). This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetBlobShapeND | ( | struct AILIANetwork * | net, |
unsigned int * | shape, | ||
unsigned int | dim, | ||
unsigned int | blob_idx | ||
) |
Gets the amount of internal data (blob) during inference.
net | A network instance pointer |
shape | The storage location of the shape array. (It stores dim-1, dim-2, ... ,1, 0 order.) |
dim | The size of shape |
blob_idx | The index of the blob (0 to ailiaGetBlobCount() -1) |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetEnvironment | ( | AILIAEnvironment ** | env, |
unsigned int | env_idx, | ||
unsigned int | version | ||
) |
Gets the list of computational environments.
env | The storage location of the computational environment information (Valid until the library is released) |
env_idx | The index of the computational environment information (0 to ailiaGetEnvironmentCount() -1) |
version | AILIA_ENVIRONMENT_VERSION |
int AILIA_API ailiaGetEnvironmentCount | ( | unsigned int * | env_count | ) |
Gets the number of available computational environments (CPU, GPU).
env_count | The storage location of the number of computational environment information |
const char* AILIA_API ailiaGetErrorDetail | ( | struct AILIANetwork * | net | ) |
Returns the details of errors.
net | The network instance pointer |
The return value does not have to be released. The string is valid until the next ailia API function is called. If model is encrypted, this function returns empty string.
int AILIA_API ailiaGetInputBlobCount | ( | struct AILIANetwork * | net, |
unsigned int * | input_blob_count | ||
) |
Get the number of input data blobs.
net | A network instance pointer |
input_blob_count | Storage location of the number of input blobs |
This API can be call after call ailiaOpenStreamXXX(). In addition, this api returuns number of inputs when after call ailiaOpenStreamXXX. And, when call ailiaOpenWeightXXX, enumerate and optimzie initializer with input blobs. So, this api may return more count after call ailiaOpenWeightXXX.
int AILIA_API ailiaGetInputDim | ( | struct AILIANetwork * | net, |
unsigned int * | dim | ||
) |
Gets the dimension of the input data during inference.
net | A network instance pointer |
dim | The storage location of the dimension |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetInputShape | ( | struct AILIANetwork * | net, |
AILIAShape * | shape, | ||
unsigned int | version | ||
) |
Gets the shape of the input data during inference.
net | A network instance pointer |
shape | Shape information for the input data |
version | AILIA_SHAPE_VERSION |
When dimension of shape is 5 or more, please use ailiaGetInputDim() and ailiaGetInputShapeND(). When shape is not settled, this function stores 0 at unsettled dimension and otherwise stores valid value. This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetInputShapeND | ( | struct AILIANetwork * | net, |
unsigned int * | shape, | ||
unsigned int | dim | ||
) |
Gets the shape of the input data during inference.
net | A network instance pointer |
shape | The storage location of the shape array. (It stores dim-1, dim-2, ... ,1, 0 order.) |
dim | The size of shape |
When shape is not settled, this function stores 0 at unsettled dimension and otherwise stores valid value. This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetOutputBlobCount | ( | struct AILIANetwork * | net, |
unsigned int * | output_blob_count | ||
) |
Get the number of output data blobs.
net | A network instance pointer |
output_blob_count | Storage location for the number of output blobs. |
This API can be call after call ailiaOpenStreamXXX().
int AILIA_API ailiaGetOutputDim | ( | struct AILIANetwork * | net, |
unsigned int * | dim | ||
) |
Gets the dimension of the output data during inference.
net | A network instance pointer |
dim | The storage location of the dimension |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetOutputShape | ( | struct AILIANetwork * | net, |
AILIAShape * | shape, | ||
unsigned int | version | ||
) |
Gets the shape of the output data during inference.
net | A network instance pointer |
shape | Shape information of the output data |
version | AILIA_SHAPE_VERSION |
When dimension of shape is 5 or more, please use ailiaGetOutputDim() () and ailiaGetOutputShapeND(). This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetOutputShapeND | ( | struct AILIANetwork * | net, |
unsigned int * | shape, | ||
unsigned int | dim | ||
) |
Gets the shape of the output data during inference.
net | A network instance pointer |
shape | The storage location of the shape array. (It stores dim-1, dim-2, ... ,1, 0 order.) |
dim | The size of shape |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaGetSelectedEnvironment | ( | struct AILIANetwork * | net, |
AILIAEnvironment ** | env, | ||
unsigned int | version | ||
) |
Gets the selected computational environment.
net | A network instance pointer |
env | The storage location of the computational environment information (Valid until the library is released) |
version | AILIA_ENVIRONMENT_VERSION |
const char* AILIA_API ailiaGetStatusString | ( | int | status_code | ) |
Returns the string describing given status code.
status_code | Status code |
The return value does not have to be released. If an instance of AILIANetwork is exist, ailiaGetErrorDetail() can be used to get the detail of the error.
int AILIA_API ailiaGetSummaryLength | ( | struct AILIANetwork * | net, |
unsigned int * | buffer_size | ||
) |
Gets the size of the buffer needed for the network summary.
net | A network instance pointer |
buffer_size | The storage location of the buffer size (including the null terminator) |
This API can be call after call ailiaOpenWeighXXX().
const char* AILIA_API ailiaGetVersion | ( | void | ) |
Get the version of the library.
The return value does not have to be released.
int AILIA_API ailiaOpenStreamEx | ( | struct AILIANetwork * | net, |
const void * | fopen_args, | ||
ailiaFileCallback | callback, | ||
int | version | ||
) |
Initializes the network instance. (User-defined file access callback)
net | A network instance pointer |
fopen_args | An argument pointer supplied by AILIA_USER_API_FOPEN |
callback | A struct for the user-defined file access callback function |
version | The version of the struct for the file access callback function ( AILIA_FILE_CALLBACK_VERSION ) |
This function reads the network instance from a file and initializes it.
int AILIA_API ailiaOpenStreamFileA | ( | struct AILIANetwork * | net, |
const char * | path | ||
) |
Initializes the network instance. (Read from file)
net | A network instance pointer |
path | The path name to the prototxt file (MBSC or UTF16) |
This function reads the network instance from a file and initializes it.
int AILIA_API ailiaOpenStreamFileW | ( | struct AILIANetwork * | net, |
const wchar_t * | path | ||
) |
int AILIA_API ailiaOpenStreamMem | ( | struct AILIANetwork * | net, |
const void * | buf, | ||
unsigned int | buf_size | ||
) |
Initializes the network instance. (Read from memory)
net | A network instance pointer |
buf | A pointer to the data in the prototxt file |
buf_size | The data size of the prototxt file |
This function reads the network instance from memory and initializes it.
int AILIA_API ailiaOpenWeightEx | ( | struct AILIANetwork * | net, |
const void * | fopen_args, | ||
ailiaFileCallback | callback, | ||
int | version | ||
) |
Reads weights into a network instance. (User-defined file access callback)
net | A network instance pointer |
fopen_args | An argument pointer supplied by AILIA_USER_API_FOPEN |
callback | A struct for the user-defined file access callback function |
version | The version of the struct for the file access callback function ( AILIA_FILE_CALLBACK_VERSION ) |
This function reads weights into the network instance from a file.
int AILIA_API ailiaOpenWeightFileA | ( | struct AILIANetwork * | net, |
const char * | path | ||
) |
Reads weights into a network instance. (Read from file)
net | A network instance pointer |
path | The path name to the protobuf/onnx file (MBSC or UTF16) |
This function reads weights into the network instance from a file.
int AILIA_API ailiaOpenWeightFileW | ( | struct AILIANetwork * | net, |
const wchar_t * | path | ||
) |
int AILIA_API ailiaOpenWeightMem | ( | struct AILIANetwork * | net, |
const void * | buf, | ||
unsigned int | buf_size | ||
) |
Reads weights into a network instance. (Read from memory)
net | A network instance pointer |
buf | A pointer to the data in the protobuf/onnx file |
buf_size | The data size of the protobuf/onnx file |
This function reads weights into the network instance from memory.
int AILIA_API ailiaPredict | ( | struct AILIANetwork * | net, |
void * | dest, | ||
unsigned int | dest_size, | ||
const void * | src, | ||
unsigned int | src_size | ||
) |
Performs the inferences and provides the inference result.
net | A network instance pointer |
dest | The result is stored in the inference result destination buffer as numeric type data in the order of X, Y, Z, and W. The buffer has the same size as the network file outputSize. |
dest_size | The number of bytes for the destination buffer for the inference result |
src | The input is stored as numeric type data in the order of the inference data X, Y, Z, and W. The input has the same size as the network file inputSize. |
src_size | The number of bytes of the inference data |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaSetInputBlobData | ( | struct AILIANetwork * | net, |
const void * | src, | ||
unsigned int | src_size, | ||
unsigned int | blob_idx | ||
) |
Provides the specified blob with the input data.
net | A network instance pointer |
src | The inference data is stored as numeric type data in the order of X, Y, Z, and W. |
src_size | The number of bytes of the inference data |
blob_idx | The index of the blob for input |
This function is used to specify the input on networks with multiple inputs. If something other than a blob in the input layer is specified for blob_idx, the function returns AILIA_STATUS_INVALID_ARGUMENT . This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaSetInputBlobShape | ( | struct AILIANetwork * | net, |
const AILIAShape * | shape, | ||
unsigned int | blob_idx, | ||
unsigned int | version | ||
) |
Change the shape of the blob given by its index.
net | network object pointer |
shape | new shape of the blob |
blob_idx | index referencing the blob to reshape |
version | AILIA_SHAPE_VERSION |
This is useful to change the network input shape in a context where there are several input blobs. If blob_idx does not correspond to an input layer, AILIA_STATUS_INVALID_ARGUMENT is returned. For other related remarks, see the documentation of ailiaSetInputShape(). If dimension of shape has 5 or more, please use ailiaSetInputBlobShapeND(). This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaSetInputBlobShapeND | ( | struct AILIANetwork * | net, |
const unsigned * | shape, | ||
const unsigned | dim, | ||
unsigned int | blob_idx | ||
) |
Change the shape of the blob given by its index.
net | network object pointer |
shape | An array of shape that contains size of each axis (dim-1, dim-2, ... ,1, 0) |
dim | The size of shape. |
blob_idx | index referencing the blob to reshape |
This is useful to change the network input shape in a context where there are several input blobs. If blob_idx does not correspond to an input layer, AILIA_STATUS_INVALID_ARGUMENT is returned. For other related remarks, see the documentation of ailiaSetInputShapeND(). This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaSetInputShape | ( | struct AILIANetwork * | net, |
const AILIAShape * | shape, | ||
unsigned int | version | ||
) |
Changes the shape of the input data during inference.
net | A network instance pointer |
shape | Shape information for the input data |
version | AILIA_SHAPE_VERSION |
This function changes the input shape defined in prototxt. The shape must have the same rank as the one contained in prototxt. Note that an error may be returned if the weights are dependent on the input shapes, among other reasons. The dimension of shape that defined in prototxt is less than 4, the unused element must be set to 1. The dimension of shape that defined in prototxt has 5 or more, please use ailiaSetInputShapeND(). This API can be call after call ailiaOpenWeighXXX()
int AILIA_API ailiaSetInputShapeND | ( | struct AILIANetwork * | net, |
const unsigned int * | shape, | ||
unsigned int | dim | ||
) |
Changes the shape of the input data during inference.
net | A network instance pointer |
shape | An array of shape that contains size of each axis (dim-1, dim-2, ... ,1, 0) |
dim | The size of shape. |
This function changes the input shape defined in prototxt. The shape must have the same rank as the one contained in prototxt. Note that an error may be returned if the weights are dependent on the input shapes, among other reasons. This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaSetMemoryMode | ( | struct AILIANetwork * | net, |
unsigned int | mode | ||
) |
Set the memory usage policy for inference.
net | A network instance pointer |
mode | Memory mode (Multiple specifications possible with logical sum) AILIA_MEMORY_XXX (Default : AILIA_MEMORY_REDUCE_CONSTANT ) |
Change the memory usage policy. If a value other than AILIA_MEMORY_NO_OPTIMIZATION is specified, the intermediate buffer secured during inference will be released, so the memory usage during inference can be reduced. Must be specified immediately after ailiaCreate() . It cannot be changed after calling ailiaOpen. If you specify to release the intermediate buffer, calling ailiaGetBlobData() for the corresponding blob will return an AILIA_STATUS_DATA_HIDDEN error.
int AILIA_API ailiaSetProfileMode | ( | struct AILIANetwork * | net, |
unsigned int | mode | ||
) |
Set the profile mode.
net | The network instance pointer |
mode | Profile mode AILIA_PROFILE_XXX (Default : AILIA_PROFILE_DISABLE ) |
Set the profile mode. The default is profile disabled. Call it after calling ailiaOpenStreamXXX. When profile mode is enabled, you can get profile result via ailiaSummary() .
int AILIA_API ailiaSetTemporaryCachePathA | ( | const char * | cache_dir | ) |
Specifies a temporary cache directory.
cache_dir | Temporary cache directory |
This system uses the specified cache directory to generate and store machine code optimized for each inference backend. Call only once at the start of execution of ailia. It ignores any second and subsequent calls, and automatically returns success. There is no particular problem if it is called from multiple threads, as it provides exclusive control internally. Some functions, such as Vulkan shader cache, cannot be used until this API function is called. Specify the file path obtained by Context.getCacheDir() for cache_dir.
int AILIA_API ailiaSetTemporaryCachePathW | ( | const wchar_t * | cache_dir | ) |
int AILIA_API ailiaSummary | ( | struct AILIANetwork * | net, |
char *const | buffer, | ||
const unsigned int | buffer_size | ||
) |
Shows the name and shape of each blob.
net | A network instance pointer |
buffer | The output destination of the summary |
buffer_size | The size of the output buffer (including the null terminator). Set the value obtained by ailiaGetSummaryLength() . |
This API can be call after call ailiaOpenWeighXXX().
int AILIA_API ailiaUpdate | ( | struct AILIANetwork * | net | ) |
Makes inferences with the input data specified in advance.
net | A network instance pointer |
This function is used when, for example, the input is provided with ailiaSetInputBlobData() . Get the inference result with ailiaGetBlobData() . This API can be call after call ailiaOpenWeighXXX().