aboutsummaryrefslogtreecommitdiff
path: root/delegate/opaque/src/armnn_external_delegate.cpp
blob: aa1f3355ab7ce43937f63cf3c681e303c974deaa (plain)
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
//
// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include <armnn_delegate.hpp>

namespace {

    TfLiteOpaqueDelegate* ArmNNDelegateCreateFunc(const void* tflite_settings)
    {
        armnnDelegate::DelegateOptions opt = armnnOpaqueDelegate::ParseArmNNSettings(
                static_cast<const tflite::TFLiteSettings*>(tflite_settings));

        auto delegate = armnnOpaqueDelegate::TfLiteArmnnOpaqueDelegateCreate(opt);
        return delegate;
    }

    void ArmNNDelegateDestroyFunc(TfLiteOpaqueDelegate* armnnDelegate)
    {
        armnnOpaqueDelegate::TfLiteArmnnOpaqueDelegateDelete(
                armnnDelegate);
    }

    int ArmNNDelegateErrnoFunc(TfLiteOpaqueDelegate* sample_stable_delegate)
    {
        return 0;
    }

    const TfLiteOpaqueDelegatePlugin armnn_delegate_plugin = {
            ArmNNDelegateCreateFunc, ArmNNDelegateDestroyFunc,
            ArmNNDelegateErrnoFunc};

    const TfLiteStableDelegate armnn_delegate = {
            /*delegate_abi_version=*/ TFL_STABLE_DELEGATE_ABI_VERSION,
            /*delegate_name=*/        "armnn_delegate",
            /*delegate_version=*/     OPAQUE_DELEGATE_VERSION,
            /*delegate_plugin=*/      &armnn_delegate_plugin
    };

}  // namespace

/**
 * The ArmNN delegate to be loaded dynamically
 */
extern "C" const TfLiteStableDelegate TFL_TheStableDelegate = armnn_delegate;