aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/graph2/backends
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute/graph2/backends')
-rw-r--r--arm_compute/graph2/backends/BackendRegistrar.h61
-rw-r--r--arm_compute/graph2/backends/BackendRegistry.h91
-rw-r--r--arm_compute/graph2/backends/CL/CLDeviceBackend.h70
-rw-r--r--arm_compute/graph2/backends/CL/CLFunctionFactory.h57
-rw-r--r--arm_compute/graph2/backends/CL/CLSubTensorHandle.h69
-rw-r--r--arm_compute/graph2/backends/CL/CLTensorHandle.h67
-rw-r--r--arm_compute/graph2/backends/NEON/NEDeviceBackend.h58
-rw-r--r--arm_compute/graph2/backends/NEON/NEFunctionFactory.h56
-rw-r--r--arm_compute/graph2/backends/NEON/NENodeValidator.h39
-rw-r--r--arm_compute/graph2/backends/NEON/NESubTensorHandle.h69
-rw-r--r--arm_compute/graph2/backends/NEON/NETensorHandle.h67
-rw-r--r--arm_compute/graph2/backends/Utils.h97
12 files changed, 801 insertions, 0 deletions
diff --git a/arm_compute/graph2/backends/BackendRegistrar.h b/arm_compute/graph2/backends/BackendRegistrar.h
new file mode 100644
index 0000000000..f9905a7f8f
--- /dev/null
+++ b/arm_compute/graph2/backends/BackendRegistrar.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef ARM_COMPUTE_GRAPH2_BACKEND_REGISTRAR_H__
+#define ARM_COMPUTE_GRAPH2_BACKEND_REGISTRAR_H__
+
+#include "arm_compute/graph2/Types.h"
+#include "arm_compute/graph2/backends/BackendRegistry.h"
+
+#include <utility>
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+namespace detail
+{
+/** Helper class to statically register a backend */
+template <typename T>
+class BackendRegistrar final
+{
+public:
+ /** Add a new backend to the backend registry
+ *
+ * @param[in] target Execution target
+ */
+ BackendRegistrar(Target target);
+};
+
+template <typename T>
+inline BackendRegistrar<T>::BackendRegistrar(Target target)
+{
+ BackendRegistry::get().add_backend<T>(target);
+}
+} // namespace detail
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_GRAPH2_BACKEND_REGISTRAR_H__ */ \ No newline at end of file
diff --git a/arm_compute/graph2/backends/BackendRegistry.h b/arm_compute/graph2/backends/BackendRegistry.h
new file mode 100644
index 0000000000..9481115009
--- /dev/null
+++ b/arm_compute/graph2/backends/BackendRegistry.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_BACKEND_REGISTRY_H__
+#define __ARM_COMPUTE_GRAPH2_BACKEND_REGISTRY_H__
+
+#include "arm_compute/graph2/IDeviceBackend.h"
+#include "arm_compute/graph2/Types.h"
+#include "support/ToolchainSupport.h"
+
+#include <map>
+#include <memory>
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** Registry holding all the supported backends */
+class BackendRegistry final
+{
+public:
+ /** Gets backend registry instance
+ *
+ * @return Backend registry instance
+ */
+ static BackendRegistry &get();
+ /** Finds a backend in the registry
+ *
+ * @param[in] target Backend target
+ *
+ * @return Pointer to the backend interface if found, else nullptr
+ */
+ IDeviceBackend *find_backend(Target target);
+ /** Checks if a backend for a given target exists
+ *
+ * @param[in] target Execution target
+ *
+ * @return True if exists else false
+ */
+ bool contains(Target target) const;
+ /** Backends accessor
+ *
+ * @return Map containing the registered backends
+ */
+ const std::map<Target, std::unique_ptr<IDeviceBackend>> &backends() const;
+ /** Registers a backend to the registry
+ *
+ * @param[in] target Execution target to register for
+ */
+ template <typename T>
+ void add_backend(Target target);
+
+private:
+ /** Default Constructor */
+ BackendRegistry();
+
+private:
+ std::map<Target, std::unique_ptr<IDeviceBackend>> _registered_backends;
+};
+
+template <typename T>
+inline void BackendRegistry::add_backend(Target target)
+{
+ _registered_backends[target] = support::cpp14::make_unique<T>();
+}
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH2_BACKEND_REGISTRY_H__ */
diff --git a/arm_compute/graph2/backends/CL/CLDeviceBackend.h b/arm_compute/graph2/backends/CL/CLDeviceBackend.h
new file mode 100644
index 0000000000..c48a85f99a
--- /dev/null
+++ b/arm_compute/graph2/backends/CL/CLDeviceBackend.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_CLDEVICEBACKEND_H__
+#define __ARM_COMPUTE_GRAPH2_CLDEVICEBACKEND_H__
+
+#include "arm_compute/graph2/IDeviceBackend.h"
+
+#include "arm_compute/runtime/CL/CLBufferAllocator.h"
+#include "arm_compute/runtime/CL/CLTuner.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** OpenCL device backend */
+class CLDeviceBackend final : public IDeviceBackend
+{
+public:
+ /** Default Constructor */
+ CLDeviceBackend();
+ /** Destructor */
+ ~CLDeviceBackend();
+ /** Switchs on or off the kernel tuning
+ *
+ * @note When true the tuner set is used, if no tuner is set a new default one is created
+ *
+ * @param[in] enable_tuning Enables tuning if false else true
+ */
+ void set_kernel_tuning(bool enable_tuning);
+
+ // Inherited overridden methods
+ void initialize_backend() override;
+ void setup_backend_context(GraphContext &ctx) override;
+ std::unique_ptr<ITensorHandle> create_tensor(const Tensor &tensor) override;
+ std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords) override;
+ std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override;
+ Status validate_node(const INode &node) override;
+ std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override;
+
+private:
+ CLTuner _tuner; /**< CL kernel tuner */
+ CLBufferAllocator _allocator; /**< CL buffer affinity allocator */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_CLDEVICEBACKEND_H__
diff --git a/arm_compute/graph2/backends/CL/CLFunctionFactory.h b/arm_compute/graph2/backends/CL/CLFunctionFactory.h
new file mode 100644
index 0000000000..94fd2b8be1
--- /dev/null
+++ b/arm_compute/graph2/backends/CL/CLFunctionFactory.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_CLFUNCTIONFACTORY_H__
+#define __ARM_COMPUTE_GRAPH2_CLFUNCTIONFACTORY_H__
+
+#include "arm_compute/runtime/IFunction.h"
+
+#include <memory>
+
+namespace arm_compute
+{
+namespace graph2
+{
+// Forward declarations
+class INode;
+class GraphContext;
+
+namespace backends
+{
+/** Factory for generating OpenCL backend functions **/
+class CLFunctionFactory final
+{
+public:
+ /** Create a backend execution function depending on the node type
+ *
+ * @param[in] node Node to create the backend function for
+ * @param[in] ctx Context to use
+ *
+ * @return Backend function
+ */
+ static std::unique_ptr<arm_compute::IFunction> create(INode *node, GraphContext &ctx);
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_CLFUNCTIONFACTORY_H__
diff --git a/arm_compute/graph2/backends/CL/CLSubTensorHandle.h b/arm_compute/graph2/backends/CL/CLSubTensorHandle.h
new file mode 100644
index 0000000000..5584a8ba4f
--- /dev/null
+++ b/arm_compute/graph2/backends/CL/CLSubTensorHandle.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_CLSUBTENSORHANDLE_H__
+#define __ARM_COMPUTE_GRAPH2_CLSUBTENSORHANDLE_H__
+
+#include "arm_compute/graph2/ITensorHandle.h"
+
+#include "arm_compute/runtime/CL/CLSubTensor.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** OpenCL Sub-Tensor handle interface object **/
+class CLSubTensorHandle final : public ITensorHandle
+{
+public:
+ /** Default constructor
+ *
+ * @param[in] parent_handle Parent tensor handle
+ * @param[in] shape Sub-Tensor shape
+ * @param[in] coords Starting coordinates
+ */
+ CLSubTensorHandle(ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords);
+ /** Destructor: free the tensor's memory */
+ ~CLSubTensorHandle() = default;
+ /** Allow instances of this class to be move constructed */
+ CLSubTensorHandle(CLSubTensorHandle &&) = default;
+ /** Allow instances of this class to be moved */
+ CLSubTensorHandle &operator=(CLSubTensorHandle &&) = default;
+
+ // Inherited overridden methods
+ void allocate() override;
+ arm_compute::ITensor &tensor() override;
+ const arm_compute::ITensor &tensor() const override;
+ void map(bool blocking) override;
+ void unmap() override;
+ bool is_subtensor() const override;
+
+private:
+ arm_compute::CLSubTensor _sub_tensor; /**< Backend Sub-Tensor */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH2_CLSUBTENSORHANDLE_H__ */
diff --git a/arm_compute/graph2/backends/CL/CLTensorHandle.h b/arm_compute/graph2/backends/CL/CLTensorHandle.h
new file mode 100644
index 0000000000..37d7147b6b
--- /dev/null
+++ b/arm_compute/graph2/backends/CL/CLTensorHandle.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_CLTENSORHANDLE_H__
+#define __ARM_COMPUTE_GRAPH2_CLTENSORHANDLE_H__
+
+#include "arm_compute/graph2/ITensorHandle.h"
+
+#include "arm_compute/runtime/CL/CLTensor.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** OpenCL Tensor handle interface object **/
+class CLTensorHandle final : public ITensorHandle
+{
+public:
+ /** Default Constructor
+ *
+ * @param[in] info Tensor metadata
+ */
+ CLTensorHandle(const ITensorInfo &info);
+ /** Destructor: free the tensor's memory */
+ ~CLTensorHandle() = default;
+ /** Allow instances of this class to be move constructed */
+ CLTensorHandle(CLTensorHandle &&) = default;
+ /** Allow instances of this class to be moved */
+ CLTensorHandle &operator=(CLTensorHandle &&) = default;
+
+ // Inherited overridden methods
+ void allocate() override;
+ arm_compute::ITensor &tensor() override;
+ const arm_compute::ITensor &tensor() const override;
+ void map(bool blocking) override;
+ void unmap() override;
+ bool is_subtensor() const override;
+
+private:
+ arm_compute::CLTensor _tensor; /**< Backend Tensor */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH2_CLTENSORHANDLE_H__ */
diff --git a/arm_compute/graph2/backends/NEON/NEDeviceBackend.h b/arm_compute/graph2/backends/NEON/NEDeviceBackend.h
new file mode 100644
index 0000000000..533a2c0863
--- /dev/null
+++ b/arm_compute/graph2/backends/NEON/NEDeviceBackend.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_NEDEVICEBACKEND_H__
+#define __ARM_COMPUTE_GRAPH2_NEDEVICEBACKEND_H__
+
+#include "arm_compute/graph2/IDeviceBackend.h"
+
+#include "arm_compute/runtime/Allocator.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** NEON device backend */
+class NEDeviceBackend final : public IDeviceBackend
+{
+public:
+ NEDeviceBackend();
+
+ // Inherited overridden methods
+ void initialize_backend() override;
+ void setup_backend_context(GraphContext &ctx) override;
+ std::unique_ptr<ITensorHandle> create_tensor(const Tensor &tensor) override;
+ std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords) override;
+ std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override;
+ Status validate_node(const INode &node) override;
+ std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override;
+
+private:
+ Allocator _allocator; /**< NEON backend allocator */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_NEDEVICEBACKEND_H__
diff --git a/arm_compute/graph2/backends/NEON/NEFunctionFactory.h b/arm_compute/graph2/backends/NEON/NEFunctionFactory.h
new file mode 100644
index 0000000000..a065340ad6
--- /dev/null
+++ b/arm_compute/graph2/backends/NEON/NEFunctionFactory.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_NEFUNCTIONFACTORY_H__
+#define __ARM_COMPUTE_GRAPH2_NEFUNCTIONFACTORY_H__
+
+#include "arm_compute/runtime/IFunction.h"
+
+#include <memory>
+
+namespace arm_compute
+{
+namespace graph2
+{
+// Forward declarations
+class INode;
+class GraphContext;
+
+namespace backends
+{
+class NEFunctionFactory final
+{
+public:
+ /** Create a backend execution function depending on the node type
+ *
+ * @param[in] node Node to create the backend function for
+ * @param[in] ctx Context to use
+ *
+ * @return Backend function
+ */
+ static std::unique_ptr<arm_compute::IFunction> create(INode *node, GraphContext &ctx);
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_NEFUNCTIONFACTORY_H__
diff --git a/arm_compute/graph2/backends/NEON/NENodeValidator.h b/arm_compute/graph2/backends/NEON/NENodeValidator.h
new file mode 100644
index 0000000000..8e8448526a
--- /dev/null
+++ b/arm_compute/graph2/backends/NEON/NENodeValidator.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_NENODEVALIDATOR_H__
+#define __ARM_COMPUTE_GRAPH2_NENODEVALIDATOR_H__
+
+#include "arm_compute/graph2/INodeVisitor.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+// TODO (geopin01) : Add node validator
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_NENODEVALIDATOR_H__
diff --git a/arm_compute/graph2/backends/NEON/NESubTensorHandle.h b/arm_compute/graph2/backends/NEON/NESubTensorHandle.h
new file mode 100644
index 0000000000..e027b0cc56
--- /dev/null
+++ b/arm_compute/graph2/backends/NEON/NESubTensorHandle.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_NESUBTENSORHANDLE_H__
+#define __ARM_COMPUTE_GRAPH2_NESUBTENSORHANDLE_H__
+
+#include "arm_compute/graph2/ITensorHandle.h"
+
+#include "arm_compute/runtime/SubTensor.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** NEON Sub-Tensor handle interface object **/
+class NESubTensorHandle final : public ITensorHandle
+{
+public:
+ /** Default constructor
+ *
+ * @param[in] parent_handle Parent tensor handle
+ * @param[in] shape Sub-Tensor shape
+ * @param[in] coords Starting coordinates
+ */
+ NESubTensorHandle(ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords);
+ /** Destructor: free the tensor's memory */
+ ~NESubTensorHandle() = default;
+ /** Allow instances of this class to be move constructed */
+ NESubTensorHandle(NESubTensorHandle &&) = default;
+ /** Allow instances of this class to be moved */
+ NESubTensorHandle &operator=(NESubTensorHandle &&) = default;
+
+ // Inherited overridden methods
+ void allocate() override;
+ arm_compute::ITensor &tensor() override;
+ const arm_compute::ITensor &tensor() const override;
+ void map(bool blocking) override;
+ void unmap() override;
+ bool is_subtensor() const override;
+
+private:
+ arm_compute::SubTensor _sub_tensor; /**< Backend Sub-Tensor */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH2_NESUBTENSORHANDLE_H__ */
diff --git a/arm_compute/graph2/backends/NEON/NETensorHandle.h b/arm_compute/graph2/backends/NEON/NETensorHandle.h
new file mode 100644
index 0000000000..c22fcdf216
--- /dev/null
+++ b/arm_compute/graph2/backends/NEON/NETensorHandle.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_NETENSORHANDLE_H__
+#define __ARM_COMPUTE_GRAPH2_NETENSORHANDLE_H__
+
+#include "arm_compute/graph2/ITensorHandle.h"
+
+#include "arm_compute/runtime/Tensor.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** NEON Tensor handle interface object **/
+class NETensorHandle final : public ITensorHandle
+{
+public:
+ /** Default Constructor
+ *
+ * @param[in] info Tensor metadata
+ */
+ NETensorHandle(const ITensorInfo &info);
+ /** Destructor: free the tensor's memory */
+ ~NETensorHandle() = default;
+ /** Allow instances of this class to be move constructed */
+ NETensorHandle(NETensorHandle &&) = default;
+ /** Allow instances of this class to be moved */
+ NETensorHandle &operator=(NETensorHandle &&) = default;
+
+ // Inherited overridden methods
+ void allocate() override;
+ arm_compute::ITensor &tensor() override;
+ const arm_compute::ITensor &tensor() const override;
+ void map(bool blocking) override;
+ void unmap() override;
+ bool is_subtensor() const override;
+
+private:
+ arm_compute::Tensor _tensor; /**< Backend Tensor */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH2_NETENSORHANDLE_H__ */
diff --git a/arm_compute/graph2/backends/Utils.h b/arm_compute/graph2/backends/Utils.h
new file mode 100644
index 0000000000..cc6f5163f2
--- /dev/null
+++ b/arm_compute/graph2/backends/Utils.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_GRAPH2_BACKENDS_UTILS_H__
+#define __ARM_COMPUTE_GRAPH2_BACKENDS_UTILS_H__
+
+#include "arm_compute/graph2/GraphContext.h"
+#include "arm_compute/runtime/IMemoryManager.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** Creates and configures a named function
+ *
+ * @param[in] name Name of the function
+ * @param[in] args Function arguments
+ *
+ * @return A configured backend function
+ */
+template <typename FunctionType, typename FunctionNameType, typename... ParameterType>
+std::pair<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> create_named_function(FunctionNameType name, ParameterType... args)
+{
+ auto f = arm_compute::support::cpp14::make_unique<FunctionType>();
+ f->configure(std::forward<ParameterType>(args)...);
+ return std::make_pair(std::move(f), name);
+}
+
+/** Creates and configures a named function
+ *
+ * @param[in] name Name of the function
+ * @param[in] mm Memory manager to use
+ * @param[in] args Function arguments
+ *
+ * @return A configured backend function
+ */
+template <typename FunctionType, typename FunctionNameType, typename MemoryManagerType, typename... ParameterType>
+std::pair<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> create_named_memory_managed_function(FunctionNameType name,
+ MemoryManagerType mm,
+ ParameterType... args)
+{
+ auto f = arm_compute::support::cpp14::make_unique<FunctionType>(mm);
+ f->configure(std::forward<ParameterType>(args)...);
+ return std::make_pair(std::move(f), name);
+}
+
+/** Checks if an operation is in place
+ *
+ * @param[in] input Pointer to input
+ * @param[in] output Pointer to output
+ *
+ * @return True if output is nullptr or input is equal to the output, else false
+ */
+inline bool is_in_place_operation(void *input, void *output)
+{
+ return (output == nullptr) || (input == output);
+}
+
+/** Returns the memory manager for a given target
+ *
+ * @param[in] ctx Graph context containing memory management metadata
+ * @param[in] target Target to retrieve the memory manager from
+ *
+ * @return The memory manager for the given target else false
+ */
+inline std::shared_ptr<IMemoryManager> get_memory_manager(GraphContext &ctx, Target target)
+{
+ bool enabled = ctx.is_memory_management_enabled() && (ctx.memory_management_ctx(target) != nullptr);
+ return enabled ? ctx.memory_management_ctx(target)->mm : nullptr;
+}
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+
+#endif /* __ARM_COMPUTE_GRAPH2_BACKENDS_UTILS_H__ */