aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/graph
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-12-07 18:31:47 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2018-12-13 10:42:12 +0000
commit05045c1e052dbba4e44bf0bb8ead3e9b5220d04e (patch)
treee17a64e9cd0f0927bd75f540b6aeb55ba24953d4 /arm_compute/graph
parent35767bc09f21050a9767a91b086b327afc928a81 (diff)
downloadComputeLibrary-05045c1e052dbba4e44bf0bb8ead3e9b5220d04e.tar.gz
COMPMID-1071: (3RDPARTY_UPDATE) Add depth multiplier on DepthwiseConv 3x3 NHWC
Change-Id: I316ff40dda379d4b84fac5d63f0c56efbacbc2b4 Reviewed-on: https://review.mlplatform.org/371 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Diffstat (limited to 'arm_compute/graph')
-rw-r--r--arm_compute/graph/GraphBuilder.h3
-rw-r--r--arm_compute/graph/backends/FunctionHelpers.h3
-rw-r--r--arm_compute/graph/backends/ValidateHelpers.h9
-rw-r--r--arm_compute/graph/frontend/Layers.h20
-rw-r--r--arm_compute/graph/nodes/DepthwiseConvolutionLayerNode.h19
5 files changed, 36 insertions, 18 deletions
diff --git a/arm_compute/graph/GraphBuilder.h b/arm_compute/graph/GraphBuilder.h
index 57ce349984..33a13f1836 100644
--- a/arm_compute/graph/GraphBuilder.h
+++ b/arm_compute/graph/GraphBuilder.h
@@ -178,6 +178,7 @@ public:
* @param[in] input Input to the depthwise convolution layer node as a NodeID-Index pair
* @param[in] kernel_spatial_extend Spatial extend of convolution kernels
* @param[in] conv_info Convolution layer information
+ * @param[in] depth_multiplier (Optional) Depth multiplier parameter.
* @param[in] method (Optional) Convolution method to use
* @param[in] weights_accessor (Optional) Accessor of the weights node data
* @param[in] bias_accessor (Optional) Accessor of the bias node data
@@ -186,7 +187,7 @@ public:
* @return Node ID of the created node, EmptyNodeID in case of error
*/
static NodeID add_depthwise_convolution_node(Graph &g, NodeParams params, NodeIdxPair input,
- Size2D kernel_spatial_extend, PadStrideInfo conv_info,
+ Size2D kernel_spatial_extend, PadStrideInfo conv_info, int depth_multiplier = 1,
DepthwiseConvolutionMethod method = DepthwiseConvolutionMethod::Default,
ITensorAccessorUPtr weights_accessor = nullptr, ITensorAccessorUPtr bias_accessor = nullptr, const QuantizationInfo quant_info = QuantizationInfo());
/** Adds an element-wise layer node to the graph
diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h
index 0d7210f7f8..3e71e3922a 100644
--- a/arm_compute/graph/backends/FunctionHelpers.h
+++ b/arm_compute/graph/backends/FunctionHelpers.h
@@ -447,7 +447,7 @@ std::unique_ptr<IFunction> create_depthwise_convolution_layer(DepthwiseConvoluti
const PadStrideInfo conv_info = node.convolution_info();
const DepthwiseConvolutionMethod dwc_algorithm = node.depthwise_convolution_method();
- const unsigned int depth_multiplier = 1;
+ const unsigned int depth_multiplier = node.depth_multiplier();
const ActivationLayerInfo fused_act = node.fused_activation();
// Create and configure function (we assume that functions have been validated before creation)
@@ -483,6 +483,7 @@ std::unique_ptr<IFunction> create_depthwise_convolution_layer(DepthwiseConvoluti
<< " Input shape: " << input->info()->tensor_shape()
<< " Weights shape: " << weights->info()->tensor_shape()
<< " Output shape: " << output->info()->tensor_shape()
+ << " Depth multiplier: " << depth_multiplier
<< (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "")
<< std::endl);
return func;
diff --git a/arm_compute/graph/backends/ValidateHelpers.h b/arm_compute/graph/backends/ValidateHelpers.h
index a6864c2286..75e2363f82 100644
--- a/arm_compute/graph/backends/ValidateHelpers.h
+++ b/arm_compute/graph/backends/ValidateHelpers.h
@@ -182,8 +182,9 @@ Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node)
arm_compute::ITensorInfo *biases = get_backing_tensor_info(node.input(2));
arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0));
- const PadStrideInfo conv_info = node.convolution_info();
- const DepthwiseConvolutionMethod dwc_algorithm = node.depthwise_convolution_method();
+ const PadStrideInfo conv_info = node.convolution_info();
+ const DepthwiseConvolutionMethod dwc_algorithm = node.depthwise_convolution_method();
+ const int depth_multiplier = node.depth_multiplier();
// Validate function
Status status{};
@@ -191,10 +192,10 @@ Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node)
{
case DepthwiseConvolutionMethod::Default:
case DepthwiseConvolutionMethod::GEMV:
- status = DepthwiseConvolutionLayer::validate(input, weights, biases, output, conv_info);
+ status = DepthwiseConvolutionLayer::validate(input, weights, biases, output, conv_info, depth_multiplier);
break;
case DepthwiseConvolutionMethod::Optimized3x3:
- status = DepthwiseConvolutionLayer3x3::validate(input, weights, biases, output, conv_info);
+ status = DepthwiseConvolutionLayer3x3::validate(input, weights, biases, output, conv_info, depth_multiplier);
break;
default:
ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported depthwise convolution method");
diff --git a/arm_compute/graph/frontend/Layers.h b/arm_compute/graph/frontend/Layers.h
index 78a3f20f1f..d0703317cd 100644
--- a/arm_compute/graph/frontend/Layers.h
+++ b/arm_compute/graph/frontend/Layers.h
@@ -414,24 +414,27 @@ class DepthwiseConvolutionLayer final : public ILayer
public:
/** Construct a depthwise convolution layer.
*
- * @param[in] conv_width Convolution width.
- * @param[in] conv_height Convolution height.
- * @param[in] weights Accessor to get kernel weights from.
- * @param[in] bias Accessor to get kernel bias from.
- * @param[in] conv_info Padding and stride information.
- * @param[in] quant_info (Optional) Quantization info used for weights
+ * @param[in] conv_width Convolution width.
+ * @param[in] conv_height Convolution height.
+ * @param[in] weights Accessor to get kernel weights from.
+ * @param[in] bias Accessor to get kernel bias from.
+ * @param[in] conv_info Padding and stride information.
+ * @param[in] depth_multiplier (Optional) Depth multiplier parameter.
+ * @param[in] quant_info (Optional) Quantization info used for weights
*/
DepthwiseConvolutionLayer(unsigned int conv_width,
unsigned int conv_height,
ITensorAccessorUPtr weights,
ITensorAccessorUPtr bias,
PadStrideInfo conv_info,
- const QuantizationInfo quant_info = QuantizationInfo())
+ int depth_multiplier = 1,
+ const QuantizationInfo quant_info = QuantizationInfo())
: _conv_width(conv_width),
_conv_height(conv_height),
_conv_info(std::move(conv_info)),
_weights(std::move(weights)),
_bias(std::move(bias)),
+ _depth_multiplier(depth_multiplier),
_quant_info(std::move(quant_info))
{
}
@@ -441,7 +444,7 @@ public:
NodeIdxPair input = { s.tail_node(), 0 };
NodeParams common_params = { name(), s.hints().target_hint };
return GraphBuilder::add_depthwise_convolution_node(s.graph(), common_params,
- input, Size2D(_conv_width, _conv_height), _conv_info,
+ input, Size2D(_conv_width, _conv_height), _conv_info, _depth_multiplier,
s.hints().depthwise_convolution_method_hint,
std::move(_weights), std::move(_bias), std::move(_quant_info));
}
@@ -452,6 +455,7 @@ private:
const PadStrideInfo _conv_info;
ITensorAccessorUPtr _weights;
ITensorAccessorUPtr _bias;
+ int _depth_multiplier;
const QuantizationInfo _quant_info;
};
diff --git a/arm_compute/graph/nodes/DepthwiseConvolutionLayerNode.h b/arm_compute/graph/nodes/DepthwiseConvolutionLayerNode.h
index 7fa44b798f..8c0aae13c9 100644
--- a/arm_compute/graph/nodes/DepthwiseConvolutionLayerNode.h
+++ b/arm_compute/graph/nodes/DepthwiseConvolutionLayerNode.h
@@ -36,10 +36,13 @@ class DepthwiseConvolutionLayerNode final : public INode
public:
/** Constructor
*
- * @param[in] info Convolution layer attributes
- * @param[in] method Depthwise convolution method to use
+ * @param[in] info Convolution layer attributes
+ * @param[in] depth_multiplier (Optional) Depth multiplier parameter.
+ * @param[in] method (Optional) Depthwise convolution method to use
*/
- DepthwiseConvolutionLayerNode(PadStrideInfo info, DepthwiseConvolutionMethod method = DepthwiseConvolutionMethod::Default);
+ DepthwiseConvolutionLayerNode(PadStrideInfo info,
+ int depth_multiplier = 1,
+ DepthwiseConvolutionMethod method = DepthwiseConvolutionMethod::Default);
/** Sets the depthwise convolution method to use
*
* @param[in] method Depthwise convolution method to use
@@ -53,6 +56,11 @@ public:
* @return Depthwise convolution layer method do be used by the node
*/
DepthwiseConvolutionMethod depthwise_convolution_method() const;
+ /** Depth multiplier accessor
+ *
+ * @return Depth multiplier
+ */
+ int depth_multiplier() const;
/** Convolution metadata accessor
*
* @return Convolution information
@@ -73,12 +81,14 @@ public:
* @param[in] input_descriptor Input descriptor
* @param[in] weights_descriptor Weights descriptor
* @param[in] info Convolution operation attributes
+ * @param[in] depth_multiplier (Optional) Depth multiplier parameter.
*
* @return Output descriptor
*/
static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor,
const TensorDescriptor &weights_descriptor,
- const PadStrideInfo &info);
+ const PadStrideInfo &info,
+ int depth_multiplier = 1);
// Inherited overridden methods:
NodeType type() const override;
@@ -91,6 +101,7 @@ public:
private:
PadStrideInfo _info;
+ int _depth_multiplier;
DepthwiseConvolutionMethod _method;
ActivationLayerInfo _fused_activation;
};