# Prepare a model with a chosen delegate

Source: [https://docs.qualcomm.com/doc/80-70014-54/topic/prepare-a-model-with-a-chosen-delegate.html](https://docs.qualcomm.com/doc/80-70014-54/topic/prepare-a-model-with-a-chosen-delegate.html)

After creating an interpreter and allocating the necessary memory to run the model,
        prepare the model with a chosen delegate. This step creates an execution graph from the
        model loaded before and uses the underlying library to perform inference on the delegate
        hardware.

The following example code creates the XNNPACK delegate for running a TensorFlow Lite
            model on the Arm CPU. The delegate is created by calling the
                `TfLiteXNNPackDelegateCreate(…)` API. You can also customize the
            delegate with the Delegate Options API.

    TfLiteDelegate *delegate = NULL;
    TfLiteXNNPackDelegateOptions xnnpack_options =
    TfLiteXNNPackDelegateOptionsDefault();
    xnnpack_options.num_threads = num_threads;
      
    TfLiteDelegate* xnnpack_delegate =
    TfLiteXNNPackDelegateCreate(&xnnpack_options);
    if (interpreter->ModifyGraphWithDelegate(xnnpack_delegate) != kTfLiteOk) {
      // Report error and fall back to another delegate, or the default backend
    }
    Copy to clipboard

**Parent Topic:** [Run inference](https://docs.qualcomm.com/doc/80-70014-54/topic/run-inference.html)

Last Published: Jul 12, 2024

[Previous Topic
Create a TensorFlow Lite interpreter](https://docs.qualcomm.com/bundle/publicresource/80-70014-54/topics/create-a-tensorflow-lite-interpreter.md) [Next Topic
Prepare input/output buffers](https://docs.qualcomm.com/bundle/publicresource/80-70014-54/topics/prepare-input-output-buffers.md)