aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-10-02 18:51:47 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commite2c82fee3b6d38f6e79412c78176792b817defd0 (patch)
treeaa6821e33cfe8001c33086191c81c18d66ac7837 /arm_compute
parent48a60f9f7b0b7b5cf38253b7a2ac576aac43ef78 (diff)
downloadComputeLibrary-e2c82fee3b6d38f6e79412c78176792b817defd0.tar.gz
COMPMID-550: Adds support for branches.
Change-Id: I778007c9221ce3156400284c4039b90245eb2b7f Reviewed-on: http://mpd-gerrit.cambridge.arm.com/90043 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/core/SubTensorInfo.h14
-rw-r--r--arm_compute/graph/CL/CLMap.h10
-rw-r--r--arm_compute/graph/CL/CLUnmap.h8
-rw-r--r--arm_compute/graph/Graph.h12
-rw-r--r--arm_compute/graph/INode.h3
-rw-r--r--arm_compute/graph/ITensorObject.h75
-rw-r--r--arm_compute/graph/Nodes.h1
-rw-r--r--arm_compute/graph/SubGraph.h94
-rw-r--r--arm_compute/graph/SubTensor.h42
-rw-r--r--arm_compute/graph/Tensor.h43
-rw-r--r--arm_compute/graph/Types.h25
-rw-r--r--arm_compute/graph/nodes/ActivationLayer.h4
-rw-r--r--arm_compute/graph/nodes/BatchNormalizationLayer.h3
-rw-r--r--arm_compute/graph/nodes/BranchLayer.h77
-rw-r--r--arm_compute/graph/nodes/ConvolutionLayer.h3
-rw-r--r--arm_compute/graph/nodes/DepthConcatenateLayer.h58
-rw-r--r--arm_compute/graph/nodes/FloorLayer.h4
-rw-r--r--arm_compute/graph/nodes/FullyConnectedLayer.h3
-rw-r--r--arm_compute/graph/nodes/L2NormalizeLayer.h4
-rw-r--r--arm_compute/graph/nodes/NormalizationLayer.h3
-rw-r--r--arm_compute/graph/nodes/PoolingLayer.h4
-rw-r--r--arm_compute/graph/nodes/SoftmaxLayer.h7
22 files changed, 404 insertions, 93 deletions
diff --git a/arm_compute/core/SubTensorInfo.h b/arm_compute/core/SubTensorInfo.h
index 54fb66a573..81a27026e7 100644
--- a/arm_compute/core/SubTensorInfo.h
+++ b/arm_compute/core/SubTensorInfo.h
@@ -61,6 +61,14 @@ public:
SubTensorInfo(SubTensorInfo &&) = default;
/** Allow instances of this class to be moved */
SubTensorInfo &operator=(SubTensorInfo &&) = default;
+ /** Returns the coordinates of the sub-tensor inside the parent tensor
+ *
+ * @return Sub-tensor coordinates
+ */
+ Coordinates coords() const
+ {
+ return _coords;
+ }
// Inherited methods overridden:
void set_data_type(DataType data_type) override
@@ -171,7 +179,11 @@ public:
void set_valid_region(ValidRegion valid_region) override
{
ARM_COMPUTE_ERROR_ON(_parent == nullptr);
- ARM_COMPUTE_ERROR_ON_INVALID_SUBTENSOR_VALID_REGION(_parent->valid_region(), valid_region);
+ // Check if subtensor is valid if parent is configured
+ if(_parent->tensor_shape().total_size() != 0)
+ {
+ ARM_COMPUTE_ERROR_ON_INVALID_SUBTENSOR_VALID_REGION(_parent->valid_region(), valid_region);
+ }
_valid_region = std::move(valid_region);
}
diff --git a/arm_compute/graph/CL/CLMap.h b/arm_compute/graph/CL/CLMap.h
index a205ebcad1..732a1df77f 100644
--- a/arm_compute/graph/CL/CLMap.h
+++ b/arm_compute/graph/CL/CLMap.h
@@ -29,11 +29,11 @@
namespace arm_compute
{
-class CLTensor;
+class ICLTensor;
namespace graph
{
-class Tensor;
+class ITensorObject;
/** OpenCL map function */
class CLMap : public arm_compute::IFunction
{
@@ -43,7 +43,7 @@ public:
* @param[in] tensor Tensor to map
* @param[in] blocking Flag to specify if the map should be blocking or not (defaults to false)
*/
- CLMap(Tensor *tensor, bool blocking = false);
+ CLMap(ITensorObject *tensor, bool blocking = false);
/** Prevent instances from being copy constructed */
CLMap(const CLMap &) = delete;
/** Prevent instances from being copy assigned */
@@ -57,8 +57,8 @@ public:
void run() override;
private:
- arm_compute::CLTensor *_tensor; /**< Tensor */
- bool _blocking; /**< Blocking flag */
+ arm_compute::ICLTensor *_tensor; /**< Tensor */
+ bool _blocking; /**< Blocking flag */
};
} // namespace graph
} // namespace arm_compute
diff --git a/arm_compute/graph/CL/CLUnmap.h b/arm_compute/graph/CL/CLUnmap.h
index a72706353b..17745c436b 100644
--- a/arm_compute/graph/CL/CLUnmap.h
+++ b/arm_compute/graph/CL/CLUnmap.h
@@ -29,11 +29,11 @@
namespace arm_compute
{
-class CLTensor;
+class ICLTensor;
namespace graph
{
-class Tensor;
+class ITensorObject;
/** OpenCL un-map function */
class CLUnmap : public arm_compute::IFunction
{
@@ -42,7 +42,7 @@ public:
*
* @param[in] tensor Tensor to un-map
*/
- CLUnmap(Tensor *tensor);
+ CLUnmap(ITensorObject *tensor);
/** Prevent instances from being copy constructed */
CLUnmap(const CLUnmap &) = delete;
/** Prevent instances from being copy assigned */
@@ -56,7 +56,7 @@ public:
void run() override;
private:
- arm_compute::CLTensor *_tensor; /**< Tensor */
+ arm_compute::ICLTensor *_tensor; /**< Tensor */
};
} // namespace graph
} // namespace arm_compute
diff --git a/arm_compute/graph/Graph.h b/arm_compute/graph/Graph.h
index 9d06f44bee..4afe96b40b 100644
--- a/arm_compute/graph/Graph.h
+++ b/arm_compute/graph/Graph.h
@@ -25,6 +25,8 @@
#define __ARM_COMPUTE_GRAPH_GRAPH_H__
#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
+#include "arm_compute/graph/SubTensor.h"
#include "arm_compute/graph/Tensor.h"
#include "arm_compute/graph/Types.h"
#include "support/ToolchainSupport.h"
@@ -64,7 +66,7 @@ public:
*
* @param[in] tensor Tensor to add
*/
- void add_tensor(std::unique_ptr<Tensor> tensor);
+ void add_tensor_object(std::unique_ptr<ITensorObject> tensor);
/** Manually sets the output of the current node
*
* @param[in] tmp Output info to set
@@ -98,6 +100,14 @@ Graph &operator<<(Graph &graph, TensorInfo &&info);
* @return Updated graph
*/
Graph &operator<<(Graph &graph, Tensor &&tensor);
+/** Overloaded stream operator to add a sub-tensor to the graph
+ *
+ * @param[in, out] graph Graph to add the tensor
+ * @param[in] sub_tensor Sub-tensor to be added
+ *
+ * @return Updated graph
+ */
+Graph &operator<<(Graph &graph, SubTensor &&sub_tensor);
/** Overloaded stream operator to provide a target hint to the graph
*
* @param[in, out] graph Graph to provide the hint to
diff --git a/arm_compute/graph/INode.h b/arm_compute/graph/INode.h
index 1b22bdf639..56b50b9424 100644
--- a/arm_compute/graph/INode.h
+++ b/arm_compute/graph/INode.h
@@ -25,6 +25,7 @@
#define __ARM_COMPUTE_GRAPH_INODE_H__
#include "arm_compute/graph/GraphContext.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
#include "arm_compute/runtime/IFunction.h"
@@ -46,7 +47,7 @@ public:
* @param[in] input Input tensor of the node
* @param[in] output Output tensor of the node
*/
- virtual std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) = 0;
+ virtual std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) = 0;
/** Override the existing target hint
*
* @note If the input is DONT_CARE then the method has to pick a technology,
diff --git a/arm_compute/graph/ITensorObject.h b/arm_compute/graph/ITensorObject.h
new file mode 100644
index 0000000000..61be2865c7
--- /dev/null
+++ b/arm_compute/graph/ITensorObject.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017 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_GRAPH_ITENSOROBJECT_H__
+#define __ARM_COMPUTE_GRAPH_ITENSOROBJECT_H__
+
+#include "arm_compute/graph/ITensorAccessor.h"
+#include "arm_compute/graph/Types.h"
+#include "support/ToolchainSupport.h"
+
+#include <memory>
+
+namespace arm_compute
+{
+namespace graph
+{
+/** Tensor object interface */
+class ITensorObject
+{
+public:
+ /** Default Destructor */
+ virtual ~ITensorObject() = default;
+ /** Calls accessor on tensor
+ *
+ * @return True if succeeds else false
+ */
+ virtual bool call_accessor() = 0;
+ /** Checks if tensor has an accessor set.
+ *
+ * @return True if an accessor has been set else false
+ */
+ virtual bool has_accessor() const = 0;
+ /** Sets target of the tensor
+ *
+ * @param[in] target Target where the tensor should be pinned in
+ *
+ * @return Backend tensor
+ */
+ virtual ITensor *set_target(TargetHint target) = 0;
+ /** Returns a pointer to the internal tensor
+ *
+ * @return Tensor
+ */
+ virtual ITensor *tensor() = 0;
+ /** Return the target that this tensor is pinned on
+ *
+ * @return Target of the tensor
+ */
+ virtual TargetHint target() const = 0;
+ /** Allocates the tensor */
+ virtual void allocate() = 0;
+};
+} // namespace graph
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH_ITENSOROBJECT_H__ */
diff --git a/arm_compute/graph/Nodes.h b/arm_compute/graph/Nodes.h
index 548deabeb6..d1ed715ae8 100644
--- a/arm_compute/graph/Nodes.h
+++ b/arm_compute/graph/Nodes.h
@@ -26,6 +26,7 @@
#include "arm_compute/graph/nodes/ActivationLayer.h"
#include "arm_compute/graph/nodes/BatchNormalizationLayer.h"
+#include "arm_compute/graph/nodes/BranchLayer.h"
#include "arm_compute/graph/nodes/ConvolutionLayer.h"
#include "arm_compute/graph/nodes/FloorLayer.h"
#include "arm_compute/graph/nodes/FullyConnectedLayer.h"
diff --git a/arm_compute/graph/SubGraph.h b/arm_compute/graph/SubGraph.h
new file mode 100644
index 0000000000..d768bf9119
--- /dev/null
+++ b/arm_compute/graph/SubGraph.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2017 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_GRAPH_SUBGRAPH_H__
+#define __ARM_COMPUTE_GRAPH_SUBGRAPH_H__
+
+#include "arm_compute/graph/Graph.h"
+#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
+#include "arm_compute/graph/SubTensor.h"
+#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/Types.h"
+#include "arm_compute/runtime/IFunction.h"
+
+#include <memory>
+
+namespace arm_compute
+{
+namespace graph
+{
+/** SubGraph class */
+class SubGraph
+{
+public:
+ /** Constructor */
+ SubGraph();
+ /** Adds a node to the graph
+ *
+ * @param[in] node Node to add
+ */
+ void add_node(std::unique_ptr<INode> node);
+ /** Adds a tensor to the graph
+ *
+ * @param[in] tensor Tensor to add
+ */
+ void add_tensor_object(std::unique_ptr<ITensorObject> tensor);
+ /** Constructs a graph from a subgraph
+ *
+ * @param[in] hint Execution target hint
+ * @param[in] input Input to the graph
+ * @param[in] output Output to the graph
+ *
+ * @return A graph
+ */
+ std::unique_ptr<Graph> construct(TargetHint hint, std::unique_ptr<ITensorObject> input, std::unique_ptr<ITensorObject> output);
+ /** Checks if the subgraph has an input
+ *
+ * @return True if the sub-graph has an input else false
+ */
+ bool has_input() const;
+ /** Checks if the subgraph has an output
+ *
+ * @return True if the sub-graph has an output else false
+ */
+ bool has_output() const;
+
+private:
+ std::vector<std::unique_ptr<INode>> _nodes;
+ std::unique_ptr<ITensorObject> _input;
+ std::unique_ptr<ITensorObject> _output;
+};
+
+SubGraph &operator<<(SubGraph &graph, Tensor &&tensor);
+SubGraph &operator<<(SubGraph &graph, SubTensor &&sub_tensor);
+
+template <typename Node>
+SubGraph &operator<<(SubGraph &sub_graph, Node node)
+{
+ sub_graph.add_node(arm_compute::support::cpp14::make_unique<Node>(std::move(node)));
+ return sub_graph;
+}
+} // namespace graph
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH_INODE_H__ */
diff --git a/arm_compute/graph/SubTensor.h b/arm_compute/graph/SubTensor.h
index ace93d20a3..22a0a9e27f 100644
--- a/arm_compute/graph/SubTensor.h
+++ b/arm_compute/graph/SubTensor.h
@@ -25,6 +25,7 @@
#define __ARM_COMPUTE_GRAPH_SUBTENSOR_H__
#include "arm_compute/graph/ITensorAccessor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Tensor.h"
#include "arm_compute/graph/Types.h"
#include "support/ToolchainSupport.h"
@@ -36,7 +37,7 @@ namespace arm_compute
namespace graph
{
/** SubTensor class */
-class SubTensor final
+class SubTensor final : public ITensorObject
{
public:
/** Default Constructor */
@@ -55,7 +56,7 @@ public:
* @param[in] coords Starting coordinates of the sub-tensor in the parent tensor
* @param[in] target Execution target
*/
- SubTensor(ITensor *parent, TensorShape tensor_shape, Coordinates coords, TargetHint target);
+ SubTensor(arm_compute::ITensor *parent, TensorShape tensor_shape, Coordinates coords, TargetHint target);
/** Prevent instances of this class from being copied (As this class contains pointers) */
SubTensor(const SubTensor &) = delete;
/** Prevent instances of this class from being copied (As this class contains pointers) */
@@ -67,37 +68,24 @@ public:
/** Default Destructor */
~SubTensor() = default;
- /** Sets the given TensorInfo to the tensor
- *
- * @param[in] info TensorInfo to set
- */
- void set_info(SubTensorInfo &&info);
- /** Returns tensor's TensorInfo
- *
- * @return TensorInfo of the tensor
- */
- const SubTensorInfo &info() const;
- /** Returns a pointer to the internal tensor
- *
- * @return Tensor
- */
- ITensor *tensor();
- /** Return the target that this tensor is pinned on
- *
- * @return Target of the tensor
- */
- TargetHint target() const;
+ // Inherited methods overriden:
+ bool call_accessor() override;
+ bool has_accessor() const override;
+ arm_compute::ITensor *set_target(TargetHint target) override;
+ arm_compute::ITensor *tensor() override;
+ TargetHint target() const override;
+ void allocate() override;
private:
/** Instantiates a sub-tensor */
void instantiate_subtensor();
private:
- TargetHint _target; /**< Target that this tensor is pinned on */
- Coordinates _coords; /**< SubTensor Coordinates */
- SubTensorInfo _info; /**< SubTensor metadata */
- ITensor *_parent; /**< Parent tensor */
- std::unique_ptr<ITensor> _subtensor; /**< SubTensor */
+ TargetHint _target; /**< Target that this tensor is pinned on */
+ TensorShape _tensor_shape; /**< SubTensor shape */
+ Coordinates _coords; /**< SubTensor Coordinates */
+ arm_compute::ITensor *_parent; /**< Parent tensor */
+ std::unique_ptr<arm_compute::ITensor> _subtensor; /**< SubTensor */
};
} // namespace graph
} // namespace arm_compute
diff --git a/arm_compute/graph/Tensor.h b/arm_compute/graph/Tensor.h
index 9fdd56db6e..dcb0c661d6 100644
--- a/arm_compute/graph/Tensor.h
+++ b/arm_compute/graph/Tensor.h
@@ -25,6 +25,7 @@
#define __ARM_COMPUTE_GRAPH_TENSOR_H__
#include "arm_compute/graph/ITensorAccessor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
#include "support/ToolchainSupport.h"
@@ -35,7 +36,7 @@ namespace arm_compute
namespace graph
{
/** Tensor class */
-class Tensor
+class Tensor final : public ITensorObject
{
public:
/** Constructor
@@ -84,43 +85,27 @@ public:
* @param[in] info TensorInfo to set
*/
void set_info(TensorInfo &&info);
- /** Calls accessor on tensor
- *
- * @return True if succeeds else false
- */
- bool call_accessor();
- /** Sets target of the tensor
- *
- * @param[in] target Target where the tensor should be pinned in
- *
- * @return
- */
- ITensor *set_target(TargetHint target);
/** Returns tensor's TensorInfo
*
* @return TensorInfo of the tensor
*/
const TensorInfo &info() const;
- /** Returns a pointer to the internal tensor
- *
- * @return Tensor
- */
- ITensor *tensor();
/** Allocates and fills the tensor if needed */
void allocate_and_fill_if_needed();
- /** Allocates the tensor */
- void allocate();
- /** Return the target that this tensor is pinned on
- *
- * @return Target of the tensor
- */
- TargetHint target() const;
+
+ // Inherited methods overriden:
+ bool call_accessor() override;
+ bool has_accessor() const override;
+ arm_compute::ITensor *set_target(TargetHint target) override;
+ arm_compute::ITensor *tensor() override;
+ TargetHint target() const override;
+ void allocate() override;
private:
- TargetHint _target; /**< Target that this tensor is pinned on */
- TensorInfo _info; /**< Tensor metadata */
- std::unique_ptr<ITensorAccessor> _accessor; /**< Tensor Accessor */
- std::unique_ptr<ITensor> _tensor; /**< Tensor */
+ TargetHint _target; /**< Target that this tensor is pinned on */
+ TensorInfo _info; /**< Tensor metadata */
+ std::unique_ptr<ITensorAccessor> _accessor; /**< Tensor Accessor */
+ std::unique_ptr<arm_compute::ITensor> _tensor; /**< Tensor */
};
} // namespace graph
} // namespace arm_compute
diff --git a/arm_compute/graph/Types.h b/arm_compute/graph/Types.h
index e48ff84abf..c4396412a7 100644
--- a/arm_compute/graph/Types.h
+++ b/arm_compute/graph/Types.h
@@ -32,19 +32,20 @@ namespace arm_compute
{
namespace graph
{
-using arm_compute::ITensor;
-using arm_compute::TensorInfo;
-using arm_compute::SubTensorInfo;
-using arm_compute::DataType;
-using arm_compute::Coordinates;
-using arm_compute::TensorShape;
-using arm_compute::PadStrideInfo;
-using arm_compute::WeightsInfo;
using arm_compute::ActivationLayerInfo;
+using arm_compute::Coordinates;
+using arm_compute::DataType;
+using arm_compute::DimensionRoundingType;
+using arm_compute::ITensorInfo;
using arm_compute::NormType;
using arm_compute::NormalizationLayerInfo;
+using arm_compute::PadStrideInfo;
using arm_compute::PoolingLayerInfo;
using arm_compute::PoolingType;
+using arm_compute::SubTensorInfo;
+using arm_compute::TensorInfo;
+using arm_compute::TensorShape;
+using arm_compute::WeightsInfo;
/**< Execution hint to the graph executor */
enum class TargetHint
@@ -54,12 +55,18 @@ enum class TargetHint
NEON /**< Run node on a NEON capable device */
};
-/**< Convolution method hint to the graph executor */
+/** Convolution method hint to the graph executor */
enum class ConvolutionMethodHint
{
GEMM, /**< Convolution using GEMM */
DIRECT /**< Direct convolution */
};
+
+/** Branch layer merging method */
+enum class BranchMergeMethod
+{
+ DEPTH_CONCATENATE /**< Concatenate across depth */
+};
} // namespace graph
} // namespace arm_compute
#endif /*__ARM_COMPUTE_GRAPH_TYPES_H__*/
diff --git a/arm_compute/graph/nodes/ActivationLayer.h b/arm_compute/graph/nodes/ActivationLayer.h
index efe8112e77..bc619a8df9 100644
--- a/arm_compute/graph/nodes/ActivationLayer.h
+++ b/arm_compute/graph/nodes/ActivationLayer.h
@@ -26,7 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
-#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
namespace arm_compute
@@ -44,7 +44,7 @@ public:
ActivationLayer(const ActivationLayerInfo activation_info);
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
private:
const ActivationLayerInfo _activation_info; /**< Activation layer info */
diff --git a/arm_compute/graph/nodes/BatchNormalizationLayer.h b/arm_compute/graph/nodes/BatchNormalizationLayer.h
index f01cac2361..df7b1d19a9 100644
--- a/arm_compute/graph/nodes/BatchNormalizationLayer.h
+++ b/arm_compute/graph/nodes/BatchNormalizationLayer.h
@@ -26,6 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Tensor.h"
#include "arm_compute/graph/Types.h"
@@ -52,7 +53,7 @@ public:
}
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
private:
Tensor _mean;
diff --git a/arm_compute/graph/nodes/BranchLayer.h b/arm_compute/graph/nodes/BranchLayer.h
new file mode 100644
index 0000000000..3d13f5f2d3
--- /dev/null
+++ b/arm_compute/graph/nodes/BranchLayer.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 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_GRAPH_BRANCH_LAYER_H__
+#define __ARM_COMPUTE_GRAPH_BRANCH_LAYER_H__
+
+#include "arm_compute/graph/GraphContext.h"
+#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
+#include "arm_compute/graph/SubGraph.h"
+#include "arm_compute/graph/SubTensor.h"
+#include "arm_compute/graph/Types.h"
+
+#include "arm_compute/core/Helpers.h"
+
+#include <vector>
+
+namespace arm_compute
+{
+namespace graph
+{
+/** Branch Layer node */
+class BranchLayer final : public INode
+{
+public:
+ /** Default Constructor
+ *
+ * @param[in] merge_method Branch merging method
+ * @param[in] sub_graph1 First graph branch
+ * @param[in] sub_graph2 Second graph branch
+ * @param[in] rest_sub_graphs Rest sub-graph branches
+ */
+ template <typename... Ts>
+ BranchLayer(BranchMergeMethod merge_method, SubGraph &&sub_graph1, SubGraph &&sub_graph2, Ts &&... rest_sub_graphs)
+ : _branch_merge_method(merge_method), _sub_graphs()
+ {
+ /* TODO:(geopin01) Use traits to make sure variadic arguments are of SubGraph type */
+ _sub_graphs.push_back(arm_compute::support::cpp14::make_unique<SubGraph>(std::move(sub_graph1)));
+ _sub_graphs.push_back(arm_compute::support::cpp14::make_unique<SubGraph>(std::move(sub_graph2)));
+
+ for_each([&](SubGraph & sub_graph)
+ {
+ _sub_graphs.push_back(arm_compute::support::cpp14::make_unique<SubGraph>(std::move(sub_graph)));
+ },
+ std::move(rest_sub_graphs)...);
+ }
+
+ // Inherited methods overriden:
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
+
+private:
+ BranchMergeMethod _branch_merge_method;
+ std::vector<std::unique_ptr<SubGraph>> _sub_graphs;
+};
+} // namespace graph
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH_BRANCH_LAYER_H__ */
diff --git a/arm_compute/graph/nodes/ConvolutionLayer.h b/arm_compute/graph/nodes/ConvolutionLayer.h
index 04ba3dd6b7..0905524de8 100644
--- a/arm_compute/graph/nodes/ConvolutionLayer.h
+++ b/arm_compute/graph/nodes/ConvolutionLayer.h
@@ -26,6 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/SubTensor.h"
#include "arm_compute/graph/Tensor.h"
#include "arm_compute/graph/Types.h"
@@ -77,7 +78,7 @@ public:
}
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
private:
/** Instantiates a non-grouped convolution
diff --git a/arm_compute/graph/nodes/DepthConcatenateLayer.h b/arm_compute/graph/nodes/DepthConcatenateLayer.h
new file mode 100644
index 0000000000..ac347a46d6
--- /dev/null
+++ b/arm_compute/graph/nodes/DepthConcatenateLayer.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 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_GRAPH_DEPTH_CONCATENATE_LAYER_H__
+#define __ARM_COMPUTE_GRAPH_DEPTH_CONCATENATE_LAYER_H__
+
+#include "arm_compute/graph/GraphContext.h"
+#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/Types.h"
+
+namespace arm_compute
+{
+namespace graph
+{
+/** Depth Concatenate Layer node */
+class DepthConcatenateLayer
+{
+public:
+ /** Default Constructor */
+ DepthConcatenateLayer() = default;
+ DepthConcatenateLayer(const DepthConcatenateLayer &) = delete;
+ DepthConcatenateLayer &operator=(const DepthConcatenateLayer &) = delete;
+ DepthConcatenateLayer(DepthConcatenateLayer &&) = default;
+ DepthConcatenateLayer &operator=(DepthConcatenateLayer &&) = delete;
+
+ // Inherited methods overriden:
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, std::vector<ITensor *> inputs, ITensor *output);
+ void print_info();
+
+private:
+ TargetHint _hint{ TargetHint::DONT_CARE };
+ std::vector<ITensor *> _inputs{ nullptr };
+ ITensor *_output{ nullptr };
+};
+} // namespace graph
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_GRAPH_DEPTH_CONCATENATE_LAYER_H__ */
diff --git a/arm_compute/graph/nodes/FloorLayer.h b/arm_compute/graph/nodes/FloorLayer.h
index 40fde3b791..f88a5b9d94 100644
--- a/arm_compute/graph/nodes/FloorLayer.h
+++ b/arm_compute/graph/nodes/FloorLayer.h
@@ -26,7 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
-#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
namespace arm_compute
{
@@ -37,7 +37,7 @@ class FloorLayer : public INode
{
public:
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
};
} // namespace graph
diff --git a/arm_compute/graph/nodes/FullyConnectedLayer.h b/arm_compute/graph/nodes/FullyConnectedLayer.h
index d31e060457..270676a6b5 100644
--- a/arm_compute/graph/nodes/FullyConnectedLayer.h
+++ b/arm_compute/graph/nodes/FullyConnectedLayer.h
@@ -26,6 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Tensor.h"
#include "arm_compute/graph/Types.h"
@@ -50,7 +51,7 @@ public:
}
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
// Inherited methods overriden:
private:
diff --git a/arm_compute/graph/nodes/L2NormalizeLayer.h b/arm_compute/graph/nodes/L2NormalizeLayer.h
index ab333a221c..ddc1646485 100644
--- a/arm_compute/graph/nodes/L2NormalizeLayer.h
+++ b/arm_compute/graph/nodes/L2NormalizeLayer.h
@@ -26,7 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
-#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
namespace arm_compute
@@ -48,7 +48,7 @@ public:
}
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
private:
unsigned int _axis;
diff --git a/arm_compute/graph/nodes/NormalizationLayer.h b/arm_compute/graph/nodes/NormalizationLayer.h
index 02efd1cbeb..e1c45094d8 100644
--- a/arm_compute/graph/nodes/NormalizationLayer.h
+++ b/arm_compute/graph/nodes/NormalizationLayer.h
@@ -26,6 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
namespace arm_compute
@@ -43,7 +44,7 @@ public:
explicit NormalizationLayer(const NormalizationLayerInfo norm_info);
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
private:
const NormalizationLayerInfo _norm_info; /**< Normalization layer information */
diff --git a/arm_compute/graph/nodes/PoolingLayer.h b/arm_compute/graph/nodes/PoolingLayer.h
index 87b15d06cb..5c45bc04ed 100644
--- a/arm_compute/graph/nodes/PoolingLayer.h
+++ b/arm_compute/graph/nodes/PoolingLayer.h
@@ -26,7 +26,7 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
-#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
namespace arm_compute
@@ -44,7 +44,7 @@ public:
PoolingLayer(const PoolingLayerInfo pool_info);
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
private:
const PoolingLayerInfo _pool_info; /**< Pooling layer information */
diff --git a/arm_compute/graph/nodes/SoftmaxLayer.h b/arm_compute/graph/nodes/SoftmaxLayer.h
index 2e1bd98c8d..b5d1bc53fd 100644
--- a/arm_compute/graph/nodes/SoftmaxLayer.h
+++ b/arm_compute/graph/nodes/SoftmaxLayer.h
@@ -26,20 +26,19 @@
#include "arm_compute/graph/GraphContext.h"
#include "arm_compute/graph/INode.h"
-#include "arm_compute/graph/Tensor.h"
+#include "arm_compute/graph/ITensorObject.h"
#include "arm_compute/graph/Types.h"
namespace arm_compute
{
namespace graph
{
/** Softmax layer node */
-class SoftmaxLayer : public INode
+class SoftmaxLayer final : public INode
{
public:
// Inherited methods overriden:
- std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override;
+ std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
};
-
} // namespace graph
} // namespace arm_compute
#endif /* __ARM_COMPUTE_GRAPH_SOFTMAX_LAYER_H__ */