24.02.1
LUTManager.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024 Arm Limited.
3
*
4
* SPDX-License-Identifier: MIT
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in all
14
* copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
25
#ifndef ACL_SRC_CORE_HELPERS_LUTMANAGER_H
26
#define ACL_SRC_CORE_HELPERS_LUTMANAGER_H
27
28
#include "
arm_compute/core/CoreTypes.h
"
29
#include "
arm_compute/core/QuantizationInfo.h
"
30
#include "
arm_compute/function_info/ActivationLayerInfo.h
"
31
32
#include <map>
33
#include <memory>
34
35
namespace
arm_compute
36
{
37
38
struct
LUTInfo
39
{
40
ActivationLayerInfo::ActivationFunction
act
;
41
DataType
dt
;
42
QuantizationInfo
qinfo
;
43
// Operators enable use of map with Lutinfo as key
44
friend
bool
operator<
(
const
LUTInfo
&l,
const
LUTInfo
&r)
45
{
46
return
(l.
act
< r.
act
) || ((l.
act
== r.
act
) && (l.
dt
< r.
dt
)) ||
47
((l.
act
== r.
act
) && (l.
dt
== r.
dt
) && (l.
qinfo
.
scale
() < r.
qinfo
.
scale
())) ||
48
((l.
act
== r.
act
) && (l.
dt
== r.
dt
) && (l.
qinfo
.
scale
() == r.
qinfo
.
scale
()) &&
49
(l.
qinfo
.
offset
() < l.
qinfo
.
offset
()));
50
}
51
bool
operator==
(
const
LUTInfo
&l)
52
{
53
return
this->act == l.
act
&& this->dt == l.
dt
&& this->qinfo == l.
qinfo
;
54
}
55
};
56
57
/* Class to handle getting look up table */
58
class
LUTManager
59
{
60
public
:
61
LUTManager
() =
default
;
62
63
static
LUTManager
&
get_instance
();
64
#ifdef __aarch64__
65
std::shared_ptr<ActivationLayerInfo::LookupTable65536> get_lut_table(
LUTInfo
info
);
66
67
private
:
68
std::map<LUTInfo, std::weak_ptr<ActivationLayerInfo::LookupTable65536>> map_fp16{};
69
#endif // __aarch64__
70
};
71
72
}
// namespace arm_compute
73
#endif // ACL_SRC_CORE_HELPERS_LUTMANAGER_H
arm_compute::LUTInfo
Definition:
LUTManager.h:38
arm_compute::LUTManager::get_instance
static LUTManager & get_instance()
Definition:
LUTManager.cpp:73
arm_compute::QuantizationInfo
Quantization information.
Definition:
QuantizationInfo.h:67
arm_compute::LUTInfo::qinfo
QuantizationInfo qinfo
Definition:
LUTManager.h:42
ActivationLayerInfo.h
arm_compute::LUTManager::LUTManager
LUTManager()=default
arm_compute::LUTInfo::dt
DataType dt
Definition:
LUTManager.h:41
arm_compute::LUTInfo::act
ActivationLayerInfo::ActivationFunction act
Definition:
LUTManager.h:40
arm_compute::LUTInfo::operator<
friend bool operator<(const LUTInfo &l, const LUTInfo &r)
Definition:
LUTManager.h:44
arm_compute::LUTManager
Definition:
LUTManager.h:58
arm_compute::ActivationFunction
ActivationFunction
Available activation functions.
Definition:
ActivationLayerInfo.h:41
arm_compute::QuantizationInfo::scale
const std::vector< float > & scale() const
Scale vector accessor.
Definition:
QuantizationInfo.h:116
CoreTypes.h
arm_compute
Copyright (c) 2017-2024 Arm Limited.
Definition:
introduction.dox:24
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
arm_compute::DataType
DataType
Available data types.
Definition:
CoreTypes.h:83
QuantizationInfo.h
arm_compute::QuantizationInfo::offset
const std::vector< int32_t > & offset() const
Offset vector accessor.
Definition:
QuantizationInfo.h:124
arm_compute::LUTInfo::operator==
bool operator==(const LUTInfo &l)
Definition:
LUTManager.h:51
src
core
helpers
LUTManager.h
Generated on Mon Mar 18 2024 11:31:57 for Compute Library by
1.8.17