From f674aa0fd2809126debdaaeb8067067790d86907 Mon Sep 17 00:00:00 2001 From: Derek Lamberti Date: Thu, 1 Aug 2019 15:56:25 +0100 Subject: IVGCVSW-3277 Mem export/import suppor for Tensors * Rename MemoryStrategy to EdgeStrategy * Add MemImportLayer * Import memory rather than copy when possible Change-Id: I1d3a9414f2cbe517dc2aae9bbd4fdd92712b38ef Signed-off-by: Derek Lamberti --- include/armnn/ILayerSupport.hpp | 4 ++++ include/armnn/MemorySources.hpp | 51 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 include/armnn/MemorySources.hpp (limited to 'include') diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp index 45360984ff..33f86dea59 100644 --- a/include/armnn/ILayerSupport.hpp +++ b/include/armnn/ILayerSupport.hpp @@ -172,6 +172,10 @@ public: const TensorInfo& output, Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsMemImportSupported(const TensorInfo& input, + const TensorInfo& output, + Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsMergeSupported(const TensorInfo& input0, const TensorInfo& input1, const TensorInfo& output, diff --git a/include/armnn/MemorySources.hpp b/include/armnn/MemorySources.hpp new file mode 100644 index 0000000000..e138f56fd4 --- /dev/null +++ b/include/armnn/MemorySources.hpp @@ -0,0 +1,51 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include + +namespace armnn +{ + +enum class MemorySource +{ + Malloc = 1, + DmaBuf = 2, + DmaBufProtected = 4 +}; + +using MemorySourceFlags = unsigned int; + +template +struct IsMemorySource +{ + static const bool value = false; +}; + +template<> +struct IsMemorySource +{ + static const bool value = true; +}; + +template ::value>::type* = nullptr> +MemorySourceFlags Combine(Arg sourceA, Arg sourceB) +{ + return static_cast(sourceA) | static_cast(sourceB); +} + +template ::value>::type* = nullptr> +MemorySourceFlags Combine(Arg source, Args... rest) +{ + return static_cast(source) | Combine(rest...); +} + +inline bool CheckFlag(MemorySourceFlags flags, MemorySource source) +{ + return (static_cast(source) & flags) != 0; +} + +} //namespace armnn \ No newline at end of file -- cgit v1.2.1