blob: e909767a7b841777b9665b3afa2e2eae1df72ce4 [file] [log] [blame]
Georgios Pinitas8a5146f2021-01-12 15:51:07 +00001/*
2 * Copyright (c) 2021 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#ifndef SRC_CPU_CPUCONTEXT_H
25#define SRC_CPU_CPUCONTEXT_H
26
27#include "src/common/AllocatorWrapper.h"
28#include "src/common/IContext.h"
29
30namespace arm_compute
31{
32namespace cpu
33{
34/** Structure that encodes the CPU capabilities to be used */
35struct CpuCapabilities
36{
37 bool neon{ false };
38 bool sve{ false };
39 bool sve2{ false };
40
41 bool fp16{ false };
42 bool bf16{ false };
43 bool dot{ false };
44 bool mmla_int8{ false };
45 bool mmla_fp{ false };
46
47 int32_t max_threads{ -1 };
48};
49
50/** CPU context implementation class */
51class CpuContext final : public IContext
52{
53public:
54 /** Default Constructor
55 *
56 * @param[in] options Creational options
57 */
58 explicit CpuContext(const AclContextOptions *options);
59 /** Cpu Capabilities accessor
60 *
61 * @return The ISA capabilities to be used by the CPU
62 */
63 const CpuCapabilities &capabilities() const;
64 /** Backing memory allocator accessor
65 *
66 * @return Allocator that allocates CPU memory
67 */
68 AllocatorWrapper &allocator();
69
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000070 // Inherrited methods overridden
71 ITensorV2 *create_tensor(const AclTensorDescriptor &desc, bool allocate) override;
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000072 IQueue *create_queue(const AclQueueOptions *options) override;
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000073
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000074private:
75 AllocatorWrapper _allocator;
76 CpuCapabilities _caps;
77};
78} // namespace cpu
79} // namespace arm_compute
80
81#endif /* SRC_CPU_CPUCONTEXT_H */