From 0c76b23726a86a46da44c3f52348db53f73ae242 Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Fri, 7 May 2021 17:52:36 +0100 Subject: IVGCVSW-5818 Enable import on GPU Signed-off-by: Narumol Prangnawarat Change-Id: I4e4eb107aa2bfa09625840d738001f33152e6792 --- src/backends/cl/ClBackend.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/backends/cl/ClBackend.cpp') diff --git a/src/backends/cl/ClBackend.cpp b/src/backends/cl/ClBackend.cpp index f97cb4bba8..35770d9219 100644 --- a/src/backends/cl/ClBackend.cpp +++ b/src/backends/cl/ClBackend.cpp @@ -4,12 +4,13 @@ // #include "ClBackend.hpp" +#include "ClBackendContext.hpp" #include "ClBackendId.hpp" #include "ClBackendModelContext.hpp" -#include "ClWorkloadFactory.hpp" -#include "ClBackendContext.hpp" +#include "ClImportTensorHandleFactory.hpp" #include "ClLayerSupport.hpp" #include "ClTensorHandleFactory.hpp" +#include "ClWorkloadFactory.hpp" #include #include @@ -71,6 +72,8 @@ IBackendInternal::IWorkloadFactoryPtr ClBackend::CreateWorkloadFactory( registry.RegisterMemoryManager(memoryManager); registry.RegisterFactory(std::make_unique(memoryManager)); + registry.RegisterFactory(std::make_unique( + static_cast(MemorySource::Malloc), static_cast(MemorySource::Malloc))); return std::make_unique( PolymorphicPointerDowncast(memoryManager)); @@ -83,6 +86,24 @@ IBackendInternal::IWorkloadFactoryPtr ClBackend::CreateWorkloadFactory( registry.RegisterMemoryManager(memoryManager); registry.RegisterFactory(std::make_unique(memoryManager)); + registry.RegisterFactory(std::make_unique( + static_cast(MemorySource::Malloc), static_cast(MemorySource::Malloc))); + + return std::make_unique( + PolymorphicPointerDowncast(memoryManager), CreateBackendSpecificModelContext(modelOptions)); +} + +IBackendInternal::IWorkloadFactoryPtr ClBackend::CreateWorkloadFactory( + TensorHandleFactoryRegistry& registry, + const ModelOptions& modelOptions, + MemorySourceFlags inputFlags, + MemorySourceFlags outputFlags) const +{ + auto memoryManager = std::make_shared(std::make_unique()); + + registry.RegisterMemoryManager(memoryManager); + registry.RegisterFactory(std::make_unique(memoryManager)); + registry.RegisterFactory(std::make_unique(inputFlags, outputFlags)); return std::make_unique( PolymorphicPointerDowncast(memoryManager), CreateBackendSpecificModelContext(modelOptions)); @@ -90,7 +111,8 @@ IBackendInternal::IWorkloadFactoryPtr ClBackend::CreateWorkloadFactory( std::vector ClBackend::GetHandleFactoryPreferences() const { - return std::vector {ClTensorHandleFactory::GetIdStatic()}; + return std::vector {ClTensorHandleFactory::GetIdStatic(), + ClImportTensorHandleFactory::GetIdStatic()}; } void ClBackend::RegisterTensorHandleFactories(TensorHandleFactoryRegistry& registry) @@ -99,6 +121,19 @@ void ClBackend::RegisterTensorHandleFactories(TensorHandleFactoryRegistry& regis registry.RegisterMemoryManager(mgr); registry.RegisterFactory(std::make_unique(mgr)); + registry.RegisterFactory(std::make_unique( + static_cast(MemorySource::Malloc), static_cast(MemorySource::Malloc))); +} + +void ClBackend::RegisterTensorHandleFactories(TensorHandleFactoryRegistry& registry, + MemorySourceFlags inputFlags, + MemorySourceFlags outputFlags) +{ + auto mgr = std::make_shared(std::make_unique()); + + registry.RegisterMemoryManager(mgr); + registry.RegisterFactory(std::make_unique(mgr)); + registry.RegisterFactory(std::make_unique(inputFlags, outputFlags)); } IBackendInternal::IBackendContextPtr ClBackend::CreateBackendContext(const IRuntime::CreationOptions& options) const -- cgit v1.2.1