aboutsummaryrefslogtreecommitdiff
path: root/src/graph/nodes
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2017-11-24 09:54:20 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:41:04 +0000
commit7bfe4c52823b3fad82339e5a686aa94e30d57e7b (patch)
tree619a7f096bb27f4b00059254024526dd233343e0 /src/graph/nodes
parentf3dfa279d536906dac3e618244b2c1d33e5ff28a (diff)
downloadComputeLibrary-7bfe4c52823b3fad82339e5a686aa94e30d57e7b.tar.gz
COMPMID-554 Add Nodes
- DepthwiseConvolutionLayer Change-Id: Icaef85d7474f7532bf7d93d11b5c787712e57bdd Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/110524 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'src/graph/nodes')
-rw-r--r--src/graph/nodes/DepthwiseConvolutionLayer.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/graph/nodes/DepthwiseConvolutionLayer.cpp b/src/graph/nodes/DepthwiseConvolutionLayer.cpp
new file mode 100644
index 0000000000..1c006d61db
--- /dev/null
+++ b/src/graph/nodes/DepthwiseConvolutionLayer.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+#include "arm_compute/graph/nodes/DepthwiseConvolutionLayer.h"
+
+#include "arm_compute/graph/Error.h"
+#include "arm_compute/graph/NodeContext.h"
+#include "arm_compute/graph/OperationRegistry.h"
+#include "support/ToolchainSupport.h"
+
+using namespace arm_compute::graph;
+
+std::unique_ptr<arm_compute::IFunction> DepthwiseConvolutionLayer::instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output)
+{
+ ARM_COMPUTE_ERROR_ON_UNALLOCATED_TENSOR_OBJECT(input, output);
+
+ arm_compute::ITensor *in = input->tensor();
+ arm_compute::ITensor *out = output->tensor();
+ _target_hint = ctx.hints().target_hint();
+
+ if(_weights.tensor() == nullptr)
+ {
+ TensorShape shape = in->info()->tensor_shape();
+ shape.set(Window::DimX, _conv_width);
+ shape.set(Window::DimY, _conv_height);
+ _weights.set_info(TensorInfo(TensorShape(shape), in->info()->num_channels(), in->info()->data_type(), in->info()->fixed_point_position()));
+ }
+ if(_biases.has_accessor() && _biases.tensor() == nullptr)
+ {
+ _biases.set_info(TensorInfo(TensorShape(in->info()->dimension(2)), in->info()->num_channels(), in->info()->data_type(), in->info()->fixed_point_position()));
+ }
+
+ bool weights_is_loaded = _weights.tensor() != nullptr;
+ bool biases_is_loaded = _biases.has_accessor() ? _biases.tensor() != nullptr : false;
+
+ _weights.set_target(_target_hint);
+ _biases.set_target(_target_hint);
+
+ // Create node context
+ NodeContext node_ctx(OperationType::DepthwiseConvolutionLayer);
+ node_ctx.set_target(_target_hint);
+ node_ctx.add_input(in);
+ node_ctx.add_input(_weights.tensor());
+ if(_biases.has_accessor())
+ {
+ node_ctx.add_input(_biases.tensor());
+ }
+ node_ctx.add_output(out);
+ node_ctx.add_parameter<PadStrideInfo>("ConvolutionInfo", _conv_info);
+ node_ctx.add_parameter<bool>("Optimized3x3", _opt3x3);
+
+ // Fill tensors
+ if(!weights_is_loaded)
+ {
+ _weights.allocate_and_fill_if_needed();
+ }
+ if(!biases_is_loaded)
+ {
+ _biases.allocate_and_fill_if_needed();
+ }
+
+ // Get function
+ return OperationRegistry::get().find_operation(OperationType::DepthwiseConvolutionLayer, _target_hint)->configure(node_ctx);
+}