-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCacheDataHandler.hpp
68 lines (47 loc) · 1.36 KB
/
CacheDataHandler.hpp
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
63
64
65
66
67
68
//
// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <HalInterfaces.h>
#include <vector>
#include <unordered_map>
#include <NeuralNetworks.h>
namespace armnn_driver
{
using HidlToken = android::hardware::hidl_array<uint8_t, ANEURALNETWORKS_BYTE_SIZE_OF_CACHE_TOKEN>;
class CacheHandle
{
public:
CacheHandle(const HidlToken token, const size_t cacheSize)
: m_HidlToken(token), m_CacheSize(cacheSize) {}
~CacheHandle() {};
HidlToken GetToken() const
{
return m_HidlToken;
}
size_t GetCacheSize() const
{
return m_CacheSize;
}
private:
const HidlToken m_HidlToken;
const size_t m_CacheSize;
};
class CacheDataHandler
{
public:
CacheDataHandler() {}
~CacheDataHandler() {}
void Register(const HidlToken token, const size_t hashValue, const size_t cacheSize);
bool Validate(const HidlToken token, const size_t hashValue, const size_t cacheSize) const;
size_t Hash(std::vector<uint8_t>& cacheData);
size_t GetCacheSize(HidlToken token);
void Clear();
private:
CacheDataHandler(const CacheDataHandler&) = delete;
CacheDataHandler& operator=(const CacheDataHandler&) = delete;
std::unordered_map<size_t, CacheHandle> m_CacheDataMap;
};
CacheDataHandler& CacheDataHandlerInstance();
} // armnn_driver