aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl/ClRegistryInitializer.cpp
blob: aadc14bd68083bc27763ed24ea0b54556bbea81a (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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "ClBackend.hpp"

#include <armnn/BackendRegistry.hpp>

namespace
{

using namespace armnn;

static BackendRegistry::StaticRegistryInitializer g_RegisterHelper
{
    BackendRegistryInstance(),
    ClBackend::GetIdStatic(),
    []()
    {
        // Check if we have a CustomMemoryAllocator associated with the backend
        // and if so register it with the backend.
        auto customAllocators = BackendRegistryInstance().GetAllocators();
        auto allocatorIterator = customAllocators.find(ClBackend::GetIdStatic());
        if (allocatorIterator != customAllocators.end())
        {
            return IBackendInternalUniquePtr(new ClBackend(allocatorIterator->second));
        }
        return IBackendInternalUniquePtr(new ClBackend);
    }
};

} // Anonymous namespace