aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-03-27 17:15:49 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:49:16 +0000
commitfbb805450c1509cee2d9270bc8e04ce9165ac4bc (patch)
treea97ace1862360e232268b5071b79d6cdaf887455
parent3672df36e7b61f280d66b6cbb11c2b4254fbbc8c (diff)
downloadComputeLibrary-fbb805450c1509cee2d9270bc8e04ce9165ac4bc.tar.gz
COMPMID-1028: Add GLES backend
Change-Id: If3172cdb6528dbc20262836174aedaef52c78bdb Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/126111 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
-rw-r--r--SConscript2
-rw-r--r--arm_compute/graph2/Types.h1
-rw-r--r--arm_compute/graph2/Utils.h4
-rw-r--r--arm_compute/graph2/backends/GLES/GCDeviceBackend.h59
-rw-r--r--arm_compute/graph2/backends/GLES/GCFunctionFactory.h57
-rw-r--r--arm_compute/graph2/backends/GLES/GCNodeValidator.h52
-rw-r--r--arm_compute/graph2/backends/GLES/GCTensorHandle.h67
-rw-r--r--src/graph2/Utils.cpp18
-rw-r--r--src/graph2/backends/GLES/GCDeviceBackend.cpp133
-rw-r--r--src/graph2/backends/GLES/GCFunctionsFactory.cpp507
-rw-r--r--src/graph2/backends/GLES/GCNodeValidator.cpp122
-rw-r--r--src/graph2/backends/GLES/GCTensorHandle.cpp69
-rw-r--r--src/graph2/detail/ExecutionHelpers.cpp3
-rw-r--r--src/graph2/frontend/Stream.cpp2
-rw-r--r--utils/GraphUtils.h6
15 files changed, 1092 insertions, 10 deletions
diff --git a/SConscript b/SConscript
index cf2dd878e5..f90ee3e536 100644
--- a/SConscript
+++ b/SConscript
@@ -223,6 +223,8 @@ if env['gles_compute']:
runtime_files += Glob('src/runtime/GLES_COMPUTE/*.cpp')
runtime_files += Glob('src/runtime/GLES_COMPUTE/functions/*.cpp')
+ graph2_files += Glob('src/graph2/backends/GLES/*.cpp')
+
arm_compute_core_a = build_library('arm_compute_core-static', core_files, static=True)
Export('arm_compute_core_a')
diff --git a/arm_compute/graph2/Types.h b/arm_compute/graph2/Types.h
index b619cf1673..2625657393 100644
--- a/arm_compute/graph2/Types.h
+++ b/arm_compute/graph2/Types.h
@@ -93,6 +93,7 @@ enum class Target
UNSPECIFIED, /**< Unspecified Target */
NEON, /**< NEON capable target device */
CL, /**< OpenCL capable target device */
+ GC, /**< GLES compute capable target device */
};
/** Supported Element-wise operations */
diff --git a/arm_compute/graph2/Utils.h b/arm_compute/graph2/Utils.h
index 750665a491..0295bcb9af 100644
--- a/arm_compute/graph2/Utils.h
+++ b/arm_compute/graph2/Utils.h
@@ -84,9 +84,11 @@ Target get_default_target();
void force_target_to_graph(Graph &g, Target target);
/** Creates a default @ref PassManager
*
+ * @param[in] target Target to create the pass manager for
+ *
* @return A PassManager with default mutating passes
*/
-PassManager create_default_pass_manager();
+PassManager create_default_pass_manager(Target target);
/** Default setups the graph context if not done manually
*
* @param[in] ctx Graph Context
diff --git a/arm_compute/graph2/backends/GLES/GCDeviceBackend.h b/arm_compute/graph2/backends/GLES/GCDeviceBackend.h
new file mode 100644
index 0000000000..22ba91496b
--- /dev/null
+++ b/arm_compute/graph2/backends/GLES/GCDeviceBackend.h
@@ -0,0 +1,59 @@
+/*
+ * 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_GCDEVICEBACKEND_H__
+#define __ARM_COMPUTE_GRAPH2_GCDEVICEBACKEND_H__
+
+#include "arm_compute/graph2/IDeviceBackend.h"
+
+#include "arm_compute/runtime/GLES_COMPUTE/GCBufferAllocator.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** GLES Compute device backend */
+class GCDeviceBackend final : public IDeviceBackend
+{
+public:
+ /** Default Constructor */
+ GCDeviceBackend();
+
+ // 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, bool extend_parent) override;
+ std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override;
+ Status validate_node(INode &node) override;
+ std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override;
+
+private:
+ GCBufferAllocator _allocator; /**< GLES buffer affinity allocator */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_GCDEVICEBACKEND_H__
diff --git a/arm_compute/graph2/backends/GLES/GCFunctionFactory.h b/arm_compute/graph2/backends/GLES/GCFunctionFactory.h
new file mode 100644
index 0000000000..4f7b2f451a
--- /dev/null
+++ b/arm_compute/graph2/backends/GLES/GCFunctionFactory.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_GCFUNCTIONFACTORY_H__
+#define __ARM_COMPUTE_GRAPH2_GCFUNCTIONFACTORY_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 GLES compute backend functions **/
+class GCFunctionFactory 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_GCFUNCTIONFACTORY_H__
diff --git a/arm_compute/graph2/backends/GLES/GCNodeValidator.h b/arm_compute/graph2/backends/GLES/GCNodeValidator.h
new file mode 100644
index 0000000000..16b225b282
--- /dev/null
+++ b/arm_compute/graph2/backends/GLES/GCNodeValidator.h
@@ -0,0 +1,52 @@
+/*
+ * 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_GCNODEVALIDATOR_H__
+#define __ARM_COMPUTE_GRAPH2_GCNODEVALIDATOR_H__
+
+#include "arm_compute/core/Error.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+// Forward declarations
+class INode;
+
+namespace backends
+{
+class GCNodeValidator final
+{
+public:
+ /** Validate a node
+ *
+ * @param[in] node Node to validate
+ *
+ * @return An error status
+ */
+ static Status validate(INode *node);
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif //__ARM_COMPUTE_GRAPH2_GCNODEVALIDATOR_H__
diff --git a/arm_compute/graph2/backends/GLES/GCTensorHandle.h b/arm_compute/graph2/backends/GLES/GCTensorHandle.h
new file mode 100644
index 0000000000..8ead236614
--- /dev/null
+++ b/arm_compute/graph2/backends/GLES/GCTensorHandle.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_GCTENSORHANDLE_H__
+#define __ARM_COMPUTE_GRAPH2_GCTENSORHANDLE_H__
+
+#include "arm_compute/graph2/ITensorHandle.h"
+
+#include "arm_compute/runtime/GLES_COMPUTE/GCTensor.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** GLES compute tensor handle interface object **/
+class GCTensorHandle final : public ITensorHandle
+{
+public:
+ /** Default Constructor
+ *
+ * @param[in] info Tensor metadata
+ */
+ GCTensorHandle(const ITensorInfo &info);
+ /** Destructor: free the tensor's memory */
+ ~GCTensorHandle() = default;
+ /** Allow instances of this class to be move constructed */
+ GCTensorHandle(GCTensorHandle &&) = default;
+ /** Allow instances of this class to be moved */
+ GCTensorHandle &operator=(GCTensorHandle &&) = 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::GCTensor _tensor; /**< Backend Tensor */
+};
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH2_GCTENSORHANDLE_H__ */
diff --git a/src/graph2/Utils.cpp b/src/graph2/Utils.cpp
index 3ff400bf61..a3e90f43bc 100644
--- a/src/graph2/Utils.cpp
+++ b/src/graph2/Utils.cpp
@@ -46,7 +46,10 @@ Target get_default_target()
{
return Target::CL;
}
-
+ if(is_target_supported(Target::GC))
+ {
+ return Target::GC;
+ }
ARM_COMPUTE_ERROR("No backend exists!");
}
@@ -71,14 +74,17 @@ void force_target_to_graph(Graph &g, Target target)
}
}
-PassManager create_default_pass_manager()
+PassManager create_default_pass_manager(Target target)
{
PassManager pm;
- pm.append(support::cpp14::make_unique<InPlaceOperationMutator>());
- pm.append(support::cpp14::make_unique<NodeFusionMutator>());
- pm.append(support::cpp14::make_unique<SplitLayerSubTensorMutator>());
- pm.append(support::cpp14::make_unique<DepthConcatSubTensorMutator>());
+ if(target != Target::GC)
+ {
+ pm.append(support::cpp14::make_unique<InPlaceOperationMutator>());
+ pm.append(support::cpp14::make_unique<NodeFusionMutator>());
+ pm.append(support::cpp14::make_unique<SplitLayerSubTensorMutator>());
+ pm.append(support::cpp14::make_unique<DepthConcatSubTensorMutator>());
+ }
return pm;
}
diff --git a/src/graph2/backends/GLES/GCDeviceBackend.cpp b/src/graph2/backends/GLES/GCDeviceBackend.cpp
new file mode 100644
index 0000000000..7dab422a82
--- /dev/null
+++ b/src/graph2/backends/GLES/GCDeviceBackend.cpp
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+#include "arm_compute/graph2/backends/GLES/GCDeviceBackend.h"
+
+#include "arm_compute/graph2/Graph.h"
+#include "arm_compute/graph2/GraphContext.h"
+#include "arm_compute/graph2/INode.h"
+#include "arm_compute/graph2/Logger.h"
+#include "arm_compute/graph2/Tensor.h"
+#include "arm_compute/graph2/backends/BackendRegistrar.h"
+#include "arm_compute/graph2/backends/GLES/GCFunctionFactory.h"
+#include "arm_compute/graph2/backends/GLES/GCNodeValidator.h"
+#include "arm_compute/graph2/backends/GLES/GCTensorHandle.h"
+
+#include "arm_compute/core/TensorInfo.h"
+#include "arm_compute/runtime/BlobLifetimeManager.h"
+#include "arm_compute/runtime/GLES_COMPUTE/GCBufferAllocator.h"
+#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
+#include "arm_compute/runtime/MemoryManagerOnDemand.h"
+#include "arm_compute/runtime/PoolManager.h"
+
+#include "support/ToolchainSupport.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+/** Register GLES backend */
+static detail::BackendRegistrar<GCDeviceBackend> GCDeviceBackend_registrar(Target::GC);
+
+GCDeviceBackend::GCDeviceBackend()
+ : _allocator()
+{
+}
+
+void GCDeviceBackend::initialize_backend()
+{
+ // Setup Scheduler
+ GCScheduler::get().default_init();
+}
+
+void GCDeviceBackend::setup_backend_context(GraphContext &ctx)
+{
+ // Setup a management backend
+ if(ctx.memory_management_ctx(Target::GC) == nullptr)
+ {
+ MemoryManagerContext mm_ctx;
+ mm_ctx.target = Target::GC;
+ mm_ctx.mm = create_memory_manager(MemoryManagerAffinity::Buffer);
+
+ ctx.insert_memory_management_ctx(std::move(mm_ctx));
+ }
+}
+
+std::unique_ptr<ITensorHandle> GCDeviceBackend::create_tensor(const Tensor &tensor)
+{
+ // Get tensor descriptor
+ const TensorDescriptor &tensor_desc = tensor.desc();
+ ARM_COMPUTE_ERROR_ON(tensor_desc.target != Target::GC);
+
+ // Create backend tensor handle
+ TensorInfo info(tensor_desc.shape, 1, tensor_desc.data_type);
+ auto backend_tensor_handle = support::cpp14::make_unique<GCTensorHandle>(info);
+
+ return std::move(backend_tensor_handle);
+}
+
+std::unique_ptr<ITensorHandle> GCDeviceBackend::create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent)
+{
+ ARM_COMPUTE_UNUSED(parent, shape, coords, extend_parent);
+ ARM_COMPUTE_ERROR("GLES backend has no sub-tensor support!");
+ return nullptr;
+}
+
+std::unique_ptr<arm_compute::IFunction> GCDeviceBackend::configure_node(INode &node, GraphContext &ctx)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Configuring GC node with ID : " << node.id() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.assigned_target() != Target::GC);
+
+ // Configure node
+ return GCFunctionFactory::create(&node, ctx);
+}
+
+arm_compute::Status GCDeviceBackend::validate_node(INode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating GC node with ID : " << node.id() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.assigned_target() != Target::GC);
+
+ return GCNodeValidator::validate(&node);
+}
+
+std::shared_ptr<arm_compute::IMemoryManager> GCDeviceBackend::create_memory_manager(MemoryManagerAffinity affinity)
+{
+ if(affinity == MemoryManagerAffinity::Offset)
+ {
+ ARM_COMPUTE_LOG_GRAPH_WARNING("GC Backend does not support offset affinity memory management!");
+ return nullptr;
+ }
+
+ auto lifetime_mgr = std::make_shared<BlobLifetimeManager>();
+ auto pool_mgr = std::make_shared<PoolManager>();
+ auto mm = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr, pool_mgr);
+
+ mm->set_allocator(&_allocator);
+
+ return mm;
+}
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/graph2/backends/GLES/GCFunctionsFactory.cpp b/src/graph2/backends/GLES/GCFunctionsFactory.cpp
new file mode 100644
index 0000000000..24ab2bce37
--- /dev/null
+++ b/src/graph2/backends/GLES/GCFunctionsFactory.cpp
@@ -0,0 +1,507 @@
+/*
+ * 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.
+ */
+#include "arm_compute/graph2/backends/GLES/GCFunctionFactory.h"
+
+#include "arm_compute/core/utils/misc/Cast.h"
+#include "arm_compute/graph2/Graph.h"
+#include "arm_compute/graph2/GraphContext.h"
+#include "arm_compute/graph2/Logger.h"
+#include "arm_compute/graph2/TypePrinter.h"
+#include "arm_compute/graph2/Types.h"
+#include "arm_compute/graph2/backends/Utils.h"
+#include "arm_compute/graph2/nodes/Nodes.h"
+#include "arm_compute/runtime/GLES_COMPUTE/GCFunctions.h"
+
+#include "support/ToolchainSupport.h"
+
+using namespace arm_compute::utils::cast;
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+namespace
+{
+/** Returns backing tensor of a given tensor
+ *
+ * @param[in] tensor Tensor to extract the backing tensor from
+ *
+ * @return Backing tensor if present else nullptr
+ */
+arm_compute::IGCTensor *get_backing_tensor(arm_compute::graph2::Tensor *tensor)
+{
+ arm_compute::IGCTensor *backing_tensor = nullptr;
+ if(tensor != nullptr)
+ {
+ ARM_COMPUTE_ERROR_ON(tensor->desc().target != arm_compute::graph2::Target::GC);
+ // Get backing tensor handle
+ ITensorHandle *tensor_handle = tensor->handle();
+ // Get backing tensor
+ backing_tensor = (tensor_handle != nullptr) ? polymorphic_cast<IGCTensor *>(&tensor_handle->tensor()) : nullptr;
+ }
+
+ return backing_tensor;
+}
+
+/** Create a backend activation layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend activation layer function
+ */
+std::unique_ptr<IFunction> create_activation_layer(ActivationLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC ActivationLayerNode node with ID : " << node.id() << " and Name: " << node.name()
+ << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 1);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const ActivationLayerInfo act_info = node.activation_info();
+
+ // Create function
+ auto func = support::cpp14::make_unique<GCActivationLayer>();
+ func->configure(input, output, act_info);
+
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCActivationLayer"
+ << " Data Type: " << input->info()->data_type()
+ << " Shape: " << input->info()->tensor_shape()
+ << " Activation function: " << act_info.activation()
+ << " a: " << act_info.a()
+ << " b: " << act_info.b()
+ << " InPlace : " << is_in_place_operation(input, output)
+ << std::endl);
+
+ return std::move(func);
+}
+
+/** Create a backend batch normalization layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend batch normalization layer function
+ */
+std::unique_ptr<IFunction> create_batch_normalization_layer(BatchNormalizationLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating GC BatchNormalization node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+
+ // TODO (geopin01) : Var and mean are compulsory, switch function to accept nullptr as beta and/or gamma
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 5);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *mean = get_backing_tensor(node.input(1));
+ IGCTensor *var = get_backing_tensor(node.input(2));
+ IGCTensor *beta = get_backing_tensor(node.input(3));
+ IGCTensor *gamma = get_backing_tensor(node.input(4));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const float epsilon = node.epsilon();
+ const ActivationLayerInfo fused_act = node.fused_activation();
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<GCBatchNormalizationLayer>();
+ func->configure(input, output, mean, var, beta, gamma, epsilon, fused_act);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCBatchNormalizationLayer"
+ << " Data Type: " << input->info()->data_type()
+ << " Shape: " << input->info()->tensor_shape()
+ << " Epsilon: " << epsilon << " "
+ << (fused_act.enabled() ? to_string(fused_act.activation()) : "")
+ << " InPlace : " << is_in_place_operation(input, output)
+ << std::endl);
+
+ return std::move(func);
+}
+
+/** Create a backend convolution layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend convolution layer function
+ */
+std::unique_ptr<IFunction> create_convolution_layer(ConvolutionLayerNode &node, GraphContext &ctx)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating GC ConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 3);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *weights = get_backing_tensor(node.input(1));
+ IGCTensor *biases = get_backing_tensor(node.input(2));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const PadStrideInfo conv_info = node.convolution_info();
+ const ConvolutionMethod conv_algorithm = node.convolution_method();
+
+ // Create and configure function (we assume that functions have been validated before creation)
+ std::shared_ptr<IMemoryManager> mm = get_memory_manager(ctx, Target::GC);
+ std::unique_ptr<IFunction> func;
+ std::string func_name;
+
+ if(conv_algorithm == ConvolutionMethod::DIRECT)
+ {
+ std::tie(func, func_name) = create_named_function<GCDirectConvolutionLayer>(
+ std::string("GCDirectConvolutionLayer"), input, weights, biases, output, conv_info);
+ }
+ else
+ {
+ std::tie(func, func_name) = create_named_memory_managed_function<GCConvolutionLayer>(std::string("GCConvolutionLayer"), mm,
+ input, weights, biases, output, conv_info);
+ }
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << func_name
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Weights shape: " << weights->info()->tensor_shape()
+ << " Output shape: " << output->info()->tensor_shape()
+ << std::endl);
+ return func;
+}
+
+/** Create a backend layer depth concatenate function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend depth concatenate layer function
+ */
+std::unique_ptr<arm_compute::IFunction> create_depth_concatenate_layer(DepthConcatenateLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating GC DepthConcatenate node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Return nullptr if depth concatenate is switched off
+ if(!node.is_enabled())
+ {
+ return nullptr;
+ }
+
+ // Extract IO and info
+ std::vector<arm_compute::IGCTensor *> inputs;
+ for(unsigned int i = 0; i < node.num_inputs(); ++i)
+ {
+ inputs.push_back(get_backing_tensor(node.input(i)));
+ }
+ IGCTensor *output = get_backing_tensor(node.output(0));
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<GCDepthConcatenateLayer>();
+ func->configure(inputs, output);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCDepthConcatenateLayer"
+ << " Data Type: " << output->info()->data_type()
+ << " Shape: " << output->info()->tensor_shape()
+ << " Num Inputs: " << inputs.size()
+ << std::endl);
+
+ return std::move(func);
+}
+
+/** Create a backend layer depth-wise convolution function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend depth-wise convolution layer function
+ */
+std::unique_ptr<IFunction> create_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC DepthwiseConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name()
+ << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 3);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *weights = get_backing_tensor(node.input(1));
+ IGCTensor *biases = get_backing_tensor(node.input(2));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const PadStrideInfo conv_info = node.convolution_info();
+ const DepthwiseConvolutionMethod dwc_algorithm = node.depthwise_convolution_method();
+
+ // Create and configure function (we assume that functions have been validated before creation)
+ std::unique_ptr<IFunction> func;
+ std::string func_name;
+ if(dwc_algorithm == DepthwiseConvolutionMethod::OPTIMIZED_3x3)
+ {
+ std::tie(func, func_name) = create_named_function<GCDepthwiseConvolutionLayer3x3>(
+ std::string("GCDepthwiseConvolutionLayer3x3"), input, weights, biases, output, conv_info);
+ }
+ else
+ {
+ ARM_COMPUTE_ERROR("Generic DepthwiseConvolutionLayer is not supported in GLES backend");
+ }
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << func_name
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Weights shape: " << weights->info()->tensor_shape()
+ << " Output shape: " << output->info()->tensor_shape()
+ << std::endl);
+ return func;
+}
+
+/** Create a backend element-wise operation layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend element-wise operation layer function
+ */
+std::unique_ptr<IFunction> create_eltwise_layer(EltwiseLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 2);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input1 = get_backing_tensor(node.input(0));
+ IGCTensor *input2 = get_backing_tensor(node.input(1));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const EltwiseOperation eltwise_op = node.eltwise_operation();
+ ARM_COMPUTE_ERROR_ON(input1 == nullptr);
+ ARM_COMPUTE_ERROR_ON(input2 == nullptr);
+ ARM_COMPUTE_ERROR_ON(output == nullptr);
+
+ std::unique_ptr<IFunction> func = nullptr;
+ std::string func_name;
+ if(eltwise_op == EltwiseOperation::ADD)
+ {
+ std::tie(func, func_name) = create_named_function<GCArithmeticAddition>(std::string("GCArithmeticAddition"),
+ input1, input2, output,
+ ConvertPolicy::SATURATE);
+ }
+ else if(eltwise_op == EltwiseOperation::SUB)
+ {
+ ARM_COMPUTE_ERROR("Arithmetic subtraction is not supported in GLES backend");
+ }
+ else if(eltwise_op == EltwiseOperation::MUL)
+ {
+ std::tie(func, func_name) = create_named_function<GCPixelWiseMultiplication>(
+ std::string("GCPixelWiseMultiplication"), input1, input2, output, 1.f);
+ }
+ else
+ {
+ ARM_COMPUTE_ERROR("Unsupported element-wise operation!");
+ }
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << func_name
+ << " Data Type: " << input1->info()->data_type()
+ << " Shape : " << input1->info()->tensor_shape()
+ << std::endl);
+
+ return func;
+}
+
+/** Create a backend fully connected layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend fully connected layer function
+ */
+std::unique_ptr<IFunction> create_fully_connected_layer(FullyConnectedLayerNode &node, GraphContext &ctx)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC FullyConnectedLayer node with ID : " << node.id() << " and Name: " << node.name()
+ << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 3);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *weights = get_backing_tensor(node.input(1));
+ IGCTensor *biases = get_backing_tensor(node.input(2));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<GCFullyConnectedLayer>(get_memory_manager(ctx, Target::GC));
+ func->configure(input, weights, biases, output);
+ ARM_COMPUTE_ERROR_ON(input == nullptr);
+ ARM_COMPUTE_ERROR_ON(weights == nullptr);
+ ARM_COMPUTE_ERROR_ON(output == nullptr);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCFullyConnectedLayer"
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Weights shape: " << weights->info()->tensor_shape()
+ << " Biases Shape: " << biases->info()->tensor_shape()
+ << " Output shape: " << output->info()->tensor_shape()
+ << std::endl);
+
+ return std::move(func);
+}
+
+/** Create a backend normalization layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend normalization layer function
+ */
+std::unique_ptr<IFunction> create_normalization_layer(NormalizationLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC NormalizationLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 1);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const NormalizationLayerInfo norm_info = node.normalization_info();
+ ARM_COMPUTE_ERROR_ON(input == nullptr);
+ ARM_COMPUTE_ERROR_ON(output == nullptr);
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<GCNormalizationLayer>();
+ func->configure(input, output, norm_info);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCNormalizationLayer"
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Output shape: " << output->info()->tensor_shape()
+ << " Normalization info: " << norm_info.type()
+ << std::endl);
+
+ return std::move(func);
+}
+
+/** Create a backend pooling layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend pooling layer function
+ */
+std::unique_ptr<IFunction> create_pooling_layer(PoolingLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC PoolingLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 1);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const PoolingLayerInfo pool_info = node.pooling_info();
+ ARM_COMPUTE_ERROR_ON(input == nullptr);
+ ARM_COMPUTE_ERROR_ON(output == nullptr);
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<GCPoolingLayer>();
+ func->configure(input, output, pool_info);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCPoolingLayer"
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Output shape: " << output->info()->tensor_shape()
+ << " Pooling info: " << pool_info.pool_type()
+ << std::endl);
+
+ return std::move(func);
+}
+
+/** Create a backend softmax layer function
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend softmax layer function
+ */
+std::unique_ptr<IFunction> create_softmax_layer(SoftmaxLayerNode &node, GraphContext &ctx)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE(
+ "Creating GC SoftmaxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_ERROR_ON(node.num_inputs() != 1);
+ ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ IGCTensor *input = get_backing_tensor(node.input(0));
+ IGCTensor *output = get_backing_tensor(node.output(0));
+ const float beta = node.beta();
+ ARM_COMPUTE_ERROR_ON(input == nullptr);
+ ARM_COMPUTE_ERROR_ON(output == nullptr);
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<GCSoftmaxLayer>(get_memory_manager(ctx, Target::CL));
+ func->configure(input, output, beta);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated GCSoftmaxLayer"
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Output shape: " << output->info()->tensor_shape()
+ << std::endl);
+
+ return std::move(func);
+}
+} // namespace
+
+std::unique_ptr<IFunction> GCFunctionFactory::create(INode *node, GraphContext &ctx)
+{
+ if(node == nullptr)
+ {
+ return nullptr;
+ }
+
+ NodeType type = node->type();
+ switch(type)
+ {
+ case NodeType::ActivationLayer:
+ return create_activation_layer(*polymorphic_downcast<ActivationLayerNode *>(node));
+ case NodeType::BatchNormalizationLayer:
+ return create_batch_normalization_layer(*polymorphic_downcast<BatchNormalizationLayerNode *>(node));
+ case NodeType::ConvolutionLayer:
+ return create_convolution_layer(*polymorphic_downcast<ConvolutionLayerNode *>(node), ctx);
+ case NodeType::DepthConcatenateLayer:
+ return create_depth_concatenate_layer(*polymorphic_downcast<DepthConcatenateLayerNode *>(node));
+ case NodeType::DepthwiseConvolutionLayer:
+ return create_depthwise_convolution_layer(*polymorphic_downcast<DepthwiseConvolutionLayerNode *>(node));
+ case NodeType::EltwiseLayer:
+ return create_eltwise_layer(*polymorphic_downcast<EltwiseLayerNode *>(node));
+ case NodeType::FullyConnectedLayer:
+ return create_fully_connected_layer(*polymorphic_downcast<FullyConnectedLayerNode *>(node), ctx);
+ case NodeType::NormalizationLayer:
+ return create_normalization_layer(*polymorphic_downcast<NormalizationLayerNode *>(node));
+ case NodeType::PoolingLayer:
+ return create_pooling_layer(*polymorphic_downcast<PoolingLayerNode *>(node));
+ case NodeType::SoftmaxLayer:
+ return create_softmax_layer(*polymorphic_downcast<SoftmaxLayerNode *>(node), ctx);
+ default:
+ return nullptr;
+ }
+}
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/graph2/backends/GLES/GCNodeValidator.cpp b/src/graph2/backends/GLES/GCNodeValidator.cpp
new file mode 100644
index 0000000000..b8daae566d
--- /dev/null
+++ b/src/graph2/backends/GLES/GCNodeValidator.cpp
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+#include "arm_compute/graph2/backends/GLES/GCNodeValidator.h"
+
+#include "arm_compute/graph2/backends/ValidateHelpers.h"
+#include "arm_compute/graph2/nodes/Nodes.h"
+
+#include "arm_compute/core/utils/misc/Cast.h"
+#include "arm_compute/runtime/GLES_COMPUTE/GCFunctions.h"
+
+using namespace arm_compute::utils::cast;
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+namespace
+{
+/** Validates a Depthwise Convolution layer node
+ *
+ * @param[in] node Node to validate
+ *
+ * @return Status
+ */
+Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating GCDepthwiseConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3);
+ ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ arm_compute::ITensorInfo *weights = detail::get_backing_tensor_info(node.input(1));
+ ARM_COMPUTE_ERROR_ON(weights == nullptr);
+
+ // TODO (geopin01) : Switch when validation is implemented
+ // Validate function
+ ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->tensor_shape().x() != 3 && weights->tensor_shape().y() != 3, "Unsupported depthwise convolution");
+ node.set_depthwise_convolution_method(DepthwiseConvolutionMethod::OPTIMIZED_3x3);
+
+ return Status{};
+}
+/** Validates a Convolution layer node
+ *
+ * @param[in] node Node to validate
+ *
+ * @return Status
+ */
+Status validate_convolution_layer(ConvolutionLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3);
+ ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1);
+
+ // Extract IO and info
+ arm_compute::ITensorInfo *weights = detail::get_backing_tensor_info(node.input(1));
+ const PadStrideInfo conv_info = node.convolution_info();
+ const ConvolutionMethod conv_algorithm = node.convolution_method();
+
+ // Validate function
+ if(conv_algorithm == ConvolutionMethod::DIRECT)
+ {
+ bool is_square = weights->tensor_shape().x() == weights->tensor_shape().y();
+ bool is_direct = (weights->tensor_shape().x() == 1) || (weights->tensor_shape().x() == 3) || (weights->tensor_shape().x() == 5);
+ bool is_correct_stride = (conv_info.stride().first) <= 2 && (conv_info.stride().second <= 2);
+ if(!(is_square && is_direct && is_correct_stride))
+ {
+ node.set_convolution_method(ConvolutionMethod::DEFAULT);
+ }
+ }
+
+ return Status{};
+}
+} // namespace
+
+Status GCNodeValidator::validate(INode *node)
+{
+ if(node == nullptr)
+ {
+ return Status{};
+ }
+
+ NodeType type = node->type();
+ switch(type)
+ {
+ case NodeType::ConvolutionLayer:
+ return validate_convolution_layer(*polymorphic_downcast<ConvolutionLayerNode *>(node));
+ case NodeType::DepthwiseConvolutionLayer:
+ return validate_depthwise_convolution_layer(*polymorphic_downcast<DepthwiseConvolutionLayerNode *>(node));
+ case NodeType::FlattenLayer:
+ return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation");
+ case NodeType::ReshapeLayer:
+ return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation");
+ default:
+ return Status{};
+ }
+}
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/graph2/backends/GLES/GCTensorHandle.cpp b/src/graph2/backends/GLES/GCTensorHandle.cpp
new file mode 100644
index 0000000000..aa9ac8c2e9
--- /dev/null
+++ b/src/graph2/backends/GLES/GCTensorHandle.cpp
@@ -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.
+ */
+#include "arm_compute/graph2/backends/GLES/GCTensorHandle.h"
+
+namespace arm_compute
+{
+namespace graph2
+{
+namespace backends
+{
+GCTensorHandle::GCTensorHandle(const ITensorInfo &info)
+ : _tensor()
+{
+ _tensor.allocator()->init(info);
+}
+
+void GCTensorHandle::allocate()
+{
+ _tensor.allocator()->allocate();
+}
+
+const arm_compute::ITensor &GCTensorHandle::tensor() const
+{
+ return _tensor;
+}
+
+arm_compute::ITensor &GCTensorHandle::tensor()
+{
+ return _tensor;
+}
+
+void GCTensorHandle::map(bool blocking)
+{
+ _tensor.map(blocking);
+}
+
+void GCTensorHandle::unmap()
+{
+ _tensor.unmap();
+}
+
+bool GCTensorHandle::is_subtensor() const
+{
+ return false;
+}
+} // namespace backends
+} // namespace graph2
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/graph2/detail/ExecutionHelpers.cpp b/src/graph2/detail/ExecutionHelpers.cpp
index 48588f1361..ae214ad5a6 100644
--- a/src/graph2/detail/ExecutionHelpers.cpp
+++ b/src/graph2/detail/ExecutionHelpers.cpp
@@ -87,7 +87,8 @@ void validate_all_nodes(Graph &g)
Target assigned_target = node->assigned_target();
auto backend = backends::BackendRegistry::get().find_backend(assigned_target);
ARM_COMPUTE_ERROR_ON_MSG(!backend, "Requested backend doesn't exist!");
- backend->validate_node(*node);
+ Status status = backend->validate_node(*node);
+ ARM_COMPUTE_ERROR_ON_MSG(!bool(status), status.error_description().c_str());
}
}
}
diff --git a/src/graph2/frontend/Stream.cpp b/src/graph2/frontend/Stream.cpp
index 3386d6547f..4e794f28df 100644
--- a/src/graph2/frontend/Stream.cpp
+++ b/src/graph2/frontend/Stream.cpp
@@ -39,7 +39,7 @@ Stream::Stream(size_t id, std::string name)
void Stream::finalize(Target target, const GraphConfig &config)
{
- PassManager pm = create_default_pass_manager();
+ PassManager pm = create_default_pass_manager(target);
_ctx.set_config(config);
_manager.finalize_graph(_g, _ctx, pm, target);
}
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h
index 1ae11f6a7b..e70a1a275f 100644
--- a/utils/GraphUtils.h
+++ b/utils/GraphUtils.h
@@ -326,12 +326,16 @@ inline std::unique_ptr<graph::ITensorAccessor> get_output_accessor(const std::st
*/
inline graph2::Target set_target_hint2(int target)
{
- ARM_COMPUTE_ERROR_ON_MSG(target > 2, "Invalid target. Target must be 0 (NEON) or 1 (OpenCL)");
+ ARM_COMPUTE_ERROR_ON_MSG(target > 3, "Invalid target. Target must be 0 (NEON), 1 (OpenCL), 2 (OpenCL + Tuner), 3 (GLES)");
if((target == 1 || target == 2) && arm_compute::opencl_is_available())
{
// If type of target is OpenCL, check if OpenCL is available and initialize the scheduler
return graph2::Target::CL;
}
+ else if(target == 3)
+ {
+ return graph2::Target::GC;
+ }
else
{
return graph2::Target::NEON;