Main Interface Functions

Create Default Parameter

xlm_common_params_t xlm_create_default_param();

Create default model general parameters

  • Return Value

    • Construct the xlm_common_params_t structure data with default parameter.

Initialize the Instance

int xlm_init(xlm_common_params_t *param, xlm_callback_t callback, void **llm_handle);

Initialize the instance.

  • Parameters

    • [in]: param, general parameters of the model generated during initialization.

    • [in]: callback, the callback function pointer for registering a task, i.e., the execution entity of the task.

    • [out]: llm_handle, the inference handle, which is used for the management of subsequent tasks.

  • Return Value

    • 0 (Initialization successful), -1 (Initialization failed).

Audio Input

int xlm_feed_audio_online(xlm_handle_t handle, xlm_online_audio_t audio_input);

Provides audio input to the model.

  • Parameters

    • [in]:handle, inference handle obtained via the xlm_init interface.
    • [in]:audio_input, audio input, containing the pointer to the data and its length.
  • Return Value

    • 0 (Audio data transmitted successful), -1 (Data transmission failed; the task is terminated).

Synchronous Inference

int xlm_infer(xlm_handle_t handle, xlm_input_t *input, void *userdata);

Synchronous inference, starting the inference includes a complete prefill and decode process.

  • Parameters

    • [in]: handle, the inference handle obtained through the xlm_init interface.

    • [in]: input, the model inference input, including data such as prompt, image, and task priority.

    • [in]: userdata, user-defined data, which is returned through the callback function along with the inference result.

  • Return Value

    • 0 (Inference task executed successfully), -1 (Failed to obtain the inference handle, task returned).

Asynchronous Inference

int xlm_infer_async(xlm_handle_t handle, xlm_input_t *input, void *userdata);

Asynchronous inference, starting the inference includes a complete prefill and decode process.

  • Parameters

    • [in]: handle, the inference handle obtained through the xlm_init interface.

    • [in]: input, the model inference input, including data such as prompt, image, and task priority.

    • [in]: userdata, user-defined data, which is returned through the callback function along with the inference result.

  • Return Value

    • 0 (Inference task executed successfully), -1 (Failed to obtain the inference handle, task returned).

Destroy the Instance

int xlm_destroy(xlm_handle_t *handle);

Release the inference instance resources.

  • Parameters

    • [in]: handle, the inference handle obtained through the xlm_init interface.
  • Return Value

    • 0 (Task destroyed successfully), -1 (Failed to obtain the inference handle, interface returned).