Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 1 | /* |
| 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" |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 29 | #include "src/common/cpuinfo/CpuInfo.h" |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | namespace cpu |
| 34 | { |
| 35 | /** Structure that encodes the CPU capabilities to be used */ |
| 36 | struct CpuCapabilities |
| 37 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 38 | cpuinfo::CpuInfo cpu_info{}; |
| 39 | int32_t max_threads{ -1 }; |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /** CPU context implementation class */ |
| 43 | class CpuContext final : public IContext |
| 44 | { |
| 45 | public: |
| 46 | /** Default Constructor |
| 47 | * |
| 48 | * @param[in] options Creational options |
| 49 | */ |
| 50 | explicit CpuContext(const AclContextOptions *options); |
| 51 | /** Cpu Capabilities accessor |
| 52 | * |
| 53 | * @return The ISA capabilities to be used by the CPU |
| 54 | */ |
| 55 | const CpuCapabilities &capabilities() const; |
| 56 | /** Backing memory allocator accessor |
| 57 | * |
| 58 | * @return Allocator that allocates CPU memory |
| 59 | */ |
| 60 | AllocatorWrapper &allocator(); |
| 61 | |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 62 | // Inherrited methods overridden |
| 63 | ITensorV2 *create_tensor(const AclTensorDescriptor &desc, bool allocate) override; |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 64 | IQueue *create_queue(const AclQueueOptions *options) override; |
Georgios Pinitas | 4164814 | 2021-08-03 08:24:00 +0100 | [diff] [blame] | 65 | std::tuple<IOperator *, StatusCode> create_activation(const AclTensorDescriptor &src, |
| 66 | const AclTensorDescriptor &dst, |
| 67 | const AclActivationDescriptor &act, |
| 68 | bool is_validate) override; |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 69 | |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 70 | private: |
| 71 | AllocatorWrapper _allocator; |
| 72 | CpuCapabilities _caps; |
| 73 | }; |
| 74 | } // namespace cpu |
| 75 | } // namespace arm_compute |
| 76 | |
| 77 | #endif /* SRC_CPU_CPUCONTEXT_H */ |