From cdc0149ffe40f14ff4695149d9bdf551f8e07702 Mon Sep 17 00:00:00 2001 From: Teresa Charlin Date: Tue, 9 Jun 2020 18:00:20 +0100 Subject: IVGCVSW-4928 Introduce "ShapeInferenceMethod" Option. Signed-off-by: Teresa Charlin Change-Id: I70ef1a9f3cefa1d4cf9220f0e13131d11e7c6418 --- include/armnn/INetwork.hpp | 8 +++++++- include/armnn/Types.hpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'include/armnn') diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index ade6c52c90..49cd582e67 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -599,12 +599,15 @@ struct OptimizerOptions : m_ReduceFp32ToFp16(false) , m_Debug(false) , m_ReduceFp32ToBf16(false) + , m_shapeInferenceMethod(armnn::ShapeInferenceMethod::ValidateOnly) {} - OptimizerOptions(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16 = false) + OptimizerOptions(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16 = false, + ShapeInferenceMethod shapeInferenceMethod = armnn::ShapeInferenceMethod::ValidateOnly) : m_ReduceFp32ToFp16(reduceFp32ToFp16) , m_Debug(debug) , m_ReduceFp32ToBf16(reduceFp32ToBf16) + , m_shapeInferenceMethod(shapeInferenceMethod) { if (m_ReduceFp32ToFp16 && m_ReduceFp32ToBf16) { @@ -620,6 +623,9 @@ struct OptimizerOptions // Reduce Fp32 data to Bf16 for faster processing bool m_ReduceFp32ToBf16; + + // Infer output size when not available + ShapeInferenceMethod m_shapeInferenceMethod; }; /// Create an optimized version of the network diff --git a/include/armnn/Types.hpp b/include/armnn/Types.hpp index 7c8a533e60..fb6f134766 100644 --- a/include/armnn/Types.hpp +++ b/include/armnn/Types.hpp @@ -143,6 +143,22 @@ enum class OutputShapeRounding Ceiling = 1 }; +/// +/// The ShapeInferenceMethod modify how the output shapes are treated. +/// When ValidateOnly is selected, the output shapes are inferred from the input parameters of the layer +/// and any mismatch is reported. +/// When InferAndValidate is selected 2 actions must be performed: (1)infer output shape from inputs and (2)validate the +/// shapes as in ValidateOnly. This option has been added to work with tensors which rank or dimension sizes are not +/// specified explicitly, however this information can be calculated from the inputs. +/// +enum class ShapeInferenceMethod +{ + /// Validate all output shapes + ValidateOnly = 0, + /// Infer missing output shapes and validate all output shapes + InferAndValidate = 1 +}; + /// Each backend should implement an IBackend. class IBackend { -- cgit v1.2.1