blob: ec7c62ba11a23ead4eeb4358e6106139b85d8d5e [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
Cian McGriskin7894ef92023-08-01 14:04:09 +01002// Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#pragma once
6
Matthew Bentham7c1603a2019-06-21 17:22:23 +01007#include "RefMemoryManager.hpp"
8
Jan Eilers8eb25602020-03-09 12:13:48 +00009#include <armnn/Optional.hpp>
Colm Donelan0c479742021-12-10 12:43:54 +000010#include <armnn/backends/WorkloadFactory.hpp>
Jan Eilers8eb25602020-03-09 12:13:48 +000011#include <armnn/utility/IgnoreUnused.hpp>
David Beck29c75de2018-10-23 13:35:58 +010012
telsoa014fcda012018-03-09 14:13:49 +000013
14namespace armnn
15{
16
17template <typename QueueDescriptorType>
18constexpr bool IsOperationQueueDescriptor(const QueueDescriptorType&) { return true; }
telsoa014fcda012018-03-09 14:13:49 +000019template <>
20constexpr bool IsOperationQueueDescriptor(const MemCopyQueueDescriptor&) { return false; }
telsoa014fcda012018-03-09 14:13:49 +000021template <>
22constexpr bool IsOperationQueueDescriptor(const ConstantQueueDescriptor&) { return false; }
telsoa014fcda012018-03-09 14:13:49 +000023template <>
24constexpr bool IsOperationQueueDescriptor(const PermuteQueueDescriptor&) { return false; }
25
telsoa01c577f2c2018-08-31 09:22:23 +010026// Reference workload factory.
telsoa014fcda012018-03-09 14:13:49 +000027class RefWorkloadFactory : public IWorkloadFactory
28{
29public:
Matthew Bentham7c1603a2019-06-21 17:22:23 +010030 explicit RefWorkloadFactory(const std::shared_ptr<RefMemoryManager>& memoryManager);
31 RefWorkloadFactory();
32
Matteo Martincigh3d6898c2019-01-15 16:11:44 +000033 ~RefWorkloadFactory() {}
telsoa014fcda012018-03-09 14:13:49 +000034
David Beck79141b92018-10-23 16:09:36 +010035 const BackendId& GetBackendId() const override;
telsoa014fcda012018-03-09 14:13:49 +000036
David Beck29c75de2018-10-23 13:35:58 +010037 static bool IsLayerSupported(const Layer& layer,
38 Optional<DataType> dataType,
telsoa01c577f2c2018-08-31 09:22:23 +010039 std::string& outReasonIfUnsupported);
telsoa014fcda012018-03-09 14:13:49 +000040
Sadik Armagan04a72972020-09-14 15:44:18 +010041 static bool IsLayerSupported(const IConnectableLayer& layer,
42 Optional<DataType> dataType,
43 std::string& outReasonIfUnsupported,
44 const ModelOptions& modelOptions);
45
Matteo Martincigh3d6898c2019-01-15 16:11:44 +000046 bool SupportsSubTensors() const override { return false; }
telsoa014fcda012018-03-09 14:13:49 +000047
Sadik Armaganc83eb252020-07-22 16:32:06 +010048 ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateSubTensorHandle instead")
Matteo Martincigh3d6898c2019-01-15 16:11:44 +000049 std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
50 TensorShape const& subTensorShape,
51 unsigned int const* subTensorOrigin) const override
telsoa014fcda012018-03-09 14:13:49 +000052 {
Jan Eilers8eb25602020-03-09 12:13:48 +000053 IgnoreUnused(parent, subTensorShape, subTensorOrigin);
telsoa014fcda012018-03-09 14:13:49 +000054 return nullptr;
telsoa01c577f2c2018-08-31 09:22:23 +010055 }
telsoa014fcda012018-03-09 14:13:49 +000056
Sadik Armaganc83eb252020-07-22 16:32:06 +010057 ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
David Monahan3fb7e102019-08-20 11:25:29 +010058 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
59 const bool IsMemoryManaged = true) const override;
telsoa014fcda012018-03-09 14:13:49 +000060
Sadik Armaganc83eb252020-07-22 16:32:06 +010061 ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
Matteo Martincigh3d6898c2019-01-15 16:11:44 +000062 std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
David Monahan3fb7e102019-08-20 11:25:29 +010063 DataLayout dataLayout,
64 const bool IsMemoryManaged = true) const override;
Francis Murtagh351d13d2018-09-24 15:01:18 +010065
Teresa Charlin611c7fb2022-01-07 09:47:29 +000066 std::unique_ptr<IWorkload> CreateWorkload(LayerType type,
67 const QueueDescriptor& descriptor,
68 const WorkloadInfo& info) const override;
69
telsoa014fcda012018-03-09 14:13:49 +000070private:
telsoa014fcda012018-03-09 14:13:49 +000071 template <typename F32Workload, typename U8Workload, typename QueueDescriptorType>
72 std::unique_ptr<IWorkload> MakeWorkload(const QueueDescriptorType& descriptor, const WorkloadInfo& info) const;
Matthew Bentham7c1603a2019-06-21 17:22:23 +010073
74 mutable std::shared_ptr<RefMemoryManager> m_MemoryManager;
telsoa014fcda012018-03-09 14:13:49 +000075};
76
77} // namespace armnn