C API¶
rbln_get_layout_nbytes¶
Retrieves the number of bytes occupied for RBLNTensorLayout
uint64_t rbln_get_layout_nbytes(const RBLNTensorLayout * layout)
This function returns the total number of bytes occupied by the given tensor layout.
parameters:
Name | Description |
---|---|
layout |
[in] Pointer to the RBLNTensorLayout |
return: The number of bytes used by the tensor layout.
Usages in examples: #L15, #L35, #L117
rbln_create_model¶
Creates an RBLN compiled model instance from a RBLN compiled model file.
RBLNModel * rbln_create_model(const char * path)
This function loads a compiled RBLN model from the specified file path and creates an RBLN model instance.
parameters:
Name | Description |
---|---|
path |
[in] Path to the RBLN model file (*.rbln). |
return: Pointer to the created RBLN model, or NULL if loading fails. *
Usages in examples: #L50, #L101
rbln_destroy_model¶
Destroys the specified RBLN model handle.
void rbln_destroy_model(RBLNModel * handle)
This function releases the resources associated with the given RBLN model handle.
parameters:
Name | Description |
---|---|
handle |
[in] Handle to the RBLN model to be destroyed. |
Usages in examples: #L89, #L132
rbln_create_runtime¶
Creates an RBLN synchronous runtime from a compiled RBLN model.
RBLNRuntime * rbln_create_runtime(
RBLNModel * model,
const char * name,
int device_id,
)
This function initializes and creates an RBLN synchronous runtime using the specified compiled model, module name, and device ID.
parameters:
Name | Description |
---|---|
model |
[in] Handle to the compiled RBLN model. |
name |
[in] Name of the module. |
device_id |
[in] Device number to be used for the runtime. |
return: Pointer to the created RBLN Runtime, or NULL if creation fails.
Usage in examples: #L53
rbln_create_async_runtime¶
Creates an RBLN asynchronous runtime from a compiled RBLN model.
RBLNRuntime * rbln_create_async_runtime(
RBLNModel * model,
const char * name,
int device_id,
)
This function initializes and creates an RBLN asynchronous runtime using the specified compiled model, module name, and device ID.
parameters:
Name | Description |
---|---|
model |
[in] Handle to the compiled RBLN model. |
name |
[in] Name of the module. |
device_id |
[in] Device number to be used for the runtime. |
return: Pointer to the created RBLN asynchronous runtime, or NULL if creation fails.
Usage in examples: #L104
rbln_destroy_runtime¶
Destroys the specified RBLN Runtime handle.
void rbln_destroy_runtime(RBLNRuntime * rt)
This function releases the resources associated with the given RBLN Runtime handle.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime to be destroyed. |
Usages in examples: #L86, #L129
rbln_get_num_inputs¶
Retrieves the number of input buffers for the specified RBLN Runtime.
uint32_t rbln_get_num_inputs(RBLNRuntime * rt)
This function returns the total number of input buffers required by the given RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
return: The number of input buffers.
Usage in examples: #L56
rbln_get_num_outputs¶
Retrieves the number of output buffers for the specified RBLN Runtime.
uint32_t rbln_get_num_outputs(RBLNRuntime * rt)
This function returns the total number of output buffers required by the given RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
return: The number of output buffers.
Usages in examples: #L73, #L107
rbln_get_input_layout¶
Retrieves the layout information of the specified input buffer.
const RBLNTensorLayout * rbln_get_input_layout(
RBLNRuntime * rt,
uint64_t idx,
)
This function returns the tensor layout of the input buffer at the given index for the specified RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
idx |
[in] Index of the input buffer. |
return: Pointer to the tensor layout of the input buffer.
Usages in examples: #L13, #L115
rbln_get_output_layout¶
Retrieves the layout of the specified output buffer.
const RBLNTensorLayout * rbln_get_output_layout(
RBLNRuntime * rt,
uint64_t idx,
)
This function returns the tensor layout of the output buffer at the given index for the specified RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
idx |
[in] Index of the output buffer. |
return: Pointer to the tensor layout of the output buffer.
Usage in examples: #L35
rbln_set_input¶
Assigns input data to the specified input buffer.
RBLNRetCode rbln_set_input(
RBLNRuntime * rt,
uint64_t idx,
const void * data,
)
This function sets the input data for the input buffer at the given index for the specified RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
idx |
[in] Index of the input buffer. |
data |
[in] Pointer to the input data. |
return: 0 on success, or an error code on failure.
Usage in examples: #L60
rbln_set_input_by_name¶
Assigns input data to the specified input buffer by name.
RBLNRetCode rbln_set_input_by_name(
RBLNRuntime * rt,
const char * name,
const void * data,
)
This function sets the input data for the input buffer with the specified name for the RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
name |
[in] Name of the input buffer. |
data |
[in] Pointer to the input data. |
return: 0 on success, or an error code on failure.
Usage in examples: #L28
rbln_get_input_name¶
Get the name to the specified input buffer by index.
const char * rbln_get_input_name(
RBLNRuntime * rt,
uint64_t idx,
)
This function gets the name for the input buffer with the specified index for the RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Handle to the RBLN Runtime. |
idx |
[in] Index of the input buffer. |
return: name to the input buffer at the specified index
Usage in examples: #L25
rbln_run¶
Triggers a synchronous inference for the RBLN Runtime.
RBLNRetCode rbln_run(RBLNRuntime * rt)
This function starts the inference process for the specified RBLN Runtime instance.
parameters:
Name | Description |
---|---|
rt |
[in] Pointer to the RBLN Runtime. |
return: 0 on success, or an error code on failure.
Usage in examples: #L70
rbln_async_run¶
Triggers An asynchronous inference for the RBLN Runtime.
int rbln_async_run(
RBLNRuntime * rt,
const void * inputs,
const void * outputs,
)
This function starts the asynchronous inference process for the specified RBLN Runtime instance, using the provided input and output buffers.
parameters:
Name | Description |
---|---|
rt |
[in] Pointer to the RBLN Runtime. |
inputs |
[in] Pointer to the input buffers. |
outputs |
[in] Pointer to the output buffers. |
return: The request index on success, or an error code on failure.
Usage in examples: #L122
rbln_async_wait¶
Waits for the completion of an asynchronous inference request in the RBLN Runtime.
RBLNRetCode rbln_async_wait(
RBLNRuntime * rt,
int rid,
int timeout,
)
This function blocks until the specified asynchronous inference request is complete or the specified timeout period elapses.
parameters:
Name | Description |
---|---|
rt |
[in] Pointer to the RBLN Runtime instance. |
rid |
[in] Index of the request to wait for. |
timeout |
[in] Maximum time to wait for the request to complete, in milliseconds. |
return: Retrieves 0 on success, or an error code on failure.
Usage in examples: #L126
rbln_get_input¶
Retrieves a pointer to the specified input buffer.
void * rbln_get_input(
RBLNRuntime * rt,
uint64_t idx,
)
This function returns a pointer to the input buffer at the given index
parameters:
Name | Description |
---|---|
rt |
[in] Pointer to the RBLN Runtime instance. |
idx |
[in] Index of the input buffer. |
return: Pointer to the input buffer at the specified index, or NULL if the index is invalid.
Usage in examples: #L10
rbln_get_output¶
Retrieves a pointer to the specified output buffer.
void * rbln_get_output(
RBLNRuntime * rt,
uint64_t idx,
)
This function returns a pointer to the output buffer at the given index.
parameters:
Name | Description |
---|---|
rt |
[in] Pointer to the RBLN Runtime instance. |
idx |
[in] Index of the output buffer. |
return: Pointer to the output buffer at the specified index, or NULL if the index is invalid.
Usages in examples: #L38, #L77
RBLNModel¶
struct RBLNModel
typedef struct RBLNModel RBLNModel
RBLNRuntime¶
struct RBLNRuntime
typedef struct RBLNRuntime RBLNRuntime
RBLNTensorLayout¶
Type | Name | Description |
---|---|---|
RBLNDType | dtype | Data type. |
size_t | elemsize | byte per elements |
int | ndim | Number of dimension. |
int32_t[256] | shape | Shape of tensor. |
char[256] | name | Name of the tensor (optional) |
enum RBLNRetCode¶
values |
---|
RBLNRetCode_SUCCESS = 0 |
RBLNRetCode_FAILURE |
RBLNRetCode_INVALID |
enum RBLNDType¶
values |
---|
NONE = -1 |
INT8 = 0 |
FLOAT16 |
FLOAT32 |
INT16 |
INT32 |
INT64 |
DTYPE_MAX |
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|