aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/graph/GraphBuilder.h9
-rw-r--r--arm_compute/graph/INodeVisitor.h9
-rw-r--r--arm_compute/graph/TypePrinter.h3
-rw-r--r--arm_compute/graph/Types.h1
-rw-r--r--arm_compute/graph/backends/FunctionHelpers.h38
-rw-r--r--arm_compute/graph/backends/ValidateHelpers.h20
-rw-r--r--arm_compute/graph/frontend/Layers.h21
-rw-r--r--arm_compute/graph/nodes/DequantizationLayerNode.h53
-rw-r--r--arm_compute/graph/nodes/Nodes.h1
-rw-r--r--arm_compute/graph/nodes/NodesFwd.h1
10 files changed, 155 insertions, 1 deletions
diff --git a/arm_compute/graph/GraphBuilder.h b/arm_compute/graph/GraphBuilder.h
index dc41ed5367..c1c56c3dd2 100644
--- a/arm_compute/graph/GraphBuilder.h
+++ b/arm_compute/graph/GraphBuilder.h
@@ -205,6 +205,15 @@ public:
* @return Node ID of the created node, EmptyNodeID in case of error
*/
static NodeID add_elementwise_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, EltwiseOperation operation);
+ /** Adds a dequantization node to the graph
+ *
+ * @param[in] g Graph to add the node to
+ * @param[in] params Common node parameters
+ * @param[in] input Input to the dequantization node as a NodeID-Index pair
+ *
+ * @return Node ID of the created node, EmptyNodeID in case of error
+ */
+ static NodeID add_dequantization_node(Graph &g, NodeParams params, NodeIdxPair input);
/** Adds a detection output layer node to the graph
*
* @param[in] g Graph to add the node to
diff --git a/arm_compute/graph/INodeVisitor.h b/arm_compute/graph/INodeVisitor.h
index c9f9d2172c..c17b7753d6 100644
--- a/arm_compute/graph/INodeVisitor.h
+++ b/arm_compute/graph/INodeVisitor.h
@@ -71,6 +71,11 @@ public:
* @param[in] n Node to visit.
*/
virtual void visit(DepthwiseConvolutionLayerNode &n) = 0;
+ /** Visit DequantizationLayerNode.
+ *
+ * @param[in] n Node to visit.
+ */
+ virtual void visit(DequantizationLayerNode &n) = 0;
/** Visit DetectionOutputLayerNode.
*
* @param[in] n Node to visit.
@@ -200,6 +205,10 @@ public:
{
default_visit();
}
+ virtual void visit(DequantizationLayerNode &) override
+ {
+ default_visit();
+ }
virtual void visit(DetectionOutputLayerNode &) override
{
default_visit();
diff --git a/arm_compute/graph/TypePrinter.h b/arm_compute/graph/TypePrinter.h
index 131fd39277..7610852aaf 100644
--- a/arm_compute/graph/TypePrinter.h
+++ b/arm_compute/graph/TypePrinter.h
@@ -83,6 +83,9 @@ inline ::std::ostream &operator<<(::std::ostream &os, const NodeType &node_type)
case NodeType::DeconvolutionLayer:
os << "DeconvolutionLayer";
break;
+ case NodeType::DequantizationLayer:
+ os << "DequantizationLayer";
+ break;
case NodeType::DetectionOutputLayer:
os << "DetectionOutputLayer";
break;
diff --git a/arm_compute/graph/Types.h b/arm_compute/graph/Types.h
index 5b82f93686..c01f9a8f4e 100644
--- a/arm_compute/graph/Types.h
+++ b/arm_compute/graph/Types.h
@@ -138,6 +138,7 @@ enum class NodeType
ConvolutionLayer,
DeconvolutionLayer,
DepthwiseConvolutionLayer,
+ DequantizationLayer,
DetectionOutputLayer,
DetectionPostProcessLayer,
EltwiseLayer,
diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h
index 02bfe9dc22..960011c1e2 100644
--- a/arm_compute/graph/backends/FunctionHelpers.h
+++ b/arm_compute/graph/backends/FunctionHelpers.h
@@ -607,6 +607,44 @@ std::unique_ptr<IFunction> create_depthwise_convolution_layer(DepthwiseConvoluti
return func;
}
+/** Create a backend dequantize layer function
+ *
+ * @tparam DequantizationLayer Function Backend dequantize function
+ * @tparam TargetInfo Target-specific information
+ *
+ * @param[in] node Node to create the backend function for
+ *
+ * @return Backend dequantize layer function
+ */
+template <typename DequantizationLayerFunction, typename TargetInfo>
+std::unique_ptr<IFunction> create_dequantization_layer(DequantizationLayerNode &node)
+{
+ validate_node<TargetInfo>(node, 1 /* expected inputs */, 1 /* expected outputs */);
+
+ // Extract IO and info
+ typename TargetInfo::TensorType *input = get_backing_tensor<TargetInfo>(node.input(0));
+ typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0));
+
+ ARM_COMPUTE_ERROR_ON(input == nullptr);
+ ARM_COMPUTE_ERROR_ON(output == nullptr);
+
+ // Create and configure function
+ auto func = support::cpp14::make_unique<DequantizationLayerFunction>();
+ func->configure(input, output);
+
+ // Log info
+ ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated "
+ << node.name()
+ << " Type: " << node.type()
+ << " Target: " << TargetInfo::TargetType
+ << " Data Type: " << input->info()->data_type()
+ << " Input shape: " << input->info()->tensor_shape()
+ << " Input quantization info: " << output->info()->quantization_info()
+ << " Output shape: " << output->info()->tensor_shape()
+ << std::endl);
+
+ return std::move(func);
+}
/** Create a backend detection output layer function
*
* @tparam DetectionOutputLayer Function Backend detection output function
diff --git a/arm_compute/graph/backends/ValidateHelpers.h b/arm_compute/graph/backends/ValidateHelpers.h
index 9170006d9c..090e2d6b7c 100644
--- a/arm_compute/graph/backends/ValidateHelpers.h
+++ b/arm_compute/graph/backends/ValidateHelpers.h
@@ -199,7 +199,27 @@ Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node)
return status;
}
+/** Validates a dequantize layer node
+ *
+ * @tparam DequantizationLayer Dequantize layer type
+ *
+ * @param[in] node Node to validate
+ *
+ * @return Status
+ */
+template <typename DequantizationLayer>
+Status validate_dequantization_layer(DequantizationLayerNode &node)
+{
+ ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl);
+ ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1);
+ ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1);
+ // Extract IO and info
+ arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0));
+ arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0));
+
+ return DequantizationLayer::validate(input, output);
+}
/** Validates a detection output layer node
*
* @tparam DetectionOutputLayer DetectionOutput layer type
diff --git a/arm_compute/graph/frontend/Layers.h b/arm_compute/graph/frontend/Layers.h
index 120997a8b4..61cd83c107 100644
--- a/arm_compute/graph/frontend/Layers.h
+++ b/arm_compute/graph/frontend/Layers.h
@@ -489,6 +489,25 @@ private:
const QuantizationInfo _weights_quant_info;
const QuantizationInfo _out_quant_info;
};
+/** Dequantization Layer */
+class DequantizationLayer final : public ILayer
+{
+public:
+ /** Construct a dequantization layer.
+ *
+ */
+ DequantizationLayer()
+ {
+ }
+
+ NodeID create_layer(IStream &s) override
+ {
+ NodeParams common_params = { name(), s.hints().target_hint };
+ NodeIdxPair input = { s.tail_node(), 0 };
+ return GraphBuilder::add_dequantization_node(s.graph(), common_params, input);
+ }
+};
+
/** DetectionOutput Layer */
class DetectionOutputLayer final : public ILayer
{
@@ -555,7 +574,7 @@ private:
class DummyLayer final : public ILayer
{
public:
- /** Construct an input layer.
+ /** Construct a dummy layer.
*
* @param[in] shape Output shape
*/
diff --git a/arm_compute/graph/nodes/DequantizationLayerNode.h b/arm_compute/graph/nodes/DequantizationLayerNode.h
new file mode 100644
index 0000000000..8b3d4add65
--- /dev/null
+++ b/arm_compute/graph/nodes/DequantizationLayerNode.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2019 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_DEQUANTIZATION_NODE_H
+#define ARM_COMPUTE_GRAPH_DEQUANTIZATION_NODE_H
+
+#include "arm_compute/graph/INode.h"
+
+namespace arm_compute
+{
+namespace graph
+{
+/** Dequantize Layer node
+ *
+ * Dequantize layer transforms a given input to a dequantized output.
+ *
+ */
+class DequantizationLayerNode final : public INode
+{
+public:
+ /** Constructor
+ */
+ DequantizationLayerNode();
+
+ // Inherited overridden methods:
+ NodeType type() const override;
+ bool forward_descriptors() override;
+ TensorDescriptor configure_output(size_t idx) const override;
+ void accept(INodeVisitor &v) override;
+};
+} // namespace graph
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_GRAPH_DEQUANTIZATION_NODE_H */ \ No newline at end of file
diff --git a/arm_compute/graph/nodes/Nodes.h b/arm_compute/graph/nodes/Nodes.h
index 1586270093..7b586b855f 100644
--- a/arm_compute/graph/nodes/Nodes.h
+++ b/arm_compute/graph/nodes/Nodes.h
@@ -33,6 +33,7 @@
#include "arm_compute/graph/nodes/ConvolutionLayerNode.h"
#include "arm_compute/graph/nodes/DeconvolutionLayerNode.h"
#include "arm_compute/graph/nodes/DepthwiseConvolutionLayerNode.h"
+#include "arm_compute/graph/nodes/DequantizationLayerNode.h"
#include "arm_compute/graph/nodes/DetectionOutputLayerNode.h"
#include "arm_compute/graph/nodes/DetectionPostProcessLayerNode.h"
#include "arm_compute/graph/nodes/DummyNode.h"
diff --git a/arm_compute/graph/nodes/NodesFwd.h b/arm_compute/graph/nodes/NodesFwd.h
index 53f2a6a1b5..42fe0d0baf 100644
--- a/arm_compute/graph/nodes/NodesFwd.h
+++ b/arm_compute/graph/nodes/NodesFwd.h
@@ -39,6 +39,7 @@ class ConstNode;
class ConvolutionLayerNode;
class DeconvolutionLayerNode;
class DepthwiseConvolutionLayerNode;
+class DequantizationLayerNode;
class DetectionOutputLayerNode;
class DetectionPostProcessLayerNode;
class DummyNode;