diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-10-02 18:51:47 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | e2c82fee3b6d38f6e79412c78176792b817defd0 (patch) | |
tree | aa6821e33cfe8001c33086191c81c18d66ac7837 /arm_compute/graph/nodes | |
parent | 48a60f9f7b0b7b5cf38253b7a2ac576aac43ef78 (diff) | |
download | ComputeLibrary-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/graph/nodes')
-rw-r--r-- | arm_compute/graph/nodes/ActivationLayer.h | 4 | ||||
-rw-r--r-- | arm_compute/graph/nodes/BatchNormalizationLayer.h | 3 | ||||
-rw-r--r-- | arm_compute/graph/nodes/BranchLayer.h | 77 | ||||
-rw-r--r-- | arm_compute/graph/nodes/ConvolutionLayer.h | 3 | ||||
-rw-r--r-- | arm_compute/graph/nodes/DepthConcatenateLayer.h | 58 | ||||
-rw-r--r-- | arm_compute/graph/nodes/FloorLayer.h | 4 | ||||
-rw-r--r-- | arm_compute/graph/nodes/FullyConnectedLayer.h | 3 | ||||
-rw-r--r-- | arm_compute/graph/nodes/L2NormalizeLayer.h | 4 | ||||
-rw-r--r-- | arm_compute/graph/nodes/NormalizationLayer.h | 3 | ||||
-rw-r--r-- | arm_compute/graph/nodes/PoolingLayer.h | 4 | ||||
-rw-r--r-- | arm_compute/graph/nodes/SoftmaxLayer.h | 7 |
11 files changed, 154 insertions, 16 deletions
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__ */ |