aboutsummaryrefslogtreecommitdiff
path: root/ArmnnDriverImpl.hpp
blob: c06009773aff5c027011430eae592018328358be (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//

#pragma once

#include <HalInterfaces.h>

#include "DriverOptions.hpp"

#include <armnn/ArmNN.hpp>

namespace armnn_driver
{

struct HalVersion_1_0
{
    using Model = ::android::hardware::neuralnetworks::V1_0::Model;
    using Capabilities = ::android::hardware::neuralnetworks::V1_0::Capabilities;
    using getCapabilities_cb = ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb;
    using getSupportedOperations_cb = ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb;
};

#if defined(ARMNN_ANDROID_NN_V1_1)
struct HalVersion_1_1
{
    using Model = ::android::hardware::neuralnetworks::V1_1::Model;
    using Capabilities = ::android::hardware::neuralnetworks::V1_1::Capabilities;
    using getCapabilities_cb = ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb;
    using getSupportedOperations_cb = ::android::hardware::neuralnetworks::V1_1::IDevice::getSupportedOperations_1_1_cb;
};
#endif

template <typename HalVersion>
class ArmnnDriverImpl
{
public:
    using HalModel = typename HalVersion::Model;
    using HalCapabilities = typename HalVersion::Capabilities;
    using HalGetCapabilities_cb = typename HalVersion::getCapabilities_cb;
    using HalGetSupportedOperations_cb = typename HalVersion::getSupportedOperations_cb;

    static Return<void> getCapabilities(
            const armnn::IRuntimePtr& runtime,
            HalGetCapabilities_cb cb);
    static Return<void> getSupportedOperations(
            const armnn::IRuntimePtr& runtime,
            const DriverOptions& options,
            const HalModel& model,
            HalGetSupportedOperations_cb);
    static Return<ErrorStatus> prepareModel(
            const armnn::IRuntimePtr& runtime,
            const armnn::IGpuAccTunedParametersPtr& clTunedParameters,
            const DriverOptions& options,
            const HalModel& model,
            const android::sp<IPreparedModelCallback>& cb,
            bool float32ToFloat16 = false);
    static Return<DeviceStatus> getStatus();
};

} // namespace armnn_driver