ArmNN
 20.11
armnn Namespace Reference

Copyright (c) 2020 ARM Limited. More...

Namespaces

 gatordmock
 
 optimizations
 
 profiling
 
 stringUtils
 
 test
 
 timelinedecoder
 
 utility
 

Classes

struct  abs
 
class  AbsLayer
 
struct  AbsQueueDescriptor
 
struct  ActivationDescriptor
 An ActivationDescriptor for the ActivationLayer. More...
 
class  ActivationLayer
 This layer represents an activation operation with the specified activation function. More...
 
struct  ActivationQueueDescriptor
 
class  AddedLayerObservable
 
class  AdditionLayer
 This layer represents an addition operation. More...
 
struct  AdditionQueueDescriptor
 
struct  ArgMinMaxDescriptor
 An ArgMinMaxDescriptor for ArgMinMaxLayer. More...
 
class  ArgMinMaxLayer
 This layer represents a ArgMinMax operation. More...
 
struct  ArgMinMaxQueueDescriptor
 
class  BackendId
 
struct  BackendOptions
 Struct for the users to pass backend specific options. More...
 
class  BackendProfilingException
 
class  BackendRegistry
 
struct  BackendSettings
 
class  BackendUnavailableException
 Class for non-fatal exceptions raised while initialising a backend. More...
 
struct  BackendVersion
 
class  BadOptionalAccessException
 
class  BaseIterator
 
class  BaseMemoryManager
 
class  BaseTensor
 
class  BaseWorkload
 
struct  BatchNormalizationDescriptor
 A BatchNormalizationDescriptor for the BatchNormalizationLayer. More...
 
class  BatchNormalizationLayer
 This layer represents a batch normalization operation. More...
 
struct  BatchNormalizationQueueDescriptor
 
struct  BatchToSpaceNdDescriptor
 A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer. More...
 
class  BatchToSpaceNdLayer
 This layer represents a BatchToSpaceNd operation. More...
 
struct  BatchToSpaceNdQueueDescriptor
 
class  BFloat16
 
class  BFloat16Decoder
 
class  BFloat16Encoder
 
struct  BiasAndWeightsTypesCompatible
 
struct  BiasAndWeightsTypesMatch
 
class  BindableLayer
 
class  BooleanDecoder
 
class  BooleanDecoderBool
 
class  BooleanEncoder
 
struct  BroadcastLoop
 
struct  Capability
 Capability of the TensorHandleFactory. More...
 
struct  CheckLocation
 
class  ClAbsWorkload
 
class  ClActivationWorkload
 
class  ClAdditionWorkload
 
class  ClArgMinMaxWorkload
 
class  ClBackend
 
class  ClBackendContext
 
class  ClBackendModelContext
 The ClBackendModelContext is used to pass in CL specific backend ModelOptions. More...
 
class  ClBatchNormalizationFloatWorkload
 
class  ClBatchToSpaceNdWorkload
 
class  ClComparisonWorkload
 
class  ClConcatWorkload
 
class  ClConstantWorkload
 
class  ClContextControl
 
class  ClConvertFp16ToFp32Workload
 
class  ClConvertFp32ToFp16Workload
 
class  ClConvolution2dWorkload
 
class  ClDepthToSpaceWorkload
 
class  ClDepthwiseConvolutionWorkload
 
class  ClDequantizeWorkload
 
class  ClDivisionFloatWorkload
 
class  ClExpWorkload
 
class  ClFillWorkload
 
class  ClFloorFloatWorkload
 
class  ClFullyConnectedWorkload
 
class  ClGatherWorkload
 
class  ClInstanceNormalizationWorkload
 
class  ClL2NormalizationFloatWorkload
 
class  ClLayerSupport
 
class  ClLogicalAndWorkload
 
class  ClLogicalNotWorkload
 
class  ClLogicalOrWorkload
 
class  ClLogSoftmaxWorkload
 
class  ClLstmFloatWorkload
 
class  ClMaximumWorkload
 
class  ClMeanWorkload
 
class  ClMemoryManager
 
class  ClMinimumWorkload
 
class  ClMultiplicationWorkload
 
class  ClNegWorkload
 
class  ClNormalizationFloatWorkload
 
class  ClPadWorkload
 
class  ClPermuteWorkload
 
class  ClPooling2dWorkload
 
class  ClPreluWorkload
 
class  ClQLstmWorkload
 
class  ClQuantizedLstmWorkload
 
class  ClQuantizeWorkload
 
class  ClReshapeWorkload
 
class  ClResizeWorkload
 
class  ClRsqrtWorkload
 
class  ClRuntimeUnavailableException
 
class  ClSliceWorkload
 
class  ClSoftmaxWorkload
 
class  ClSpaceToBatchNdWorkload
 
class  ClSpaceToDepthWorkload
 
class  ClSplitterWorkload
 
class  ClStackWorkload
 
class  ClStridedSliceWorkload
 
class  ClSubTensorHandle
 
class  ClSubtractionWorkload
 
class  ClTensorHandle
 
class  ClTensorHandleFactory
 
class  ClTransposeConvolution2dWorkload
 
class  ClTransposeWorkload
 
class  ClTunedParameters
 
class  ClWorkloadFactory
 
struct  ComparisonDescriptor
 A ComparisonDescriptor for the ComparisonLayer. More...
 
class  ComparisonLayer
 This layer represents a comparison operation. More...
 
struct  ComparisonQueueDescriptor
 
class  ConcatLayer
 This layer represents a merge operation. More...
 
struct  ConcatQueueDescriptor
 
class  ConstantLayer
 A layer that the constant data can be bound to. More...
 
struct  ConstantQueueDescriptor
 
class  ConstCpuTensorHandle
 
class  ConstPassthroughCpuTensorHandle
 
struct  ConstructInPlace
 Disambiguation tag that can be passed to the constructor to indicate that the contained object should be constructed in-place. More...
 
class  ConstTensor
 A tensor defined by a TensorInfo (shape and data type) and an immutable backing store. More...
 
class  ConvertBf16ToFp32Layer
 This layer converts data type BFloat16 to Float32. More...
 
struct  ConvertBf16ToFp32QueueDescriptor
 
class  ConvertFp16ToFp32Layer
 This layer converts data type Float 16 to Float 32. More...
 
struct  ConvertFp16ToFp32QueueDescriptor
 
class  ConvertFp32ToBf16Layer
 This layer converts data type Float32 to BFloat16. More...
 
struct  ConvertFp32ToBf16QueueDescriptor
 
class  ConvertFp32ToFp16Layer
 This layer converts data type Float 32 to Float 16. More...
 
struct  ConvertFp32ToFp16QueueDescriptor
 
struct  Convolution2dDescriptor
 A Convolution2dDescriptor for the Convolution2dLayer. More...
 
class  Convolution2dLayer
 This layer represents a convolution 2d operation. More...
 
struct  Convolution2dQueueDescriptor
 
class  CopyMemGenericWorkload
 
class  CpuTensorHandle
 
class  DebugLayer
 This layer visualizes the data flowing through the network. More...
 
struct  DebugQueueDescriptor
 
class  Decoder
 
class  DepthToSpaceLayer
 This layer represents a DepthToSpace operation. More...
 
struct  DepthToSpaceQueueDescriptor
 
struct  DepthwiseConvolution2dDescriptor
 A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer. More...
 
class  DepthwiseConvolution2dLayer
 This layer represents a depthwise convolution 2d operation. More...
 
struct  DepthwiseConvolution2dQueueDescriptor
 
class  DequantizeLayer
 This layer dequantizes the input tensor. More...
 
struct  DequantizeQueueDescriptor
 
struct  DetectionPostProcessDescriptor
 
class  DetectionPostProcessLayer
 This layer represents a detection postprocess operator. More...
 
struct  DetectionPostProcessQueueDescriptor
 
class  DeviceSpec
 
class  DivisionLayer
 This layer represents a division operation. More...
 
struct  DivisionQueueDescriptor
 
class  DotAttributeSet
 
class  DotBase
 
class  DotDefaults
 
class  DotEdge
 
class  DotGraph
 
class  DotNode
 
class  DynamicBackend
 
class  DynamicBackendUtils
 
class  DynamicQuantizationVisitor
 Visitor class to establish min/max ranges based on the type of the layer. More...
 
class  ElementwiseBaseLayer
 NOTE: this is an abstract class to encapsulate the element wise operations, it does not implement: std::unique_ptr<IWorkload> Layer::CreateWorkload(const IWorkloadFactory& factory) const = 0; Layer* Clone(Graph& graph) const = 0;. More...
 
struct  ElementwiseBinaryFunction
 
struct  ElementwiseUnaryDescriptor
 A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer. More...
 
struct  ElementwiseUnaryFunction
 
class  ElementwiseUnaryLayer
 This layer represents a elementwiseUnary operation. More...
 
struct  ElementwiseUnaryQueueDescriptor
 
struct  EmptyOptional
 EmptyOptional is used to initialize the Optional class in case we want to have default value for an Optional in a function declaration. More...
 
class  Encoder
 
struct  EqualQueueDescriptor
 
class  ErasedLayerNamesObservable
 
class  Event
 Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Event::GetMeasurements() is called. More...
 
class  Exception
 Base class for all ArmNN exceptions so that users can filter to just those. More...
 
class  ExecutionFrame
 
struct  exp
 
struct  FakeQuantizationDescriptor
 A FakeQuantizationDescriptor for the FakeQuantizationLayer. More...
 
class  FakeQuantizationLayer
 This layer represents a fake quantization operation. More...
 
struct  FakeQuantizationQueueDescriptor
 
class  FileNotFoundException
 
struct  FillDescriptor
 A FillDescriptor for the FillLayer. More...
 
class  FillLayer
 This layer represents a fill operation. More...
 
struct  FillQueueDescriptor
 
class  FirstInputTypedWorkload
 
class  Float16Decoder
 
class  Float16Encoder
 
class  Float32Decoder
 
class  Float32Encoder
 
class  FloorLayer
 This layer represents a floor operation. More...
 
struct  FloorQueueDescriptor
 
struct  FullyConnectedDescriptor
 A FullyConnectedDescriptor for the FullyConnectedLayer. More...
 
class  FullyConnectedLayer
 This layer represents a fully connected operation. More...
 
struct  FullyConnectedQueueDescriptor
 
struct  GatherDescriptor
 A GatherDescriptor for the GatherLayer. More...
 
class  GatherLayer
 This layer represents a Gather operator. More...
 
struct  GatherQueueDescriptor
 
class  Graph
 
class  GraphObservable
 
class  GraphValidationException
 
struct  GreaterQueueDescriptor
 
class  HtmlBold
 
class  HtmlFont
 
class  HtmlSection
 
class  HtmlSimpleTag
 
class  IAclTensorHandle
 
class  IBackend
 Each backend should implement an IBackend. More...
 
class  IBackendContext
 
class  IBackendInternal
 
class  IBackendModelContext
 
class  IClTensorHandle
 
class  IConnectableLayer
 Interface for a layer that is connectable to other layers via InputSlots and OutputSlots. More...
 
class  IDeviceSpec
 Device specific knowledge to be passed to the optimizer. More...
 
class  IExecutionFrame
 ExecutionFrame interface to enqueue a workload computation. More...
 
class  IGpuAccTunedParameters
 Manages a set of GpuAcc parameters which have been tuned for maximum performance. More...
 
class  IGraphObservable
 
class  IInputSlot
 An input connection slot for a layer. More...
 
class  ILayerSupport
 
class  ILayerVisitor
 
class  IMemoryManager
 
class  ImportMemGenericWorkload
 
class  INetwork
 Main network class which provides the interface for building up a neural network. More...
 
struct  INetworkProperties
 
class  INetworkQuantizer
 Quantizer class Quantizes a float32 InputNetwork. More...
 
class  InputLayer
 A layer user-provided data can be bound to (e.g. inputs, outputs). More...
 
class  InputSlot
 
struct  InstanceNormalizationDescriptor
 An InstanceNormalizationDescriptor for InstanceNormalizationLayer. More...
 
class  InstanceNormalizationLayer
 This layer represents an instance normalization operation. More...
 
struct  InstanceNormalizationQueueDescriptor
 
class  Instrument
 
class  Int32Decoder
 
class  Int32Encoder
 
class  Int32ToInt32tDecoder
 
class  Int32ToInt32tEncoder
 
class  InvalidArgumentException
 
class  IOptimizedNetwork
 
class  IOutputSlot
 An output connection slot for a layer. More...
 
class  IProfiler
 
struct  IQuantizationScheme
 
class  IRuntime
 
struct  IsHalfType
 
struct  IsMemorySource
 
struct  IsMemorySource< MemorySource >
 
class  ISubgraphViewConverter
 
class  ITensorHandle
 
class  ITensorHandleFactory
 
class  IWorkload
 Workload interface to enqueue a layer computation. More...
 
class  IWorkloadFactory
 
struct  JsonChildObject
 
class  JsonPrinter
 
struct  L2NormalizationDescriptor
 A L2NormalizationDescriptor for the L2NormalizationLayer. More...
 
class  L2NormalizationLayer
 This layer represents a L2 normalization operation. More...
 
struct  L2NormalizationQueueDescriptor
 
class  Layer
 
class  LayerSupportBase
 
struct  LayerTypeOfImpl
 
struct  LayerTypeOfImpl< LayerType::Activation >
 
struct  LayerTypeOfImpl< LayerType::Addition >
 
struct  LayerTypeOfImpl< LayerType::ArgMinMax >
 
struct  LayerTypeOfImpl< LayerType::BatchNormalization >
 
struct  LayerTypeOfImpl< LayerType::BatchToSpaceNd >
 
struct  LayerTypeOfImpl< LayerType::Comparison >
 
struct  LayerTypeOfImpl< LayerType::Concat >
 
struct  LayerTypeOfImpl< LayerType::Constant >
 
struct  LayerTypeOfImpl< LayerType::ConvertBf16ToFp32 >
 
struct  LayerTypeOfImpl< LayerType::ConvertFp16ToFp32 >
 
struct  LayerTypeOfImpl< LayerType::ConvertFp32ToBf16 >
 
struct  LayerTypeOfImpl< LayerType::ConvertFp32ToFp16 >
 
struct  LayerTypeOfImpl< LayerType::Convolution2d >
 
struct  LayerTypeOfImpl< LayerType::Debug >
 
struct  LayerTypeOfImpl< LayerType::DepthToSpace >
 
struct  LayerTypeOfImpl< LayerType::DepthwiseConvolution2d >
 
struct  LayerTypeOfImpl< LayerType::Dequantize >
 
struct  LayerTypeOfImpl< LayerType::DetectionPostProcess >
 
struct  LayerTypeOfImpl< LayerType::Division >
 
struct  LayerTypeOfImpl< LayerType::ElementwiseUnary >
 
struct  LayerTypeOfImpl< LayerType::FakeQuantization >
 
struct  LayerTypeOfImpl< LayerType::Fill >
 
struct  LayerTypeOfImpl< LayerType::Floor >
 
struct  LayerTypeOfImpl< LayerType::FullyConnected >
 
struct  LayerTypeOfImpl< LayerType::Gather >
 
struct  LayerTypeOfImpl< LayerType::Input >
 
struct  LayerTypeOfImpl< LayerType::InstanceNormalization >
 
struct  LayerTypeOfImpl< LayerType::L2Normalization >
 
struct  LayerTypeOfImpl< LayerType::LogicalBinary >
 
struct  LayerTypeOfImpl< LayerType::LogSoftmax >
 
struct  LayerTypeOfImpl< LayerType::Lstm >
 
struct  LayerTypeOfImpl< LayerType::Map >
 
struct  LayerTypeOfImpl< LayerType::Maximum >
 
struct  LayerTypeOfImpl< LayerType::Mean >
 
struct  LayerTypeOfImpl< LayerType::MemCopy >
 
struct  LayerTypeOfImpl< LayerType::MemImport >
 
struct  LayerTypeOfImpl< LayerType::Merge >
 
struct  LayerTypeOfImpl< LayerType::Minimum >
 
struct  LayerTypeOfImpl< LayerType::Multiplication >
 
struct  LayerTypeOfImpl< LayerType::Normalization >
 
struct  LayerTypeOfImpl< LayerType::Output >
 
struct  LayerTypeOfImpl< LayerType::Pad >
 
struct  LayerTypeOfImpl< LayerType::Permute >
 
struct  LayerTypeOfImpl< LayerType::Pooling2d >
 
struct  LayerTypeOfImpl< LayerType::PreCompiled >
 
struct  LayerTypeOfImpl< LayerType::Prelu >
 
struct  LayerTypeOfImpl< LayerType::QLstm >
 
struct  LayerTypeOfImpl< LayerType::Quantize >
 
struct  LayerTypeOfImpl< LayerType::QuantizedLstm >
 
struct  LayerTypeOfImpl< LayerType::Rank >
 
struct  LayerTypeOfImpl< LayerType::Reshape >
 
struct  LayerTypeOfImpl< LayerType::Resize >
 
struct  LayerTypeOfImpl< LayerType::Slice >
 
struct  LayerTypeOfImpl< LayerType::Softmax >
 
struct  LayerTypeOfImpl< LayerType::SpaceToBatchNd >
 
struct  LayerTypeOfImpl< LayerType::SpaceToDepth >
 
struct  LayerTypeOfImpl< LayerType::Splitter >
 
struct  LayerTypeOfImpl< LayerType::Stack >
 
struct  LayerTypeOfImpl< LayerType::StandIn >
 
struct  LayerTypeOfImpl< LayerType::StridedSlice >
 
struct  LayerTypeOfImpl< LayerType::Subtraction >
 
struct  LayerTypeOfImpl< LayerType::Switch >
 
struct  LayerTypeOfImpl< LayerType::Transpose >
 
struct  LayerTypeOfImpl< LayerType::TransposeConvolution2d >
 
struct  LayerTypeOfImpl< LayerType::Unmap >
 
class  LayerValidationException
 
class  LayerVisitorBase
 Visitor base class with empty implementations. More...
 
class  LayerWithParameters
 
class  LoadedNetwork
 
struct  LogicalBinaryDescriptor
 A LogicalBinaryDescriptor for the LogicalBinaryLayer. More...
 
struct  LogicalBinaryFunction
 
class  LogicalBinaryLayer
 This layer represents a Logical Binary operation. More...
 
struct  LogicalBinaryQueueDescriptor
 
struct  LogicalUnaryFunction
 
class  LogSink
 
class  LogSoftmaxLayer
 This layer represents a log softmax operation. More...
 
struct  LogSoftmaxQueueDescriptor
 
struct  LstmBasicParameters
 
struct  LstmDescriptor
 An LstmDescriptor for the LstmLayer. More...
 
struct  LstmInputParams
 
struct  LstmInputParamsInfo
 
class  LstmLayer
 This layer represents a LSTM operation. More...
 
struct  LstmOptCifgParameters
 
struct  LstmOptLayerNormParameters
 
struct  LstmOptPeepholeParameters
 
struct  LstmOptProjectionParameters
 
struct  LstmQueueDescriptor
 
class  MapLayer
 This layer represents a memory copy operation. More...
 
struct  MapQueueDescriptor
 
class  MapWorkload
 
struct  maximum
 
class  MaximumLayer
 This layer represents a maximum operation. More...
 
struct  MaximumQueueDescriptor
 
struct  MeanDescriptor
 A MeanDescriptor for the MeanLayer. More...
 
class  MeanLayer
 This layer represents a mean operation. More...
 
struct  MeanQueueDescriptor
 
struct  Measurement
 
class  MemCopyLayer
 This layer represents a memory copy operation. More...
 
struct  MemCopyQueueDescriptor
 
class  MemImportLayer
 This layer represents a memory import operation. More...
 
struct  MemImportQueueDescriptor
 
class  MemoryExportException
 
class  MemoryImportException
 
struct  MemSyncQueueDescriptor
 
class  MergeLayer
 This layer dequantizes the input tensor. More...
 
struct  MergeQueueDescriptor
 
struct  minimum
 
class  MinimumLayer
 This layer represents a minimum operation. More...
 
struct  MinimumQueueDescriptor
 
class  MockBackend
 
class  MockBackendInitialiser
 
class  MockBackendProfilingContext
 
class  MockBackendProfilingService
 
class  MockImportBackend
 
class  MockImportBackendInitialiser
 
class  MockImportLayerSupport
 
class  MockLayerSupport
 
class  MultiplicationLayer
 This layer represents a multiplication operation. More...
 
struct  MultiplicationQueueDescriptor
 
class  MultiTypedWorkload
 
class  NeonAbsWorkload
 
class  NeonActivationWorkload
 
class  NeonAdditionWorkload
 
class  NeonArgMinMaxWorkload
 
class  NeonBackend
 
class  NeonBackendModelContext
 The NeonBackendModelContext is used to pass in Neon specific backend ModelOptions. More...
 
class  NeonBatchNormalizationWorkload
 
class  NeonBatchToSpaceNdWorkload
 
class  NeonComparisonWorkload
 
class  NeonConcatWorkload
 
class  NeonConstantWorkload
 
class  NeonConvertBf16ToFp32Workload
 
class  NeonConvertFp16ToFp32Workload
 
class  NeonConvertFp32ToBf16Workload
 
class  NeonConvertFp32ToFp16Workload
 
class  NeonConvolution2dWorkload
 
class  NeonDepthToSpaceWorkload
 
class  NeonDepthwiseConvolutionWorkload
 
class  NeonDequantizeWorkload
 
class  NeonDetectionPostProcessWorkload
 
class  NeonDivisionWorkload
 
class  NeonExpWorkload
 
class  NeonFillWorkload
 
class  NeonFloorFloatWorkload
 
class  NeonFullyConnectedWorkload
 
class  NeonGatherWorkload
 
class  NeonInstanceNormalizationWorkload
 
class  NeonInterceptorScheduler
 
class  NeonL2NormalizationFloatWorkload
 
class  NeonLayerSupport
 
class  NeonLogicalAndWorkload
 
class  NeonLogicalNotWorkload
 
class  NeonLogicalOrWorkload
 
class  NeonLogSoftmaxWorkload
 
class  NeonLstmFloatWorkload
 
class  NeonMaximumWorkload
 
class  NeonMeanWorkload
 
class  NeonMemoryManager
 
class  NeonMinimumWorkload
 
class  NeonMultiplicationWorkload
 
class  NeonNegWorkload
 
class  NeonNormalizationFloatWorkload
 
class  NeonPadWorkload
 
class  NeonPermuteWorkload
 
class  NeonPooling2dWorkload
 
class  NeonPreluWorkload
 
class  NeonQLstmWorkload
 
class  NeonQuantizedLstmWorkload
 
class  NeonQuantizeWorkload
 
class  NeonReshapeWorkload
 
class  NeonResizeWorkload
 
class  NeonRsqrtWorkload
 
class  NeonSliceWorkload
 
class  NeonSoftmaxWorkload
 
class  NeonSpaceToBatchNdWorkload
 
class  NeonSpaceToDepthWorkload
 
class  NeonSplitterWorkload
 
class  NeonStackWorkload
 
class  NeonStridedSliceWorkload
 
class  NeonSubTensorHandle
 
class  NeonSubtractionWorkload
 
class  NeonTensorHandle
 
class  NeonTensorHandleFactory
 
class  NeonTimer
 
class  NeonTransposeConvolution2dWorkload
 
class  NeonTransposeWorkload
 
class  NeonWorkloadFactory
 
class  Network
 Private implementation of INetwork. More...
 
class  NetworkQuantizer
 
class  NodeContent
 
struct  NormalizationDescriptor
 A NormalizationDescriptor for the NormalizationLayer. More...
 
class  NormalizationLayer
 This layer represents a normalization operation. More...
 
struct  NormalizationQueueDescriptor
 
class  NullPointerException
 
class  NullWorkload
 
class  OpenClTimer
 OpenClTimer instrument that times all OpenCl kernels executed between calls to Start() and Stop(). More...
 
class  Optimization
 
struct  OptimizationResult
 
class  OptimizationViews
 
class  OptimizedNetwork
 
class  OptimizeForConnection
 
class  OptimizeForConnectionImpl
 Wrapper Optimization class that calls Wrapped::Run for every connection BaseType -> ChildType. More...
 
class  OptimizeForExclusiveConnection
 
class  OptimizeForExclusiveConnectionImpl
 Wrapper Optimization class that calls Wrapped::Run for every connection BaseType -> ChildType. More...
 
class  OptimizeForType
 
class  OptimizeForTypeImpl
 Wrapper Optimization base class that calls Wrapped::Run() for every layer of type BaseType. More...
 
class  OptimizeForTypeImpl< Layer, Wrapped >
 Specialization that calls Wrapped::Run() for any layer type. More...
 
class  Optimizer
 
struct  OptimizerOptions
 
class  Optional
 
class  OptionalBase
 OptionalBase is the common functionality between reference and non-reference optional types. More...
 
class  OptionalReferenceSwitch
 The default implementation is the non-reference case. More...
 
class  OptionalReferenceSwitch< true, T >
 This is the special case for reference types. More...
 
struct  OriginsDescriptor
 An OriginsDescriptor for the ConcatLayer. More...
 
class  OutputHandler
 
class  OutputLayer
 A layer user-provided data can be bound to (e.g. inputs, outputs). More...
 
class  OutputSlot
 
class  OverrideInputRangeVisitor
 Visitor object for overriding the input range of the quantized input layers in a network. More...
 
struct  PadDescriptor
 A PadDescriptor for the PadLayer. More...
 
class  PadLayer
 This layer represents a pad operation. More...
 
struct  PadQueueDescriptor
 
class  ParseException
 
class  PassthroughCpuTensorHandle
 
class  PerAxisIterator
 
class  PermutationVector
 
struct  PermuteDescriptor
 A PermuteDescriptor for the PermuteLayer. More...
 
class  PermuteLayer
 This layer represents a permutation operation. More...
 
struct  PermuteQueueDescriptor
 
class  PolymorphicDowncastException
 
struct  Pooling2dDescriptor
 A Pooling2dDescriptor for the Pooling2dLayer. More...
 
class  Pooling2dLayer
 This layer represents a pooling 2d operation. More...
 
struct  Pooling2dQueueDescriptor
 
struct  PreCompiledDescriptor
 A PreCompiledDescriptor for the PreCompiledLayer. More...
 
class  PreCompiledLayer
 
struct  PreCompiledQueueDescriptor
 
class  PreluLayer
 
struct  PreluQueueDescriptor
 
class  Profiler
 
class  ProfilerManager
 
class  QASymm8Decoder
 
class  QASymm8Encoder
 
class  QASymmS8Decoder
 
class  QASymmS8Encoder
 
struct  QAsymmS8QuantizationScheme
 
struct  QAsymmU8QuantizationScheme
 
struct  QLstmBasicParameters
 
struct  QLstmDescriptor
 A QLstmDescriptor for the QLstmLayer. More...
 
class  QLstmLayer
 This layer represents a QLstm operation. More...
 
struct  QLstmOptCifgParameters
 
struct  QLstmOptLayerNormParameters
 
struct  QLstmOptPeepholeParameters
 
struct  QLstmOptProjectionParameters
 
struct  QLstmQueueDescriptor
 
class  QSymm16Decoder
 
class  QSymm16Encoder
 
struct  QSymm16QuantizationScheme
 
class  QSymm8PerAxisDecoder
 
class  QSymm8PerAxisEncoder
 
class  QSymmS8Decoder
 
class  QSymmS8Encoder
 
struct  QSymmS8QuantizationScheme
 
struct  QuantizationParametersAreEqual
 
struct  QuantizedLstmInputParams
 
struct  QuantizedLstmInputParamsInfo
 
class  QuantizedLstmLayer
 This layer represents a QuantizedLstm operation. More...
 
struct  QuantizedLstmParameters
 
struct  QuantizedLstmQueueDescriptor
 
struct  QuantizedMultiplierSmallerThanOne
 Performs multiplication of an integer with a multiplier which is less than one, using quantized integer arithmetic which is consistent with AndroidNN's CPU executor. More...
 
class  QuantizeLayer
 
struct  QuantizeQueueDescriptor
 
struct  QuantizerOptions
 
class  QuantizerVisitor
 Visitor object for quantizing layers in a network. More...
 
struct  QueueDescriptor
 
struct  QueueDescriptorWithParameters
 
class  RangeTracker
 
class  RankLayer
 
struct  RankQueueDescriptor
 
class  RefActivationWorkload
 
class  RefArgMinMaxWorkload
 
class  RefBackend
 
class  RefBatchNormalizationWorkload
 
class  RefBatchToSpaceNdWorkload
 
class  RefComparisonWorkload
 
class  RefConcatWorkload
 
class  RefConstantWorkload
 
class  RefConvertBf16ToFp32Workload
 
class  RefConvertFp16ToFp32Workload
 
class  RefConvertFp32ToBf16Workload
 
class  RefConvertFp32ToFp16Workload
 
class  RefConvolution2dWorkload
 
class  RefDebugWorkload
 
class  RefDepthToSpaceWorkload
 
class  RefDepthwiseConvolution2dWorkload
 
class  RefDequantizeWorkload
 
class  RefDetectionPostProcessWorkload
 
class  RefElementwiseUnaryWorkload
 
class  RefElementwiseWorkload
 
class  RefFakeQuantizationFloat32Workload
 
class  RefFillWorkload
 
class  RefFloorWorkload
 
class  RefFullyConnectedWorkload
 
class  RefGatherWorkload
 
class  RefInstanceNormalizationWorkload
 
class  RefL2NormalizationWorkload
 
class  RefLayerSupport
 
class  RefLogicalBinaryWorkload
 
class  RefLogicalUnaryWorkload
 
class  RefLogSoftmaxWorkload
 
class  RefLstmWorkload
 
class  RefMeanWorkload
 
class  RefMemoryManager
 
class  RefNormalizationWorkload
 
class  RefPadWorkload
 
class  RefPermuteWorkload
 
class  RefPooling2dWorkload
 
class  RefPreluWorkload
 
class  RefQLstmWorkload
 
class  RefQuantizeWorkload
 
struct  RefRankWorkload
 
class  RefReshapeWorkload
 
class  RefResizeBilinearWorkload
 
class  RefResizeWorkload
 
class  RefSliceWorkload
 
class  RefSoftmaxWorkload
 
class  RefSpaceToBatchNdWorkload
 
class  RefSpaceToDepthWorkload
 
class  RefSplitterWorkload
 
class  RefStackWorkload
 
class  RefStridedSliceWorkload
 
class  RefTensorHandle
 
class  RefTensorHandleFactory
 
class  RefTransposeConvolution2dWorkload
 
class  RefTransposeWorkload
 
class  RefWorkloadFactory
 
struct  ReshapeDescriptor
 A ReshapeDescriptor for the ReshapeLayer. More...
 
class  ReshapeLayer
 This layer represents a reshape operation. More...
 
struct  ReshapeQueueDescriptor
 
struct  ResizeBilinearDescriptor
 A ResizeBilinearDescriptor for the ResizeBilinearLayer. More...
 
struct  ResizeBilinearQueueDescriptor
 
struct  ResizeDescriptor
 A ResizeDescriptor for the ResizeLayer. More...
 
class  ResizeLayer
 This layer represents a resize operation. More...
 
struct  ResizeQueueDescriptor
 
struct  ResolveTypeImpl
 
struct  ResolveTypeImpl< DataType::BFloat16 >
 
struct  ResolveTypeImpl< DataType::Boolean >
 
struct  ResolveTypeImpl< DataType::Float16 >
 
struct  ResolveTypeImpl< DataType::Float32 >
 
struct  ResolveTypeImpl< DataType::QAsymmS8 >
 
struct  ResolveTypeImpl< DataType::QAsymmU8 >
 
struct  ResolveTypeImpl< DataType::QSymmS16 >
 
struct  ResolveTypeImpl< DataType::QSymmS8 >
 
struct  ResolveTypeImpl< DataType::Signed32 >
 
struct  rsqrt
 
class  RsqrtLayer
 
struct  RsqrtQueueDescriptor
 
struct  Rule
 
class  Runtime
 
class  RuntimeException
 
class  ScaledInt32Decoder
 
class  ScaledInt32PerAxisDecoder
 
class  ScopedCpuTensorHandle
 
class  ScopedProfilingEvent
 
struct  ScopedRecord
 
struct  ShapesAreBroadcastCompatible
 
struct  ShapesAreSameRank
 
struct  ShapesAreSameTotalSize
 
class  SimpleLogger
 
struct  SliceDescriptor
 A SliceDescriptor for the SliceLayer. More...
 
class  SliceLayer
 
struct  SliceQueueDescriptor
 
struct  SoftmaxDescriptor
 A SoftmaxDescriptor for the SoftmaxLayer. More...
 
class  SoftmaxLayer
 This layer represents a softmax operation. More...
 
struct  SoftmaxQueueDescriptor
 
struct  SpaceToBatchNdDescriptor
 A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer. More...
 
class  SpaceToBatchNdLayer
 This layer represents a SpaceToBatchNd operation. More...
 
struct  SpaceToBatchNdQueueDescriptor
 
struct  SpaceToDepthDescriptor
 A SpaceToDepthDescriptor for the SpaceToDepthLayer. More...
 
class  SpaceToDepthLayer
 This layer represents a SpaceToDepth operation. More...
 
struct  SpaceToDepthQueueDescriptor
 
class  SplitterLayer
 This layer represents a split operation. More...
 
struct  SplitterQueueDescriptor
 
struct  sqrt
 
struct  StackDescriptor
 A StackDescriptor for the StackLayer. More...
 
class  StackLayer
 This layer represents a stack operation. More...
 
struct  StackQueueDescriptor
 
class  StandardOutputSink
 
struct  StandInDescriptor
 A StandInDescriptor for the StandIn layer. More...
 
class  StandInLayer
 This layer represents an unknown operation in the input graph. More...
 
class  StaticRangeVisitor
 Visitor class to establish min/max ranges based on the type of the layer. More...
 
struct  StridedSliceDescriptor
 A StridedSliceDescriptor for the StridedSliceLayer. More...
 
class  StridedSliceLayer
 This layer represents a strided slice operation. More...
 
struct  StridedSliceQueueDescriptor
 
struct  StringifyLayerParameters
 StringifyLayerParameters allows serializing layer parameters to string. More...
 
struct  StringifyLayerParameters< ActivationDescriptor >
 
struct  StringifyLayerParameters< BatchNormalizationDescriptor >
 
struct  StringifyLayerParameters< BatchToSpaceNdDescriptor >
 
struct  StringifyLayerParameters< Convolution2dDescriptor >
 
struct  StringifyLayerParameters< DepthwiseConvolution2dDescriptor >
 
struct  StringifyLayerParameters< DetectionPostProcessDescriptor >
 
struct  StringifyLayerParameters< FakeQuantizationDescriptor >
 
struct  StringifyLayerParameters< FullyConnectedDescriptor >
 
struct  StringifyLayerParameters< L2NormalizationDescriptor >
 
struct  StringifyLayerParameters< LstmDescriptor >
 
struct  StringifyLayerParameters< MeanDescriptor >
 
struct  StringifyLayerParameters< NormalizationDescriptor >
 
struct  StringifyLayerParameters< OriginsDescriptor >
 
struct  StringifyLayerParameters< PadDescriptor >
 
struct  StringifyLayerParameters< PermuteDescriptor >
 
struct  StringifyLayerParameters< Pooling2dDescriptor >
 
struct  StringifyLayerParameters< PreCompiledDescriptor >
 
struct  StringifyLayerParameters< ReshapeDescriptor >
 
struct  StringifyLayerParameters< ResizeBilinearDescriptor >
 
struct  StringifyLayerParameters< ResizeDescriptor >
 
struct  StringifyLayerParameters< SoftmaxDescriptor >
 
struct  StringifyLayerParameters< SpaceToBatchNdDescriptor >
 
struct  StringifyLayerParameters< SpaceToDepthDescriptor >
 
struct  StringifyLayerParameters< StackDescriptor >
 
struct  StringifyLayerParameters< StridedSliceDescriptor >
 
struct  StringifyLayerParameters< TransposeConvolution2dDescriptor >
 
struct  StringifyLayerParameters< TransposeDescriptor >
 
struct  StringifyLayerParameters< ViewsDescriptor >
 
struct  StringMapping
 StringMapping is helper class to be able to use strings as template parameters, so this allows simplifying code which only differs in a string, such as a debug string literal. More...
 
class  SubgraphView
 The SubgraphView class represents a subgraph of a Graph. More...
 
class  SubgraphViewSelector
 Algorithm that splits a Graph into Subgraphs based on a filtering of layers (e.g. More...
 
class  SubtractionLayer
 This layer represents a subtraction operation. More...
 
struct  SubtractionQueueDescriptor
 
class  SwitchLayer
 This layer calculates both true and false outputs for input. More...
 
struct  SwitchQueueDescriptor
 
class  SyncMemGenericWorkload
 
class  Tensor
 A tensor defined by a TensorInfo (shape and data type) and a mutable backing store. More...
 
class  TensorBufferArrayView
 
class  TensorHandleFactoryRegistry
 
class  TensorInfo
 
struct  TensorNumDimensionsAreCorrect
 
class  TensorShape
 
class  TestBatchNormalizationLayerVisitor
 
class  TestConstantLayerVisitor
 
class  TestConvolution2dLayerVisitor
 
class  TestDepthwiseConvolution2dLayerVisitor
 
class  TestFullyConnectedLayerVistor
 
class  TestInputLayerVisitor
 
class  TestLayerVisitor
 
class  TestLstmLayerVisitor
 
class  TestOutputLayerVisitor
 
class  TestQLstmLayerVisitor
 
class  TestQuantizedLstmLayerVisitor
 
class  TimeoutException
 
class  TransformIterator
 
struct  TransposeConvolution2dDescriptor
 A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer. More...
 
class  TransposeConvolution2dLayer
 This layer represents a 2D transpose convolution operation. More...
 
struct  TransposeConvolution2dQueueDescriptor
 
struct  TransposeDescriptor
 A TransposeDescriptor for the TransposeLayer. More...
 
class  TransposeLayer
 This layer represents a transpose operation. More...
 
struct  TransposeQueueDescriptor
 
struct  TypeAnyOf
 
class  TypedIterator
 
class  TypedWorkload
 
struct  TypeIs
 
struct  TypeNotPerAxisQuantized
 
struct  TypesAreEqual
 
class  UnimplementedException
 
class  UnmapLayer
 This layer represents a memory copy operation. More...
 
struct  UnmapQueueDescriptor
 
class  UnmapWorkload
 
struct  ViewsDescriptor
 A ViewsDescriptor for the SplitterLayer. More...
 
struct  VisitorNoThrowPolicy
 
struct  VisitorThrowingPolicy
 
class  WallClockTimer
 
class  WorkloadDataCollector
 
class  WorkloadFactoryBase
 
struct  WorkloadInfo
 Contains information about inputs and outputs to a layer. More...
 

Typedefs

using BackendIdVector = std::vector< BackendId >
 
using BackendIdSet = std::unordered_set< BackendId >
 
using NetworkOptions = std::vector< BackendOptions >
 
using ModelOptions = std::vector< BackendOptions >
 
using IBackendInternalUniquePtr = std::unique_ptr< IBackendInternal >
 
using DynamicBackendPtr = std::unique_ptr< DynamicBackend >
 
using IBackendContextUniquePtr = std::unique_ptr< IBackendContext >
 
using IMemoryManagerUniquePtr = std::unique_ptr< IMemoryManager >
 
using LogSoftmaxDescriptor = SoftmaxDescriptor
 A LogSoftmaxDescriptor for the LogSoftmaxLayer. More...
 
using DepthToSpaceDescriptor = SpaceToDepthDescriptor
 A DepthToSpaceDescriptor for the DepthToSpaceLayer. More...
 
using ConcatDescriptor = OriginsDescriptor
 
using MergerDescriptor = OriginsDescriptor
 MergerDescriptor is deprecated, use ConcatDescriptor instead. More...
 
using SplitterDescriptor = ViewsDescriptor
 
using ILayerSupportSharedPtr = std::shared_ptr< ILayerSupport >
 
using INetworkPtr = std::unique_ptr< INetwork, void(*)(INetwork *network)>
 
using IOptimizedNetworkPtr = std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)>
 
using NetworkId = int
 
using IRuntimePtr = std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)>
 
using IGpuAccTunedParametersPtr = std::shared_ptr< IGpuAccTunedParameters >
 The following API is replaced by the backend options API. More...
 
using MemorySourceFlags = unsigned int
 
using BindingPointInfo = std::pair< armnn::LayerBindingId, armnn::TensorInfo >
 
using InputTensors = std::vector< std::pair< LayerBindingId, class ConstTensor > >
 
using OutputTensors = std::vector< std::pair< LayerBindingId, class Tensor > >
 
using IBackendSharedPtr = std::shared_ptr< IBackend >
 
using IBackendUniquePtr = std::unique_ptr< IBackend, void(*)(IBackend *backend)>
 
using LayerBindingId = int
 Type of identifiers for bindable layers (inputs, outputs). More...
 
using LayerGuid = profiling::ProfilingGuid
 Define LayerGuid type. More...
 
using DebugCallbackFunction = std::function< void(LayerGuid guid, unsigned int slotIndex, ITensorHandle *tensorHandle)>
 Define the type of callback for the Debug layer to call. More...
 
using INetworkQuantizerPtr = std::unique_ptr< class INetworkQuantizer, void(*)(INetworkQuantizer *quantizer)>
 
using WorkloadQueue = std::vector< std::unique_ptr< IWorkload > >
 
using Coordinates = std::array< unsigned int, MaxNumOfTensorDimensions >
 
using Dimensions = std::array< unsigned int, MaxNumOfTensorDimensions >
 
using CompiledBlobDeleter = std::function< void(const void *)>
 
using CompiledBlobPtr = std::unique_ptr< void, CompiledBlobDeleter >
 
using supported = ISubgraphViewConverter
 
using LayerPriority = unsigned int
 
using AdditionalInfoObjectPtr = std::shared_ptr< void >
 
using PreCompiledObjectDeleter = std::function< void(const void *)>
 
using PreCompiledObjectPtr = std::unique_ptr< void, PreCompiledObjectDeleter >
 
template<LayerType Type>
using LayerTypeOf = typename LayerTypeOfImpl< Type >::Type
 
using BackendsMap = std::map< BackendId, std::unique_ptr< class IBackendInternal > >
 
using OffsetScalePair = std::pair< float, int >
 
using TContainer = mapbox::util::variant< std::vector< float >, std::vector< int >, std::vector< unsigned char > >
 
template<DataType DT>
using ResolveType = typename ResolveTypeImpl< DT >::Type
 
using LoadedNetworks = std::unordered_map< NetworkId, std::unique_ptr< LoadedNetwork > >
 
using IReportStructure = profiling::IReportStructure
 
using ParameterStringifyFunction = std::function< void(const std::string &name, const std::string &value)>
 
using instead = SubgraphView
 
using MinMaxRange = std::pair< float, float >
 
using MinMaxRanges = std::vector< MinMaxRange >
 
using MinMaxRangeMap = std::unordered_map< LayerGuid, MinMaxRanges >
 
using Half = half_float::half
 
template<typename QueueDescriptor >
using FloatWorkload = TypedWorkload< QueueDescriptor, armnn::DataType::Float16, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Float32Workload = TypedWorkload< QueueDescriptor, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Uint8Workload = TypedWorkload< QueueDescriptor, armnn::DataType::QAsymmU8 >
 
template<typename QueueDescriptor >
using Int32Workload = TypedWorkload< QueueDescriptor, armnn::DataType::Signed32 >
 
template<typename QueueDescriptor >
using BooleanWorkload = TypedWorkload< QueueDescriptor, armnn::DataType::Boolean >
 
template<typename QueueDescriptor >
using BaseFloat32ComparisonWorkload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean >
 
template<typename QueueDescriptor >
using BaseUint8ComparisonWorkload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::QAsymmU8, armnn::DataType::Boolean >
 
template<typename QueueDescriptor >
using BFloat16ToFloat32Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::BFloat16, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Float32ToBFloat16Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float32, armnn::DataType::BFloat16 >
 
template<typename QueueDescriptor >
using Float16ToFloat32Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float16, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Float32ToFloat16Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float32, armnn::DataType::Float16 >
 
template<typename QueueDescriptor >
using Uint8ToFloat32Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::QAsymmU8, armnn::DataType::Float32 >
 
using InputQueueDescriptor = MemCopyQueueDescriptor
 
using OutputQueueDescriptor = MemCopyQueueDescriptor
 
using MergerQueueDescriptor = ConcatQueueDescriptor
 
using FactoryId = ITensorHandleFactory::FactoryId
 
using RefDebugBFloat16Workload = RefDebugWorkload< DataType::BFloat16 >
 
using RefDebugFloat16Workload = RefDebugWorkload< DataType::Float16 >
 
using RefDebugFloat32Workload = RefDebugWorkload< DataType::Float32 >
 
using RefDebugQAsymmU8Workload = RefDebugWorkload< DataType::QAsymmU8 >
 
using RefDebugQAsymmS8Workload = RefDebugWorkload< DataType::QAsymmS8 >
 
using RefDebugQSymmS16Workload = RefDebugWorkload< DataType::QSymmS16 >
 
using RefDebugQSymmS8Workload = RefDebugWorkload< DataType::QSymmS8 >
 
using RefDebugSigned32Workload = RefDebugWorkload< DataType::Signed32 >
 
template<typename DataType = float>
using RefAdditionWorkload = RefElementwiseWorkload< std::plus< DataType >, AdditionQueueDescriptor, StringMapping::RefAdditionWorkload_Execute >
 
template<typename DataType = float>
using RefSubtractionWorkload = RefElementwiseWorkload< std::minus< DataType >, SubtractionQueueDescriptor, StringMapping::RefSubtractionWorkload_Execute >
 
template<typename DataType = float>
using RefMultiplicationWorkload = RefElementwiseWorkload< std::multiplies< DataType >, MultiplicationQueueDescriptor, StringMapping::RefMultiplicationWorkload_Execute >
 
template<typename DataType = float>
using RefDivisionWorkload = RefElementwiseWorkload< std::divides< DataType >, DivisionQueueDescriptor, StringMapping::RefDivisionWorkload_Execute >
 
template<typename DataType = float>
using RefMaximumWorkload = RefElementwiseWorkload< armnn::maximum< DataType >, MaximumQueueDescriptor, StringMapping::RefMaximumWorkload_Execute >
 
template<typename DataType = float>
using RefMinimumWorkload = RefElementwiseWorkload< armnn::minimum< DataType >, MinimumQueueDescriptor, StringMapping::RefMinimumWorkload_Execute >
 
using RefPermuteBFloat16Workload = RefPermuteWorkload< DataType::BFloat16 >
 
using RefPermuteFloat16Workload = RefPermuteWorkload< DataType::Float16 >
 
using RefPermuteFloat32Workload = RefPermuteWorkload< DataType::Float32 >
 
using RefPermuteQAsymmS8Workload = RefPermuteWorkload< DataType::QAsymmS8 >
 
using RefPermuteQAsymm8Workload = RefPermuteWorkload< DataType::QAsymmU8 >
 
using RefPermuteQSymm16Workload = RefPermuteWorkload< DataType::QSymmS16 >
 
using RefTransposeBFloat16Workload = RefTransposeWorkload< DataType::BFloat16 >
 
using RefTransposeFloat16Workload = RefTransposeWorkload< DataType::Float16 >
 
using RefTransposeFloat32Workload = RefTransposeWorkload< DataType::Float32 >
 
using RefTransposeQAsymmS8Workload = RefTransposeWorkload< DataType::QAsymmS8 >
 
using RefTransposeQAsymm8Workload = RefTransposeWorkload< DataType::QAsymmU8 >
 
using RefTransposeQSymm16Workload = RefTransposeWorkload< DataType::QSymmS16 >
 

Enumerations

enum  Compute { Undefined = 0, CpuRef = 1, CpuAcc = 2, GpuAcc = 3 }
 The Compute enum is now deprecated and it is now being replaced by BackendId. More...
 
enum  CapabilityClass { PaddingRequired = 1, CapabilityClassMax = 254 }
 Capability class to calculate in the GetCapabilities function so that only the capability in the scope can be choose to calculate. More...
 
enum  EdgeStrategy { Undefined, DirectCompatibility, ExportToTarget, CopyToTarget }
 
enum  BoostLogSeverityMapping {
  trace, debug, info, warning,
  error, fatal
}
 
enum  MemorySource { Undefined = 0, Malloc = 1, DmaBuf = 2, DmaBufProtected = 4 }
 
enum  Status { Success = 0, Failure = 1 }
 enumeration More...
 
enum  DataType {
  Float16 = 0, Float32 = 1, QAsymmU8 = 2, Signed32 = 3,
  Boolean = 4, QSymmS16 = 5, QuantizedSymm8PerAxis = 6, QSymmS8 = 7,
  QAsymmS8 = 8, BFloat16 = 9, Signed64 = 10, QuantisedAsymm8 = QAsymmU8,
  QuantisedSymm16 = QSymmS16
}
 
enum  DataLayout { NCHW = 1, NHWC = 2 }
 
enum  ActivationFunction {
  Sigmoid = 0, TanH = 1, Linear = 2, ReLu = 3,
  BoundedReLu = 4, SoftReLu = 5, LeakyReLu = 6, Abs = 7,
  Sqrt = 8, Square = 9, Elu = 10, HardSwish = 11
}
 
enum  ArgMinMaxFunction { Min = 0, Max = 1 }
 
enum  ComparisonOperation {
  Equal = 0, Greater = 1, GreaterOrEqual = 2, Less = 3,
  LessOrEqual = 4, NotEqual = 5
}
 
enum  LogicalBinaryOperation { LogicalAnd = 0, LogicalOr = 1 }
 
enum  UnaryOperation {
  Abs = 0, Exp = 1, Sqrt = 2, Rsqrt = 3,
  Neg = 4, LogicalNot = 5
}
 
enum  PoolingAlgorithm { Max = 0, Average = 1, L2 = 2 }
 
enum  ResizeMethod { Bilinear = 0, NearestNeighbor = 1 }
 
enum  Dimensionality { NotSpecified = 0, Specified = 1, Scalar = 2 }
 
enum  PaddingMethod { IgnoreValue = 0, Exclude = 1 }
 The padding method modifies the output of pooling layers. More...
 
enum  NormalizationAlgorithmChannel { Across = 0, Within = 1 }
 
enum  NormalizationAlgorithmMethod { LocalBrightness = 0, LocalContrast = 1 }
 
enum  OutputShapeRounding { Floor = 0, Ceiling = 1 }
 
enum  ShapeInferenceMethod { ValidateOnly = 0, InferAndValidate = 1 }
 The ShapeInferenceMethod modify how the output shapes are treated. More...
 
enum  LogSeverity {
  Trace, Debug, Info, Warning,
  Error, Fatal
}
 
enum  GraphEvent { LayerAdded, LayerErased }
 
enum  LayerType {
  X, Activation, Addition, ArgMinMax,
  BatchNormalization, BatchToSpaceNd, Comparison, Concat,
  Constant, ConvertBf16ToFp32, ConvertFp16ToFp32, ConvertFp32ToBf16,
  ConvertFp32ToFp16, Convolution2d, Debug, DepthToSpace,
  DepthwiseConvolution2d, Dequantize, DetectionPostProcess, Division,
  ElementwiseUnary, FakeQuantization, Fill, Floor,
  FullyConnected, Gather, Input, InstanceNormalization,
  L2Normalization, LogicalBinary, LogSoftmax, Lstm,
  QLstm, Map, Maximum, Mean,
  MemCopy, MemImport, Merge, Minimum,
  Multiplication, Normalization, Output, Pad,
  Permute, Pooling2d, PreCompiled, Prelu,
  Quantize, QuantizedLstm, Reshape, Rank,
  Resize, Slice, Softmax, SpaceToBatchNd,
  SpaceToDepth, Splitter, Stack, StandIn,
  StridedSlice, Subtraction, Switch, Transpose,
  TransposeConvolution2d, Unmap, FirstLayer = Activation, LastLayer = Unmap
}
 
enum  JsonObjectType { Measurement, Event }
 
enum  TuningLevel { None, Rapid, Normal, Exhaustive }
 

Functions

std::shared_ptr< ILayerSupportGetILayerSupportByBackendId (const armnn::BackendId &backend)
 Convenience function to retrieve the ILayerSupport for a backend. More...
 
constexpr char const * GetComputeDeviceAsCString (Compute compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const std::vector< Compute > &compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const std::set< Compute > &compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const Compute &compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const BackendId &id)
 
template<template< typename... > class TContainer, typename... TContainerTemplateArgs>
std::ostream & operator<< (std::ostream &os, const TContainer< BackendId, TContainerTemplateArgs... > &ids)
 
template<typename F >
void ParseOptions (const std::vector< BackendOptions > &options, BackendId backend, F f)
 
BackendRegistryBackendRegistryInstance ()
 
std::ostream & operator<< (std::ostream &os, const BackendVersion &backendVersion)
 
template<typename TensorShapeIt >
OriginsDescriptor CreateMergerDescriptorForConcatenation (TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
 
template<typename TensorShapeIt >
OriginsDescriptor CreateDescriptorForConcatenation (TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
 Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing concatenation of a number of input tensors. More...
 
template<typename ExceptionType >
void ConditionalThrow (bool condition, const std::string &message)
 
template<typename ExceptionType >
void ConditionalThrow (bool condition)
 
template<typename ExceptionType , typename ComparedType >
void ConditionalThrowIfNotEqual (const std::string &message, const ComparedType &leftHandSide, const ComparedType &rightHandSide)
 ComparedType must support: operator==(const ComparedType&) operator<<(ostream&, const ComparedType&) More...
 
IOptimizedNetworkPtr Optimize (const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
 Create an optimized version of the network. More...
 
bool IsActivationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsAdditionSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsBatchNormalizationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsBatchToSpaceNdSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConcatSupported (const BackendId &backend, const std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConstantSupported (const BackendId &backend, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConvertFp16ToFp32Supported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConvertFp32ToFp16Supported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConvolution2dSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDebugSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDepthwiseConvolutionSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDequantizeSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDivisionSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsEqualSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsFakeQuantizationSupported (const BackendId &backend, const TensorInfo &input, const FakeQuantizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsFloorSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsFullyConnectedSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsGreaterSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsInputSupported (const BackendId &backend, const TensorInfo &input, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsL2NormalizationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsLstmSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMaximumSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnSupported=nullptr, size_t reasonIfUnSupportedMaxLength=0)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMeanSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const MeanDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMemCopySupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMergeSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMergerSupported (const BackendId &backend, const std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMinimumSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMultiplicationSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsNormalizationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsOutputSupported (const BackendId &backend, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsPadSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsPermuteSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const PermuteDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsPreCompiledSupported (const BackendId &backend, const TensorInfo &input, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsPreluSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &alpha, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsPooling2dSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const Pooling2dDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsQuantizedLstmSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &previousCellStateIn, const TensorInfo &previousOutputIn, const TensorInfo &cellStateOut, const TensorInfo &output, const QuantizedLstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsReshapeSupported (const BackendId &backend, const TensorInfo &input, const ReshapeDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsResizeBilinearSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsResizeSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsRsqrtSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsSoftmaxSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsSpaceToBatchNdSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const SpaceToBatchNdDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsSpaceToDepthSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const SpaceToDepthDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsSplitterSupported (const BackendId &backend, const TensorInfo &input, const ViewsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 
bool IsSplitterSupported (const BackendId &backend, const TensorInfo &input, const std::vector< std::reference_wrapper< TensorInfo >> &outputs, const ViewsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsStackSupported (const BackendId &backend, const std::vector< const TensorInfo *> inputs, const TensorInfo &output, const StackDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsStridedSliceSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsSubtractionSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsSwitchSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output0, const TensorInfo &output1, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsTransposeConvolution2dSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
std::string LevelToString (LogSeverity level)
 
void SetLogFilter (LogSeverity level)
 
void SetAllLoggingSinks (bool standardOut, bool debugOut, bool coloured)
 
constexpr LogSeverity ConvertLogSeverity (BoostLogSeverityMapping severity)
 
template<typename Arg , typename std::enable_if< IsMemorySource< Arg >::value >::type * = nullptr>
MemorySourceFlags Combine (Arg sourceA, Arg sourceB)
 
template<typename Arg , typename ... Args, typename std::enable_if< IsMemorySource< Arg >::value >::type * = nullptr>
MemorySourceFlags Combine (Arg source, Args... rest)
 
bool CheckFlag (MemorySourceFlags flags, MemorySource source)
 
template<typename T , class... Args>
Optional< T > MakeOptional (Args &&... args)
 Utility template that constructs an object of type T in-place and wraps it inside an Optional<T> object. More...
 
constexpr char const * GetStatusAsCString (Status status)
 
constexpr char const * GetActivationFunctionAsCString (ActivationFunction activation)
 
constexpr char const * GetArgMinMaxFunctionAsCString (ArgMinMaxFunction function)
 
constexpr char const * GetComparisonOperationAsCString (ComparisonOperation operation)
 
constexpr char const * GetUnaryOperationAsCString (UnaryOperation operation)
 
constexpr char const * GetLogicalBinaryOperationAsCString (LogicalBinaryOperation operation)
 
constexpr char const * GetPoolingAlgorithmAsCString (PoolingAlgorithm pooling)
 
constexpr char const * GetOutputShapeRoundingAsCString (OutputShapeRounding rounding)
 
constexpr char const * GetPaddingMethodAsCString (PaddingMethod method)
 
constexpr unsigned int GetDataTypeSize (DataType dataType)
 
template<unsigned N>
constexpr bool StrEqual (const char *strA, const char(&strB)[N])
 
constexpr armnn::Compute ParseComputeDevice (const char *str)
 Deprecated function that will be removed together with the Compute enum. More...
 
constexpr const char * GetDataTypeName (DataType dataType)
 
constexpr const char * GetDataLayoutName (DataLayout dataLayout)
 
constexpr const char * GetNormalizationAlgorithmChannelAsCString (NormalizationAlgorithmChannel channel)
 
constexpr const char * GetNormalizationAlgorithmMethodAsCString (NormalizationAlgorithmMethod method)
 
constexpr const char * GetResizeMethodAsCString (ResizeMethod method)
 
template<typename T >
constexpr bool IsQuantizedType ()
 
constexpr bool IsQuantized8BitType (DataType dataType)
 
constexpr bool IsQuantizedType (DataType dataType)
 
std::ostream & operator<< (std::ostream &os, Status stat)
 
std::ostream & operator<< (std::ostream &os, const armnn::TensorShape &shape)
 
template<typename QuantizedType >
QuantizedType Quantize (float value, float scale, int32_t offset)
 Quantize a floating point data type into an 8-bit data type. More...
 
template<typename QuantizedType >
float Dequantize (QuantizedType value, float scale, int32_t offset)
 Dequantize an 8-bit data type into a floating point data type. More...
 
void VerifyTensorInfoDataType (const armnn::TensorInfo &info, armnn::DataType dataType)
 
template<typename ... Ts>
void IgnoreUnused (Ts &&...)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_signed< Source >::value &&std::is_integral< Source >::value &&std::is_signed< Dest >::value &&std::is_integral< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_floating_point< Source >::value &&std::is_floating_point< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_floating_point< Source >::value &&std::is_signed< Dest >::value &&std::is_integral< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_signed< Source >::value &&std::is_integral< Source >::value &&std::is_floating_point< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_signed< Dest >::value &&std::is_integral< Dest >::value &&std::is_unsigned< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_floating_point< Dest >::value &&std::is_unsigned< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_unsigned< Dest >::value &&std::is_signed< Source >::value &&std::is_integral< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_unsigned< Dest >::value &&std::is_floating_point< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename DestType , typename SourceType >
DestType PolymorphicDowncast (SourceType value)
 Polymorphic downcast for build in pointers only. More...
 
template<typename DestType , typename SourceType >
auto PolymorphicPointerDowncast (const SourceType &value)
 Polymorphic downcast for shared pointers and build in pointers. More...
 
std::chrono::high_resolution_clock::time_point GetTimeNow ()
 
std::chrono::duration< double, std::milli > GetTimeDuration (std::chrono::high_resolution_clock::time_point start_time)
 
template<typename Function , typename Iterator >
constexpr TransformIterator< Function, Iterator > MakeTransformIterator (Iterator i, Function f)
 
void ConfigureLogging (bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
 Configures the logging behaviour of the ARMNN library. More...
 
template<typename T >
bool CompatibleTypes (DataType)
 
template<>
bool CompatibleTypes< float > (DataType dataType)
 
template<>
bool CompatibleTypes< Half > (DataType dataType)
 
template<>
bool CompatibleTypes< BFloat16 > (DataType dataType)
 
template<>
bool CompatibleTypes< uint8_t > (DataType dataType)
 
template<>
bool CompatibleTypes< int8_t > (DataType dataType)
 
template<>
bool CompatibleTypes< int16_t > (DataType dataType)
 
template<>
bool CompatibleTypes< int32_t > (DataType dataType)
 
void swap (OriginsDescriptor &first, OriginsDescriptor &second)
 
void swap (ViewsDescriptor &first, ViewsDescriptor &second)
 
char const * GetLayerTypeAsCString (LayerType type)
 
template<typename T >
constexpr LayerType LayerEnumOf (const T *=nullptr)
 
template<>
constexpr LayerType LayerEnumOf (const ActivationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const AdditionLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ArgMinMaxLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const BatchNormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const BatchToSpaceNdLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ComparisonLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConcatLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConstantLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertBf16ToFp32Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertFp16ToFp32Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertFp32ToBf16Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertFp32ToFp16Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const Convolution2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DebugLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DepthToSpaceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DepthwiseConvolution2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DequantizeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DetectionPostProcessLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DivisionLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ElementwiseUnaryLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FakeQuantizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FillLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FloorLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FullyConnectedLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const GatherLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const InputLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const InstanceNormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const L2NormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LogicalBinaryLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LogSoftmaxLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MapLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MaximumLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MeanLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MemCopyLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MemImportLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MergeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MinimumLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MultiplicationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const NormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const OutputLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PadLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PermuteLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const Pooling2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PreCompiledLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PreluLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const QuantizeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const QLstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const QuantizedLstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const RankLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ReshapeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ResizeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SliceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SoftmaxLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SpaceToBatchNdLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SpaceToDepthLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SplitterLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const StackLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const StandInLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const StridedSliceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SubtractionLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SwitchLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const TransposeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const TransposeConvolution2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const UnmapLayer *)
 
bool CheckTensorDataTypesEqual (const TensorInfo &input0, const TensorInfo &input1)
 
bool IsArgMinMaxSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsConcatSupported (const BackendId &backend, std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsDetectionPostProcessSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const DetectionPostProcessDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsGatherSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsGatherSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const GatherDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsMemImportSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsMergerSupported (const BackendId &backend, std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsQuantizeSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsQLstmSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &previousOutputIn, const TensorInfo &previousCellStateIn, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
bool IsReshapeSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ReshapeDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
 
template<typename T , typename V >
void SetValueChecked (Optional< T &> optionalRef, V &&val)
 
template<typename Float16Func , typename Float32Func , typename Uint8Func , typename Int32Func , typename BooleanFunc , typename ... Params>
bool IsSupportedForDataTypeGeneric (Optional< std::string &> reasonIfUnsupported, DataType dataType, Float16Func float16FuncPtr, Float32Func float32FuncPtr, Uint8Func uint8FuncPtr, Int32Func int32FuncPtr, BooleanFunc booleanFuncPtr, Params &&... params)
 
template<typename ... Params>
bool TrueFunc (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseFunc (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseFuncF16 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseFuncF32 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseFuncU8 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseFuncI32 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseInputFuncF32 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseInputFuncF16 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseOutputFuncF32 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<typename ... Params>
bool FalseOutputFuncF16 (Optional< std::string &> reasonIfUnsupported, Params &&... params)
 
template<LogSeverity Level>
void SetLoggingSinks (bool standardOut, bool debugOut, bool coloured)
 
void ReportError (const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
 
void ReportWarning (const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
 
OptimizationResult ReturnWithError (OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
 
bool CheckScaleSetOnQuantizedType (Layer *layer, Optional< std::vector< std::string > &> errMessages)
 
template<typename LayerT >
LayerT * ConvertBf16ToFp32Weight (Layer *l)
 
OptimizationResult AttemptBackendAssignment (BackendSettings &backendSettings, Graph &graph, Layer *layer, BackendId backend, DataType dataTypeIn, DataType dataTypeOut, const std::vector< BackendId > &availablePreferredBackends, std::string &reasonIfUnsupported, Optional< std::vector< std::string > &> errMessages)
 
OptimizationResult AssignBackends (OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > &> errMessages)
 
OptimizationResult AssignBackends (OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
 
BackendsMap CreateSupportedBackends (TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
 
OptimizationResult ApplyBackendOptimizations (OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > &> errMessages)
 
bool RequiresCopy (ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
 
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput (BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
 
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput (BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
 
ITensorHandleFactory::FactoryId CalculateSlotOption (BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry &registry)
 
EdgeStrategy CalculateEdgeStrategy (BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry &registry, bool importEnabled)
 
OptimizationResult SelectTensorHandleStrategy (Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, bool importEnabled, Optional< std::vector< std::string > &> errMessages)
 
ConstTensor CreateQuantizedConst (const ConstTensor &tensor, std::vector< uint8_t > &backing)
 
template<typename srcType >
void QuantizeConstant (const srcType *src, uint8_t *dst, size_t numElements, float &scale, int &offset)
 
template<typename LayerContainer >
void VisitLayers (const LayerContainer &layerContainer, ILayerVisitor &visitor)
 
std::vector< ConvertBf16ToFp32Layer * > InsertConvertBf16ToFp32LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersAfter (Graph &graph, Layer &layer)
 
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter (Graph &graph, Layer &layer)
 
std::vector< DebugLayer * > InsertDebugLayerAfter (Graph &graph, Layer &layer)
 
template<typename T >
void Append (Optimizer::Optimizations &optimizations, T &&optimization)
 
template<typename Front , typename... Others>
void Append (Optimizer::Optimizations &optimizations, Front &&front, Others &&... others)
 
template<typename... Args>
Optimizer::Optimizations MakeOptimizations (Args &&... args)
 
Measurement FindMeasurement (const std::string &name, const Event *event)
 
std::vector< MeasurementFindKernelMeasurements (const Event *event)
 
const EventGetEventPtr (const Event *ptr)
 
const EventGetEventPtr (const std::unique_ptr< Event > &ptr)
 
int CalcLevel (const Event *eventPtr)
 
void ExtractJsonObjects (unsigned int inferenceIndex, const Event *parentEvent, JsonChildObject &parentObject, std::map< const Event *, std::vector< const Event *>> descendantsMap)
 
template<typename Delegate >
void ForEachLayerInput (LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo, Delegate function)
 
template<typename Delegate >
void ForEachLayerOutput (LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo, Delegate function)
 
void AssignSplitId (LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo)
 
bool IsReadyForSplitAssignment (LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo)
 
 BOOST_AUTO_TEST_CASE (CheckConvolution2dLayer)
 
 BOOST_AUTO_TEST_CASE (CheckNamedConvolution2dLayer)
 
 BOOST_AUTO_TEST_CASE (CheckConvolution2dLayerWithBiases)
 
 BOOST_AUTO_TEST_CASE (CheckNamedConvolution2dLayerWithBiases)
 
 BOOST_AUTO_TEST_CASE (CheckDepthwiseConvolution2dLayer)
 
 BOOST_AUTO_TEST_CASE (CheckNamedDepthwiseConvolution2dLayer)
 
 BOOST_AUTO_TEST_CASE (CheckDepthwiseConvolution2dLayerWithBiases)
 
 BOOST_AUTO_TEST_CASE (CheckNamedDepthwiseConvolution2dLayerWithBiases)
 
 BOOST_AUTO_TEST_CASE (CheckFullyConnectedLayer)
 
 BOOST_AUTO_TEST_CASE (CheckNamedFullyConnectedLayer)
 
 BOOST_AUTO_TEST_CASE (CheckFullyConnectedLayerWithBiases)
 
 BOOST_AUTO_TEST_CASE (CheckNamedFullyConnectedLayerWithBiases)
 
 BOOST_AUTO_TEST_CASE (CheckBatchNormalizationLayer)
 
 BOOST_AUTO_TEST_CASE (CheckNamedBatchNormalizationLayer)
 
 BOOST_AUTO_TEST_CASE (CheckConstLayer)
 
 BOOST_AUTO_TEST_CASE (CheckNamedConstLayer)
 
 BOOST_AUTO_TEST_CASE (CheckLstmLayerBasic)
 
 BOOST_AUTO_TEST_CASE (CheckNamedLstmLayerBasic)
 
 BOOST_AUTO_TEST_CASE (CheckLstmLayerCifgDisabled)
 
 BOOST_AUTO_TEST_CASE (CheckNamedLstmLayerCifgDisabled)
 
 BOOST_AUTO_TEST_CASE (CheckLstmLayerPeephole)
 
 BOOST_AUTO_TEST_CASE (CheckLstmLayerPeepholeCifgDisabled)
 
 BOOST_AUTO_TEST_CASE (CheckNamedLstmLayerPeephole)
 
 BOOST_AUTO_TEST_CASE (CheckLstmLayerProjection)
 
 BOOST_AUTO_TEST_CASE (CheckNamedLstmLayerProjection)
 
 BOOST_AUTO_TEST_CASE (CheckQLstmLayerBasic)
 
 BOOST_AUTO_TEST_CASE (CheckNamedQLstmLayerBasic)
 
 BOOST_AUTO_TEST_CASE (CheckQLstmLayerCifgDisabled)
 
 BOOST_AUTO_TEST_CASE (CheckQLstmLayerCifgDisabledPeepholeEnabled)
 
 BOOST_AUTO_TEST_CASE (CheckQLstmLayerCifgEnabledPeepholeEnabled)
 
 BOOST_AUTO_TEST_CASE (CheckQLstmLayerProjectionEnabled)
 
 BOOST_AUTO_TEST_CASE (CheckQLstmLayerCifgDisabledLayerNormEnabled)
 
 BOOST_AUTO_TEST_CASE (CheckQuantizedLstmLayer)
 
 BOOST_AUTO_TEST_CASE (CheckNamedQuantizedLstmLayer)
 
size_t GetProfilerEventSequenceSize (armnn::Profiler *profiler)
 
void VisitLayersTopologically (const INetwork *inputNetwork, ILayerVisitor &visitor)
 
 BOOST_AUTO_TEST_CASE (QuantizeAddition)
 
INetworkPtr CreateNetworkWithActivationLayer (const ActivationDescriptor &descriptor, const TensorShape &shape)
 
INetworkPtr CreateNetworkWithInputOutputLayers ()
 
TensorInfo GetInputTensorInfo (const Network *network)
 
 BOOST_AUTO_TEST_CASE (InputOutputLayerDynamicQuant)
 
 BOOST_AUTO_TEST_CASE (QuantizeAbsActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeLinearActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeReLuActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeSoftReLuActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeBoundedReluActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeTanHActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeLeakyReLuActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeELuActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeHardSwishActivation)
 
 BOOST_AUTO_TEST_CASE (QuantizeBatchNorm)
 
 BOOST_AUTO_TEST_CASE (QuantizeDepthToSpace)
 
 BOOST_AUTO_TEST_CASE (OverrideInputRangeEmptyNetwork)
 
 BOOST_AUTO_TEST_CASE (OverrideInputRangeNoInputLayers)
 
 BOOST_AUTO_TEST_CASE (OverrideInputRangeInputLayers)
 
INetworkPtr CreateNetworkWithFullyConnectedLayer (const bool biasEnabled, const TensorShape &inputShape, const TensorShape &outputShape)
 
void ValidateFullyConnectedLayer (const bool biasEnabled)
 
 BOOST_AUTO_TEST_CASE (QuantizeFill)
 
 BOOST_AUTO_TEST_CASE (QuantizeFullyConnected)
 
 BOOST_AUTO_TEST_CASE (QuantizeFullyConnectedBiasEnabled)
 
void TestQuantizeConvolution2d (bool useBiases)
 
 BOOST_AUTO_TEST_CASE (QuantizeConvolution2d)
 
 BOOST_AUTO_TEST_CASE (QuantizeConvolution2dWithBiases)
 
void TestQuantizeDepthwiseConvolution2d (bool useBiases)
 
 BOOST_AUTO_TEST_CASE (QuantizeDepthwiseConvolution2d)
 
 BOOST_AUTO_TEST_CASE (QuantizeDepthwiseConvolution2dWithBiases)
 
 BOOST_AUTO_TEST_CASE (QuantizeInstanceNormalization)
 
 BOOST_AUTO_TEST_CASE (QuantizeLogSoftmax)
 
INetworkPtr CreateNetworkWithSoftmaxLayer (const SoftmaxDescriptor &descriptor, const TensorShape &shape)
 
 BOOST_AUTO_TEST_CASE (QuantizeSoftmax)
 
 BOOST_AUTO_TEST_CASE (QuantizeStandIn)
 
IConnectableLayerCreateStartOfLeakyReluNetwork (INetwork *network, const TensorInfo &info)
 
void CompleteLeakyReluNetwork (INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
 
 BOOST_AUTO_TEST_CASE (QuantizePermute)
 
 BOOST_AUTO_TEST_CASE (QuantizeSpaceToBatch)
 
 BOOST_AUTO_TEST_CASE (QuantizeSpaceToDepth)
 
 BOOST_AUTO_TEST_CASE (QuantizePooling2d)
 
 BOOST_AUTO_TEST_CASE (QuantizeConstant)
 
 BOOST_AUTO_TEST_CASE (QuantizeArgMinMax)
 
 BOOST_AUTO_TEST_CASE (QuantizeComparison)
 
 BOOST_AUTO_TEST_CASE (QuantizeConcat)
 
 BOOST_AUTO_TEST_CASE (QuantizeReshape)
 
 BOOST_AUTO_TEST_CASE (QuantizeSplitter)
 
 BOOST_AUTO_TEST_CASE (QuantizeResize)
 
 BOOST_AUTO_TEST_CASE (QuantizeStridedSlice)
 
 BOOST_AUTO_TEST_CASE (QuantizeBatchToSpace)
 
 BOOST_AUTO_TEST_CASE (QuantizePrelu)
 
void TestQuantizeTransposeConvolution2d (bool useBiases)
 
 BOOST_AUTO_TEST_CASE (QuantizeTransposeConvolution2d)
 
 BOOST_AUTO_TEST_CASE (QuantizeTransposeConvolution2dWithBiases)
 
 BOOST_AUTO_TEST_CASE (QuantizeStack)
 
 BOOST_AUTO_TEST_CASE (QuantizeSlice)
 
std::vector< uint8_t > SetupQuantize (float value)
 
 BOOST_AUTO_TEST_CASE (QuantizeInf)
 
 BOOST_AUTO_TEST_CASE (QuantizeNegativeInf)
 
void PreserveTypeTestImpl (const DataType &dataType)
 
 BOOST_AUTO_TEST_CASE (PreserveTypeFloat32)
 
 BOOST_AUTO_TEST_CASE (PreserveTypeQAsymmU8)
 
 BOOST_AUTO_TEST_CASE (PreserveTypeQsymm8)
 
 BOOST_AUTO_TEST_CASE (PreserveTypeQsymm16)
 
 BOOST_AUTO_TEST_CASE (TestConnectionPreservationAfterDynamicQuant)
 
void RuntimeLoadedNetworksReserve (armnn::Runtime *runtime)
 
std::ostream & boost_test_print_type (std::ostream &ostr, const TensorInfo &right)
 
std::ostream & boost_test_print_type (std::ostream &ostr, const TensorShape &shape)
 
 BOOST_AUTO_TEST_CASE (CheckInputLayerVisitorBindingIdAndName)
 
 BOOST_AUTO_TEST_CASE (CheckInputLayerVisitorBindingIdAndNameNull)
 
 BOOST_AUTO_TEST_CASE (CheckOutputLayerVisitorBindingIdAndName)
 
 BOOST_AUTO_TEST_CASE (CheckOutputLayerVisitorBindingIdAndNameNull)
 
void CheckLayerBindingId (LayerBindingId visitorId, LayerBindingId id)
 
profiling::ProfilingServiceGetProfilingService (armnn::Runtime *runtime)
 
std::ostream & operator<< (std::ostream &os, const BFloat16 &b)
 
void ReportUntouchedLayers (OptimizationViews &optimizationViews, std::map< LayerGuid, Layer *> untouched)
 
template<typename LayerType >
LayerTypeFuseLayerWithoutParameters (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseLayerWithParameters (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseLayerWithWeightsAndBiases (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
arm_compute::NormalizationLayerInfo CreateAclNormalizationLayerInfoForL2Normalization (const armnn::TensorInfo &tensorInfo, armnn::DataLayout dataLayout)
 
arm_compute::ActivationLayerInfo::ActivationFunction ConvertActivationFunctionToAclActivationFunction (ActivationFunction armnnFunction)
 
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo (const ActivationDescriptor &actDesc)
 
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo (const ActivationDescriptor *activationDescPtr)
 
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo (const QueueDescriptor &queueDescriptor)
 
arm_compute::ComparisonOperation ConvertComparisonOperationToAcl (const ComparisonDescriptor &descriptor)
 
arm_compute::PoolingType ConvertPoolingAlgorithmToAclPoolingType (PoolingAlgorithm poolingAlgorithm)
 
arm_compute::DimensionRoundingType ConvertOutputShapeRoundingToAclDimensionRoundingType (OutputShapeRounding rounding)
 
arm_compute::NormType ConvertNormalizationAlgorithmChannelToAclNormType (NormalizationAlgorithmChannel channelType)
 
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo (const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
 
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo (const FullyConnectedDescriptor &fullyConnectedDesc, arm_compute::ActivationLayerInfo activationLayerInfo)
 
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy (ResizeMethod resizeMethod)
 
template<typename T >
ComputeSoftmaxAclAxis (const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)
 
std::set< unsigned int > ComputeSplitAxis (const armnn::SplitterDescriptor &desc, const TensorShape &input)
 
int ComputeAclAxis (const int &armnnAxis, const armnn::TensorInfo &tensor)
 Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank, rank) More...
 
unsigned int ComputePositiveAxis (const int &axis, const armnn::TensorInfo &tensor)
 Function to convert axis to its positive equivalent value. More...
 
TensorShape GetUnpaddedTensorStrides (const TensorInfo &tensorInfo)
 
armnn::Optional< armnn::DataTypeGetBiasTypeFromWeightsType (armnn::Optional< armnn::DataType > weightsType)
 
template<typename F >
bool CheckSupportRule (F rule, Optional< std::string &> reasonIfUnsupported, const char *reason)
 
template<typename T >
bool AllTypesAreEqualImpl (T)
 
template<typename T , typename... Rest>
bool AllTypesAreEqualImpl (T t1, T t2, Rest... rest)
 
constexpr const char * MockImportBackendId ()
 
constexpr const char * MockBackendId ()
 
DataType GetBiasDataType (DataType inputDataType)
 
armnn::ConstTensor PermuteTensor (const ConstCpuTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
 
void ReshapeWeightsForAcl (TensorInfo &weightInfo, DataLayout dataLayout)
 
template<typename DataType >
ConstTensor ReorderWeightChannelsForAcl (const ConstTensor &weightHandle, DataLayout dataLayout, void *permuteBuffer)
 
TensorInfo ConvertWeightTensorInfoFromArmnnToAcl (const TensorInfo &weightInfo, DataLayout dataLayout)
 
armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl (const ConstCpuTensorHandle *weightTensor, DataLayout dataLayout, void *permuteBuffer)
 
int32_t ConvertMaskToACLFormat (int32_t mask, int32_t numDim)
 
template<typename CopyFunc >
void CopyTensorContentsGeneric (const ITensorHandle *srcTensor, ITensorHandle *dstTensor, CopyFunc copy)
 
template<typename SrcTensorHandleType , typename DstTensorHandleType , typename DescriptorType >
void GatherTensorHandlePairs (const DescriptorType &descriptor, std::vector< std::pair< SrcTensorHandleType *, DstTensorHandleType *>> &tensorHandlePairs)
 
std::string LowerString (std::string value)
 
TuningLevel ParseTuningLevel (const BackendOptions::Var &value, TuningLevel defaultValue)
 
bool ParseBoolean (const BackendOptions::Var &value, bool defaultValue)
 
std::string ParseFile (const BackendOptions::Var &value, std::string defaultValue)
 
void ConfigureTuner (arm_compute::CLTuner &tuner, TuningLevel level)
 
constexpr const char * ClBackendId ()
 
constexpr const char * ClTensorHandleFactoryId ()
 
arm_compute::Status ClAbsWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClActivationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor)
 
arm_compute::Status ClAdditionValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClArgMinMaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor)
 
arm_compute::Status ClBatchNormalizationValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &desc, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClBatchToSpaceNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &desc)
 
arm_compute::Status ClComparisonWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ComparisonDescriptor &descriptor)
 
arm_compute::Status ClConcatWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const OriginsDescriptor &descriptor)
 
arm_compute::Status ClConstantWorkloadValidate (const TensorInfo &output)
 
arm_compute::Status ClConvertFp16ToFp32WorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClConvertFp32ToFp16WorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClDepthToSpaceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthToSpaceDescriptor &desc)
 
arm_compute::Status ClDepthwiseConvolutionWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClDequantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClDivisionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClExpWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClFloorWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClFullyConnectedWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClGatherWorkloadValidate (const TensorInfo &input, const TensorInfo &indices, const TensorInfo &output, const GatherDescriptor &descriptor)
 
arm_compute::Status ClInstanceNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const InstanceNormalizationDescriptor &descriptor)
 
arm_compute::Status ClL2NormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor)
 
arm_compute::Status ClLogicalAndWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClLogicalNotWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClLogicalOrWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClLogSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const LogSoftmaxDescriptor &descriptor)
 
arm_compute::Status ClLstmFloatWorkloadValidate (const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
 
arm_compute::Status ClMaximumWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClMeanValidate (const TensorInfo &input, const TensorInfo &output, const MeanDescriptor &desc)
 
arm_compute::Status ClMinimumWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClMultiplicationWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClNegWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor)
 
arm_compute::Status ClPadValidate (const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
 
arm_compute::Status ClPermuteWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const PermuteDescriptor &descriptor)
 
arm_compute::Status ClPooling2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Pooling2dDescriptor &descriptor)
 
arm_compute::Status ClPreluWorkloadValidate (const TensorInfo &input, const TensorInfo &alpha, const TensorInfo &output)
 
arm_compute::Status ClQLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
 
arm_compute::Status ClQuantizedLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &previousCellStateIn, const TensorInfo &previousOutputIn, const TensorInfo &cellStateOut, const TensorInfo &output, const QuantizedLstmInputParamsInfo &paramsInfo)
 
arm_compute::Status ClQuantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClReshapeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClResizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor)
 
arm_compute::Status ClRsqrtWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SliceDescriptor &descriptor)
 
arm_compute::Status ClSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor)
 
arm_compute::Status ClSpaceToBatchNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SpaceToBatchNdDescriptor &descriptor)
 
arm_compute::Status ClSpaceToDepthWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SpaceToDepthDescriptor &desc)
 
arm_compute::Status ClSplitterWorkloadValidate (const TensorInfo &input, const std::vector< std::reference_wrapper< TensorInfo >> &outputs, unsigned int splitAxis)
 
arm_compute::Status ClStackWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const StackDescriptor &descriptor)
 
arm_compute::Status ClStridedSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor)
 
arm_compute::Status ClSubtractionValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClTransposeConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
arm_compute::Status ClTransposeWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeDescriptor &descriptor)
 
template<typename T >
void CopyArmComputeClTensorData (arm_compute::CLTensor &dstTensor, const T *srcData)
 
auto SetClStridedSliceData (const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)
 
auto SetClSliceData (const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)
 
void InitializeArmComputeClTensorData (arm_compute::CLTensor &clTensor, const ConstCpuTensorHandle *handle)
 
RuntimeException WrapClError (const cl::Error &clError, const CheckLocation &location)
 
void RunClFunction (arm_compute::IFunction &function, const CheckLocation &location)
 
constexpr const char * NeonBackendId ()
 
constexpr const char * NeonTensorHandleFactoryId ()
 
arm_compute::Status NeonAbsWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonActivationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor)
 
arm_compute::Status NeonAdditionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonArgMinMaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor)
 
arm_compute::Status NeonBatchNormalizationValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonBatchToSpaceNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &desc)
 
arm_compute::Status NeonComparisonWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ComparisonDescriptor &descriptor)
 
arm_compute::Status NeonConcatWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const OriginsDescriptor &descriptor)
 
arm_compute::Status NeonConstantWorkloadValidate (const TensorInfo &output)
 
arm_compute::Status NeonConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonDepthToSpaceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthToSpaceDescriptor &descriptor)
 
arm_compute::Status NeonDepthwiseConvolutionWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonDequantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::DetectionPostProcessLayerInfo MakeInfo (const DetectionPostProcessDescriptor &desc)
 
arm_compute::Status NeonDetectionPostProcessValidate (const TensorInfo &boxEncodings, const TensorInfo &scores, const TensorInfo &anchors, const TensorInfo &detectionBoxes, const TensorInfo &detectionClasses, const TensorInfo &detectionScores, const TensorInfo &numDetections, const DetectionPostProcessDescriptor &desc)
 
arm_compute::Status NeonDivisionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonExpWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonFullyConnectedWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonGatherWorkloadValidate (const TensorInfo &input, const TensorInfo &indices, const TensorInfo &output, const GatherDescriptor &descriptor)
 
arm_compute::Status NeonInstanceNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const InstanceNormalizationDescriptor &descriptor)
 
arm_compute::Status NeonL2NormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor)
 
arm_compute::Status NeonLogicalAndWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status NeonLogicalNotWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonLogicalOrWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status NeonLogSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const LogSoftmaxDescriptor &descriptor)
 
arm_compute::Status NeonLstmFloatWorkloadValidate (const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
 
arm_compute::Status NeonMaximumWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status NeonMeanWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const MeanDescriptor &desc)
 
arm_compute::Status NeonMinimumWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 Validate function for validating the inputs and output. More...
 
arm_compute::Status NeonMultiplicationWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonNegWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor)
 
arm_compute::Status NeonPadWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
 
arm_compute::Status NeonPermuteWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const PermuteDescriptor &descriptor)
 
arm_compute::Status NeonPooling2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Pooling2dDescriptor &descriptor)
 
arm_compute::Status NeonPreluWorkloadValidate (const TensorInfo &input, const TensorInfo &alpha, const TensorInfo &output)
 
arm_compute::Status NeonQLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
 
arm_compute::Status NeonQuantizedLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const QuantizedLstmInputParamsInfo &paramsInfo)
 
arm_compute::Status NeonQuantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonReshapeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonResizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor)
 
arm_compute::Status NeonRsqrtWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SliceDescriptor &descriptor)
 
arm_compute::Status NeonSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor)
 
arm_compute::Status NeonSpaceToBatchNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SpaceToBatchNdDescriptor &descriptor)
 
arm_compute::Status NeonSpaceToDepthWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SpaceToDepthDescriptor &descriptor)
 
arm_compute::Status NeonSplitterWorkloadValidate (const TensorInfo &input, const std::vector< std::reference_wrapper< TensorInfo >> &outputs, unsigned int splitAxis)
 
arm_compute::Status NeonStackWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const StackDescriptor &descriptor)
 
arm_compute::Status NeonStridedSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor)
 
arm_compute::Status NeonSubtractionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonTransposeConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
arm_compute::Status NeonTransposeWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeDescriptor &descriptor)
 
template<typename T >
void CopyArmComputeTensorData (arm_compute::Tensor &dstTensor, const T *srcData)
 
void InitializeArmComputeTensorData (arm_compute::Tensor &tensor, const ConstCpuTensorHandle *handle)
 
auto SetNeonStridedSliceData (const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)
 
auto SetNeonSliceData (const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)
 
constexpr const char * RefBackendId ()
 
constexpr const char * RefTensorHandleFactoryId ()
 
template<DataType ArmnnType>
bool IsDataType (const WorkloadInfo &info)
 
bool IsSigned32 (const WorkloadInfo &info)
 
bool IsBFloat16 (const WorkloadInfo &info)
 
bool IsFloat16 (const WorkloadInfo &info)
 
bool IsQSymmS16 (const WorkloadInfo &info)
 
bool IsQSymmS8 (const WorkloadInfo &info)
 
bool IsQAsymmS8 (const WorkloadInfo &info)
 
bool IsQAsymmU8 (const WorkloadInfo &info)
 
template<typename QueueDescriptorType >
constexpr bool IsOperationQueueDescriptor (const QueueDescriptorType &)
 
template<>
constexpr bool IsOperationQueueDescriptor (const MemCopyQueueDescriptor &)
 
template<>
constexpr bool IsOperationQueueDescriptor (const ConstantQueueDescriptor &)
 
template<>
constexpr bool IsOperationQueueDescriptor (const PermuteQueueDescriptor &)
 
float Activation (float in, ActivationFunction function, float a, float b)
 
void Activation (Decoder< float > &in, Encoder< float > &out, const TensorInfo &tensorInfo, ActivationFunction function, float a, float b)
 
template<typename OUT >
void ArgMinMax (Decoder< float > &in, OUT *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
 
template void ArgMinMax (Decoder< float > &in, int32_t *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
 
template void ArgMinMax (Decoder< float > &in, int64_t *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
 
void BatchNormImpl (const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
 
unsigned int Offset (const TensorShape &shape, unsigned int batch, unsigned int height, unsigned int width, unsigned int channels, const DataLayoutIndexed &dataLayout)
 
void BatchToSpaceNd (const DataLayoutIndexed &dataLayout, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, const std::vector< unsigned int > &blockShape, const std::vector< std::pair< unsigned int, unsigned int >> &cropsData, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
 
void Concatenate (const ConcatQueueDescriptor &data)
 
void Convolve (const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rFilterShape, Decoder< float > &rFilterDecoder, bool biasEnabled, Decoder< float > *pBiasDecoder, DataLayout dataLayout, unsigned int paddingTop, unsigned int paddingLeft, unsigned int xStride, unsigned int yStride, unsigned int xDilation, unsigned int yDilation, bool depthwise)
 
template<typename T >
void Debug (const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< BFloat16 > (const TensorInfo &inputInfo, const BFloat16 *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< Half > (const TensorInfo &inputInfo, const Half *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< float > (const TensorInfo &inputInfo, const float *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< uint8_t > (const TensorInfo &inputInfo, const uint8_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< int8_t > (const TensorInfo &inputInfo, const int8_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< int16_t > (const TensorInfo &inputInfo, const int16_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< int32_t > (const TensorInfo &inputInfo, const int32_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template<typename T >
std::unique_ptr< Decoder< T > > MakeDecoder (const TensorInfo &info, const void *data=nullptr)
 
template<>
std::unique_ptr< Decoder< float > > MakeDecoder (const TensorInfo &info, const void *data)
 
template<>
std::unique_ptr< Decoder< bool > > MakeDecoder (const TensorInfo &info, const void *data)
 
template<>
std::unique_ptr< Decoder< int32_t > > MakeDecoder (const TensorInfo &info, const void *data)
 
void DepthToSpace (const TensorInfo &inputInfo, const DepthToSpaceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
 
void Dequantize (Decoder< float > &inputDecoder, Encoder< float > &outputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo)
 
std::vector< unsigned int > GenerateRangeK (unsigned int k)
 
void TopKSort (unsigned int k, unsigned int *indices, const float *values, unsigned int numElement)
 
float IntersectionOverUnion (const float *boxI, const float *boxJ)
 
std::vector< unsigned int > NonMaxSuppression (unsigned int numBoxes, const std::vector< float > &boxCorners, const std::vector< float > &scores, float nmsScoreThreshold, unsigned int maxDetection, float nmsIouThreshold)
 
void AllocateOutputData (unsigned int numOutput, unsigned int numSelected, const std::vector< float > &boxCorners, const std::vector< unsigned int > &outputIndices, const std::vector< unsigned int > &selectedBoxes, const std::vector< unsigned int > &selectedClasses, const std::vector< float > &selectedScores, float *detectionBoxes, float *detectionScores, float *detectionClasses, float *numDetections)
 
void DetectionPostProcess (const TensorInfo &boxEncodingsInfo, const TensorInfo &scoresInfo, const TensorInfo &anchorsInfo, const TensorInfo &detectionBoxesInfo, const TensorInfo &detectionClassesInfo, const TensorInfo &detectionScoresInfo, const TensorInfo &numDetectionsInfo, const DetectionPostProcessDescriptor &desc, Decoder< float > &boxEncodings, Decoder< float > &scores, Decoder< float > &anchors, float *detectionBoxes, float *detectionClasses, float *detectionScores, float *numDetections)
 
template<typename T >
std::unique_ptr< Encoder< T > > MakeEncoder (const TensorInfo &info, void *data=nullptr)
 
template<>
std::unique_ptr< Encoder< float > > MakeEncoder (const TensorInfo &info, void *data)
 
template<>
std::unique_ptr< Encoder< bool > > MakeEncoder (const TensorInfo &info, void *data)
 
template<>
std::unique_ptr< Encoder< int32_t > > MakeEncoder (const TensorInfo &info, void *data)
 
void Fill (Encoder< float > &output, const TensorShape &desiredOutputShape, const float value)
 Creates a tensor and fills it with a scalar value. More...
 
void FullyConnected (const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > &rBiasDecoder, bool biasEnabled, unsigned int K, bool transposeWeights)
 Performs a matrix multiplication and optionally adds a bias. More...
 
void Gather (const TensorInfo &paramsInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo, Decoder< float > &params, const int32_t *indices, Encoder< float > &output, const int32_t axis)
 
void InstanceNorm (const InstanceNormalizationQueueDescriptor &data, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
 
void LogSoftmax (Decoder< float > &input, Encoder< float > &output, const TensorInfo &inputInfo, const LogSoftmaxDescriptor &descriptor)
 
bool NextIndex (const unsigned int numDims, const armnn::TensorShape &dims, std::vector< unsigned int > &current)
 
unsigned int ReducedOutputOffset (const unsigned int numDims, const armnn::TensorShape &dims, std::vector< unsigned int > &index, const unsigned int numAxis, const std::vector< unsigned int > &axis)
 
void Mean (const armnn::TensorInfo &inputInfo, const armnn::TensorInfo &outputInfo, const std::vector< unsigned int > &axis, Decoder< float > &input, Encoder< float > &output)
 
void Pad (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const PadQueueDescriptor &data)
 
void Pooling2d (Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
 Computes the Pooling2d operation. More...
 
void PreluImpl (const PreluQueueDescriptor &data, Decoder< float > &inputData, Decoder< float > &alphaData, Encoder< float > &outputData)
 
void FakeQuantization (const float *inputData, float *outputData, uint32_t numElements, float min, float max)
 
const TensorInfoGetTensorInfo (const ITensorHandle *tensorHandle)
 float32 helpers More...
 
template<typename DataType , typename PayloadType >
const DataTypeGetInputTensorData (unsigned int idx, const PayloadType &data)
 
template<typename DataType , typename PayloadType >
DataTypeGetOutputTensorData (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
const float * GetInputTensorDataFloat (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
float * GetOutputTensorDataFloat (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
const HalfGetInputTensorDataHalf (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
HalfGetOutputTensorDataHalf (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
const BFloat16GetInputTensorDataBFloat16 (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
BFloat16GetOutputTensorDataBFloat16 (unsigned int idx, const PayloadType &data)
 
template<typename T >
std::vector< float > Dequantize (const T *quant, const TensorInfo &info)
 u8 helpers More...
 
template<typename T >
void Dequantize (const T *inputData, float *outputData, const TensorInfo &info)
 
void Quantize (uint8_t *quant, const float *dequant, const TensorInfo &info)
 
void Resize (Decoder< float > &in, const TensorInfo &inputInfo, Encoder< float > &out, const TensorInfo &outputInfo, DataLayoutIndexed dataLayout, armnn::ResizeMethod resizeMethod, bool alignCorners, bool halfPixelCenters)
 
void Slice (const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
 
void Softmax (Decoder< float > &in, Encoder< float > &out, const TensorInfo &inputTensorInfo, float beta, int axis)
 Computes the softmax function on some inputs, into outputs, with a shape given by tensorInfo. More...
 
unsigned int GetOffset (const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
 
void SpaceToBatchNd (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToBatchNdDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
 
void SpaceToDepth (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToDepthDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
 
void Split (const SplitterQueueDescriptor &data)
 
template<typename DataType >
void Splitter (const SplitterQueueDescriptor &data)
 
void Stack (const StackQueueDescriptor &data, std::vector< std::unique_ptr< Decoder< float >>> &inputs, Encoder< float > &output)
 
void StridedSlice (const TensorInfo &inputInfo, const StridedSliceDescriptor &params, const void *inputData, void *outputData, unsigned int dataTypeSize)
 
void TransposeConvolution2dImpl (const TransposeConvolution2dDescriptor &descriptor, const TensorShape &inputShape, Decoder< float > &inputDecoder, const TensorShape &outputShape, Encoder< float > &outputEncoder, const TensorShape &weightsShape, Decoder< float > &weightsDecoder, Decoder< float > *biasesDecoder)
 
std::istream & operator>> (std::istream &in, armnn::Compute &compute)
 
std::istream & operator>> (std::istream &in, armnn::BackendId &backend)
 

Variables

constexpr unsigned int MaxNumOfTensorDimensions = 5U
 
constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u
 The lowest performance data capture interval we support is 10 miliseconds. More...
 
constexpr std::size_t g_ProfilingEventCountHint = 1024
 
constexpr bool g_WriteProfilingEventSequence = true
 
constexpr bool g_AggregateProfilingEventsByInference = true
 
constexpr bool g_WriteReportToStdOutOnProfilerDestruction = false
 
thread_local Profilertl_Profiler = nullptr
 
const float g_AsymmU8QuantizationBase = 255.0f
 
const float g_AsymmS8QuantizationBase = 255.0f
 
const float g_SymmS8QuantizationBase = 127.0f
 
const float g_SymmS16QuantizationBase = 32767.0f
 
const float g_TestTolerance = 0.000001f
 
const std::set< armnn::LayerTypepaddingRequiredLayers
 

Detailed Description

Copyright (c) 2020 ARM Limited.

When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.

Optional is a drop in replacement for std::optional until we migrate to c++-17.

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.

Only a subset of the optional features are implemented that we intend to use in ArmNN. There are two distinct implementations here:

1, for normal constructable/destructable types and reference types 2, for reference types The std::optional features we support are:

  • has_value() and operator bool() to tell if the optional has a value
  • value() returns a reference to the held object

Typedef Documentation

◆ AdditionalInfoObjectPtr

using AdditionalInfoObjectPtr = std::shared_ptr<void>

Definition at line 208 of file Layer.hpp.

◆ BackendIdSet

using BackendIdSet = std::unordered_set<BackendId>

Definition at line 191 of file BackendId.hpp.

◆ BackendIdVector

using BackendIdVector = std::vector<BackendId>

Definition at line 190 of file BackendId.hpp.

◆ BackendsMap

using BackendsMap = std::map<BackendId, std::unique_ptr<class IBackendInternal> >

Definition at line 325 of file Network.hpp.

◆ BaseFloat32ComparisonWorkload

◆ BaseUint8ComparisonWorkload

◆ BFloat16ToFloat32Workload

◆ BindingPointInfo

Definition at line 261 of file Tensor.hpp.

◆ BooleanWorkload

◆ CompiledBlobDeleter

using CompiledBlobDeleter = std::function<void(const void*)>

Definition at line 17 of file ISubgraphViewConverter.hpp.

◆ CompiledBlobPtr

using CompiledBlobPtr = std::unique_ptr<void, CompiledBlobDeleter>

Definition at line 18 of file ISubgraphViewConverter.hpp.

◆ ConcatDescriptor

Definition at line 50 of file DescriptorsFwd.hpp.

◆ Coordinates

using Coordinates = std::array<unsigned int, MaxNumOfTensorDimensions>

Definition at line 97 of file InternalTypes.hpp.

◆ DebugCallbackFunction

using DebugCallbackFunction = std::function<void(LayerGuid guid, unsigned int slotIndex, ITensorHandle* tensorHandle)>

Define the type of callback for the Debug layer to call.

Parameters
guid- guid of layer connected to the input of the Debug layer
slotIndex- index of the output slot connected to the input of the Debug layer
tensorHandle- TensorHandle for the input tensor to the Debug layer

Definition at line 275 of file Types.hpp.

◆ DepthToSpaceDescriptor

A DepthToSpaceDescriptor for the DepthToSpaceLayer.

Definition at line 894 of file Descriptors.hpp.

◆ Dimensions

using Dimensions = std::array<unsigned int, MaxNumOfTensorDimensions>

Definition at line 98 of file InternalTypes.hpp.

◆ DynamicBackendPtr

using DynamicBackendPtr = std::unique_ptr<DynamicBackend>

Definition at line 52 of file DynamicBackend.hpp.

◆ FactoryId

◆ Float16ToFloat32Workload

◆ Float32ToBFloat16Workload

◆ Float32ToFloat16Workload

◆ Float32Workload

◆ FloatWorkload

◆ Half

using Half = half_float::half

Definition at line 16 of file Half.hpp.

◆ IBackendContextUniquePtr

using IBackendContextUniquePtr = std::unique_ptr<IBackendContext>

Definition at line 31 of file IBackendContext.hpp.

◆ IBackendInternalUniquePtr

typedef std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr

Definition at line 23 of file BackendRegistry.hpp.

◆ IBackendSharedPtr

using IBackendSharedPtr = std::shared_ptr<IBackend>

Definition at line 188 of file Types.hpp.

◆ IBackendUniquePtr

using IBackendUniquePtr = std::unique_ptr<IBackend, void(*)(IBackend* backend)>

Definition at line 189 of file Types.hpp.

◆ IGpuAccTunedParametersPtr

The following API is replaced by the backend options API.

Definition at line 177 of file IRuntime.hpp.

◆ ILayerSupportSharedPtr

using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>

Definition at line 424 of file ILayerSupport.hpp.

◆ IMemoryManagerUniquePtr

using IMemoryManagerUniquePtr = std::unique_ptr<IMemoryManager>

Definition at line 24 of file IMemoryManager.hpp.

◆ INetworkPtr

using INetworkPtr = std::unique_ptr<INetwork, void(*)(INetwork* network)>

Definition at line 101 of file INetwork.hpp.

◆ INetworkQuantizerPtr

using INetworkQuantizerPtr = std::unique_ptr<class INetworkQuantizer, void(*)(INetworkQuantizer* quantizer)>

Definition at line 29 of file INetworkQuantizer.hpp.

◆ InputQueueDescriptor

Definition at line 81 of file WorkloadData.hpp.

◆ InputTensors

using InputTensors = std::vector<std::pair<LayerBindingId, class ConstTensor> >

Definition at line 340 of file Tensor.hpp.

◆ instead

Definition at line 102 of file SubgraphView.hpp.

◆ Int32Workload

◆ IOptimizedNetworkPtr

using IOptimizedNetworkPtr = std::unique_ptr<IOptimizedNetwork, void(*)(IOptimizedNetwork* network)>

Definition at line 600 of file INetwork.hpp.

◆ IReportStructure

Definition at line 28 of file Runtime.hpp.

◆ IRuntimePtr

using IRuntimePtr = std::unique_ptr<IRuntime, void(*)(IRuntime* runtime)>

Definition at line 25 of file IRuntime.hpp.

◆ LayerBindingId

using LayerBindingId = int

Type of identifiers for bindable layers (inputs, outputs).

Definition at line 202 of file Types.hpp.

◆ LayerGuid

Define LayerGuid type.

Definition at line 267 of file Types.hpp.

◆ LayerPriority

using LayerPriority = unsigned int

Definition at line 207 of file Layer.hpp.

◆ LayerTypeOf

using LayerTypeOf = typename LayerTypeOfImpl<Type>::Type

Definition at line 82 of file LayersFwd.hpp.

◆ LoadedNetworks

using LoadedNetworks = std::unordered_map<NetworkId, std::unique_ptr<LoadedNetwork> >

Definition at line 27 of file Runtime.hpp.

◆ LogSoftmaxDescriptor

A LogSoftmaxDescriptor for the LogSoftmaxLayer.

Definition at line 153 of file Descriptors.hpp.

◆ MemorySourceFlags

using MemorySourceFlags = unsigned int

Definition at line 21 of file MemorySources.hpp.

◆ MergerDescriptor

MergerDescriptor is deprecated, use ConcatDescriptor instead.

Definition at line 54 of file DescriptorsFwd.hpp.

◆ MergerQueueDescriptor

Definition at line 139 of file WorkloadData.hpp.

◆ MinMaxRange

using MinMaxRange = std::pair<float, float>

Definition at line 28 of file QuantizerTest.cpp.

◆ MinMaxRangeMap

using MinMaxRangeMap = std::unordered_map<LayerGuid, MinMaxRanges>

Definition at line 30 of file QuantizerTest.cpp.

◆ MinMaxRanges

using MinMaxRanges = std::vector<MinMaxRange>

Definition at line 29 of file QuantizerTest.cpp.

◆ ModelOptions

using ModelOptions = std::vector<BackendOptions>

Definition at line 17 of file BackendOptions.hpp.

◆ NetworkId

using NetworkId = int

Definition at line 20 of file IRuntime.hpp.

◆ NetworkOptions

using NetworkOptions = std::vector<BackendOptions>

Definition at line 15 of file BackendOptions.hpp.

◆ OffsetScalePair

using OffsetScalePair = std::pair<float, int>

Definition at line 16 of file NetworkQuantizationScheme.hpp.

◆ OutputQueueDescriptor

Definition at line 82 of file WorkloadData.hpp.

◆ OutputTensors

using OutputTensors = std::vector<std::pair<LayerBindingId, class Tensor> >

Definition at line 341 of file Tensor.hpp.

◆ ParameterStringifyFunction

using ParameterStringifyFunction = std::function<void(const std::string& name, const std::string& value)>

Definition at line 14 of file SerializeLayerParameters.hpp.

◆ PreCompiledObjectDeleter

using PreCompiledObjectDeleter = std::function<void(const void*)>

Definition at line 19 of file PreCompiledLayer.hpp.

◆ PreCompiledObjectPtr

using PreCompiledObjectPtr = std::unique_ptr<void, PreCompiledObjectDeleter>

Definition at line 20 of file PreCompiledLayer.hpp.

◆ RefAdditionWorkload

◆ RefDebugBFloat16Workload

◆ RefDebugFloat16Workload

◆ RefDebugFloat32Workload

◆ RefDebugQAsymmS8Workload

◆ RefDebugQAsymmU8Workload

◆ RefDebugQSymmS16Workload

◆ RefDebugQSymmS8Workload

◆ RefDebugSigned32Workload

◆ RefDivisionWorkload

◆ RefMaximumWorkload

◆ RefMinimumWorkload

◆ RefMultiplicationWorkload

◆ RefPermuteBFloat16Workload

◆ RefPermuteFloat16Workload

◆ RefPermuteFloat32Workload

◆ RefPermuteQAsymm8Workload

◆ RefPermuteQAsymmS8Workload

◆ RefPermuteQSymm16Workload

◆ RefSubtractionWorkload

◆ RefTransposeBFloat16Workload

◆ RefTransposeFloat16Workload

◆ RefTransposeFloat32Workload

◆ RefTransposeQAsymm8Workload

◆ RefTransposeQAsymmS8Workload

◆ RefTransposeQSymm16Workload

◆ ResolveType

using ResolveType = typename ResolveTypeImpl<DT>::Type

Definition at line 73 of file ResolveType.hpp.

◆ SplitterDescriptor

Definition at line 55 of file DescriptorsFwd.hpp.

◆ supported

Definition at line 31 of file ISubgraphViewConverter.hpp.

◆ TContainer

using TContainer = mapbox::util::variant<std::vector<float>, std::vector<int>, std::vector<unsigned char> >

Definition at line 34 of file NetworkQuantizer.cpp.

◆ Uint8ToFloat32Workload

◆ Uint8Workload

◆ WorkloadQueue

using WorkloadQueue = std::vector< std::unique_ptr<IWorkload> >

Definition at line 13 of file ExecutionFrame.hpp.

Enumeration Type Documentation

◆ ActivationFunction

enum ActivationFunction
strong
Enumerator
Sigmoid 
TanH 
Linear 
ReLu 
BoundedReLu 

min(a, max(b, input)) ReLu1 & ReLu6.

SoftReLu 
LeakyReLu 
Abs 
Sqrt 
Square 
Elu 
HardSwish 

Definition at line 56 of file Types.hpp.

◆ ArgMinMaxFunction

enum ArgMinMaxFunction
strong
Enumerator
Min 
Max 

Definition at line 72 of file Types.hpp.

◆ BoostLogSeverityMapping

◆ CapabilityClass

enum CapabilityClass
strong

Capability class to calculate in the GetCapabilities function so that only the capability in the scope can be choose to calculate.

Enumerator
PaddingRequired 
CapabilityClassMax 

Definition at line 20 of file ITensorHandleFactory.hpp.

21 {
22  PaddingRequired = 1,
23 
24  // add new enum values here
25 
26  CapabilityClassMax = 254
27 };

◆ ComparisonOperation

enum ComparisonOperation
strong
Enumerator
Equal 
Greater 
GreaterOrEqual 
Less 
LessOrEqual 
NotEqual 

Definition at line 78 of file Types.hpp.

◆ Compute

enum Compute
strong

The Compute enum is now deprecated and it is now being replaced by BackendId.

Enumerator
Undefined 
CpuRef 

CPU Execution: Reference C++ kernels.

CpuAcc 

CPU Execution: NEON: ArmCompute.

GpuAcc 

GPU Execution: OpenCL: ArmCompute.

Definition at line 21 of file BackendId.hpp.

22 {
23  Undefined = 0,
24  /// CPU Execution: Reference C++ kernels
25  CpuRef = 1,
26  /// CPU Execution: NEON: ArmCompute
27  CpuAcc = 2,
28  /// GPU Execution: OpenCL: ArmCompute
29  GpuAcc = 3
30 };
CPU Execution: Reference C++ kernels.
GPU Execution: OpenCL: ArmCompute.
CPU Execution: NEON: ArmCompute.

◆ DataLayout

enum DataLayout
strong
Enumerator
NCHW 
NHWC 

Definition at line 50 of file Types.hpp.

51 {
52  NCHW = 1,
53  NHWC = 2
54 };

◆ DataType

enum DataType
strong
Enumerator
Float16 
Float32 
QAsymmU8 
Signed32 
Boolean 
QSymmS16 
QuantizedSymm8PerAxis 
QSymmS8 
QAsymmS8 
BFloat16 
Signed64 
QuantisedAsymm8 
QuantisedSymm16 

Definition at line 32 of file Types.hpp.

◆ Dimensionality

enum Dimensionality
strong
Enumerator
NotSpecified 
Specified 
Scalar 

Definition at line 117 of file Types.hpp.

◆ EdgeStrategy

enum EdgeStrategy
strong
Enumerator
Undefined 
DirectCompatibility 

No strategy has been defined. Used internally to verify integrity of optimizations.

ExportToTarget 

Destination backend can work directly with tensors on source backend.

CopyToTarget 

Source backends tensor data can be exported to destination backend tensor without copy.

Copy contents from source backend tensor to destination backend tensor.

Definition at line 99 of file ITensorHandleFactory.hpp.

100 {
101  Undefined, /// No strategy has been defined. Used internally to verify integrity of optimizations.
102  DirectCompatibility, /// Destination backend can work directly with tensors on source backend.
103  ExportToTarget, /// Source backends tensor data can be exported to destination backend tensor without copy.
104  CopyToTarget /// Copy contents from source backend tensor to destination backend tensor.
105 };
No strategy has been defined. Used internally to verify integrity of optimizations.
Source backends tensor data can be exported to destination backend tensor without copy...
Destination backend can work directly with tensors on source backend.

◆ GraphEvent

enum GraphEvent
strong
Enumerator
LayerAdded 
LayerErased 

Definition at line 12 of file IGraphObservable.hpp.

◆ JsonObjectType

enum JsonObjectType
strong
Enumerator
Measurement 
Event 

Definition at line 18 of file JsonPrinter.hpp.

◆ LayerType

enum LayerType
strong
Enumerator
Activation 
Addition 
ArgMinMax 
BatchNormalization 
BatchToSpaceNd 
Comparison 
Concat 
Constant 
ConvertBf16ToFp32 
ConvertFp16ToFp32 
ConvertFp32ToBf16 
ConvertFp32ToFp16 
Convolution2d 
Debug 
DepthToSpace 
DepthwiseConvolution2d 
Dequantize 
DetectionPostProcess 
Division 
ElementwiseUnary 
FakeQuantization 
Fill 
Floor 
FullyConnected 
Gather 
Input 
InstanceNormalization 
L2Normalization 
LogicalBinary 
LogSoftmax 
Lstm 
QLstm 
Map 
Maximum 
Mean 
MemCopy 
MemImport 
Merge 
Minimum 
Multiplication 
Normalization 
Output 
Pad 
Permute 
Pooling2d 
PreCompiled 
Prelu 
Quantize 
QuantizedLstm 
Reshape 
Rank 
Resize 
Slice 
Softmax 
SpaceToBatchNd 
SpaceToDepth 
Splitter 
Stack 
StandIn 
StridedSlice 
Subtraction 
Switch 
Transpose 
TransposeConvolution2d 
Unmap 
FirstLayer 
LastLayer 

Definition at line 86 of file InternalTypes.hpp.

87 {
88 #define X(name) name,
90 #undef X
93 };
#define LIST_OF_LAYER_TYPE
This list uses X macro technique.
float Activation(float in, ActivationFunction function, float a, float b)
Definition: Activation.cpp:13

◆ LogicalBinaryOperation

Enumerator
LogicalAnd 
LogicalOr 

Definition at line 88 of file Types.hpp.

◆ LogSeverity

enum LogSeverity
strong
Enumerator
Trace 
Debug 
Info 
Warning 
Error 
Fatal 

Definition at line 12 of file Utils.hpp.

13 {
14  Trace,
15  Debug,
16  Info,
17  Warning,
18  Error,
19  Fatal
20 };
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:18

◆ MemorySource

enum MemorySource
strong
Enumerator
Undefined 
Malloc 
DmaBuf 
DmaBufProtected 

Definition at line 13 of file MemorySources.hpp.

◆ NormalizationAlgorithmChannel

Enumerator
Across 
Within 

Definition at line 141 of file Types.hpp.

◆ NormalizationAlgorithmMethod

Enumerator
LocalBrightness 

Krichevsky 2012: Local Brightness Normalization.

LocalContrast 

Jarret 2009: Local Contrast Normalization.

Definition at line 147 of file Types.hpp.

148 {
149  /// Krichevsky 2012: Local Brightness Normalization
150  LocalBrightness = 0,
151  /// Jarret 2009: Local Contrast Normalization
152  LocalContrast = 1
153 };
Jarret 2009: Local Contrast Normalization.
Krichevsky 2012: Local Brightness Normalization.

◆ OutputShapeRounding

enum OutputShapeRounding
strong
Enumerator
Floor 
Ceiling 

Definition at line 155 of file Types.hpp.

◆ PaddingMethod

enum PaddingMethod
strong

The padding method modifies the output of pooling layers.

In both supported methods, the values are ignored (they are not even zeroes, which would make a difference for max pooling a tensor with negative values). The difference between IgnoreValue and Exclude is that the former counts the padding fields in the divisor of Average and L2 pooling, while Exclude does not.

Enumerator
IgnoreValue 

The padding fields count, but are ignored.

Exclude 

The padding fields don't count and are ignored.

Definition at line 133 of file Types.hpp.

134 {
135  /// The padding fields count, but are ignored
136  IgnoreValue = 0,
137  /// The padding fields don't count and are ignored
138  Exclude = 1
139 };
The padding fields don&#39;t count and are ignored.
The padding fields count, but are ignored.

◆ PoolingAlgorithm

enum PoolingAlgorithm
strong
Enumerator
Max 
Average 
L2 

Definition at line 104 of file Types.hpp.

◆ ResizeMethod

enum ResizeMethod
strong
Enumerator
Bilinear 
NearestNeighbor 

Definition at line 111 of file Types.hpp.

◆ ShapeInferenceMethod

enum ShapeInferenceMethod
strong

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.

Enumerator
ValidateOnly 

Validate all output shapes.

InferAndValidate 

Infer missing output shapes and validate all output shapes.

Definition at line 169 of file Types.hpp.

170 {
171  /// Validate all output shapes
172  ValidateOnly = 0,
173  /// Infer missing output shapes and validate all output shapes
174  InferAndValidate = 1
175 };
Validate all output shapes.
Infer missing output shapes and validate all output shapes.

◆ Status

enum Status
strong

enumeration

Enumerator
Success 
Failure 

Definition at line 26 of file Types.hpp.

◆ TuningLevel

enum TuningLevel
strong
Enumerator
None 
Rapid 
Normal 
Exhaustive 

Definition at line 69 of file ClBackendContext.cpp.

◆ UnaryOperation

enum UnaryOperation
strong
Enumerator
Abs 
Exp 
Sqrt 
Rsqrt 
Neg 
LogicalNot 

Definition at line 94 of file Types.hpp.

Function Documentation

◆ Activation() [1/2]

float Activation ( float  in,
ActivationFunction  function,
float  a,
float  b 
)

Definition at line 13 of file Activation.cpp.

References Abs, BoundedReLu, Elu, HardSwish, LeakyReLu, Linear, ReLu, Sigmoid, SoftReLu, Sqrt, Square, and TanH.

Referenced by Activation().

17 {
18  float output;
19 
20  // Compute the result of the activation function.
21  switch (function)
22  {
23  case ActivationFunction::Linear:
24  {
25  output = a * in + b;
26  break;
27  }
28  case ActivationFunction::Sigmoid:
29  {
30  output = 1.f / (1.f + expf(-in));
31  break;
32  }
33  case ActivationFunction::ReLu:
34  {
35  output = std::max(0.f, in);
36  break;
37  }
38  case ActivationFunction::BoundedReLu:
39  {
40  output = std::min(a, std::max(b, in));
41  break;
42  }
43  case ActivationFunction::SoftReLu:
44  {
45  output = logf(1.0f + expf(in));
46  break;
47  }
48  case ActivationFunction::LeakyReLu:
49  {
50  output = in > 0.0f ? in : (in * a);
51  break;
52  }
53  case ActivationFunction::Abs:
54  {
55  output = in < 0 ? -in : in;
56  break;
57  }
58  case ActivationFunction::Sqrt:
59  {
60  output = sqrtf(in);
61  break;
62  }
63  case ActivationFunction::Square:
64  {
65  output = in * in;
66  break;
67  }
68  case ActivationFunction::TanH:
69  {
70  output = a * tanhf(b * in);
71  break;
72  }
73  case ActivationFunction::Elu:
74  {
75  output = (in >= 0) ? in : a * (expf(in) - 1);
76  break;
77  }
78  case ActivationFunction::HardSwish:
79  {
80  // hard_swish(x) = x * relu6(x+3) / 6
81  // relu6(x) = min(max(x,0),6)
82  output = in * (std::min(std::max((in + 3),0.0f),6.0f)) / 6;
83  break;
84  }
85  default:
86  {
87  throw InvalidArgumentException("Unsupported activation function");
88  }
89  }
90 
91  return output;
92 }

◆ Activation() [2/2]

void Activation ( Decoder< float > &  in,
Encoder< float > &  out,
const TensorInfo tensorInfo,
ActivationFunction  function,
float  a,
float  b 
)

Definition at line 95 of file Activation.cpp.

References Activation(), Decoder< IType >::Get(), TensorInfo::GetNumElements(), and Encoder< IType >::Set().

101 {
102  unsigned int numElements = tensorInfo.GetNumElements();
103 
104  for (unsigned int i = 0; i < numElements; i++)
105  {
106  out.Set(Activation(in.Get(), function, a, b));
107  ++in;
108  ++out;
109  }
110  in -= numElements;
111  out -= numElements;
112 }
virtual void Set(IType right)=0
virtual IType Get() const =0
void Activation(Decoder< float > &in, Encoder< float > &out, const TensorInfo &tensorInfo, ActivationFunction function, float a, float b)
Definition: Activation.cpp:95

◆ AllocateOutputData()

void armnn::AllocateOutputData ( unsigned int  numOutput,
unsigned int  numSelected,
const std::vector< float > &  boxCorners,
const std::vector< unsigned int > &  outputIndices,
const std::vector< unsigned int > &  selectedBoxes,
const std::vector< unsigned int > &  selectedClasses,
const std::vector< float > &  selectedScores,
float *  detectionBoxes,
float *  detectionScores,
float *  detectionClasses,
float *  numDetections 
)

Definition at line 102 of file DetectionPostProcess.cpp.

References numeric_cast().

Referenced by DetectionPostProcess().

113 {
114  for (unsigned int i = 0; i < numOutput; ++i)
115  {
116  unsigned int boxIndex = i * 4;
117  if (i < numSelected)
118  {
119  unsigned int boxCornorIndex = selectedBoxes[outputIndices[i]] * 4;
120  detectionScores[i] = selectedScores[outputIndices[i]];
121  detectionClasses[i] = armnn::numeric_cast<float>(selectedClasses[outputIndices[i]]);
122  detectionBoxes[boxIndex] = boxCorners[boxCornorIndex];
123  detectionBoxes[boxIndex + 1] = boxCorners[boxCornorIndex + 1];
124  detectionBoxes[boxIndex + 2] = boxCorners[boxCornorIndex + 2];
125  detectionBoxes[boxIndex + 3] = boxCorners[boxCornorIndex + 3];
126  }
127  else
128  {
129  detectionScores[i] = 0.0f;
130  detectionClasses[i] = 0.0f;
131  detectionBoxes[boxIndex] = 0.0f;
132  detectionBoxes[boxIndex + 1] = 0.0f;
133  detectionBoxes[boxIndex + 2] = 0.0f;
134  detectionBoxes[boxIndex + 3] = 0.0f;
135  }
136  }
137  numDetections[0] = armnn::numeric_cast<float>(numSelected);
138 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ AllTypesAreEqualImpl() [1/2]

bool armnn::AllTypesAreEqualImpl ( )

Definition at line 59 of file LayerSupportRules.hpp.

Referenced by AllTypesAreEqualImpl(), and TypesAreEqual::TypesAreEqual().

60 {
61  return true;
62 }

◆ AllTypesAreEqualImpl() [2/2]

bool armnn::AllTypesAreEqualImpl ( t1,
t2,
Rest...  rest 
)

Definition at line 65 of file LayerSupportRules.hpp.

References AllTypesAreEqualImpl().

66 {
67  static_assert(std::is_same<T, TensorInfo>::value, "Type T must be a TensorInfo");
68 
69  return (t1.GetDataType() == t2.GetDataType()) && AllTypesAreEqualImpl(t2, rest...);
70 }
bool AllTypesAreEqualImpl(T t1, T t2, Rest... rest)

◆ Append() [1/2]

void armnn::Append ( Optimizer::Optimizations optimizations,
T &&  optimization 
)

Definition at line 30 of file Optimizer.hpp.

Referenced by Append(), and MakeOptimizations().

31 {
32  optimizations.emplace_back(new T(optimization));
33 };

◆ Append() [2/2]

void armnn::Append ( Optimizer::Optimizations optimizations,
Front &&  front,
Others &&...  others 
)

Definition at line 36 of file Optimizer.hpp.

References Append().

37 {
38  Append<Front>(optimizations, std::forward<Front>(front));
39  Append<Others...>(optimizations, std::forward<Others>(others)...);
40 };
void Append(Optimizer::Optimizations &optimizations, Front &&front, Others &&... others)
Definition: Optimizer.hpp:36

◆ ApplyBackendOptimizations()

OptimizationResult armnn::ApplyBackendOptimizations ( OptimizedNetwork optNetObjPtr,
BackendSettings backendSettings,
BackendsMap backends,
const ModelOptions modelOptions,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 537 of file Network.cpp.

References ARMNN_ASSERT, AssignBackends(), SubgraphView::begin(), SubgraphView::end(), Layer::GetBackendId(), OptimizationViews::GetFailedSubgraphs(), OptimizedNetwork::GetGraph(), OptimizationViews::GetSubstitutions(), Layer::GetType(), Input, OptimizationResult::m_Error, BackendSettings::m_SelectedBackends, Output, ReportWarning(), SubgraphViewSelector::SelectSubgraphs(), Graph::SubstituteSubgraph(), and OptimizationViews::Validate().

Referenced by Optimize().

542 {
543  ARMNN_ASSERT(optNetObjPtr);
544 
545  OptimizationResult result;
546 
547  // Get the optimized graph
548  Graph& optGraph = optNetObjPtr->GetGraph();
549 
550  // Run backend specific optimizations
551  for (auto&& selectedBackend : backendSettings.m_SelectedBackends)
552  {
553  auto backendObjPtr = backends.find(selectedBackend)->second.get();
554  ARMNN_ASSERT(backendObjPtr);
555 
556  // Select sub-graphs based on backend
557  SubgraphViewSelector::Subgraphs subgraphs =
558  SubgraphViewSelector::SelectSubgraphs(optGraph,
559  // Select layers assigned to the requested backend
560  [&backendObjPtr](const Layer& layer)
561  {
562  return layer.GetType() != LayerType::Input &&
563  layer.GetType() != LayerType::Output &&
564  layer.GetBackendId() == backendObjPtr->GetId();
565  });
566  if (subgraphs.empty())
567  {
568  // No sub-graphs found, try with next selected backend
569  continue;
570  }
571 
572  // Try to optimize each sub-graph
573  for (auto& subgraph : subgraphs)
574  {
575  // Try to optimize the current sub-graph
576  OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph, modelOptions);
577  ARMNN_ASSERT(optimizationViews.Validate(*subgraph));
578 
579  // Optimization attempted, check the resulting optimized sub-graph
580  for (auto& substitution : optimizationViews.GetSubstitutions())
581  {
582  // Sub-graph optimized, substitute the sub-graph with the new optimized one in the main optimized graph
583  SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
584  SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
585  optGraph.SubstituteSubgraph(substitutableSubgraph, replacementSubgraph);
586 
587  // Assign the current backend to the optimized sub-graph
588  std::for_each(replacementSubgraph.begin(), replacementSubgraph.end(), [&selectedBackend](Layer* l)
589  {
590  ARMNN_ASSERT(l);
591  l->SetBackendId(selectedBackend);
592  });
593  }
594 
595  if (!optimizationViews.GetFailedSubgraphs().empty())
596  {
597  std::stringstream warningMsg;
598  warningMsg << "Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() << " backend.";
599  ReportWarning(warningMsg.str(), errMessages);
600 
601  // Failed to optimize the given sub-graph, re-assign the sub-graph layers to other available backends
602  BackendSettings settingsCopy(backendSettings);
603  if (!backendObjPtr->GetId().IsCpuRef())
604  {
605  // Add the current backend to the list of backends to ignore
606  settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
607  }
608 
609  int count=0;
610  for (auto& failedSubgraph : optimizationViews.GetFailedSubgraphs())
611  {
612  // An error occurred: the optimization was attempted but not performed, try different backends
613  std::stringstream subgraphMsg;
614  subgraphMsg << "Re-assigning backends to " << failedSubgraph.GetLayers().size()
615  << " layers inside sub-graph " << count++;
616  ReportWarning(subgraphMsg.str(), errMessages);
617 
618  OptimizationResult reassignmentResult = AssignBackends(optNetObjPtr,
619  settingsCopy,
620  *subgraph,
621  errMessages);
622  if (reassignmentResult.m_Error)
623  {
624  // Failed to re-assign one of the remaining backends to each layer of the sub-graph
625  result.m_Error = true;
626  return result;
627  }
628  }
629  }
630  }
631  }
632 
633  return result;
634 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
Definition: Network.cpp:84
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:504

◆ ArgMinMax() [1/3]

void ArgMinMax ( Decoder< float > &  in,
OUT *  out,
const TensorInfo inputTensorInfo,
const TensorInfo outputTensorInfo,
ArgMinMaxFunction  function,
int  axis 
)

Definition at line 16 of file ArgMinMax.cpp.

References Decoder< IType >::Get(), TensorInfo::GetNumDimensions(), armnnUtils::GetNumElementsBetween(), TensorInfo::GetShape(), armnnUtils::GetUnsignedAxis(), IgnoreUnused(), Max, Min, and numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

18 {
19  IgnoreUnused(outputTensorInfo);
20 
21  unsigned int uAxis = armnnUtils::GetUnsignedAxis(inputTensorInfo.GetNumDimensions(), axis);
22 
23  const unsigned int outerElements = armnnUtils::GetNumElementsBetween(inputTensorInfo.GetShape(), 0, uAxis);
24  const unsigned int axisSize = inputTensorInfo.GetShape()[uAxis];
25  const unsigned int innerElements = armnnUtils::GetNumElementsBetween(inputTensorInfo.GetShape(),
26  uAxis + 1,
27  inputTensorInfo.GetNumDimensions());
28 
29  for (unsigned int outer = 0; outer < outerElements; ++outer) {
30  for (unsigned int inner = 0; inner < innerElements; ++inner) {
31  in[outer * axisSize * innerElements + inner];
32  auto tmpValue = in.Get();
33  unsigned int tmpIndex = 0;
34  for (unsigned int i = 1; i < axisSize; ++i) {
35  in[(outer * axisSize * innerElements) + (i * innerElements) + inner];
36  const auto& value = in.Get();
37  if ((function == armnn::ArgMinMaxFunction::Min && value < tmpValue) ||
38  (function == armnn::ArgMinMaxFunction::Max && value > tmpValue)) {
39  tmpValue = value;
40  tmpIndex = i;
41  }
42  }
43 
44  out[outer * innerElements + inner] = armnn::numeric_cast<OUT>(tmpIndex);
45  }
46  }
47 }
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
void IgnoreUnused(Ts &&...)
virtual IType Get() const =0
unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ArgMinMax() [2/3]

template void armnn::ArgMinMax ( Decoder< float > &  in,
int32_t *  out,
const TensorInfo inputTensorInfo,
const TensorInfo outputTensorInfo,
ArgMinMaxFunction  function,
int  axis 
)

◆ ArgMinMax() [3/3]

template void armnn::ArgMinMax ( Decoder< float > &  in,
int64_t *  out,
const TensorInfo inputTensorInfo,
const TensorInfo outputTensorInfo,
ArgMinMaxFunction  function,
int  axis 
)

◆ AssignBackends() [1/2]

OptimizationResult AssignBackends ( OptimizedNetwork optNetObjPtr,
BackendSettings backendSettings,
Graph::Iterator firstLayer,
Graph::Iterator lastLayer,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 378 of file Network.cpp.

References ARMNN_ASSERT_MSG, AttemptBackendAssignment(), CheckScaleSetOnQuantizedType(), Constant, CpuRef, Float32, BackendSettings::GetAvailablePreferredBackends(), OptimizedNetwork::GetGraph(), BackendSettings::IsBackendSupported(), BackendSettings::IsCpuRefUsed(), OptimizationResult::IsError(), OptimizationResult::IsOk(), OptimizationResult::IsWarningOnly(), OptimizationResult::m_Error, BackendSettings::m_SelectedBackends, MemCopy, Permute, ReportError(), and ReturnWithError().

Referenced by ApplyBackendOptimizations(), AssignBackends(), BOOST_AUTO_TEST_CASE(), and Optimize().

383 {
384  OptimizationResult result;
385 
386  // Helper lambda to compose meaningful error message before returning with error
387  auto ReturnError = [&](const Layer* layer)
388  {
389  return ReturnWithError(result, layer, backendSettings, errMessages);
390  };
391 
392 
393  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
394  if (availablePreferredBackends.empty())
395  {
396  std::stringstream failureMsg;
397  failureMsg << "No preferred backends are available";
398  ReportError(failureMsg.str(), errMessages);
399 
400  result.m_Error = true;
401  return result;
402  }
403 
404  for (auto it = firstLayer; it != lastLayer; ++it)
405  {
406  auto layer = *it;
407 
408  DataType dataTypeIn = layer->GetNumInputSlots() == 0 ? DataType::Float32 :
409  layer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo().GetDataType();
410  DataType dataTypeOut = layer->GetNumOutputSlots() == 0 ? DataType::Float32 :
411  layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
412 
413  std::string reasonIfUnsupported;
414  bool found = false;
415  if (!CheckScaleSetOnQuantizedType(layer, errMessages))
416  {
417  // don't bomb immediately, find all the quantized outputs
418  // which haven't had a scale set and report them all back.
419  result.m_Error = true;
420  }
421 
422  // First try assign layer to hint backend
423  if (layer->GetBackendHint().has_value() &&
424  backendSettings.IsBackendSupported(layer->GetBackendHint().value()) &&
425  AttemptBackendAssignment(backendSettings,
426  optNetObjPtr->GetGraph(),
427  layer,
428  layer->GetBackendHint().value(),
429  dataTypeIn,
430  dataTypeOut,
431  availablePreferredBackends,
432  reasonIfUnsupported,
433  errMessages).IsOk())
434  {
435  found = true;
436  backendSettings.m_SelectedBackends.insert(layer->GetBackendHint().value());
437  }
438  else
439  {
440  // Try assign layer to prefered list of backends
441  for (const auto& backend : availablePreferredBackends)
442  {
443  if (layer->GetBackendHint().has_value() &&
444  layer->GetBackendHint().value() == backend)
445  {
446  continue; //Don't re-test the backend hint
447  }
448 
449  OptimizationResult res = AttemptBackendAssignment(backendSettings,
450  optNetObjPtr->GetGraph(),
451  layer,
452  backend,
453  dataTypeIn,
454  dataTypeOut,
455  availablePreferredBackends,
456  reasonIfUnsupported,
457  errMessages);
458 
459  if (res.IsOk())
460  {
461  found = true;
462  backendSettings.m_SelectedBackends.insert(backend);
463  break;
464  }
465  else if (res.IsError())
466  {
467  return res; // Cannot continue.
468  // Note: we don't need to log the error as it would already
469  // be logged in AttemptBackendAssignment().
470  }
471  else
472  {
473  ARMNN_ASSERT_MSG(res.IsWarningOnly(), "OptimizationResult in unexpected state.");
474  }
475  }
476  }
477 
478  // If the layer is unsupported by any devices, log and return a null network.
479  if (!found)
480  {
481  // NOTE: if the layer is not an operation queue type AND we have not got CpuRef as a
482  // fallback we should set the compute device on the layer to CpuRef (these are not
483  // available as accelerated operations, or are only available under certain
484  // conditions, currently they comprise MemCopy, Constant, Permute)
485  armnn::LayerType layerType = layer->GetType();
486  if (!backendSettings.IsCpuRefUsed() && (layerType == armnn::LayerType::MemCopy ||
487  layerType == armnn::LayerType::Constant ||
488  layerType == armnn::LayerType::Permute))
489  {
490  BackendId cpuBackendId(armnn::Compute::CpuRef);
491  layer->SetBackendId(cpuBackendId);
492  backendSettings.m_SelectedBackends.insert(cpuBackendId);
493  }
494  else
495  {
496  return ReturnError(layer);
497  }
498  }
499  }
500 
501  return result;
502 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:72
CPU Execution: Reference C++ kernels.
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:96
DataType
Definition: Types.hpp:32
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:111
OptimizationResult AttemptBackendAssignment(BackendSettings &backendSettings, Graph &graph, Layer *layer, BackendId backend, DataType dataTypeIn, DataType dataTypeOut, const std::vector< BackendId > &availablePreferredBackends, std::string &reasonIfUnsupported, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:170

◆ AssignBackends() [2/2]

OptimizationResult armnn::AssignBackends ( OptimizedNetwork optNetObjPtr,
BackendSettings backendSettings,
SubgraphView subgraph,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 504 of file Network.cpp.

References AssignBackends(), SubgraphView::begin(), and SubgraphView::end().

508 {
509  Graph::Iterator firstLayer = subgraph.begin();
510  Graph::Iterator lastLayer = subgraph.end();
511  return AssignBackends(optNetObjPtr,
512  backendSettings,
513  firstLayer,
514  lastLayer,
515  errMessages);
516 }
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:504

◆ AssignSplitId()

void armnn::AssignSplitId ( LayerSelectionInfo::LayerInfoContainer &  layerInfos,
LayerSelectionInfo &  layerInfo 
)

Definition at line 305 of file SubgraphViewSelector.cpp.

References ForEachLayerInput().

Referenced by SubgraphViewSelector::SelectSubgraphs().

306 {
307  // Check each input to see if we can attach ourselves to any of the subgraphs that have already been assigned.
308  ForEachLayerInput(layerInfos, layerInfo, [&](LayerSelectionInfo& parentInfo)
309  {
310  // We can only attach ourselves to the subgraph from this input if there isn't a cut here.
311  if (layerInfo.m_IsSelected == parentInfo.m_IsSelected)
312  {
313  // We also need to check that merging into this subgraph won't cause a dependency cycle between subgraphs.
314  // This will be the case if the subgraph that we will become part of is already a dependency
315  // of one of the subgraphs that are input to this layer, e.g:
316  //
317  // 0 | The numbers (0, 1) are the subgraph IDs of each layer and we are looking at layer X.
318  // / \ |
319  // 1 0 | We can't merge X into subgraph 0, because the left-hand input already depends on subgraph 0.
320  // \ / | We can however merge X into subgraph 1.
321  // X |
322  //
323  bool dependenciesOk = true;
324  ForEachLayerInput(layerInfos, layerInfo, [&](LayerSelectionInfo& otherParentInfo)
325  {
326  // We call HasAntecedent() ~ n^2 times, where n is the number of inputs to this layer.
327  // Hence it is important that this is efficient - see PartialSubgraph class description.
328  if (otherParentInfo.m_Subgraph->HasAntecedent(parentInfo.m_Subgraph.get()))
329  {
330  dependenciesOk = false;
331  }
332  });
333 
334  if (dependenciesOk)
335  {
336  // Merge into the subgraph of this input. If we have already been merged into another subgraph
337  // (from another input of this layer), then merge both of them together.
338  if (layerInfo.m_Subgraph == nullptr)
339  {
340  layerInfo.m_Subgraph = parentInfo.m_Subgraph;
341  }
342  else
343  {
344  // We call MergeWith() ~ n times, where n is the number of inputs to this layer.
345  // Therefore it does not need to be as performant as HasAntecedent().
346  layerInfo.m_Subgraph->MergeWith(parentInfo.m_Subgraph.get());
347  }
348  }
349  }
350  });
351 
352  // If we weren't able to merge into an existing subgraph then we need to make a new one
353  if (layerInfo.m_Subgraph == nullptr)
354  {
355  layerInfo.m_Subgraph = std::make_shared<PartialSubgraph>();
356  }
357 
358  // Record dependencies of the chosen subgraph based on the inputs of this layer.
359  ForEachLayerInput(layerInfos, layerInfo, [&](LayerSelectionInfo& parentInfo)
360  {
361  // These functions are called ~n times, where n is the number of inputs to this layer.
362  // Therefore it does not need to be as performant as HasAntecedent().
363  if (!layerInfo.m_Subgraph->IsMergedWith(parentInfo.m_Subgraph.get()))
364  {
365  layerInfo.m_Subgraph->AddDirectAntecedent(parentInfo.m_Subgraph.get());
366  }
367  });
368 }
void ForEachLayerInput(LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo, Delegate function)

◆ AttemptBackendAssignment()

OptimizationResult armnn::AttemptBackendAssignment ( BackendSettings backendSettings,
Graph graph,
Layer layer,
BackendId  backend,
DataType  dataTypeIn,
DataType  dataTypeOut,
const std::vector< BackendId > &  availablePreferredBackends,
std::string &  reasonIfUnsupported,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 170 of file Network.cpp.

References BFloat16, ConvertBf16ToFp32, ConvertFp16ToFp32, ConvertFp32ToBf16, ConvertFp32ToFp16, Convolution2d, Float16, Float32, FullyConnected, BackendId::Get(), Layer::GetBackendId(), GetDataTypeName(), GetLayerTypeAsCString(), Layer::GetType(), InsertConvertBf16ToFp32LayersBefore(), InsertConvertFp16ToFp32LayersBefore(), InsertConvertFp32ToBf16LayersAfter(), InsertConvertFp32ToFp16LayersAfter(), IWorkloadFactory::IsLayerSupported(), ReportWarning(), ReturnWithError(), and Layer::SetBackendId().

Referenced by AssignBackends().

179 {
180  OptimizationResult result;
181 
182  // Helper lambda to compose meaningful error message before returning with error
183  auto ReturnError = [&](const Layer* layer)
184  {
185  return ReturnWithError(result, layer, backendSettings, errMessages);
186  };
187 
188  // need to set the compute device on the layer
189  // before we can check if it is supported
190  layer->SetBackendId(backend);
191  if (!IWorkloadFactory::IsLayerSupported(*layer, EmptyOptional(), reasonIfUnsupported))
192  {
193  if (dataTypeIn == DataType::Float16 || dataTypeOut == DataType::Float16)
194  {
195  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
196  && layer->GetType() != LayerType::ConvertFp32ToFp16
197  && layer->GetType() != LayerType::ConvertFp16ToFp32)
198  {
199  // Insert FP16 -> FP32 conversion layer before current layer
200  std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
201  if (dataTypeIn == DataType::Float16)
202  {
203  convertFp16ToFp32Layers =
205  }
206 
207  // Insert FP32 -> FP16 conversion layer after current layer
208  std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
209  if (dataTypeOut == DataType::Float16)
210  {
211  convertFp32ToFp16Layers =
212  InsertConvertFp32ToFp16LayersAfter(graph, *layer);
213  }
214 
215  // Assign a supported backend to the newly introduced conversion layers
216  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
217  {
218  bool supportedBackendFound = false;
219  std::string reasonIfUnsupported;
220 
221  // Try preferred backend first
222  layer->SetBackendId(preferredBackend);
223  if (IWorkloadFactory::IsLayerSupported(*layer,
224  EmptyOptional(),
225  reasonIfUnsupported))
226  {
227  supportedBackendFound = true;
228  }
229  else
230  {
231  for (const auto& backend : availablePreferredBackends)
232  {
233  // Skip preferred backend (we already determined that it is not supported)
234  if (backend == preferredBackend)
235  {
236  continue;
237  }
238 
239  layer->SetBackendId(backend);
240  if (IWorkloadFactory::IsLayerSupported(*layer,
241  EmptyOptional(),
242  reasonIfUnsupported))
243  {
244  supportedBackendFound = true;
245  break;
246  }
247  }
248  }
249 
250  return supportedBackendFound;
251  };
252 
253  for (ConvertFp16ToFp32Layer* convertLayer : convertFp16ToFp32Layers)
254  {
255  if (!AssignFirstSupportedBackend(convertLayer, backend))
256  {
257  return ReturnError(convertLayer);
258  }
259  }
260 
261  for (ConvertFp32ToFp16Layer* convertLayer : convertFp32ToFp16Layers)
262  {
263  if (!AssignFirstSupportedBackend(convertLayer, backend))
264  {
265  return ReturnError(convertLayer);
266  }
267  }
268 
269  return result;
270  }
271  }
272  else if (dataTypeIn == DataType::BFloat16 || dataTypeOut == DataType::BFloat16)
273  {
274  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
275  && layer->GetType() != LayerType::ConvertFp32ToBf16
276  && layer->GetType() != LayerType::ConvertBf16ToFp32)
277  {
278  // Insert BF16 -> FP32 conversion layer before current layer
279  std::vector<ConvertBf16ToFp32Layer*> convertBf16ToFp32Layers;
280  if (dataTypeIn == DataType::BFloat16)
281  {
282  convertBf16ToFp32Layers =
284  if (layer->GetType() == LayerType::Convolution2d)
285  {
286  ConvertBf16ToFp32Weight<Convolution2dLayer>(layer);
287  }
288  else if (layer->GetType() == LayerType::FullyConnected)
289  {
290  ConvertBf16ToFp32Weight<FullyConnectedLayer>(layer);
291  }
292  }
293 
294  // Insert FP32 -> BF16 conversion layer after current layer
295  std::vector<ConvertFp32ToBf16Layer*> convertFp32ToBf16Layers;
296  if (dataTypeOut == DataType::BFloat16)
297  {
298  convertFp32ToBf16Layers =
299  InsertConvertFp32ToBf16LayersAfter(graph, *layer);
300  }
301 
302  // Assign a supported backend to the newly introduced conversion layers
303  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
304  {
305  bool supportedBackendFound = false;
306  std::string reasonIfUnsupported;
307 
308  // Try preferred backend first
309  layer->SetBackendId(preferredBackend);
310  if (IWorkloadFactory::IsLayerSupported(*layer,
311  EmptyOptional(),
312  reasonIfUnsupported))
313  {
314  supportedBackendFound = true;
315  }
316  else
317  {
318  for (const auto& backend : availablePreferredBackends)
319  {
320  // Skip preferred backend (we already determined that it is not supported)
321  if (backend == preferredBackend)
322  {
323  continue;
324  }
325 
326  layer->SetBackendId(backend);
327  if (IWorkloadFactory::IsLayerSupported(*layer,
328  EmptyOptional(),
329  reasonIfUnsupported))
330  {
331  supportedBackendFound = true;
332  break;
333  }
334  }
335  }
336 
337  return supportedBackendFound;
338  };
339 
340  for (ConvertBf16ToFp32Layer* convertLayer : convertBf16ToFp32Layers)
341  {
342  if (!AssignFirstSupportedBackend(convertLayer, backend))
343  {
344  return ReturnError(convertLayer);
345  }
346  }
347 
348  for (ConvertFp32ToBf16Layer* convertLayer : convertFp32ToBf16Layers)
349  {
350  if (!AssignFirstSupportedBackend(convertLayer, backend))
351  {
352  return ReturnError(convertLayer);
353  }
354  }
355 
356  return result;
357  }
358  }
359 
360  std::stringstream warningMsg;
361  warningMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
362  << " is not supported on requested backend " << layer->GetBackendId().Get()
363  << " for input data type " << GetDataTypeName(dataTypeIn)
364  << " and output data type " << GetDataTypeName(dataTypeOut)
365  << " (reason: " << reasonIfUnsupported
366  << "), falling back to the next backend.";
367  ReportWarning(warningMsg.str(), errMessages);
368 
369  return OptimizationResult(true, false);
370  }
371  else
372  {
373  return result;
374  }
375 }
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:96
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > &rBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:180
char const * GetLayerTypeAsCString(LayerType type)
std::vector< ConvertBf16ToFp32Layer * > InsertConvertBf16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersAfter(Graph &graph, Layer &layer)
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
Definition: Network.cpp:84

◆ BackendRegistryInstance()

◆ BatchNormImpl()

void BatchNormImpl ( const BatchNormalizationQueueDescriptor data,
Decoder< float > &  meanDecoder,
Decoder< float > &  varianceDecoder,
Decoder< float > &  betaDecoder,
Decoder< float > &  gammaDecoder,
Decoder< float > &  inputDecoder,
Encoder< float > &  outputEncoder 
)

Definition at line 18 of file BatchNormImpl.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), TensorInfo::GetShape(), GetTensorInfo(), DataLayoutIndexed::GetWidthIndex(), BatchNormalizationDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_Eps, QueueDescriptor::m_Inputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Encoder< IType >::Set().

Referenced by RefBatchNormalizationWorkload::Execute().

25 {
26  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]);
27  const TensorShape inputShape = inputInfo.GetShape();
28 
29  armnnUtils::DataLayoutIndexed dataLayout(data.m_Parameters.m_DataLayout);
30 
31  unsigned int inputBatches = inputShape[0];
32  unsigned int inputHeight = inputShape[dataLayout.GetHeightIndex()];
33  unsigned int inputWidth = inputShape[dataLayout.GetWidthIndex()];
34  unsigned int inputChannels = inputShape[dataLayout.GetChannelsIndex()];
35 
36  for (unsigned int c = 0; c < inputChannels; c++)
37  {
38  meanDecoder[c];
39  varianceDecoder[c];
40  betaDecoder[c];
41  gammaDecoder[c];
42  float mean = meanDecoder.Get();
43  float var = varianceDecoder.Get();
44  float beta = betaDecoder.Get();
45  float gamma = gammaDecoder.Get();
46 
47  float mult = gamma / sqrtf(var + data.m_Parameters.m_Eps);
48  float add = beta - mult * mean;
49 
50  for (unsigned int n = 0; n < inputBatches; n++)
51  {
52  for (unsigned int h = 0; h < inputHeight; h++)
53  {
54  for (unsigned int w = 0; w < inputWidth; w++)
55  {
56  unsigned int index = dataLayout.GetIndex(inputShape, n, c, h, w);
57  inputDecoder[index];
58  outputEncoder[index];
59  outputEncoder.Set(mult * inputDecoder.Get() + add);
60  }
61  }
62  }
63  }
64 }
virtual void Set(IType right)=0
virtual IType Get() const =0
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38

◆ BatchToSpaceNd()

void BatchToSpaceNd ( const DataLayoutIndexed dataLayout,
const TensorInfo inputTensorInfo,
const TensorInfo outputTensorInfo,
const std::vector< unsigned int > &  blockShape,
const std::vector< std::pair< unsigned int, unsigned int >> &  cropsData,
Decoder< float > &  inputDecoder,
Encoder< float > &  outputEncoder 
)

Definition at line 35 of file BatchToSpaceNd.cpp.

References ARMNN_ASSERT_MSG, BatchToSpaceNd(), Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), TensorShape::GetNumDimensions(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), Offset(), and Encoder< IType >::Set().

Referenced by BatchToSpaceNd(), BatchToSpaceNdLayer::BatchToSpaceNdLayer(), and BOOST_AUTO_TEST_CASE().

42 {
43  TensorShape inputShape = inputTensorInfo.GetShape();
44 
45  ARMNN_ASSERT_MSG(inputShape.GetNumDimensions() == 4, "Expected Input with 4 Dimensions");
46 
47  TensorShape outputShape = outputTensorInfo.GetShape();
48 
49  ARMNN_ASSERT_MSG(outputShape.GetNumDimensions() == 4, "Expected Output with 4 Dimensions");
50 
51  const unsigned int inputBatchSize = inputShape[0];
52  const unsigned int channels = inputShape[dataLayout.GetChannelsIndex()];
53 
54  const unsigned int outputBatchSize = outputShape[0];
55  const unsigned int outputHeight = outputShape[dataLayout.GetHeightIndex()];
56  const unsigned int outputWidth = outputShape[dataLayout.GetWidthIndex()];
57 
58  ARMNN_ASSERT_MSG(blockShape.size() > 0, "BlockShape must contain 1 or more entries");
59 
60  const unsigned int blockShapeHeight = blockShape[0];
61  const unsigned int blockShapeWidth = blockShape[1];
62 
63  ARMNN_ASSERT_MSG(cropsData.size() > 0, "Crops must contain 1 or more entries");
64 
65  const unsigned int cropsTop = cropsData[0].first;
66  const unsigned int cropsLeft = cropsData[1].first;
67 
68  for (unsigned int inBatch = 0; inBatch < inputBatchSize; ++inBatch)
69  {
70  const unsigned int outBatch = inBatch % outputBatchSize;
71  const unsigned int spatialOffset = inBatch / outputBatchSize;
72 
73  for (unsigned int inH = 0; inH < inputTensorInfo.GetShape()[dataLayout.GetHeightIndex()]; ++inH) {
74  const unsigned int outH = inH * blockShapeHeight + spatialOffset / blockShapeWidth - cropsTop;
75 
76  if (outH >= outputHeight)
77  {
78  continue;
79  }
80 
81  for (unsigned int inW = 0; inW < inputTensorInfo.GetShape()[dataLayout.GetWidthIndex()]; ++inW) {
82  const unsigned int outW = inW * blockShapeWidth + spatialOffset % blockShapeWidth - cropsLeft;
83 
84  if (outW >= outputWidth)
85  {
86  continue;
87  }
88 
89  for (unsigned int c = 0; c < channels; c++)
90  {
91  unsigned int outOffset = Offset(outputShape, outBatch, outH, outW, c, dataLayout);
92  unsigned int inOffset = Offset(inputShape, inBatch, inH, inW, c, dataLayout);
93 
94  outputEncoder[outOffset];
95  inputDecoder[inOffset];
96  outputEncoder.Set(inputDecoder.Get());
97  }
98  }
99  }
100  }
101 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
unsigned int Offset(const TensorShape &shape, unsigned int batch, unsigned int height, unsigned int width, unsigned int channels, const DataLayoutIndexed &dataLayout)
virtual void Set(IType right)=0
unsigned int GetHeightIndex() const
virtual IType Get() const =0
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
unsigned int GetChannelsIndex() const

◆ BOOST_AUTO_TEST_CASE() [1/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckInputLayerVisitorBindingIdAndName  )

Definition at line 13 of file TestInputOutputLayerVisitor.cpp.

References IConnectableLayer::Accept(), and Network::AddInputLayer().

14 {
15  const char* layerName = "InputLayer";
16  TestInputLayerVisitor visitor(1, layerName);
17  Network net;
18 
19  IConnectableLayer *const layer = net.AddInputLayer(1, layerName);
20  layer->Accept(visitor);
21 }

◆ BOOST_AUTO_TEST_CASE() [2/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckInputLayerVisitorBindingIdAndNameNull  )

Definition at line 23 of file TestInputOutputLayerVisitor.cpp.

References IConnectableLayer::Accept(), and Network::AddInputLayer().

24 {
25  TestInputLayerVisitor visitor(1);
26  Network net;
27 
28  IConnectableLayer *const layer = net.AddInputLayer(1);
29  layer->Accept(visitor);
30 }

◆ BOOST_AUTO_TEST_CASE() [3/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckOutputLayerVisitorBindingIdAndName  )

Definition at line 32 of file TestInputOutputLayerVisitor.cpp.

References IConnectableLayer::Accept(), and Network::AddOutputLayer().

33 {
34  const char* layerName = "OutputLayer";
35  TestOutputLayerVisitor visitor(1, layerName);
36  Network net;
37 
38  IConnectableLayer *const layer = net.AddOutputLayer(1, layerName);
39  layer->Accept(visitor);
40 }

◆ BOOST_AUTO_TEST_CASE() [4/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckOutputLayerVisitorBindingIdAndNameNull  )

Definition at line 42 of file TestInputOutputLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddOutputLayer(), and BOOST_AUTO_TEST_SUITE_END().

43 {
44  TestOutputLayerVisitor visitor(1);
45  Network net;
46 
47  IConnectableLayer *const layer = net.AddOutputLayer(1);
48  layer->Accept(visitor);
49 }

◆ BOOST_AUTO_TEST_CASE() [5/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeAddition  )

Definition at line 226 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

227 {
228  INetworkPtr network = INetwork::Create();
229 
230  // Add the layers
231  IConnectableLayer* input0 = network->AddInputLayer(0);
232  IConnectableLayer* input1 = network->AddInputLayer(1);
233  IConnectableLayer* addition = network->AddAdditionLayer();
234  IConnectableLayer* output = network->AddOutputLayer(2);
235 
236  // Establish connections
237  input0->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
238  input1->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
239  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
240 
241  // Set TensorInfo
242  const TensorShape shape{1U};
243  TensorInfo info(shape, DataType::Float32);
244  input0->GetOutputSlot(0).SetTensorInfo(info);
245  input1->GetOutputSlot(0).SetTensorInfo(info);
246  addition->GetOutputSlot(0).SetTensorInfo(info);
247 
248  const QuantizerOptions qAsymmU8Options(DataType::QAsymmU8);
249  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get(), qAsymmU8Options)->ExportNetwork();
250  TestAdditionQuantization validatorQAsymmU8(shape, shape);
251  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
252 
253  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
254  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
255  TestAdditionQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
256  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
257 
258  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
259  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
260  TestAdditionQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
261  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
262 
263  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
264  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
265  TestAdditionQuantization validatorQSymmS16(qSymmS16options, shape, shape);
266  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
267 }
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [6/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckConvolution2dLayer  )

Definition at line 268 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddConvolution2dLayer(), Float32, Convolution2dDescriptor::m_DataLayout, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, and NHWC.

Referenced by BOOST_AUTO_TEST_CASE(), and QuantizeData().

269 {
270  Convolution2dDescriptor descriptor;
271  descriptor.m_PadLeft = 2;
272  descriptor.m_PadRight = 3;
273  descriptor.m_PadBottom = 1;
274  descriptor.m_PadTop = 5;
275  descriptor.m_StrideX = 2;
276  descriptor.m_StrideY = 3;
277  descriptor.m_DataLayout = DataLayout::NHWC;
278 
279  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
280  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
281  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
282 
283  TestConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional());
284 
285  Network net;
286 
287  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional());
288  layer->Accept(visitor);
289 }

◆ BOOST_AUTO_TEST_CASE() [7/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedConvolution2dLayer  )

Definition at line 291 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddConvolution2dLayer(), Float32, Convolution2dDescriptor::m_DataLayout, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, and NHWC.

292 {
293  const char* layerName = "Convolution2dLayer";
294  Convolution2dDescriptor descriptor;
295  descriptor.m_PadLeft = 2;
296  descriptor.m_PadRight = 3;
297  descriptor.m_PadBottom = 1;
298  descriptor.m_PadTop = 5;
299  descriptor.m_StrideX = 2;
300  descriptor.m_StrideY = 3;
301  descriptor.m_DataLayout = DataLayout::NHWC;
302 
303  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
304  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
305  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
306 
307  TestConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional(), layerName);
308 
309  Network net;
310 
311  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional(), layerName);
312  layer->Accept(visitor);
313 }

◆ BOOST_AUTO_TEST_CASE() [8/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckConvolution2dLayerWithBiases  )

Definition at line 315 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddConvolution2dLayer(), Float32, Convolution2dDescriptor::m_BiasEnabled, Convolution2dDescriptor::m_DataLayout, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, and NHWC.

316 {
317  Convolution2dDescriptor descriptor;
318  descriptor.m_PadLeft = 2;
319  descriptor.m_PadRight = 3;
320  descriptor.m_PadBottom = 1;
321  descriptor.m_PadTop = 5;
322  descriptor.m_StrideX = 2;
323  descriptor.m_StrideY = 3;
324  descriptor.m_DataLayout = DataLayout::NHWC;
325  descriptor.m_BiasEnabled = true;
326 
327  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
328  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
329  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
330 
331  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
332  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
333  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
334  Optional<ConstTensor> optionalBiases(biases);
335 
336  TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases);
337 
338  Network net;
339 
340  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases);
341  layer->Accept(visitor);
342 }

◆ BOOST_AUTO_TEST_CASE() [9/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedConvolution2dLayerWithBiases  )

Definition at line 344 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddConvolution2dLayer(), Float32, Convolution2dDescriptor::m_BiasEnabled, Convolution2dDescriptor::m_DataLayout, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, and NHWC.

345 {
346  const char* layerName = "Convolution2dLayer";
347  Convolution2dDescriptor descriptor;
348  descriptor.m_PadLeft = 2;
349  descriptor.m_PadRight = 3;
350  descriptor.m_PadBottom = 1;
351  descriptor.m_PadTop = 5;
352  descriptor.m_StrideX = 2;
353  descriptor.m_StrideY = 3;
354  descriptor.m_DataLayout = DataLayout::NHWC;
355  descriptor.m_BiasEnabled = true;
356 
357  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
358  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
359  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
360 
361  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
362  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
363  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
364  Optional<ConstTensor> optionalBiases(biases);
365 
366  TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName);
367 
368  Network net;
369 
370  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases, layerName);
371  layer->Accept(visitor);
372 }

◆ BOOST_AUTO_TEST_CASE() [10/90]

armnn::BOOST_AUTO_TEST_CASE ( InputOutputLayerDynamicQuant  )

Definition at line 346 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithInputOutputLayers(), IInputSlot::GetConnection(), TensorInfo::GetDataType(), GetDataTypeName(), IConnectableLayer::GetInputSlot(), GetInputTensorInfo(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), and info.

347 {
349 
350  armnn::TensorInfo tensorInfo = GetInputTensorInfo(PolymorphicDowncast<const Network*>(network.get()));
351 
352  // Outliers -56 and 98
353  std::vector<float> inputData({0, 0, 0, -56, 98, 0, 0, 0});
354  armnn::ConstTensor inputTensor(tensorInfo, inputData.data());
355 
356  InputTensors inputTensors;
357  inputTensors.push_back(std::make_pair(0, inputTensor));
358 
360 
361  quantizer->Refine(inputTensors);
362 
363  // Outliers -77 and 65
364  std::vector<float> inputData2({0, -77, 0, -56, 65, 0, 0, 0});
365  armnn::ConstTensor inputTensor2(tensorInfo, inputData2.data());
366  InputTensors inputTensors2;
367  inputTensors2.push_back(std::make_pair(0, inputTensor2));
368 
369  quantizer->Refine(inputTensors2);
370 
371  INetworkPtr quantizedNetwork = quantizer->ExportNetwork();
372  // Output Layer should be quantized for a min max of -77 and 98
373  // according to QU8 Quantization Scheme
374  std::unique_ptr<IQuantizationScheme> quantizationScheme = std::make_unique<QAsymmU8QuantizationScheme>();
375  OffsetScalePair qParams = quantizationScheme->ComputeScheme(-77.0, 98.0);
376 
377  class TestOutputLayerVisitor : public LayerVisitorBase<VisitorNoThrowPolicy>
378  {
379  public:
380  TestOutputLayerVisitor(const OffsetScalePair& offsetScalePair, const DataType& dataType) :
381  m_OffsetScalePair(offsetScalePair), m_DataType(dataType) {}
382 
383  void VisitOutputLayer(const IConnectableLayer* layer,
384  LayerBindingId id,
385  const char* name = nullptr) override
386  {
387  IgnoreUnused(id, name);
388  const TensorInfo& info = layer->GetInputSlot(0).GetConnection()->GetTensorInfo();
389  BOOST_CHECK_MESSAGE(info.GetDataType() == m_DataType,
390  std::string(armnn::GetDataTypeName(info.GetDataType()))
391  .append(" == ").append(armnn::GetDataTypeName(m_DataType)));
392  // int_32t
393  BOOST_CHECK(info.GetQuantizationOffset() == m_OffsetScalePair.second);
394  // float
395  BOOST_TEST(info.GetQuantizationScale() == m_OffsetScalePair.first, boost::test_tools::tolerance(0.001));
396  }
397 
398  private:
399  const OffsetScalePair m_OffsetScalePair;
400  const DataType m_DataType;
401  };
402 
403  TestOutputLayerVisitor visitor(qParams, quantizationScheme->GetDataType());
404  quantizedNetwork->Accept(visitor);
405 }
std::pair< float, int > OffsetScalePair
INetworkPtr CreateNetworkWithInputOutputLayers()
std::unique_ptr< class INetworkQuantizer, void(*)(INetworkQuantizer *quantizer)> INetworkQuantizerPtr
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:340
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:202
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:180
DataType
Definition: Types.hpp:32
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
TensorInfo GetInputTensorInfo(const Network *network)
static INetworkQuantizerPtr Create(INetwork *inputNetwork, const QuantizerOptions &options=QuantizerOptions())
Create Quantizer object wrapped in unique_ptr.

◆ BOOST_AUTO_TEST_CASE() [11/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckDepthwiseConvolution2dLayer  )

Definition at line 374 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddDepthwiseConvolution2dLayer(), Float32, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, and NHWC.

375 {
376  DepthwiseConvolution2dDescriptor descriptor;
377  descriptor.m_PadLeft = 2;
378  descriptor.m_PadRight = 3;
379  descriptor.m_PadBottom = 1;
380  descriptor.m_PadTop = 5;
381  descriptor.m_StrideX = 2;
382  descriptor.m_StrideY = 3;
383  descriptor.m_DataLayout = DataLayout::NHWC;
384 
385  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
386  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
387  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
388 
389  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional());
390 
391  Network net;
392 
393  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, EmptyOptional());
394  layer->Accept(visitor);
395 }

◆ BOOST_AUTO_TEST_CASE() [12/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedDepthwiseConvolution2dLayer  )

Definition at line 397 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddDepthwiseConvolution2dLayer(), Float32, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, and NHWC.

398 {
399  const char* layerName = "DepthwiseConvolution2dLayer";
400  DepthwiseConvolution2dDescriptor descriptor;
401  descriptor.m_PadLeft = 2;
402  descriptor.m_PadRight = 3;
403  descriptor.m_PadBottom = 1;
404  descriptor.m_PadTop = 5;
405  descriptor.m_StrideX = 2;
406  descriptor.m_StrideY = 3;
407  descriptor.m_DataLayout = DataLayout::NHWC;
408 
409  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
410  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
411  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
412 
413  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional(), layerName);
414 
415  Network net;
416 
417  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor,
418  weights,
419  EmptyOptional(),
420  layerName);
421  layer->Accept(visitor);
422 }

◆ BOOST_AUTO_TEST_CASE() [13/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeAbsActivation  )

Definition at line 407 of file QuantizerTest.cpp.

References Abs, INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, and VisitLayersTopologically().

408 {
409  ActivationDescriptor descriptor;
410  descriptor.m_Function = ActivationFunction::Abs;
411  descriptor.m_A = 3.5f;
412  descriptor.m_B = -10.0f;
413 
414  const TensorShape shape{1U};
415  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
416 
417  const QuantizerOptions qAsymmU8Options(DataType::QAsymmU8);
418  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get(), qAsymmU8Options)->ExportNetwork();
419  TestActivationQuantization validatorQAsymmU8(shape, shape);
420  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
421 
422  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
423  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
424  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
425  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
426 
427  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
428  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
429  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
430  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
431 
432  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
433  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
434  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
435  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
436 }
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [14/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckDepthwiseConvolution2dLayerWithBiases  )

Definition at line 424 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddDepthwiseConvolution2dLayer(), Float32, DepthwiseConvolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, and NHWC.

425 {
426  DepthwiseConvolution2dDescriptor descriptor;
427  descriptor.m_PadLeft = 2;
428  descriptor.m_PadRight = 3;
429  descriptor.m_PadBottom = 1;
430  descriptor.m_PadTop = 5;
431  descriptor.m_StrideX = 2;
432  descriptor.m_StrideY = 3;
433  descriptor.m_DataLayout = DataLayout::NHWC;
434  descriptor.m_BiasEnabled = true;
435 
436  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
437  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
438  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
439 
440  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
441  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
442  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
443  Optional<ConstTensor> optionalBiases(biases);
444 
445  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases);
446 
447  Network net;
448 
449  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases);
450  layer->Accept(visitor);
451 }

◆ BOOST_AUTO_TEST_CASE() [15/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeLinearActivation  )

Definition at line 438 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), Linear, ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

439 {
440  ActivationDescriptor descriptor;
441  descriptor.m_Function = ActivationFunction::Linear;
442  descriptor.m_A = 3.5f;
443  descriptor.m_B = -10.0f;
444 
445  const TensorShape shape{1U};
446  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
447 
448  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
449  TestActivationQuantization validatorQAsymmU8(shape, shape);
450  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
451 
452  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
453  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
454  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
455  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
456 
457  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
458  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
459  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
460  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
461 
462  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
463  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
464  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
465  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
466 }
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [16/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedDepthwiseConvolution2dLayerWithBiases  )

Definition at line 453 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddDepthwiseConvolution2dLayer(), Float32, DepthwiseConvolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, and NHWC.

454 {
455  const char* layerName = "DepthwiseConvolution2dLayer";
456  DepthwiseConvolution2dDescriptor descriptor;
457  descriptor.m_PadLeft = 2;
458  descriptor.m_PadRight = 3;
459  descriptor.m_PadBottom = 1;
460  descriptor.m_PadTop = 5;
461  descriptor.m_StrideX = 2;
462  descriptor.m_StrideY = 3;
463  descriptor.m_DataLayout = DataLayout::NHWC;
464  descriptor.m_BiasEnabled = true;
465 
466  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
467  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
468  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
469 
470  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
471  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
472  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
473  Optional<ConstTensor> optionalBiases(biases);
474 
475  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName);
476 
477  Network net;
478 
479  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases, layerName);
480  layer->Accept(visitor);
481 }

◆ BOOST_AUTO_TEST_CASE() [17/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeReLuActivation  )

Definition at line 468 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, ReLu, and VisitLayersTopologically().

469 {
470  ActivationDescriptor descriptor;
471  descriptor.m_Function = ActivationFunction::ReLu;
472  descriptor.m_A = 3.5f;
473  descriptor.m_B = -10.0f;
474 
475  const TensorShape shape{1U};
476  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
477 
478  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
479  TestActivationQuantization validatorQAsymmU8(shape, shape);
480  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
481 
482  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
483  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
484  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
485  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
486 
487  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
488  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
489  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
490  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
491 
492  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
493  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
494  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
495  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
496 }
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [18/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckFullyConnectedLayer  )

Definition at line 483 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddFullyConnectedLayer(), Float32, and FullyConnectedDescriptor::m_TransposeWeightMatrix.

484 {
485  FullyConnectedDescriptor descriptor;
486  descriptor.m_TransposeWeightMatrix = true;
487 
488  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
489  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
490  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
491 
492  TestFullyConnectedLayerVistor visitor(descriptor, weights, EmptyOptional());
493 
494  Network net;
495 
496  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, EmptyOptional());
497  layer->Accept(visitor);
498 }

◆ BOOST_AUTO_TEST_CASE() [19/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSoftReLuActivation  )

Definition at line 498 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, SoftReLu, and VisitLayersTopologically().

499 {
500  ActivationDescriptor descriptor;
501  descriptor.m_Function = ActivationFunction::SoftReLu;
502  descriptor.m_A = 3.5f;
503  descriptor.m_B = -10.0f;
504 
505  const TensorShape shape{1U};
506  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
507 
508  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
509  TestActivationQuantization validatorQAsymmU8(shape, shape);
510  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
511 
512  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
513  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
514  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
515  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
516 
517  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
518  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
519  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
520  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
521 
522  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
523  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
524  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
525  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
526 }
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [20/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedFullyConnectedLayer  )

Definition at line 500 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddFullyConnectedLayer(), Float32, and FullyConnectedDescriptor::m_TransposeWeightMatrix.

501 {
502  const char* layerName = "FullyConnectedLayer";
503  FullyConnectedDescriptor descriptor;
504  descriptor.m_TransposeWeightMatrix = true;
505 
506  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
507  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
508  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
509 
510  TestFullyConnectedLayerVistor visitor(descriptor, weights, EmptyOptional(), layerName);
511 
512  Network net;
513 
514  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, EmptyOptional(), layerName);
515  layer->Accept(visitor);
516 }

◆ BOOST_AUTO_TEST_CASE() [21/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckFullyConnectedLayerWithBiases  )

Definition at line 518 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddFullyConnectedLayer(), Float32, FullyConnectedDescriptor::m_BiasEnabled, and FullyConnectedDescriptor::m_TransposeWeightMatrix.

519 {
520  FullyConnectedDescriptor descriptor;
521  descriptor.m_TransposeWeightMatrix = true;
522  descriptor.m_BiasEnabled = true;
523 
524  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
525  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
526  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
527 
528  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
529  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
530  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
531  Optional<ConstTensor> optionalBiases(biases);
532 
533  TestFullyConnectedLayerVistor visitor(descriptor, weights, optionalBiases);
534 
535  Network net;
536 
537  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, optionalBiases);
538  layer->Accept(visitor);
539 }

◆ BOOST_AUTO_TEST_CASE() [22/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeBoundedReluActivation  )

Definition at line 528 of file QuantizerTest.cpp.

References BoundedReLu, INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

529 {
530  class TestBoundedReluActivationQuantization : public TestQuantization
531  {
532  public:
533  TestBoundedReluActivationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
534  : TestQuantization(inputShape, outputShape) {}
535 
536  TestBoundedReluActivationQuantization(const QuantizerOptions& options,
537  const TensorShape& inputShape,
538  const TensorShape& outputShape)
539  : TestQuantization(options, inputShape, outputShape) {}
540 
541  void VisitActivationLayer(const IConnectableLayer* layer,
542  const ActivationDescriptor& descriptor,
543  const char* name = nullptr) override
544  {
545  IgnoreUnused(descriptor, name);
546  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
547 
548  // Based off default static range [0.0f, 3.5f]
549  TestQuantizationParams(info, {3.5f / g_AsymmU8QuantizationBase, 0},
550  {3.5f / g_AsymmS8QuantizationBase, -128},
551  {3.5f / g_SymmS8QuantizationBase, 0},
552  {3.5f / g_SymmS16QuantizationBase, 0});
553  }
554  };
555 
556  ActivationDescriptor descriptor;
557  descriptor.m_Function = ActivationFunction::BoundedReLu;
558  descriptor.m_A = 3.5f;
559  descriptor.m_B = -10.0f;
560 
561  const TensorShape shape{1U};
562  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
563 
564  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
565  TestBoundedReluActivationQuantization validatorQAsymmU8(shape, shape);
566  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
567 
568  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
569  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
570  TestBoundedReluActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
571  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
572 
573  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
574  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
575  TestBoundedReluActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
576  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
577 
578  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
579  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
580  TestBoundedReluActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
581  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
582 }
const float g_AsymmU8QuantizationBase
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [23/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedFullyConnectedLayerWithBiases  )

Definition at line 541 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddFullyConnectedLayer(), Float32, FullyConnectedDescriptor::m_BiasEnabled, and FullyConnectedDescriptor::m_TransposeWeightMatrix.

542 {
543  const char* layerName = "FullyConnectedLayer";
544  FullyConnectedDescriptor descriptor;
545  descriptor.m_TransposeWeightMatrix = true;
546  descriptor.m_BiasEnabled = true;
547 
548  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
549  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
550  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
551 
552  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
553  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
554  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
555  Optional<ConstTensor> optionalBiases(biases);
556 
557  TestFullyConnectedLayerVistor visitor(descriptor, weights, optionalBiases, layerName);
558 
559  Network net;
560 
561  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, optionalBiases, layerName);
562  layer->Accept(visitor);
563 }

◆ BOOST_AUTO_TEST_CASE() [24/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckBatchNormalizationLayer  )

Definition at line 565 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddBatchNormalizationLayer(), Float32, BatchNormalizationDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_Eps, and NHWC.

566 {
567  BatchNormalizationDescriptor descriptor;
568  descriptor.m_Eps = 0.0002f;
569  descriptor.m_DataLayout = DataLayout::NHWC;
570 
571  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
572  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
573  ConstTensor mean(TensorInfo(4, dimensions.data(), DataType::Float32), data);
574 
575  std::vector<float> varianceData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
576  std::vector<unsigned int> varianceDimensions = {1, 1, 3, 3};
577  ConstTensor variance(TensorInfo(4, varianceDimensions.data(), DataType::Float32), varianceData);
578 
579  std::vector<float> betaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
580  std::vector<unsigned int> betaDimensions = {1, 1, 3, 3};
581  ConstTensor beta(TensorInfo(4, betaDimensions.data(), DataType::Float32), betaData);
582 
583  std::vector<float> gammaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
584  std::vector<unsigned int> gammaDimensions = {1, 1, 3, 3};
585  ConstTensor gamma(TensorInfo(4, gammaDimensions.data(), DataType::Float32), gammaData);
586 
587  TestBatchNormalizationLayerVisitor visitor(descriptor, mean, variance, beta, gamma);
588 
589  Network net;
590 
591  IConnectableLayer* const layer = net.AddBatchNormalizationLayer(descriptor, mean, variance, beta, gamma);
592  layer->Accept(visitor);
593 }

◆ BOOST_AUTO_TEST_CASE() [25/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeTanHActivation  )

Definition at line 584 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, TanH, and VisitLayersTopologically().

585 {
586  class TestTanHActivationQuantization : public TestQuantization
587  {
588  public:
589  TestTanHActivationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
590  : TestQuantization(inputShape, outputShape) {}
591 
592  TestTanHActivationQuantization(const QuantizerOptions& options,
593  const TensorShape& inputShape,
594  const TensorShape& outputShape)
595  : TestQuantization(options, inputShape, outputShape) {}
596 
597  void VisitActivationLayer(const IConnectableLayer* layer,
598  const ActivationDescriptor& descriptor,
599  const char* name = nullptr) override
600  {
601  IgnoreUnused(descriptor, name);
602  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
603 
604  // Based off default static range [-1.0f, 1.0f]
605  TestQuantizationParams(
606  info, {2.0f / g_AsymmU8QuantizationBase, 128},
607  {2.0f / g_AsymmS8QuantizationBase, 0},
608  {1.0f / g_SymmS8QuantizationBase , 0},
609  {1.0f / g_SymmS16QuantizationBase, 0});
610  }
611  };
612 
613  ActivationDescriptor descriptor;
614  descriptor.m_Function = ActivationFunction::TanH;
615  descriptor.m_A = 3.5f;
616  descriptor.m_B = -10.0f;
617 
618  const TensorShape shape{1U};
619  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
620 
621  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
622  TestTanHActivationQuantization validatorQAsymmU8(shape, shape);
623  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
624 
625  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
626  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
627  TestTanHActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
628  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
629 
630  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
631  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
632  TestTanHActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
633  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
634 
635  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
636  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
637  TestTanHActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
638  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
639 }
const float g_AsymmU8QuantizationBase
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [26/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedBatchNormalizationLayer  )

Definition at line 595 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddBatchNormalizationLayer(), Float32, BatchNormalizationDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_Eps, and NHWC.

596 {
597  const char* layerName = "BatchNormalizationLayer";
598  BatchNormalizationDescriptor descriptor;
599  descriptor.m_Eps = 0.0002f;
600  descriptor.m_DataLayout = DataLayout::NHWC;
601 
602  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
603  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
604  ConstTensor mean(TensorInfo(4, dimensions.data(), DataType::Float32), data);
605 
606  std::vector<float> varianceData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
607  std::vector<unsigned int> varianceDimensions = {1, 1, 3, 3};
608  ConstTensor variance(TensorInfo(4, varianceDimensions.data(), DataType::Float32), varianceData);
609 
610  std::vector<float> betaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
611  std::vector<unsigned int> betaDimensions = {1, 1, 3, 3};
612  ConstTensor beta(TensorInfo(4, betaDimensions.data(), DataType::Float32), betaData);
613 
614  std::vector<float> gammaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
615  std::vector<unsigned int> gammaDimensions = {1, 1, 3, 3};
616  ConstTensor gamma(TensorInfo(4, gammaDimensions.data(), DataType::Float32), gammaData);
617 
618  TestBatchNormalizationLayerVisitor visitor(descriptor, mean, variance, beta, gamma, layerName);
619 
620  Network net;
621 
622  IConnectableLayer* const layer = net.AddBatchNormalizationLayer(
623  descriptor, mean, variance, beta, gamma, layerName);
624  layer->Accept(visitor);
625 }

◆ BOOST_AUTO_TEST_CASE() [27/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckConstLayer  )

Definition at line 627 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddConstantLayer(), and Float32.

628 {
629  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
630  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
631  ConstTensor input(TensorInfo(4, dimensions.data(), DataType::Float32), data);
632 
633  TestConstantLayerVisitor visitor(input);
634 
635  Network net;
636 
637  IConnectableLayer* const layer = net.AddConstantLayer(input);
638  layer->Accept(visitor);
639 }

◆ BOOST_AUTO_TEST_CASE() [28/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedConstLayer  )

Definition at line 641 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddConstantLayer(), and Float32.

642 {
643  const char* layerName = "ConstantLayer";
644  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
645  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
646  ConstTensor input(TensorInfo(4, dimensions.data(), DataType::Float32), data);
647 
648  TestConstantLayerVisitor visitor(input, layerName);
649 
650  Network net;
651 
652  IConnectableLayer* const layer = net.AddConstantLayer(input, layerName);
653  layer->Accept(visitor);
654 }

◆ BOOST_AUTO_TEST_CASE() [29/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerBasic  )

Definition at line 656 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, and LstmInputParams::m_RecurrentToOutputWeights.

657 {
658  LstmDescriptor descriptor;
659  descriptor.m_ActivationFunc = 3;
660  descriptor.m_ClippingThresProj = 0.5f;
661  descriptor.m_ClippingThresCell = 0.3f;
662  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
663 
664  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
665  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
666  ConstTensor inputToForgetWeights(
667  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
668 
669  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
670  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
671  ConstTensor inputToCellWeights(
672  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
673 
674  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
675  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
676  ConstTensor inputToOutputWeights(
677  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
678 
679  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
680  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
681  ConstTensor recurrentToForgetWeights(TensorInfo(
682  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
683 
684  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
685  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
686  ConstTensor recurrentToCellWeights(TensorInfo(
687  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
688 
689  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
690  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
691  ConstTensor recurrentToOutputWeights(TensorInfo(
692  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
693 
694  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
695  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
696  ConstTensor forgetGateBias(TensorInfo(
697  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
698 
699  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
700  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
701  ConstTensor cellBias(TensorInfo(
702  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
703 
704  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
705  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
706  ConstTensor outputGateBias(TensorInfo(
707  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
708 
709  LstmInputParams params;
710  params.m_InputToForgetWeights = &inputToForgetWeights;
711  params.m_InputToCellWeights = &inputToCellWeights;
712  params.m_InputToOutputWeights = &inputToOutputWeights;
713  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
714  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
715  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
716  params.m_ForgetGateBias = &forgetGateBias;
717  params.m_CellBias = &cellBias;
718  params.m_OutputGateBias = &outputGateBias;
719 
720  TestLstmLayerVisitor visitor(descriptor, params);
721 
722  Network net;
723 
724  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
725  layer->Accept(visitor);
726 }

◆ BOOST_AUTO_TEST_CASE() [30/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeLeakyReLuActivation  )

Definition at line 679 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), LeakyReLu, ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

680 {
681  ActivationDescriptor descriptor;
682  descriptor.m_Function = ActivationFunction::LeakyReLu;
683  descriptor.m_A = 3.5f;
684  descriptor.m_B = -10.0f;
685 
686  const TensorShape shape{1U};
687  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
688 
689  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
690  TestLeakyReLuActivationQuantization validatorQAsymmU8(shape, shape);
691  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
692 
693  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
694  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
695  TestLeakyReLuActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
696  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
697 
698  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
699  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
700  TestLeakyReLuActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
701  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
702 
703  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
704  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
705  TestLeakyReLuActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
706  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
707 }
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [31/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeELuActivation  )

Definition at line 710 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), Elu, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

711 {
712  class TestEluActivationQuantization : public TestQuantization
713  {
714  public:
715  TestEluActivationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
716  : TestQuantization(inputShape, outputShape) {}
717 
718  TestEluActivationQuantization(const QuantizerOptions& options,
719  const TensorShape& inputShape,
720  const TensorShape& outputShape)
721  : TestQuantization(options, inputShape, outputShape) {}
722 
723  void VisitActivationLayer(const IConnectableLayer* layer,
724  const ActivationDescriptor& descriptor,
725  const char* name = nullptr) override
726  {
727  IgnoreUnused(descriptor, name);
728  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
729 
730  // Based off default static range [-15.0f, 15.0f]
731  TestQuantizationParams(
732  info, {30.0f / g_AsymmU8QuantizationBase, 128},
733  {30.0f / g_AsymmS8QuantizationBase, 0},
734  {15.0f / g_SymmS8QuantizationBase, 0},
735  {15.0f / g_SymmS16QuantizationBase, 0});
736  }
737  };
738 
739  ActivationDescriptor descriptor;
740  descriptor.m_Function = ActivationFunction::Elu;
741 
742  const TensorShape shape{1U};
743  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
744 
745  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
746  TestEluActivationQuantization validatorQAsymmU8(shape, shape);
747  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
748 
749  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
750  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
751  TestEluActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
752  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
753 
754  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
755  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
756  TestEluActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
757  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
758 
759  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
760  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
761  TestEluActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
762  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
763 }
const float g_AsymmU8QuantizationBase
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [32/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerBasic  )

Definition at line 728 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, and LstmInputParams::m_RecurrentToOutputWeights.

729 {
730  const char* layerName = "LstmLayer";
731  LstmDescriptor descriptor;
732  descriptor.m_ActivationFunc = 3;
733  descriptor.m_ClippingThresProj = 0.5f;
734  descriptor.m_ClippingThresCell = 0.3f;
735  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
736 
737  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
738  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
739  ConstTensor inputToForgetWeights(
740  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
741 
742  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
743  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
744  ConstTensor inputToCellWeights(
745  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
746 
747  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
748  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
749  ConstTensor inputToOutputWeights(
750  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
751 
752  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
753  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
754  ConstTensor recurrentToForgetWeights(TensorInfo(
755  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
756 
757  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
758  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
759  ConstTensor recurrentToCellWeights(TensorInfo(
760  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
761 
762  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
763  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
764  ConstTensor recurrentToOutputWeights(TensorInfo(
765  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
766 
767  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
768  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
769  ConstTensor forgetGateBias(TensorInfo(
770  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
771 
772  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
773  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
774  ConstTensor cellBias(TensorInfo(
775  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
776 
777  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
778  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
779  ConstTensor outputGateBias(TensorInfo(
780  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
781 
782  LstmInputParams params;
783  params.m_InputToForgetWeights = &inputToForgetWeights;
784  params.m_InputToCellWeights = &inputToCellWeights;
785  params.m_InputToOutputWeights = &inputToOutputWeights;
786  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
787  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
788  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
789  params.m_ForgetGateBias = &forgetGateBias;
790  params.m_CellBias = &cellBias;
791  params.m_OutputGateBias = &outputGateBias;
792 
793  TestLstmLayerVisitor visitor(descriptor, params, layerName);
794 
795  Network net;
796 
797  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
798  layer->Accept(visitor);
799 }

◆ BOOST_AUTO_TEST_CASE() [33/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeHardSwishActivation  )

Definition at line 764 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithActivationLayer(), g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), HardSwish, IgnoreUnused(), info, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

765 {
766  class TestHardSwishActivationQuantization : public TestQuantization
767  {
768  public:
769  TestHardSwishActivationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
770  : TestQuantization(inputShape, outputShape) {}
771 
772  TestHardSwishActivationQuantization(const QuantizerOptions& options,
773  const TensorShape& inputShape,
774  const TensorShape& outputShape)
775  : TestQuantization(options, inputShape, outputShape) {}
776 
777  void VisitActivationLayer(const IConnectableLayer* layer,
778  const ActivationDescriptor& descriptor,
779  const char* name = nullptr) override
780  {
781  IgnoreUnused(descriptor, name);
782  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
783 
784  // Based off default static range [-15.0f, 15.0f]
785  TestQuantizationParams(
786  info, {30.0f / g_AsymmU8QuantizationBase, 128},
787  {30.0f / g_AsymmS8QuantizationBase, 0},
788  {15.0f / g_SymmS8QuantizationBase, 0},
789  {15.0f / g_SymmS16QuantizationBase, 0});
790  }
791  };
792 
793  ActivationDescriptor descriptor;
794  descriptor.m_Function = ActivationFunction::HardSwish;
795 
796  const TensorShape shape{1U};
797  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
798 
799  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
800  TestHardSwishActivationQuantization validatorQAsymmU8(shape, shape);
801  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
802 
803  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
804  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
805  TestHardSwishActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
806  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
807 
808  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
809  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
810  TestHardSwishActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
811  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
812 
813  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
814  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
815  TestHardSwishActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
816  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
817 }
const float g_AsymmU8QuantizationBase
INetworkPtr CreateNetworkWithActivationLayer(const ActivationDescriptor &descriptor, const TensorShape &shape)
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [34/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerCifgDisabled  )

Definition at line 801 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, and LstmInputParams::m_RecurrentToOutputWeights.

802 {
803  LstmDescriptor descriptor;
804  descriptor.m_ActivationFunc = 3;
805  descriptor.m_ClippingThresProj = 0.5f;
806  descriptor.m_ClippingThresCell = 0.3f;
807  descriptor.m_CifgEnabled = false; // if this is true then we DON'T need to set the OptCifgParams
808 
809  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
810  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
811  ConstTensor inputToForgetWeights(
812  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
813 
814  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
815  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
816  ConstTensor inputToCellWeights(
817  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
818 
819  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
820  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
821  ConstTensor inputToOutputWeights(
822  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
823 
824  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
825  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
826  ConstTensor recurrentToForgetWeights(TensorInfo(
827  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
828 
829  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
830  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
831  ConstTensor recurrentToCellWeights(TensorInfo(
832  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
833 
834  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
835  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
836  ConstTensor recurrentToOutputWeights(TensorInfo(
837  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
838 
839  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
840  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
841  ConstTensor forgetGateBias(TensorInfo(
842  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
843 
844  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
845  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
846  ConstTensor cellBias(TensorInfo(
847  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
848 
849  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
850  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
851  ConstTensor outputGateBias(TensorInfo(
852  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
853 
854  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
855  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
856  ConstTensor inputToInputWeights(
857  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32), inputToInputWeightsData);
858 
859  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
860  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
861  ConstTensor recurrentToInputWeights(TensorInfo(
862  4, recurrentToInputWeightsDimensions.data(), DataType::Float32), recurrentToInputWeightsData);
863 
864  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
865  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
866  ConstTensor inputGateBias(
867  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32), inputGateBiasData);
868 
869  LstmInputParams params;
870  params.m_InputToForgetWeights = &inputToForgetWeights;
871  params.m_InputToCellWeights = &inputToCellWeights;
872  params.m_InputToOutputWeights = &inputToOutputWeights;
873  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
874  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
875  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
876  params.m_ForgetGateBias = &forgetGateBias;
877  params.m_CellBias = &cellBias;
878  params.m_OutputGateBias = &outputGateBias;
879 
880  params.m_InputToInputWeights = &inputToInputWeights;
881  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
882  params.m_InputGateBias = &inputGateBias;
883 
884  TestLstmLayerVisitor visitor(descriptor, params);
885 
886  Network net;
887 
888  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
889  layer->Accept(visitor);
890 }

◆ BOOST_AUTO_TEST_CASE() [35/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeBatchNorm  )

Definition at line 820 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, BaseTensor< MemoryType >::GetInfo(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

821 {
822  class TestBatchNormalizationQuantization : public TestQuantization
823  {
824  public:
825  TestBatchNormalizationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
826  : TestQuantization(inputShape, outputShape) {}
827 
828  TestBatchNormalizationQuantization(const QuantizerOptions& options,
829  const TensorShape& inputShape,
830  const TensorShape& outputShape)
831  : TestQuantization(options, inputShape, outputShape) {}
832 
833  void VisitBatchNormalizationLayer(const IConnectableLayer* layer,
834  const BatchNormalizationDescriptor& desc,
835  const ConstTensor& mean,
836  const ConstTensor& variance,
837  const ConstTensor& beta,
838  const ConstTensor& gamma,
839  const char* name = nullptr) override
840  {
841  IgnoreUnused(desc, name);
842  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
843 
844  // Based off default static range [-15.0f, 15.0f]
845  TestQuantizationParams(
846  info, {30.0f / g_AsymmU8QuantizationBase, 128},
847  {30.0f / g_AsymmS8QuantizationBase, 0},
848  {15.0f / g_SymmS8QuantizationBase, 0},
849  {15.0f / g_SymmS16QuantizationBase, 0});
850 
851  // Test constants
852  TestConstantQuantizationParams(mean.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
853  TestConstantQuantizationParams(variance.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
854  TestConstantQuantizationParams(beta.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
855  TestConstantQuantizationParams(gamma.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
856  }
857  };
858 
859  INetworkPtr network = INetwork::Create();
860 
861  const TensorShape shape{3U};
862  TensorInfo info(shape, DataType::Float32);
863 
864  std::vector<float> meanData{-1.0f, 1.5f, 2.0f};
865  std::vector<float> varData{-1.0f, 1.5f, 2.0f};
866  std::vector<float> betaData{-1.0f, 1.5f, 2.0f};
867  std::vector<float> gammaData{-1.0f, 1.5f, 2.0f};
868 
869  ConstTensor mean(info, meanData);
870  ConstTensor var(info, varData);
871  ConstTensor beta(info, betaData);
872  ConstTensor gamma(info, gammaData);
873 
874  BatchNormalizationDescriptor desc;
875 
876  // Add the layers
877  IConnectableLayer* input0 = network->AddInputLayer(0);
878  IConnectableLayer* batchNorm = network->AddBatchNormalizationLayer(desc, mean, var, beta, gamma);
879  IConnectableLayer* output = network->AddOutputLayer(1);
880 
881  // Establish connections
882  input0->GetOutputSlot(0).Connect(batchNorm->GetInputSlot(0));
883  batchNorm->GetOutputSlot(0).Connect(output->GetInputSlot(0));
884 
885  // Set TensorInfo
886  input0->GetOutputSlot(0).SetTensorInfo(info);
887  batchNorm->GetOutputSlot(0).SetTensorInfo(info);
888 
889  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
890  TestBatchNormalizationQuantization validatorQAsymmU8(shape, shape);
891  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
892 
893  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
894  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
895  TestBatchNormalizationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
896  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
897 
898  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
899  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
900  TestBatchNormalizationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
901  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
902 
903  const QuantizerOptions QQsymm16Options(DataType::QSymmS16);
904  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), QQsymm16Options)->ExportNetwork();
905  TestBatchNormalizationQuantization validatorQSymmS16(QQsymm16Options, shape, shape);
906  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
907 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [36/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerCifgDisabled  )

Definition at line 892 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, and LstmInputParams::m_RecurrentToOutputWeights.

893 {
894  const char* layerName = "LstmLayer";
895  LstmDescriptor descriptor;
896  descriptor.m_ActivationFunc = 3;
897  descriptor.m_ClippingThresProj = 0.5f;
898  descriptor.m_ClippingThresCell = 0.3f;
899  descriptor.m_CifgEnabled = false; // if this is true then we DON'T need to set the OptCifgParams
900 
901  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
902  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
903  ConstTensor inputToForgetWeights(
904  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
905 
906  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
907  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
908  ConstTensor inputToCellWeights(
909  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
910 
911  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
912  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
913  ConstTensor inputToOutputWeights(
914  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
915 
916  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
917  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
918  ConstTensor recurrentToForgetWeights(TensorInfo(
919  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
920 
921  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
922  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
923  ConstTensor recurrentToCellWeights(TensorInfo(
924  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
925 
926  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
927  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
928  ConstTensor recurrentToOutputWeights(TensorInfo(
929  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
930 
931  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
932  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
933  ConstTensor forgetGateBias(TensorInfo(
934  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
935 
936  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
937  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
938  ConstTensor cellBias(TensorInfo(
939  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
940 
941  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
942  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
943  ConstTensor outputGateBias(TensorInfo(
944  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
945 
946  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
947  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
948  ConstTensor inputToInputWeights(
949  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32), inputToInputWeightsData);
950 
951  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
952  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
953  ConstTensor recurrentToInputWeights(TensorInfo(
954  4, recurrentToInputWeightsDimensions.data(), DataType::Float32), recurrentToInputWeightsData);
955 
956  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
957  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
958  ConstTensor inputGateBias(
959  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32), inputGateBiasData);
960 
961  LstmInputParams params;
962  params.m_InputToForgetWeights = &inputToForgetWeights;
963  params.m_InputToCellWeights = &inputToCellWeights;
964  params.m_InputToOutputWeights = &inputToOutputWeights;
965  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
966  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
967  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
968  params.m_ForgetGateBias = &forgetGateBias;
969  params.m_CellBias = &cellBias;
970  params.m_OutputGateBias = &outputGateBias;
971 
972  params.m_InputToInputWeights = &inputToInputWeights;
973  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
974  params.m_InputGateBias = &inputGateBias;
975 
976  TestLstmLayerVisitor visitor(descriptor, params, layerName);
977 
978  Network net;
979 
980  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
981  layer->Accept(visitor);
982 }

◆ BOOST_AUTO_TEST_CASE() [37/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeDepthToSpace  )

Definition at line 909 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, NHWC, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

910 {
911  class TestDepthToSpaceQuantization : public TestQuantization
912  {
913  public:
914  TestDepthToSpaceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
915  : TestQuantization(inputShape, outputShape) {}
916 
917  TestDepthToSpaceQuantization(const QuantizerOptions& options,
918  const TensorShape& inputShape,
919  const TensorShape& outputShape)
920  : TestQuantization(options, inputShape, outputShape) {}
921 
922  virtual void VisitDepthToSpaceLayer(const IConnectableLayer* layer,
923  const DepthToSpaceDescriptor& desc,
924  const char* name = nullptr)
925  {
926  IgnoreUnused(desc, name);
927  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
928 
929  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
930  const OffsetScalePair qAsymmS8Params{ 30.0f / g_AsymmS8QuantizationBase, 0 };
931  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0 };
932  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
933 
934  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
935  }
936  };
937 
938  const TensorShape inputShape { 1, 2, 2, 4 };
939  const TensorShape outputShape{ 1, 4, 4, 1 };
940 
941  const TensorInfo inputInfo (inputShape, DataType::Float32);
942  const TensorInfo outputInfo(outputShape, DataType::Float32);
943 
944  INetworkPtr network = INetwork::Create();
945  const DepthToSpaceDescriptor descriptor(2, armnn::DataLayout::NHWC);
946 
947  IConnectableLayer* inputLayer = network->AddInputLayer(0);
948  IConnectableLayer* depthToSpaceLayer = network->AddDepthToSpaceLayer(descriptor);
949  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
950 
951  inputLayer->GetOutputSlot(0).Connect(depthToSpaceLayer->GetInputSlot(0));
952  depthToSpaceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
953 
954  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
955  depthToSpaceLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
956 
957  // test QAsymmU8 quantization
958  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
959  TestDepthToSpaceQuantization validatorQAsymmU8(inputShape, outputShape);
960  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
961 
962  // test QAsymmS8 quantization
963  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
964  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
965  TestDepthToSpaceQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, outputShape);
966  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
967 
968  // test QSymmS8 quantization
969  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
970  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
971  TestDepthToSpaceQuantization validatorQSymmS8(qSymmS8Options, inputShape, outputShape);
972  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
973 
974  // test QSymmS16 quantization
975  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
976  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
977  TestDepthToSpaceQuantization validatorQSymmS16(Qsymm16Options, inputShape, outputShape);
978  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
979 }
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase
SpaceToDepthDescriptor DepthToSpaceDescriptor
A DepthToSpaceDescriptor for the DepthToSpaceLayer.

◆ BOOST_AUTO_TEST_CASE() [38/90]

armnn::BOOST_AUTO_TEST_CASE ( OverrideInputRangeEmptyNetwork  )

Definition at line 981 of file QuantizerTest.cpp.

References Network::GetGraph(), Graph::GetInputLayers(), RangeTracker::IsEmpty(), and VisitLayers().

982 {
983  RangeTracker ranges;
984  RangeTracker::MinMaxRange minMaxRange(-12.3f, 45.6f); // Range to use for the override
985 
986  Network network; // Empty network
987  auto inputLayers = network.GetGraph().GetInputLayers(); // Empty list of input layers
988 
989  OverrideInputRangeVisitor overrideInputRangeVisitor(ranges, 0, minMaxRange);
990  VisitLayers(inputLayers, overrideInputRangeVisitor);
991 
992  BOOST_CHECK(ranges.IsEmpty()); // Check that the map of ranges remained untouched
993 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
std::pair< float, float > MinMaxRange

◆ BOOST_AUTO_TEST_CASE() [39/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerPeephole  )

Definition at line 985 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, and LstmInputParams::m_RecurrentToOutputWeights.

986 {
987  LstmDescriptor descriptor;
988  descriptor.m_ActivationFunc = 3;
989  descriptor.m_ClippingThresProj = 0.5f;
990  descriptor.m_ClippingThresCell = 0.3f;
991  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
992  descriptor.m_PeepholeEnabled = true;
993 
994  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
995  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
996  ConstTensor inputToForgetWeights(
997  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
998 
999  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1000  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1001  ConstTensor inputToCellWeights(
1002  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1003 
1004  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1005  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1006  ConstTensor inputToOutputWeights(
1007  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1008 
1009  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1010  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1011  ConstTensor recurrentToForgetWeights(TensorInfo(
1012  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1013 
1014  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1015  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1016  ConstTensor recurrentToCellWeights(TensorInfo(
1017  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1018 
1019  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1020  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1021  ConstTensor recurrentToOutputWeights(TensorInfo(
1022  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1023 
1024  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1025  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1026  ConstTensor forgetGateBias(TensorInfo(
1027  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1028 
1029  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1030  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1031  ConstTensor cellBias(TensorInfo(
1032  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1033 
1034  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1035  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1036  ConstTensor outputGateBias(TensorInfo(
1037  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1038 
1039  std::vector<float> cellToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1040  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1041  ConstTensor cellToForgetWeights(
1042  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::Float32), cellToForgetWeightsData);
1043 
1044  std::vector<float> cellToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1045  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1046  ConstTensor cellToOutputWeights(
1047  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::Float32), cellToOutputWeightsData);
1048 
1049  LstmInputParams params;
1050  params.m_InputToForgetWeights = &inputToForgetWeights;
1051  params.m_InputToCellWeights = &inputToCellWeights;
1052  params.m_InputToOutputWeights = &inputToOutputWeights;
1053  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1054  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1055  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1056  params.m_ForgetGateBias = &forgetGateBias;
1057  params.m_CellBias = &cellBias;
1058  params.m_OutputGateBias = &outputGateBias;
1059 
1060  params.m_CellToForgetWeights = &cellToForgetWeights;
1061  params.m_CellToOutputWeights = &cellToOutputWeights;
1062 
1063  TestLstmLayerVisitor visitor(descriptor, params);
1064 
1065  Network net;
1066 
1067  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
1068  layer->Accept(visitor);
1069 }

◆ BOOST_AUTO_TEST_CASE() [40/90]

armnn::BOOST_AUTO_TEST_CASE ( OverrideInputRangeNoInputLayers  )

Definition at line 995 of file QuantizerTest.cpp.

References Network::AddAdditionLayer(), Network::GetGraph(), Graph::GetInputLayers(), RangeTracker::IsEmpty(), and VisitLayers().

996 {
997  RangeTracker ranges;
998  MinMaxRange minMaxRange(-12.3f, 45.6f); // Range to use for the override
999 
1000  Network network;
1001  network.AddAdditionLayer(); // Network with no input layers
1002  auto inputLayers = network.GetGraph().GetInputLayers(); // Empty list of input layers
1003 
1004  OverrideInputRangeVisitor overrideInputRangeVisitor(ranges, 0, minMaxRange);
1005  VisitLayers(inputLayers, overrideInputRangeVisitor);
1006 
1007  BOOST_CHECK(ranges.IsEmpty()); // Check that the map of ranges remained untouched
1008 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
std::pair< float, float > MinMaxRange

◆ BOOST_AUTO_TEST_CASE() [41/90]

armnn::BOOST_AUTO_TEST_CASE ( OverrideInputRangeInputLayers  )

Definition at line 1010 of file QuantizerTest.cpp.

References Network::AddAdditionLayer(), Network::AddInputLayer(), Network::AddOutputLayer(), IOutputSlot::Connect(), Float32, Network::GetGraph(), IConnectableLayer::GetGuid(), Graph::GetInputLayers(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), RangeTracker::GetRange(), RangeTracker::HasRanges(), info, RangeTracker::IsEmpty(), IOutputSlot::SetTensorInfo(), and VisitLayers().

1011 {
1012  RangeTracker ranges;
1013  MinMaxRange minMaxRange(-12.3f, 45.6f); // Range to use for the override
1014 
1015  Network network;
1016 
1017  // Adding the layers
1018  IConnectableLayer* input0 = network.AddInputLayer(0);
1019  IConnectableLayer* input1 = network.AddInputLayer(1);
1020  IConnectableLayer* addition = network.AddAdditionLayer();
1021  IConnectableLayer* output = network.AddOutputLayer(2);
1022 
1023  // Connecting the layer
1024  input0->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
1025  input1->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
1026  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1027 
1028  // Setting the TensorInfos
1029  TensorShape shape{1U};
1030  TensorInfo info(shape, DataType::Float32);
1031  input0->GetOutputSlot(0).SetTensorInfo(info);
1032  input1->GetOutputSlot(0).SetTensorInfo(info);
1033  addition->GetOutputSlot(0).SetTensorInfo(info);
1034 
1035  auto inputLayers = network.GetGraph().GetInputLayers(); // List of input layers
1036 
1037  // Trying to override the input range for the input layer with binding id 3 (does not exist in the network)
1038  OverrideInputRangeVisitor overrideInputRangeVisitorLayer3(ranges, 3, minMaxRange);
1039  VisitLayers(inputLayers, overrideInputRangeVisitorLayer3);
1040 
1041  // Check that the map of ranges remained untouched
1042  BOOST_CHECK(ranges.IsEmpty());
1043 
1044  // Override the input range for the input layer with binding id 1
1045  OverrideInputRangeVisitor overrideInputRangeVisitorLayer1(ranges, 1, minMaxRange);
1046  VisitLayers(inputLayers, overrideInputRangeVisitorLayer1);
1047 
1048  // Check that the map of ranges has been populated
1049  BOOST_CHECK(!ranges.IsEmpty());
1050 
1051  // Check that an entry for the input layer with binding id 0 does not exist
1052  BOOST_CHECK(!ranges.HasRanges(input0->GetGuid()));
1053 
1054  // Check that an entry for the input layer with binding id 1 exists
1055  BOOST_CHECK(ranges.HasRanges(input1->GetGuid()));
1056 
1057  // Check the the overridden values are what we intended to set
1058  BOOST_CHECK(ranges.GetRange(input1->GetGuid(), 0) == minMaxRange);
1059 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
std::pair< float, float > MinMaxRange

◆ BOOST_AUTO_TEST_CASE() [42/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerPeepholeCifgDisabled  )

Definition at line 1071 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, and LstmInputParams::m_RecurrentToOutputWeights.

1072 {
1073  LstmDescriptor descriptor;
1074  descriptor.m_ActivationFunc = 3;
1075  descriptor.m_ClippingThresProj = 0.5f;
1076  descriptor.m_ClippingThresCell = 0.3f;
1077  descriptor.m_CifgEnabled = false;
1078  descriptor.m_PeepholeEnabled = true;
1079 
1080  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1081  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1082  ConstTensor inputToForgetWeights(
1083  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
1084 
1085  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1086  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1087  ConstTensor inputToCellWeights(
1088  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1089 
1090  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1091  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1092  ConstTensor inputToOutputWeights(
1093  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1094 
1095  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1096  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1097  ConstTensor recurrentToForgetWeights(TensorInfo(
1098  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1099 
1100  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1101  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1102  ConstTensor recurrentToCellWeights(TensorInfo(
1103  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1104 
1105  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1106  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1107  ConstTensor recurrentToOutputWeights(TensorInfo(
1108  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1109 
1110  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1111  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1112  ConstTensor forgetGateBias(TensorInfo(
1113  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1114 
1115  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1116  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1117  ConstTensor cellBias(TensorInfo(
1118  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1119 
1120  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1121  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1122  ConstTensor outputGateBias(TensorInfo(
1123  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1124 
1125  std::vector<float> cellToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1126  std::vector<unsigned int> cellToInputWeightsDimensions = {1, 1, 3, 3};
1127  ConstTensor cellToInputWeights(
1128  TensorInfo(4, cellToInputWeightsDimensions.data(), DataType::Float32), cellToInputWeightsData);
1129 
1130  std::vector<float> cellToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1131  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1132  ConstTensor cellToForgetWeights(
1133  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::Float32), cellToForgetWeightsData);
1134 
1135  std::vector<float> cellToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1136  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1137  ConstTensor cellToOutputWeights(
1138  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::Float32), cellToOutputWeightsData);
1139 
1140  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1141  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1142  ConstTensor inputToInputWeights(
1143  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32), inputToInputWeightsData);
1144 
1145  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1146  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1147  ConstTensor recurrentToInputWeights(TensorInfo(
1148  4, recurrentToInputWeightsDimensions.data(), DataType::Float32), recurrentToInputWeightsData);
1149 
1150  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1151  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1152  ConstTensor inputGateBias(
1153  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32), inputGateBiasData);
1154 
1155  LstmInputParams params;
1156  // Basic params
1157  params.m_InputToForgetWeights = &inputToForgetWeights;
1158  params.m_InputToCellWeights = &inputToCellWeights;
1159  params.m_InputToOutputWeights = &inputToOutputWeights;
1160  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1161  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1162  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1163  params.m_ForgetGateBias = &forgetGateBias;
1164  params.m_CellBias = &cellBias;
1165  params.m_OutputGateBias = &outputGateBias;
1166 
1167  // Peephole params
1168  params.m_CellToInputWeights = &cellToInputWeights;
1169  params.m_CellToForgetWeights = &cellToForgetWeights;
1170  params.m_CellToOutputWeights = &cellToOutputWeights;
1171 
1172  // Cifg params
1173  params.m_InputToInputWeights = &inputToInputWeights;
1174  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1175  params.m_InputGateBias = &inputGateBias;
1176 
1177  TestLstmLayerVisitor visitor(descriptor, params);
1178 
1179  Network net;
1180 
1181  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
1182  layer->Accept(visitor);
1183 }

◆ BOOST_AUTO_TEST_CASE() [43/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeFill  )

Definition at line 1146 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, FillDescriptor::m_Value, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1147 {
1148  class TestFillQuantization : public TestQuantization
1149  {
1150  public:
1151  TestFillQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1152  : TestQuantization(inputShape, outputShape) {}
1153 
1154  TestFillQuantization(const QuantizerOptions& options,
1155  const TensorShape& inputShape,
1156  const TensorShape& outputShape)
1157  : TestQuantization(options, inputShape, outputShape) {}
1158 
1159  virtual void VisitFillLayer(const IConnectableLayer* layer,
1160  const FillDescriptor& desc,
1161  const char* name = nullptr)
1162  {
1163  IgnoreUnused(desc, name);
1164  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1165 
1166  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
1167  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
1168  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
1169  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
1170 
1171  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
1172  }
1173  };
1174 
1175  const TensorShape tensorShape{ 1U };
1176  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1177 
1178  INetworkPtr network = INetwork::Create();
1179 
1180  FillDescriptor descriptor;
1181  descriptor.m_Value = 1;
1182 
1183  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1184  IConnectableLayer* fillLayer = network->AddFillLayer(descriptor);
1185  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1186 
1187  inputLayer->GetOutputSlot(0).Connect(fillLayer->GetInputSlot(0));
1188  fillLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1189 
1190  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1191  fillLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1192 
1193  // test QAsymmU8 quantization
1194  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1195  TestFillQuantization validatorQAsymmU8(tensorShape, tensorShape);
1196  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1197 
1198  // test QAsymmS8 quantization
1199  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1200  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1201  TestFillQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
1202  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1203 
1204  // test QSymmS8 quantization
1205  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1206  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1207  TestFillQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
1208  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1209 
1210  // test QuantisedSymmS16 quantization
1211  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1212  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1213  TestFillQuantization validatorQSymmS16(qSymmS16options, tensorShape, tensorShape);
1214  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1215 }
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [44/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerPeephole  )

Definition at line 1185 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, and LstmInputParams::m_RecurrentToOutputWeights.

1186 {
1187  const char* layerName = "LstmLayer";
1188  LstmDescriptor descriptor;
1189  descriptor.m_ActivationFunc = 3;
1190  descriptor.m_ClippingThresProj = 0.5f;
1191  descriptor.m_ClippingThresCell = 0.3f;
1192  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1193  descriptor.m_PeepholeEnabled = true;
1194 
1195  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1196  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1197  ConstTensor inputToForgetWeights(
1198  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
1199 
1200  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1201  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1202  ConstTensor inputToCellWeights(
1203  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1204 
1205  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1206  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1207  ConstTensor inputToOutputWeights(
1208  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1209 
1210  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1211  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1212  ConstTensor recurrentToForgetWeights(TensorInfo(
1213  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1214 
1215  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1216  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1217  ConstTensor recurrentToCellWeights(TensorInfo(
1218  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1219 
1220  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1221  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1222  ConstTensor recurrentToOutputWeights(TensorInfo(
1223  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1224 
1225  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1226  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1227  ConstTensor forgetGateBias(TensorInfo(
1228  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1229 
1230  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1231  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1232  ConstTensor cellBias(TensorInfo(
1233  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1234 
1235  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1236  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1237  ConstTensor outputGateBias(TensorInfo(
1238  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1239 
1240  std::vector<float> cellToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1241  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1242  ConstTensor cellToForgetWeights(
1243  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::Float32), cellToForgetWeightsData);
1244 
1245  std::vector<float> cellToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1246  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1247  ConstTensor cellToOutputWeights(
1248  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::Float32), cellToOutputWeightsData);
1249 
1250  LstmInputParams params;
1251  params.m_InputToForgetWeights = &inputToForgetWeights;
1252  params.m_InputToCellWeights = &inputToCellWeights;
1253  params.m_InputToOutputWeights = &inputToOutputWeights;
1254  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1255  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1256  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1257  params.m_ForgetGateBias = &forgetGateBias;
1258  params.m_CellBias = &cellBias;
1259  params.m_OutputGateBias = &outputGateBias;
1260 
1261  params.m_CellToForgetWeights = &cellToForgetWeights;
1262  params.m_CellToOutputWeights = &cellToOutputWeights;
1263 
1264  TestLstmLayerVisitor visitor(descriptor, params, layerName);
1265 
1266  Network net;
1267 
1268  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
1269  layer->Accept(visitor);
1270 }

◆ BOOST_AUTO_TEST_CASE() [45/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeFullyConnected  )

Definition at line 1217 of file QuantizerTest.cpp.

References ValidateFullyConnectedLayer().

1218 {
1220 }
void ValidateFullyConnectedLayer(const bool biasEnabled)

◆ BOOST_AUTO_TEST_CASE() [46/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeFullyConnectedBiasEnabled  )

Definition at line 1222 of file QuantizerTest.cpp.

References ValidateFullyConnectedLayer().

1223 {
1225 }
void ValidateFullyConnectedLayer(const bool biasEnabled)

◆ BOOST_AUTO_TEST_CASE() [47/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerProjection  )

Definition at line 1273 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, and LstmInputParams::m_RecurrentToOutputWeights.

1274 {
1275  LstmDescriptor descriptor;
1276  descriptor.m_ActivationFunc = 3;
1277  descriptor.m_ClippingThresProj = 0.5f;
1278  descriptor.m_ClippingThresCell = 0.3f;
1279  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1280  descriptor.m_ProjectionEnabled = true;
1281 
1282  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1283  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1284  ConstTensor inputToForgetWeights(
1285  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
1286 
1287  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1288  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1289  ConstTensor inputToCellWeights(
1290  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1291 
1292  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1293  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1294  ConstTensor inputToOutputWeights(
1295  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1296 
1297  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1298  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1299  ConstTensor recurrentToForgetWeights(TensorInfo(
1300  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1301 
1302  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1303  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1304  ConstTensor recurrentToCellWeights(TensorInfo(
1305  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1306 
1307  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1308  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1309  ConstTensor recurrentToOutputWeights(TensorInfo(
1310  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1311 
1312  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1313  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1314  ConstTensor forgetGateBias(TensorInfo(
1315  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1316 
1317  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1318  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1319  ConstTensor cellBias(TensorInfo(
1320  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1321 
1322  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1323  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1324  ConstTensor outputGateBias(TensorInfo(
1325  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1326 
1327  std::vector<float> projectionBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1328  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1329  ConstTensor projectionBias(
1330  TensorInfo(4, projectionBiasDimensions.data(), DataType::Float32), projectionBiasData);
1331 
1332  std::vector<float> projectionWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1333  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1334  ConstTensor projectionWeights(
1335  TensorInfo(4, projectionWeightsDimensions.data(), DataType::Float32), projectionWeightsData);
1336 
1337  LstmInputParams params;
1338  params.m_InputToForgetWeights = &inputToForgetWeights;
1339  params.m_InputToCellWeights = &inputToCellWeights;
1340  params.m_InputToOutputWeights = &inputToOutputWeights;
1341  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1342  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1343  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1344  params.m_ForgetGateBias = &forgetGateBias;
1345  params.m_CellBias = &cellBias;
1346  params.m_OutputGateBias = &outputGateBias;
1347 
1348  params.m_ProjectionWeights = &projectionWeights;
1349  params.m_ProjectionBias = &projectionBias;
1350 
1351  TestLstmLayerVisitor visitor(descriptor, params);
1352 
1353  Network net;
1354 
1355  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
1356  layer->Accept(visitor);
1357 }

◆ BOOST_AUTO_TEST_CASE() [48/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConvolution2d  )

Definition at line 1303 of file QuantizerTest.cpp.

References TestQuantizeConvolution2d().

1304 {
1306 }
void TestQuantizeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [49/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConvolution2dWithBiases  )

Definition at line 1308 of file QuantizerTest.cpp.

References TestQuantizeConvolution2d().

1309 {
1311 }
void TestQuantizeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [50/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerProjection  )

Definition at line 1359 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, and LstmInputParams::m_RecurrentToOutputWeights.

1360 {
1361  const char* layerName = "LstmLayer";
1362  LstmDescriptor descriptor;
1363  descriptor.m_ActivationFunc = 3;
1364  descriptor.m_ClippingThresProj = 0.5f;
1365  descriptor.m_ClippingThresCell = 0.3f;
1366  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1367  descriptor.m_ProjectionEnabled = true;
1368 
1369  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1370  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1371  ConstTensor inputToForgetWeights(
1372  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
1373 
1374  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1375  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1376  ConstTensor inputToCellWeights(
1377  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1378 
1379  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1380  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1381  ConstTensor inputToOutputWeights(
1382  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1383 
1384  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1385  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1386  ConstTensor recurrentToForgetWeights(TensorInfo(
1387  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1388 
1389  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1390  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1391  ConstTensor recurrentToCellWeights(TensorInfo(
1392  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1393 
1394  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1395  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1396  ConstTensor recurrentToOutputWeights(TensorInfo(
1397  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1398 
1399  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1400  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1401  ConstTensor forgetGateBias(TensorInfo(
1402  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1403 
1404  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1405  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1406  ConstTensor cellBias(TensorInfo(
1407  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1408 
1409  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1410  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1411  ConstTensor outputGateBias(TensorInfo(
1412  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1413 
1414  std::vector<float> projectionBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1415  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1416  ConstTensor projectionBias(
1417  TensorInfo(4, projectionBiasDimensions.data(), DataType::Float32), projectionBiasData);
1418 
1419  std::vector<float> projectionWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1420  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1421  ConstTensor projectionWeights(
1422  TensorInfo(4, projectionWeightsDimensions.data(), DataType::Float32), projectionWeightsData);
1423 
1424  LstmInputParams params;
1425  params.m_InputToForgetWeights = &inputToForgetWeights;
1426  params.m_InputToCellWeights = &inputToCellWeights;
1427  params.m_InputToOutputWeights = &inputToOutputWeights;
1428  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1429  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1430  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1431  params.m_ForgetGateBias = &forgetGateBias;
1432  params.m_CellBias = &cellBias;
1433  params.m_OutputGateBias = &outputGateBias;
1434 
1435  params.m_ProjectionWeights = &projectionWeights;
1436  params.m_ProjectionBias = &projectionBias;
1437 
1438  TestLstmLayerVisitor visitor(descriptor, params, layerName);
1439 
1440  Network net;
1441 
1442  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
1443  layer->Accept(visitor);
1444 }

◆ BOOST_AUTO_TEST_CASE() [51/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeDepthwiseConvolution2d  )

Definition at line 1389 of file QuantizerTest.cpp.

References TestQuantizeDepthwiseConvolution2d().

1390 {
1392 }
void TestQuantizeDepthwiseConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [52/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeDepthwiseConvolution2dWithBiases  )

Definition at line 1394 of file QuantizerTest.cpp.

References TestQuantizeDepthwiseConvolution2d().

1395 {
1397 }
void TestQuantizeDepthwiseConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [53/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeInstanceNormalization  )

Definition at line 1399 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1400 {
1401  class TestInstanceNormalizationQuantization : public TestQuantization
1402  {
1403  public:
1404  TestInstanceNormalizationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1405  : TestQuantization(inputShape, outputShape) {}
1406 
1407  TestInstanceNormalizationQuantization(const QuantizerOptions& options,
1408  const TensorShape& inputShape,
1409  const TensorShape& outputShape)
1410  : TestQuantization(options, inputShape, outputShape) {}
1411 
1412  virtual void VisitInstanceNormalizationLayer(const IConnectableLayer* layer,
1413  const InstanceNormalizationDescriptor& descriptor,
1414  const char* name = nullptr)
1415  {
1416  IgnoreUnused(descriptor, name);
1417  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
1418 
1419  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
1420  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
1421  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
1422  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
1423 
1424  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
1425  }
1426  };
1427 
1428  const TensorShape tensorShape{ 1, 4, 4, 1 };
1429  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1430 
1431  INetworkPtr network = INetwork::Create();
1432 
1433  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1434  IConnectableLayer* instanceNormLayer = network->AddInstanceNormalizationLayer(InstanceNormalizationDescriptor());
1435  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1436 
1437  inputLayer->GetOutputSlot(0).Connect(instanceNormLayer->GetInputSlot(0));
1438  instanceNormLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1439 
1440  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1441  instanceNormLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1442 
1443  // test QAsymmU8 quantization
1444  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1445  TestInstanceNormalizationQuantization validatorQAsymmU8(tensorShape, tensorShape);
1446  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1447 
1448  //test QAsymmS8 quantization
1449  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1450  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1451  TestInstanceNormalizationQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
1452  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1453 
1454  // test QSymmS8 quantization
1455  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1456  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1457  TestInstanceNormalizationQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
1458  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1459 
1460  // test QSymmS16 quantization
1461  const QuantizerOptions qSymmS16Options(DataType::QSymmS16);
1462  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16Options)->ExportNetwork();
1463  TestInstanceNormalizationQuantization validatorQSymmS16(qSymmS16Options, tensorShape, tensorShape);
1464  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1465 }
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [54/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQLstmLayerBasic  )

Definition at line 1446 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_ProjectionClip, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS8, and Signed32.

1447 {
1448  QLstmDescriptor descriptor;
1449  descriptor.m_ProjectionClip = 0.5f;
1450  descriptor.m_CellClip = 0.3f;
1451  descriptor.m_CifgEnabled = true;
1452 
1453  // Basic params ONLY
1454  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1455  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1456  ConstTensor inputToForgetWeights(
1457  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1458 
1459  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1460  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1461  ConstTensor inputToCellWeights(
1462  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
1463 
1464  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1465  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1466  ConstTensor inputToOutputWeights(
1467  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
1468 
1469  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1470  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1471  ConstTensor recurrentToForgetWeights(TensorInfo(
1472  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
1473 
1474  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1475  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1476  ConstTensor recurrentToCellWeights(TensorInfo(
1477  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
1478 
1479  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1480  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1481  ConstTensor recurrentToOutputWeights(TensorInfo(
1482  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
1483 
1484  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1485  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1486  ConstTensor forgetGateBias(TensorInfo(
1487  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1488 
1489  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1490  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1491  ConstTensor cellBias(TensorInfo(
1492  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1493 
1494  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1495  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1496  ConstTensor outputGateBias(TensorInfo(
1497  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1498 
1499  LstmInputParams params;
1500  params.m_InputToForgetWeights = &inputToForgetWeights;
1501  params.m_InputToCellWeights = &inputToCellWeights;
1502  params.m_InputToOutputWeights = &inputToOutputWeights;
1503  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1504  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1505  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1506  params.m_ForgetGateBias = &forgetGateBias;
1507  params.m_CellBias = &cellBias;
1508  params.m_OutputGateBias = &outputGateBias;
1509 
1510  TestQLstmLayerVisitor visitor(descriptor, params);
1511 
1512  Network net;
1513 
1514  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1515  layer->Accept(visitor);
1516 }

◆ BOOST_AUTO_TEST_CASE() [55/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeLogSoftmax  )

Definition at line 1467 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, SoftmaxDescriptor::m_Beta, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1468 {
1469  class TestLogSoftmaxQuantization : public TestQuantization
1470  {
1471  public:
1472  TestLogSoftmaxQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1473  : TestQuantization(inputShape, outputShape) {}
1474 
1475  TestLogSoftmaxQuantization(const QuantizerOptions& options,
1476  const TensorShape& inputShape,
1477  const TensorShape& outputShape)
1478  : TestQuantization(options, inputShape, outputShape) {}
1479 
1480  void VisitLogSoftmaxLayer(const IConnectableLayer* layer,
1481  const SoftmaxDescriptor& descriptor,
1482  const char* name = nullptr) override
1483  {
1484  IgnoreUnused(descriptor, name);
1485  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1486 
1487  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
1488  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
1489  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
1490  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
1491 
1492  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
1493  }
1494  };
1495 
1496  const TensorShape tensorShape{ 1U };
1497  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1498 
1499  INetworkPtr network = INetwork::Create();
1500 
1501  LogSoftmaxDescriptor descriptor;
1502  descriptor.m_Beta = 1.0f;
1503 
1504  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1505  IConnectableLayer* logSoftmaxLayer = network->AddLogSoftmaxLayer(descriptor);
1506  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1507 
1508  inputLayer->GetOutputSlot(0).Connect(logSoftmaxLayer->GetInputSlot(0));
1509  logSoftmaxLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1510 
1511  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1512  logSoftmaxLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1513 
1514  // test QAsymmU8 quantization
1515  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1516  TestLogSoftmaxQuantization validatorQAsymmU8(tensorShape, tensorShape);
1517  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1518 
1519  // test QAsymmS8 quantization
1520  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1521  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1522  TestLogSoftmaxQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
1523  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1524 
1525  // test QSymmS8 quantization
1526  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1527  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1528  TestLogSoftmaxQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
1529  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1530 
1531  // test QuantisedSymmS16 quantization
1532  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1533  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1534  TestLogSoftmaxQuantization validatorQSymmS16(qSymmS16options, tensorShape, tensorShape);
1535  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1536 }
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
float m_Beta
Exponentiation value.
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
SoftmaxDescriptor LogSoftmaxDescriptor
A LogSoftmaxDescriptor for the LogSoftmaxLayer.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [56/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedQLstmLayerBasic  )

Definition at line 1518 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_ProjectionClip, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS8, and Signed32.

1519 {
1520  const char* layerName = "QLstmLayer";
1521  QLstmDescriptor descriptor;
1522  descriptor.m_ProjectionClip = 0.5f;
1523  descriptor.m_CellClip = 0.3f;
1524  descriptor.m_CifgEnabled = true;
1525 
1526  // Basic params ONLY
1527  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1528  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1529  ConstTensor inputToForgetWeights(
1530  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1531 
1532  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1533  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1534  ConstTensor inputToCellWeights(
1535  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
1536 
1537  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1538  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1539  ConstTensor inputToOutputWeights(
1540  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
1541 
1542  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1543  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1544  ConstTensor recurrentToForgetWeights(TensorInfo(
1545  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
1546 
1547  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1548  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1549  ConstTensor recurrentToCellWeights(TensorInfo(
1550  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
1551 
1552  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1553  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1554  ConstTensor recurrentToOutputWeights(TensorInfo(
1555  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
1556 
1557  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1558  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1559  ConstTensor forgetGateBias(TensorInfo(
1560  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1561 
1562  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1563  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1564  ConstTensor cellBias(TensorInfo(
1565  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1566 
1567  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1568  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1569  ConstTensor outputGateBias(TensorInfo(
1570  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1571 
1572  LstmInputParams params;
1573  params.m_InputToForgetWeights = &inputToForgetWeights;
1574  params.m_InputToCellWeights = &inputToCellWeights;
1575  params.m_InputToOutputWeights = &inputToOutputWeights;
1576  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1577  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1578  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1579  params.m_ForgetGateBias = &forgetGateBias;
1580  params.m_CellBias = &cellBias;
1581  params.m_OutputGateBias = &outputGateBias;
1582 
1583  TestQLstmLayerVisitor visitor(descriptor, params, layerName);
1584 
1585  Network net;
1586 
1587  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params, layerName);
1588  layer->Accept(visitor);
1589 }

◆ BOOST_AUTO_TEST_CASE() [57/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSoftmax  )

Definition at line 1559 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithSoftmaxLayer(), g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, SoftmaxDescriptor::m_Beta, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

1560 {
1561  class TestSoftmaxQuantization : public TestQuantization
1562  {
1563  public:
1564  TestSoftmaxQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1565  : TestQuantization(inputShape, outputShape) {}
1566 
1567  TestSoftmaxQuantization(const QuantizerOptions& options,
1568  const TensorShape& inputShape,
1569  const TensorShape& outputShape)
1570  : TestQuantization(options, inputShape, outputShape) {}
1571 
1572  void VisitSoftmaxLayer(const IConnectableLayer* layer,
1573  const SoftmaxDescriptor& descriptor,
1574  const char* name = nullptr) override
1575  {
1576  IgnoreUnused(descriptor, name);
1577  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1578 
1579  // Based off default static range [0.0f, 1.0f]
1580  TestQuantizationParams(info, {1.0f / g_AsymmU8QuantizationBase, 0},
1581  {1.0f / g_AsymmS8QuantizationBase, -128},
1582  {1.0f / g_SymmS8QuantizationBase, 0},
1583  {1.0f / g_SymmS16QuantizationBase, 0});
1584  }
1585  };
1586 
1587  SoftmaxDescriptor descriptor;
1588  descriptor.m_Beta = 1.0f;
1589 
1590  const TensorShape shape{1U};
1591  INetworkPtr network = CreateNetworkWithSoftmaxLayer(descriptor, shape);
1592 
1593  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1594  TestSoftmaxQuantization validatorQAsymmU8(shape, shape);
1595  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1596 
1597  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1598  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1599  TestSoftmaxQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1600  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1601 
1602  // test QSymmS8 quantization
1603  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1604  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1605  TestSoftmaxQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1606  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1607 
1608  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1609  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1610  TestSoftmaxQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1611  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1612 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
INetworkPtr CreateNetworkWithSoftmaxLayer(const SoftmaxDescriptor &descriptor, const TensorShape &shape)
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [58/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQLstmLayerCifgDisabled  )

Definition at line 1591 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_ProjectionClip, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS8, and Signed32.

1592 {
1593  QLstmDescriptor descriptor;
1594  descriptor.m_ProjectionClip = 0.5f;
1595  descriptor.m_CellClip = 0.3f;
1596  descriptor.m_CifgEnabled = false;
1597 
1598  // Basic params
1599  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1600  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1601  ConstTensor inputToForgetWeights(
1602  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1603 
1604  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1605  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1606  ConstTensor inputToCellWeights(
1607  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
1608 
1609  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1610  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1611  ConstTensor inputToOutputWeights(
1612  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
1613 
1614  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1615  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1616  ConstTensor recurrentToForgetWeights(TensorInfo(
1617  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
1618 
1619  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1620  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1621  ConstTensor recurrentToCellWeights(TensorInfo(
1622  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
1623 
1624  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1625  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1626  ConstTensor recurrentToOutputWeights(TensorInfo(
1627  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
1628 
1629  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1630  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1631  ConstTensor forgetGateBias(TensorInfo(
1632  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1633 
1634  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1635  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1636  ConstTensor cellBias(TensorInfo(
1637  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1638 
1639  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1640  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1641  ConstTensor outputGateBias(TensorInfo(
1642  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1643 
1644  // CIFG disabled params
1645  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1646  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1647  ConstTensor inputToInputWeights(
1648  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8), inputToInputWeightsData);
1649 
1650  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1651  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1652  ConstTensor recurrentToInputWeights(TensorInfo(
1653  4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8), recurrentToInputWeightsData);
1654 
1655  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1656  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1657  ConstTensor inputGateBias(
1658  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
1659 
1660  LstmInputParams params;
1661 
1662  // Basic params
1663  params.m_InputToForgetWeights = &inputToForgetWeights;
1664  params.m_InputToCellWeights = &inputToCellWeights;
1665  params.m_InputToOutputWeights = &inputToOutputWeights;
1666  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1667  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1668  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1669  params.m_ForgetGateBias = &forgetGateBias;
1670  params.m_CellBias = &cellBias;
1671  params.m_OutputGateBias = &outputGateBias;
1672 
1673  // CIFG disabled params
1674  params.m_InputToInputWeights = &inputToInputWeights;
1675  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1676  params.m_InputGateBias = &inputGateBias;
1677 
1678  TestQLstmLayerVisitor visitor(descriptor, params);
1679 
1680  Network net;
1681 
1682  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1683  layer->Accept(visitor);
1684 }

◆ BOOST_AUTO_TEST_CASE() [59/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeStandIn  )

Definition at line 1614 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), StandInDescriptor::m_NumInputs, StandInDescriptor::m_NumOutputs, QAsymmS8, QSymmS16, QSymmS8, and IOutputSlot::SetTensorInfo().

1615 {
1616  const TensorShape tensorShape{ 1U };
1617  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1618 
1619  INetworkPtr network = INetwork::Create();
1620 
1621  StandInDescriptor descriptor;
1622  descriptor.m_NumInputs = 1;
1623  descriptor.m_NumOutputs = 1;
1624 
1625  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1626  IConnectableLayer* standInLayer = network->AddStandInLayer(descriptor);
1627  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1628 
1629  inputLayer->GetOutputSlot(0).Connect(standInLayer->GetInputSlot(0));
1630  standInLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1631 
1632  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1633  standInLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1634 
1635  // test QAsymmU8 quantization
1636  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get())->ExportNetwork(),
1638 
1639  // test QAsymmS8 quantization
1640  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1641  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork(),
1643 
1644  // test QuantisedSymmS16 quantization
1645  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1646  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork(),
1648 
1649  // test QuantisedSymmS16 quantization
1650  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1651  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork(),
1653 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [60/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQLstmLayerCifgDisabledPeepholeEnabled  )

Definition at line 1686 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_PeepholeEnabled, QLstmDescriptor::m_ProjectionClip, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS16, QSymmS8, and Signed32.

1687 {
1688  QLstmDescriptor descriptor;
1689  descriptor.m_ProjectionClip = 0.5f;
1690  descriptor.m_CellClip = 0.3f;
1691  descriptor.m_CifgEnabled = false;
1692  descriptor.m_PeepholeEnabled = true;
1693 
1694  // Basic params
1695  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1696  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1697  ConstTensor inputToForgetWeights(
1698  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1699 
1700  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1701  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1702  ConstTensor inputToCellWeights(
1703  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
1704 
1705  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1706  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1707  ConstTensor inputToOutputWeights(
1708  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
1709 
1710  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1711  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1712  ConstTensor recurrentToForgetWeights(TensorInfo(
1713  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
1714 
1715  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1716  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1717  ConstTensor recurrentToCellWeights(TensorInfo(
1718  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
1719 
1720  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1721  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1722  ConstTensor recurrentToOutputWeights(TensorInfo(
1723  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
1724 
1725  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1726  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1727  ConstTensor forgetGateBias(TensorInfo(
1728  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1729 
1730  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1731  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1732  ConstTensor cellBias(TensorInfo(
1733  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1734 
1735  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1736  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1737  ConstTensor outputGateBias(TensorInfo(
1738  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1739 
1740  // CIFG disabled params
1741  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1742  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1743  ConstTensor inputToInputWeights(
1744  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8), inputToInputWeightsData);
1745 
1746  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1747  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1748  ConstTensor recurrentToInputWeights(TensorInfo(
1749  4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8), recurrentToInputWeightsData);
1750 
1751  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1752  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1753  ConstTensor inputGateBias(
1754  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
1755 
1756  // Peephole enabled, CIFG disabled params
1757  std::vector<int16_t> cellToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1758  std::vector<unsigned int> cellToInputWeightsDimensions = {1, 1, 3, 3};
1759  ConstTensor cellToInputWeights(
1760  TensorInfo(4, cellToInputWeightsDimensions.data(), DataType::QSymmS16), cellToInputWeightsData);
1761 
1762  std::vector<int16_t> cellToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1763  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1764  ConstTensor cellToForgetWeights(
1765  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::QSymmS16), cellToForgetWeightsData);
1766 
1767  std::vector<int16_t> cellToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1768  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1769  ConstTensor cellToOutputWeights(
1770  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::QSymmS16), cellToOutputWeightsData);
1771 
1772  LstmInputParams params;
1773 
1774  // Basic params
1775  params.m_InputToForgetWeights = &inputToForgetWeights;
1776  params.m_InputToCellWeights = &inputToCellWeights;
1777  params.m_InputToOutputWeights = &inputToOutputWeights;
1778  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1779  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1780  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1781  params.m_ForgetGateBias = &forgetGateBias;
1782  params.m_CellBias = &cellBias;
1783  params.m_OutputGateBias = &outputGateBias;
1784 
1785  // CIFG disabled params
1786  params.m_InputToInputWeights = &inputToInputWeights;
1787  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1788  params.m_InputGateBias = &inputGateBias;
1789 
1790  // Peephole enabled, CIFG disabled params
1791  params.m_CellToInputWeights = &cellToInputWeights;
1792  params.m_CellToForgetWeights = &cellToForgetWeights;
1793  params.m_CellToOutputWeights = &cellToOutputWeights;
1794 
1795  TestQLstmLayerVisitor visitor(descriptor, params);
1796 
1797  Network net;
1798 
1799  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1800  layer->Accept(visitor);
1801 }

◆ BOOST_AUTO_TEST_CASE() [61/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizePermute  )

Definition at line 1692 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

1693 {
1694  class TestPermuteQuantization : public TestLeakyReLuActivationQuantization
1695  {
1696  public:
1697  TestPermuteQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1698  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
1699 
1700  TestPermuteQuantization(const QuantizerOptions& options,
1701  const TensorShape& inputShape,
1702  const TensorShape& outputShape)
1703  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
1704 
1705  void VisitPermuteLayer(const IConnectableLayer* layer,
1706  const PermuteDescriptor& desc,
1707  const char* name = nullptr) override
1708  {
1709  IgnoreUnused(desc, name);
1710  CheckForwardedQuantizationSettings(layer);
1711  }
1712  };
1713 
1714  INetworkPtr network = INetwork::Create();
1715 
1716  const TensorShape shape{1U};
1717  TensorInfo info(shape, DataType::Float32);
1718 
1719  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
1720 
1721  // Add the layer under test
1722  PermuteDescriptor desc;
1723  IConnectableLayer* permute = network->AddPermuteLayer(desc);
1724 
1725  CompleteLeakyReluNetwork(network.get(), activation, permute, info);
1726 
1727  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1728  TestPermuteQuantization validatorQAsymmU8(shape, shape);
1729  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1730 
1731  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1732  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1733  TestPermuteQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1734  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1735 
1736  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1737  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1738  TestPermuteQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1739  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1740 
1741  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1742  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1743  TestPermuteQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1744  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1745 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [62/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSpaceToBatch  )

Definition at line 1747 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

1748 {
1749  class TestSpaceToBatchQuantization : public TestLeakyReLuActivationQuantization
1750  {
1751  public:
1752  TestSpaceToBatchQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1753  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
1754 
1755  TestSpaceToBatchQuantization(const QuantizerOptions& options,
1756  const TensorShape& inputShape,
1757  const TensorShape& outputShape)
1758  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
1759 
1760  void VisitSpaceToBatchNdLayer(const IConnectableLayer* layer,
1761  const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor,
1762  const char* name = nullptr) override
1763  {
1764  IgnoreUnused(spaceToBatchNdDescriptor, name);
1765  CheckForwardedQuantizationSettings(layer);
1766  }
1767  };
1768 
1769  INetworkPtr network = INetwork::Create();
1770 
1771  const TensorShape shape{1U};
1772  TensorInfo info(shape, DataType::Float32);
1773 
1774  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
1775 
1776  // Add the layer under test
1777  SpaceToBatchNdDescriptor descriptor;
1778  IConnectableLayer* spaceToBatch = network->AddSpaceToBatchNdLayer(descriptor);
1779 
1780  CompleteLeakyReluNetwork(network.get(), activation, spaceToBatch, info);
1781 
1782  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1783  TestSpaceToBatchQuantization validatorQAsymmU8(shape, shape);
1784  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1785 
1786  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1787  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1788  TestSpaceToBatchQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1789  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1790 
1791  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1792  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1793  TestSpaceToBatchQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1794  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1795 
1796  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1797  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1798  TestSpaceToBatchQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1799  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1800 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [63/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSpaceToDepth  )

Definition at line 1802 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

1803 {
1804  class TestSpaceToDepthQuantization : public TestLeakyReLuActivationQuantization
1805  {
1806  public:
1807  TestSpaceToDepthQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1808  : TestLeakyReLuActivationQuantization(inputShape, outputShape)
1809  {}
1810 
1811  TestSpaceToDepthQuantization(const QuantizerOptions& options,
1812  const TensorShape& inputShape,
1813  const TensorShape& outputShape)
1814  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape)
1815  {}
1816 
1817  void VisitSpaceToDepthLayer(const IConnectableLayer* layer,
1818  const SpaceToDepthDescriptor&,
1819  const char* = nullptr) override
1820  {
1821  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1822  TestQuantizationParams(info,
1823  { 30.0f / g_AsymmU8QuantizationBase, 128 },
1824  { 30.0f / g_AsymmS8QuantizationBase, 0 },
1825  { 15.0f / g_SymmS8QuantizationBase, 0 },
1826  { 15.0f / g_SymmS16QuantizationBase, 0 });
1827  }
1828  };
1829 
1830  INetworkPtr network = INetwork::Create();
1831 
1832  const TensorShape shape{ 1u };
1833  TensorInfo info(shape, DataType::Float32);
1834 
1835  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
1836  IConnectableLayer* spaceToDepth = network->AddSpaceToDepthLayer(SpaceToDepthDescriptor());
1837 
1838  CompleteLeakyReluNetwork(network.get(), activation, spaceToDepth, info);
1839 
1840  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1841  TestSpaceToDepthQuantization validatorQAsymmU8(shape, shape);
1842  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1843 
1844  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1845  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1846  TestSpaceToDepthQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1847  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1848 
1849  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1850  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1851  TestSpaceToDepthQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1852  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1853 
1854  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1855  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1856  TestSpaceToDepthQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1857  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1858 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
const float g_SymmS16QuantizationBase
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [64/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQLstmLayerCifgEnabledPeepholeEnabled  )

Definition at line 1803 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, QLstmDescriptor::m_PeepholeEnabled, QLstmDescriptor::m_ProjectionClip, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS16, QSymmS8, and Signed32.

1804 {
1805  QLstmDescriptor descriptor;
1806  descriptor.m_ProjectionClip = 0.5f;
1807  descriptor.m_CellClip = 0.3f;
1808  descriptor.m_CifgEnabled = true;
1809  descriptor.m_PeepholeEnabled = true;
1810 
1811  // Basic params
1812  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1813  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1814  ConstTensor inputToForgetWeights(
1815  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1816 
1817  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1818  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1819  ConstTensor inputToCellWeights(
1820  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
1821 
1822  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1823  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1824  ConstTensor inputToOutputWeights(
1825  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
1826 
1827  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1828  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1829  ConstTensor recurrentToForgetWeights(TensorInfo(
1830  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
1831 
1832  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1833  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1834  ConstTensor recurrentToCellWeights(TensorInfo(
1835  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
1836 
1837  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1838  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1839  ConstTensor recurrentToOutputWeights(TensorInfo(
1840  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
1841 
1842  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1843  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1844  ConstTensor forgetGateBias(TensorInfo(
1845  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1846 
1847  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1848  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1849  ConstTensor cellBias(TensorInfo(
1850  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1851 
1852  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1853  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1854  ConstTensor outputGateBias(TensorInfo(
1855  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1856 
1857  // Peephole enabled and CIFG enabled params
1858  std::vector<int16_t> cellToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1859  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1860  ConstTensor cellToForgetWeights(
1861  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::QSymmS16), cellToForgetWeightsData);
1862 
1863  std::vector<int16_t> cellToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1864  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1865  ConstTensor cellToOutputWeights(
1866  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::QSymmS16), cellToOutputWeightsData);
1867 
1868  LstmInputParams params;
1869 
1870  // Basic params
1871  params.m_InputToForgetWeights = &inputToForgetWeights;
1872  params.m_InputToCellWeights = &inputToCellWeights;
1873  params.m_InputToOutputWeights = &inputToOutputWeights;
1874  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1875  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1876  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1877  params.m_ForgetGateBias = &forgetGateBias;
1878  params.m_CellBias = &cellBias;
1879  params.m_OutputGateBias = &outputGateBias;
1880 
1881  // Peephole enabled and CIFG enabled params
1882  params.m_CellToForgetWeights = &cellToForgetWeights;
1883  params.m_CellToOutputWeights = &cellToOutputWeights;
1884 
1885  TestQLstmLayerVisitor visitor(descriptor, params);
1886 
1887  Network net;
1888 
1889  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1890  layer->Accept(visitor);
1891 }

◆ BOOST_AUTO_TEST_CASE() [65/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizePooling2d  )

Definition at line 1860 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IgnoreUnused(), info, LeakyReLu, ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1861 {
1862  class TestPooling2dQuantization : public TestLeakyReLuActivationQuantization
1863  {
1864  public:
1865  TestPooling2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1866  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
1867 
1868  TestPooling2dQuantization(const QuantizerOptions& options,
1869  const TensorShape& inputShape,
1870  const TensorShape& outputShape)
1871  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
1872 
1873  void VisitPooling2dLayer(const IConnectableLayer* layer,
1874  const Pooling2dDescriptor& desc,
1875  const char* name = nullptr) override
1876  {
1877  IgnoreUnused(desc, name);
1878  CheckForwardedQuantizationSettings(layer);
1879  }
1880  };
1881 
1882  auto network = INetwork::Create();
1883 
1884  TensorShape shape{1U};
1885  TensorInfo info(shape, DataType::Float32);
1886 
1887  Pooling2dDescriptor desc;
1888  ActivationDescriptor activationDescriptor;
1889  activationDescriptor.m_Function = ActivationFunction::LeakyReLu;
1890  activationDescriptor.m_A = 3.5f;
1891  activationDescriptor.m_B = -10.0f;
1892 
1893  // Add the layers
1894  IConnectableLayer* input0 = network->AddInputLayer(0);
1895  IConnectableLayer* activation = network->AddActivationLayer(activationDescriptor);
1896  IConnectableLayer* pooling2d = network->AddPooling2dLayer(desc);
1897  IConnectableLayer* output = network->AddOutputLayer(3);
1898 
1899  // Establish connections
1900  input0->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
1901  activation->GetOutputSlot(0).Connect(pooling2d->GetInputSlot(0));
1902  pooling2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1903 
1904  // Set TensorInfo
1905  input0->GetOutputSlot(0).SetTensorInfo(info);
1906  activation->GetOutputSlot(0).SetTensorInfo(info);
1907  pooling2d->GetOutputSlot(0).SetTensorInfo(info);
1908 
1909  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1910  TestPooling2dQuantization validatorQAsymmU8(shape, shape);
1911  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1912 
1913  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1914  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1915  TestPooling2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1916  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1917 
1918  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1919  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1920  TestPooling2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1921  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1922 
1923  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1924  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1925  TestPooling2dQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1926  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1927 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [66/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQLstmLayerProjectionEnabled  )

Definition at line 1893 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToOutputWeights, LstmInputParams::m_OutputGateBias, LstmInputParams::m_ProjectionBias, QLstmDescriptor::m_ProjectionClip, QLstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS8, and Signed32.

1894 {
1895  QLstmDescriptor descriptor;
1896  descriptor.m_ProjectionClip = 0.5f;
1897  descriptor.m_CellClip = 0.3f;
1898  descriptor.m_CifgEnabled = true;
1899  descriptor.m_ProjectionEnabled = true;
1900 
1901  // Basic params ONLY
1902  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1903  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1904  ConstTensor inputToForgetWeights(
1905  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1906 
1907  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1908  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1909  ConstTensor inputToCellWeights(
1910  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
1911 
1912  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1913  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1914  ConstTensor inputToOutputWeights(
1915  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
1916 
1917  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1918  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1919  ConstTensor recurrentToForgetWeights(TensorInfo(
1920  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
1921 
1922  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1923  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1924  ConstTensor recurrentToCellWeights(TensorInfo(
1925  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
1926 
1927  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1928  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1929  ConstTensor recurrentToOutputWeights(TensorInfo(
1930  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
1931 
1932  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1933  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1934  ConstTensor forgetGateBias(TensorInfo(
1935  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1936 
1937  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1938  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1939  ConstTensor cellBias(TensorInfo(
1940  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1941 
1942  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1943  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1944  ConstTensor outputGateBias(TensorInfo(
1945  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1946 
1947  // Projection enabled params
1948  std::vector<uint8_t> projectionWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1949  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1950  ConstTensor projectionWeights(TensorInfo(
1951  4, projectionWeightsDimensions.data(), DataType::QSymmS8), projectionWeightsData);
1952 
1953  std::vector<int32_t> projectionBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1954  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1955  ConstTensor projectionBias(TensorInfo(
1956  4, projectionBiasDimensions.data(), DataType::Signed32), projectionBiasData);
1957 
1958  LstmInputParams params;
1959 
1960  // Basic params
1961  params.m_InputToForgetWeights = &inputToForgetWeights;
1962  params.m_InputToCellWeights = &inputToCellWeights;
1963  params.m_InputToOutputWeights = &inputToOutputWeights;
1964  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1965  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1966  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1967  params.m_ForgetGateBias = &forgetGateBias;
1968  params.m_CellBias = &cellBias;
1969  params.m_OutputGateBias = &outputGateBias;
1970 
1971  // Projection enabled params
1972  params.m_ProjectionWeights = &projectionWeights;
1973  params.m_ProjectionBias = &projectionBias;
1974 
1975  TestQLstmLayerVisitor visitor(descriptor, params);
1976 
1977  Network net;
1978 
1979  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1980  layer->Accept(visitor);
1981 }

◆ BOOST_AUTO_TEST_CASE() [67/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConstant  )

Definition at line 1929 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1930 {
1931  class TestConstantQuantization : public TestAdditionQuantization
1932  {
1933  public:
1934  TestConstantQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1935  : TestAdditionQuantization(inputShape, outputShape) {}
1936 
1937  TestConstantQuantization(const QuantizerOptions& options,
1938  const TensorShape& inputShape,
1939  const TensorShape& outputShape)
1940  : TestAdditionQuantization(options, inputShape, outputShape) {}
1941 
1942  void VisitConstantLayer(const IConnectableLayer* layer,
1943  const ConstTensor& input,
1944  const char* name = nullptr) override
1945  {
1946  IgnoreUnused(input, name);
1947  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1948 
1949  // Based off the range of values in the const tensor used for the test: [-2.0f, 6.0f]
1950  TestQuantizationParams(info, {8.0f / g_AsymmU8QuantizationBase, 64},
1951  {8.0f / g_AsymmS8QuantizationBase, -64},
1952  {6.0f / g_SymmS8QuantizationBase, 0},
1953  {6.0f / g_SymmS16QuantizationBase, 0});
1954  }
1955  };
1956 
1957  INetworkPtr network = INetwork::Create();
1958 
1959  // Constant layer data
1960  std::vector<float> data = {-2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
1961  const TensorShape shape{1U, 1U, 3U, 3U};
1962  TensorInfo tensorInfo(shape, DataType::Float32);
1963  ConstTensor constantTensor(tensorInfo, data);
1964 
1965  // Add the layers
1966  IConnectableLayer* input = network->AddInputLayer(0);
1967  IConnectableLayer* constant = network->AddConstantLayer(constantTensor);
1968  IConnectableLayer* addition = network->AddAdditionLayer();
1969  IConnectableLayer* output = network->AddOutputLayer(1);
1970 
1971  // Establish connections
1972  input->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
1973  constant->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
1974  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1975 
1976  // Set TensorInfo in the remaining layers
1977  input->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1978  addition->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1979  constant->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1980 
1981  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1982  TestConstantQuantization validatorQAsymmU8(shape, shape);
1983  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1984 
1985  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1986  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1987  TestConstantQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1988  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1989 
1990  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1991  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1992  TestConstantQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1993  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1994 
1995  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1996  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1997  TestConstantQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1998  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1999 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [68/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQLstmLayerCifgDisabledLayerNormEnabled  )

Definition at line 1983 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQLstmLayer(), LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, LstmInputParams::m_CellLayerNormWeights, QLstmDescriptor::m_CifgEnabled, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetLayerNormWeights, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputLayerNormWeights, LstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, LstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputLayerNormWeights, QLstmDescriptor::m_ProjectionClip, LstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToOutputWeights, QSymmS16, QSymmS8, and Signed32.

1984 {
1985  QLstmDescriptor descriptor;
1986  descriptor.m_ProjectionClip = 0.5f;
1987  descriptor.m_CellClip = 0.3f;
1988  descriptor.m_CifgEnabled = false;
1989  descriptor.m_LayerNormEnabled = true;
1990 
1991  // Basic params
1992  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1993  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1994  ConstTensor inputToForgetWeights(
1995  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
1996 
1997  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1998  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1999  ConstTensor inputToCellWeights(
2000  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
2001 
2002  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2003  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
2004  ConstTensor inputToOutputWeights(
2005  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
2006 
2007  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2008  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
2009  ConstTensor recurrentToForgetWeights(TensorInfo(
2010  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
2011 
2012  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2013  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
2014  ConstTensor recurrentToCellWeights(TensorInfo(
2015  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
2016 
2017  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2018  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
2019  ConstTensor recurrentToOutputWeights(TensorInfo(
2020  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
2021 
2022  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2023  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
2024  ConstTensor forgetGateBias(TensorInfo(
2025  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
2026 
2027  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2028  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
2029  ConstTensor cellBias(TensorInfo(
2030  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
2031 
2032  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2033  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
2034  ConstTensor outputGateBias(TensorInfo(
2035  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
2036 
2037  // CIFG disabled params
2038  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2039  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
2040  ConstTensor inputToInputWeights(
2041  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8), inputToInputWeightsData);
2042 
2043  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2044  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
2045  ConstTensor recurrentToInputWeights(TensorInfo(
2046  4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8), recurrentToInputWeightsData);
2047 
2048  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2049  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
2050  ConstTensor inputGateBias(
2051  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
2052 
2053  // Layer Norm enabled, CIFG disabled params
2054  std::vector<int16_t> inputLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2055  std::vector<unsigned int> inputLayerNormWeightsDimensions = {1, 1, 3, 3};
2056  ConstTensor inputLayerNormWeights(
2057  TensorInfo(4, inputLayerNormWeightsDimensions.data(), DataType::QSymmS16), inputLayerNormWeightsData);
2058 
2059  std::vector<int16_t> forgetLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2060  std::vector<unsigned int> forgetLayerNormWeightsDimensions = {1, 1, 3, 3};
2061  ConstTensor forgetLayerNormWeights(
2062  TensorInfo(4, forgetLayerNormWeightsDimensions.data(), DataType::QSymmS16), forgetLayerNormWeightsData);
2063 
2064  std::vector<int16_t> cellLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2065  std::vector<unsigned int> cellLayerNormWeightsDimensions = {1, 1, 3, 3};
2066  ConstTensor cellLayerNormWeights(
2067  TensorInfo(4, cellLayerNormWeightsDimensions.data(), DataType::QSymmS16), cellLayerNormWeightsData);
2068 
2069  std::vector<int16_t> outputLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2070  std::vector<unsigned int> outputLayerNormWeightsDimensions = {1, 1, 3, 3};
2071  ConstTensor outputLayerNormWeights(
2072  TensorInfo(4, outputLayerNormWeightsDimensions.data(), DataType::QSymmS16), outputLayerNormWeightsData);
2073 
2074  LstmInputParams params;
2075 
2076  // Basic params
2077  params.m_InputToForgetWeights = &inputToForgetWeights;
2078  params.m_InputToCellWeights = &inputToCellWeights;
2079  params.m_InputToOutputWeights = &inputToOutputWeights;
2080  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2081  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2082  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2083  params.m_ForgetGateBias = &forgetGateBias;
2084  params.m_CellBias = &cellBias;
2085  params.m_OutputGateBias = &outputGateBias;
2086 
2087  // CIFG disabled params
2088  params.m_InputToInputWeights = &inputToInputWeights;
2089  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
2090  params.m_InputGateBias = &inputGateBias;
2091 
2092  // Layer Norm enabled, CIFG disabled params
2093  params.m_InputLayerNormWeights = &inputLayerNormWeights;
2094  params.m_ForgetLayerNormWeights = &forgetLayerNormWeights;
2095  params.m_CellLayerNormWeights = &cellLayerNormWeights;
2096  params.m_OutputLayerNormWeights = &outputLayerNormWeights;
2097 
2098  TestQLstmLayerVisitor visitor(descriptor, params);
2099 
2100  Network net;
2101 
2102  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
2103  layer->Accept(visitor);
2104 }

◆ BOOST_AUTO_TEST_CASE() [69/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeArgMinMax  )

Definition at line 2001 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), ArgMinMaxDescriptor::m_Function, Max, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2002 {
2003  class TestArgMinMaxQuantization : public TestQuantization
2004  {
2005  public:
2006  TestArgMinMaxQuantization(const TensorShape& inputShape, const TensorShape& outputShape) :
2007  TestQuantization(inputShape, outputShape) {}
2008 
2009  TestArgMinMaxQuantization(const QuantizerOptions& options,
2010  const TensorShape& inputShape,
2011  const TensorShape& outputShape) :
2012  TestQuantization(options, inputShape, outputShape)
2013  {}
2014 
2015  void VisitInputLayer(const IConnectableLayer* layer,
2016  LayerBindingId id,
2017  const char* name = nullptr) override
2018  {
2019  IgnoreUnused(layer, id, name);
2020  }
2021 
2022  void VisitOutputLayer(const IConnectableLayer* layer,
2023  LayerBindingId id,
2024  const char* name = nullptr) override
2025  {
2026  IgnoreUnused(layer, id, name);
2027  }
2028  void VisitArgMinMaxLayer(const IConnectableLayer* layer,
2029  const ArgMinMaxDescriptor& argMinMaxDescriptor,
2030  const char* name = nullptr) override
2031  {
2032  IgnoreUnused(argMinMaxDescriptor, name);
2033  TensorInfo outputInfo = layer->GetOutputSlot(0).GetTensorInfo();
2034 
2035  TestQuantizationParams(outputInfo,
2036  { 30.0f / g_AsymmU8QuantizationBase, 128 },
2037  { 30.0f / g_AsymmS8QuantizationBase, 0},
2038  { 15.0f / g_SymmS8QuantizationBase, 0},
2039  { 15.0f / g_SymmS16QuantizationBase, 0 });
2040  }
2041  };
2042 
2043  INetworkPtr network = INetwork::Create();
2044 
2045  const TensorShape inputShape{ 1, 1, 1, 5 };
2046  const TensorShape outputShape{ 1, 1, 1 };
2047 
2048  TensorInfo inputInfo(inputShape, DataType::Float32);
2049  TensorInfo outputInfo(outputShape, DataType::Float32);
2050 
2051  // Add the input layers
2052  IConnectableLayer* input = network->AddInputLayer(0);
2053 
2054  // Add the layer under test
2055  ArgMinMaxDescriptor argMinMaxDescriptor;
2056  argMinMaxDescriptor.m_Function = ArgMinMaxFunction::Max;
2057  IConnectableLayer* argMinMaxLayer = network->AddArgMinMaxLayer(argMinMaxDescriptor);
2058 
2059  // Add the output layers
2060  IConnectableLayer* output = network->AddOutputLayer(1);
2061 
2062  // Establish connections
2063  input->GetOutputSlot(0).Connect(argMinMaxLayer->GetInputSlot(0));
2064  argMinMaxLayer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2065 
2066  // Set tensor info
2067  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
2068  argMinMaxLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
2069 
2070  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2071  TestArgMinMaxQuantization validatorQAsymmU8(inputShape, outputShape);
2072  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2073 
2074  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2075  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2076  TestArgMinMaxQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, outputShape);
2077  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2078 
2079  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2080  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2081  TestArgMinMaxQuantization validatorQSymmS8(qSymmS8Options, inputShape, outputShape);
2082  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2083 
2084  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2085  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2086  TestArgMinMaxQuantization validatorQSymmS16(qSymmS16options, inputShape, outputShape);
2087  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2088 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:202
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [70/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeComparison  )

Definition at line 2090 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, LessOrEqual, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2091 {
2092  class TestComparisonQuantization : public TestQuantization
2093  {
2094  public:
2095  TestComparisonQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2096  : TestQuantization(inputShape, outputShape) {}
2097 
2098  TestComparisonQuantization(const QuantizerOptions& options,
2099  const TensorShape& inputShape,
2100  const TensorShape& outputShape)
2101  : TestQuantization(options, inputShape, outputShape) {}
2102 
2103  void VisitComparisonLayer(const IConnectableLayer* layer,
2104  const ComparisonDescriptor& descriptor,
2105  const char* name = nullptr) override
2106  {
2107  IgnoreUnused(descriptor, name);
2108  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
2109 
2110  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
2111  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
2112  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
2113  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
2114 
2115  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
2116  }
2117  };
2118 
2119  const TensorShape tensorShape{ 1u };
2120  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
2121 
2122  INetworkPtr network = INetwork::Create();
2123  ComparisonDescriptor descriptor(ComparisonOperation::LessOrEqual);
2124 
2125  IConnectableLayer* inputLayer0 = network->AddInputLayer(0);
2126  IConnectableLayer* inputLayer1 = network->AddInputLayer(1);
2127  IConnectableLayer* comparisonLayer = network->AddComparisonLayer(descriptor);
2128  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
2129 
2130  inputLayer0->GetOutputSlot(0).Connect(comparisonLayer->GetInputSlot(0));
2131  inputLayer1->GetOutputSlot(0).Connect(comparisonLayer->GetInputSlot(1));
2132  comparisonLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2133 
2134  inputLayer0->GetOutputSlot(0).SetTensorInfo(tensorInfo);
2135  inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo);
2136  comparisonLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
2137 
2138  // test QAsymmU8 quantization
2139  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2140  TestComparisonQuantization validatorQAsymmU8(tensorShape, tensorShape);
2141  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2142 
2143  // test QAsymmS8 quantization
2144  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2145  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2146  TestComparisonQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
2147  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2148 
2149  // test QSymmS8 quantization
2150  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2151  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2152  TestComparisonQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
2153  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2154 
2155  // test QuantisedSymmS16 quantization
2156  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2157  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2158  TestComparisonQuantization validatorQSymmS16(qSymmS16options, tensorShape, tensorShape);
2159  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2160 }
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [71/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckQuantizedLstmLayer  )

Definition at line 2107 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQuantizedLstmLayer(), QuantizedLstmInputParams::m_CellBias, QuantizedLstmInputParams::m_ForgetGateBias, QuantizedLstmInputParams::m_InputGateBias, QuantizedLstmInputParams::m_InputToCellWeights, QuantizedLstmInputParams::m_InputToForgetWeights, QuantizedLstmInputParams::m_InputToInputWeights, QuantizedLstmInputParams::m_InputToOutputWeights, QuantizedLstmInputParams::m_OutputGateBias, QuantizedLstmInputParams::m_RecurrentToCellWeights, QuantizedLstmInputParams::m_RecurrentToForgetWeights, QuantizedLstmInputParams::m_RecurrentToInputWeights, QuantizedLstmInputParams::m_RecurrentToOutputWeights, QSymmS8, and Signed32.

2108 {
2109  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2110  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
2111  ConstTensor inputToInputWeights(
2112  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8), inputToInputWeightsData);
2113 
2114  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2115  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
2116  ConstTensor inputToForgetWeights(
2117  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8), inputToForgetWeightsData);
2118 
2119  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2120  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
2121  ConstTensor inputToCellWeights(
2122  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8), inputToCellWeightsData);
2123 
2124  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2125  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
2126  ConstTensor inputToOutputWeights(
2127  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8), inputToOutputWeightsData);
2128 
2129 
2130  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2131  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
2132  ConstTensor recurrentToInputWeights(TensorInfo(
2133  4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8), recurrentToInputWeightsData);
2134 
2135  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2136  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
2137  ConstTensor recurrentToForgetWeights(TensorInfo(
2138  4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8), recurrentToForgetWeightsData);
2139 
2140  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2141  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
2142  ConstTensor recurrentToCellWeights(TensorInfo(
2143  4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8), recurrentToCellWeightsData);
2144 
2145  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2146  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
2147  ConstTensor recurrentToOutputWeights(TensorInfo(
2148  4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8), recurrentToOutputWeightsData);
2149 
2150 
2151  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2152  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
2153  ConstTensor inputGateBias(
2154  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
2155 
2156  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2157  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
2158  ConstTensor forgetGateBias(TensorInfo(
2159  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
2160 
2161  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2162  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
2163  ConstTensor cellBias(TensorInfo(
2164  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
2165 
2166  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2167  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
2168  ConstTensor outputGateBias(TensorInfo(
2169  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
2170 
2171  QuantizedLstmInputParams params;
2172 
2173  params.m_InputToInputWeights = &inputToInputWeights;
2174  params.m_InputToForgetWeights = &inputToForgetWeights;
2175  params.m_InputToCellWeights = &inputToCellWeights;
2176  params.m_InputToOutputWeights = &inputToOutputWeights;
2177 
2178  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
2179  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2180  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2181  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2182 
2183  params.m_InputGateBias = &inputGateBias;
2184  params.m_ForgetGateBias = &forgetGateBias;
2185  params.m_CellBias = &cellBias;
2186  params.m_OutputGateBias = &outputGateBias;
2187 
2188  TestQuantizedLstmLayerVisitor visitor(params);
2189 
2190  Network net;
2191 
2192  IConnectableLayer* const layer = net.AddQuantizedLstmLayer(params);
2193  layer->Accept(visitor);
2194 }

◆ BOOST_AUTO_TEST_CASE() [72/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConcat  )

Definition at line 2162 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IInputSlot::GetConnection(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2163 {
2164  class TestConcatQuantization : public TestQuantization
2165  {
2166  public:
2167  TestConcatQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2168  : TestQuantization(inputShape, outputShape) {}
2169 
2170  TestConcatQuantization(const QuantizerOptions& options,
2171  const TensorShape& inputShape,
2172  const TensorShape& outputShape)
2173  : TestQuantization(options, inputShape, outputShape) {}
2174 
2175  void VisitInputLayer(const IConnectableLayer* layer,
2176  LayerBindingId id,
2177  const char* name = nullptr) override
2178  {
2179  IgnoreUnused(layer, id, name);
2180  }
2181  void VisitOutputLayer(const IConnectableLayer* layer,
2182  LayerBindingId id,
2183  const char* name = nullptr) override
2184  {
2185  IgnoreUnused(layer, id, name);
2186  }
2187  void VisitConcatLayer(const IConnectableLayer* layer,
2188  const OriginsDescriptor& originsDescriptor,
2189  const char* name = nullptr) override
2190  {
2191  IgnoreUnused(originsDescriptor, name);
2192  TensorInfo outputInfo = layer->GetOutputSlot(0).GetTensorInfo();
2193  TestQuantizationParams(
2194  outputInfo, {60.8f / g_AsymmU8QuantizationBase, 65},
2195  {60.8f / g_SymmS8QuantizationBase, -63},
2196  {45.3f / g_SymmS8QuantizationBase, 0},
2197  {45.3f / g_SymmS16QuantizationBase, 0});
2198 
2199  TensorInfo inputInfo0 = layer->GetInputSlot(0).GetConnection()->GetTensorInfo();
2200  TensorInfo inputInfo1 = layer->GetInputSlot(1).GetConnection()->GetTensorInfo();
2201  TensorInfo inputInfo2 = layer->GetInputSlot(2).GetConnection()->GetTensorInfo();
2202 
2203  TestDifferentQuantizationScale(inputInfo0, inputInfo1);
2204  TestDifferentQuantizationScale(inputInfo0, inputInfo2);
2205  TestDifferentQuantizationScale(inputInfo1, inputInfo2);
2206  TestDifferentQuantizationScale(inputInfo0, outputInfo);
2207  }
2208  };
2209 
2210  INetworkPtr network = INetwork::Create();
2211 
2212  IConnectableLayer* input0 = network->AddInputLayer(0);
2213  IConnectableLayer* input1 = network->AddInputLayer(1);
2214  IConnectableLayer* input2 = network->AddInputLayer(2);
2215 
2216  OriginsDescriptor descriptor(3, 1);
2217  IConnectableLayer* concatLayer = network->AddConcatLayer(descriptor);
2218 
2219  IConnectableLayer* output0 = network->AddOutputLayer(3);
2220 
2221  // Establish connections
2222  input0->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(0));
2223  input1->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(1));
2224  input2->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(2));
2225  concatLayer->GetOutputSlot(0).Connect(output0->GetInputSlot(0));
2226 
2227  // Set TensorInfo
2228  const TensorShape shape{1U};
2229  TensorInfo info(shape, DataType::Float32);
2230 
2231  input0->GetOutputSlot(0).SetTensorInfo(info);
2232  input1->GetOutputSlot(0).SetTensorInfo(info);
2233  input2->GetOutputSlot(0).SetTensorInfo(info);
2234  concatLayer->GetOutputSlot(0).SetTensorInfo(info);
2235 
2236  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2237  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2238  INetworkQuantizerPtr quantizerPtrQAsymmU8 = INetworkQuantizer::Create(network.get());
2239  INetworkQuantizerPtr quantizerPtrQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options);
2240  INetworkQuantizerPtr quantizerPtrQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options);
2241  // Override the input ranges
2242  float min = -15.5f;
2243  float max = 45.3f;
2244 
2245  quantizerPtrQAsymmU8->OverrideInputRange(0, (min + 2.1f), (max - 3.2f));
2246  quantizerPtrQAsymmU8->OverrideInputRange(1, (min + 6.7f), max);
2247  quantizerPtrQAsymmU8->OverrideInputRange(2, min, (max - 7.8f));
2248 
2249  quantizerPtrQSymmS8->OverrideInputRange(0, (min + 2.1f), (max - 3.2f));
2250  quantizerPtrQSymmS8->OverrideInputRange(1, (min + 6.7f), max);
2251  quantizerPtrQSymmS8->OverrideInputRange(2, min, (max - 7.8f));
2252 
2253  quantizerPtrQSymmS16->OverrideInputRange(0, (min + 2.1f), (max - 3.2f));
2254  quantizerPtrQSymmS16->OverrideInputRange(1, (min + 6.7f), max);
2255  quantizerPtrQSymmS16->OverrideInputRange(2, min, (max - 7.8f));
2256 
2257  INetworkPtr quantizedNetworkQAsymmU8 = quantizerPtrQAsymmU8->ExportNetwork();
2258  TestConcatQuantization validatorQAsymmU8(shape, shape);
2259  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2260 
2261  INetworkPtr quantizedNetworkQSymmS8 = quantizerPtrQSymmS8->ExportNetwork();
2262  TestConcatQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2263  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2264 
2265  INetworkPtr quantizedNetworkQSymmS16 = quantizerPtrQSymmS16->ExportNetwork();
2266  TestConcatQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2267  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2268 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
std::unique_ptr< class INetworkQuantizer, void(*)(INetworkQuantizer *quantizer)> INetworkQuantizerPtr
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:202
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [73/90]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedQuantizedLstmLayer  )

Definition at line 2196 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddQuantizedLstmLayer(), BOOST_AUTO_TEST_SUITE_END(), QuantizedLstmInputParams::m_CellBias, QuantizedLstmInputParams::m_ForgetGateBias, QuantizedLstmInputParams::m_InputGateBias, QuantizedLstmInputParams::m_InputToCellWeights, QuantizedLstmInputParams::m_InputToForgetWeights, QuantizedLstmInputParams::m_InputToInputWeights, QuantizedLstmInputParams::m_InputToOutputWeights, QuantizedLstmInputParams::m_OutputGateBias, QuantizedLstmInputParams::m_RecurrentToCellWeights, QuantizedLstmInputParams::m_RecurrentToForgetWeights, QuantizedLstmInputParams::m_RecurrentToInputWeights, QuantizedLstmInputParams::m_RecurrentToOutputWeights, QAsymmU8, and Signed32.

2197 {
2198  const char* layerName = "LstmLayer";
2199  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2200  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
2201  ConstTensor inputToInputWeights(
2202  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QAsymmU8), inputToInputWeightsData);
2203 
2204  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2205  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
2206  ConstTensor inputToForgetWeights(
2207  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QAsymmU8), inputToForgetWeightsData);
2208 
2209  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2210  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
2211  ConstTensor inputToCellWeights(
2212  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QAsymmU8), inputToCellWeightsData);
2213 
2214  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2215  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
2216  ConstTensor inputToOutputWeights(
2217  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QAsymmU8), inputToOutputWeightsData);
2218 
2219 
2220  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2221  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
2222  ConstTensor recurrentToInputWeights(TensorInfo(
2223  4, recurrentToInputWeightsDimensions.data(), DataType::QAsymmU8), recurrentToInputWeightsData);
2224 
2225  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2226  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
2227  ConstTensor recurrentToForgetWeights(TensorInfo(
2228  4, recurrentToForgetWeightsDimensions.data(), DataType::QAsymmU8), recurrentToForgetWeightsData);
2229 
2230  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2231  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
2232  ConstTensor recurrentToCellWeights(TensorInfo(
2233  4, recurrentToCellWeightsDimensions.data(), DataType::QAsymmU8), recurrentToCellWeightsData);
2234 
2235  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2236  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
2237  ConstTensor recurrentToOutputWeights(TensorInfo(
2238  4, recurrentToOutputWeightsDimensions.data(), DataType::QAsymmU8), recurrentToOutputWeightsData);
2239 
2240 
2241  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2242  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
2243  ConstTensor inputGateBias(
2244  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
2245 
2246  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2247  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
2248  ConstTensor forgetGateBias(TensorInfo(
2249  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
2250 
2251  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2252  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
2253  ConstTensor cellBias(TensorInfo(
2254  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
2255 
2256  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2257  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
2258  ConstTensor outputGateBias(TensorInfo(
2259  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
2260 
2261  QuantizedLstmInputParams params;
2262 
2263  params.m_InputToInputWeights = &inputToInputWeights;
2264  params.m_InputToForgetWeights = &inputToForgetWeights;
2265  params.m_InputToCellWeights = &inputToCellWeights;
2266  params.m_InputToOutputWeights = &inputToOutputWeights;
2267 
2268  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
2269  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2270  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2271  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2272 
2273  params.m_InputGateBias = &inputGateBias;
2274  params.m_ForgetGateBias = &forgetGateBias;
2275  params.m_CellBias = &cellBias;
2276  params.m_OutputGateBias = &outputGateBias;
2277 
2278  TestQuantizedLstmLayerVisitor visitor(params, layerName);
2279 
2280  Network net;
2281 
2282  IConnectableLayer* const layer = net.AddQuantizedLstmLayer(params, layerName);
2283  layer->Accept(visitor);
2284 }

◆ BOOST_AUTO_TEST_CASE() [74/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeReshape  )

Definition at line 2270 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2271 {
2272  class TestReshapeQuantization : public TestLeakyReLuActivationQuantization
2273  {
2274  public:
2275  TestReshapeQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2276  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2277 
2278  TestReshapeQuantization(const QuantizerOptions& options,
2279  const TensorShape& inputShape,
2280  const TensorShape& outputShape)
2281  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2282 
2283  virtual void VisitReshapeLayer(const IConnectableLayer* layer,
2284  const ReshapeDescriptor& reshapeDescriptor,
2285  const char* name = nullptr) override
2286  {
2287  IgnoreUnused(reshapeDescriptor, name);
2288  CheckForwardedQuantizationSettings(layer);
2289  }
2290  };
2291 
2292  INetworkPtr network = INetwork::Create();
2293 
2294  const TensorShape shape{1U};
2295  TensorInfo info(shape, DataType::Float32);
2296 
2297  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2298 
2299  // Add the layer under test
2300  ReshapeDescriptor descriptor({1, 2, 3, 4});
2301  IConnectableLayer* reshape = network->AddReshapeLayer(descriptor);
2302 
2303  CompleteLeakyReluNetwork(network.get(), activation, reshape, info);
2304 
2305  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2306  TestReshapeQuantization validatorQAsymmU8(shape, shape);
2307  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2308 
2309  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2310  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2311  TestReshapeQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2312  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2313 
2314  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2315  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2316  TestReshapeQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2317  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2318 
2319  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2320  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2321  TestReshapeQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2322  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2323 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [75/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSplitter  )

Definition at line 2325 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2326 {
2327  class TestSplitterQuantization : public TestLeakyReLuActivationQuantization
2328  {
2329  public:
2330  TestSplitterQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2331  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2332 
2333  TestSplitterQuantization(const QuantizerOptions& options,
2334  const TensorShape& inputShape,
2335  const TensorShape& outputShape)
2336  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2337 
2338  virtual void VisitSplitterLayer(const IConnectableLayer* layer,
2339  const SplitterDescriptor& desc,
2340  const char* name = nullptr)
2341  {
2342  IgnoreUnused(desc, name);
2343  CheckForwardedQuantizationSettings(layer);
2344  }
2345  };
2346 
2347  INetworkPtr network = INetwork::Create();
2348 
2349  const TensorShape shape{3U};
2350  TensorInfo info(shape, DataType::Float32);
2351 
2352  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2353 
2354  // Add the layer under test
2355  ViewsDescriptor splitterDesc(2,4);
2356  IConnectableLayer* splitter = network->AddSplitterLayer(splitterDesc);
2357  CompleteLeakyReluNetwork(network.get(), activation, splitter, info);
2358 
2359  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2360  TestSplitterQuantization validatorQAsymmU8(shape, shape);
2361  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2362 
2363  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2364  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2365  TestSplitterQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2366  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2367 
2368  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2369  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2370  TestSplitterQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2371  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2372 
2373  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2374  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2375  TestSplitterQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2376  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2377 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
ViewsDescriptor SplitterDescriptor

◆ BOOST_AUTO_TEST_CASE() [76/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeResize  )

Definition at line 2379 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, ResizeDescriptor::m_TargetHeight, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2380 {
2381  class TestResizeQuantization : public TestLeakyReLuActivationQuantization
2382  {
2383  public:
2384  TestResizeQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2385  : TestLeakyReLuActivationQuantization(inputShape, outputShape)
2386  {}
2387 
2388  TestResizeQuantization(const QuantizerOptions& options,
2389  const TensorShape& inputShape,
2390  const TensorShape& outputShape)
2391  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape)
2392  {}
2393 
2394  void VisitResizeLayer(const IConnectableLayer* layer,
2395  const ResizeDescriptor& resizeDescriptor,
2396  const char* name = nullptr) override
2397  {
2398  IgnoreUnused(resizeDescriptor, name);
2399  CheckForwardedQuantizationSettings(layer);
2400  }
2401  };
2402 
2403  INetworkPtr network = INetwork::Create();
2404 
2405  const TensorShape shape{1U};
2406  TensorInfo info(shape, DataType::Float32);
2407 
2408  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2409 
2410  // Add the layer under test
2411  ResizeDescriptor descriptor;
2412  descriptor.m_TargetHeight = 3;
2413  descriptor.m_TargetWidth = 3;
2414  IConnectableLayer* resizeLayer = network->AddResizeLayer(descriptor);
2415 
2416  CompleteLeakyReluNetwork(network.get(), activation, resizeLayer, info);
2417 
2418  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2419  TestResizeQuantization validatorQAsymmU8(shape, shape);
2420  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2421 
2422  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2423  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2424  TestResizeQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2425  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2426 
2427  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2428  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2429  TestResizeQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2430  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2431 
2432  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2433  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2434  TestResizeQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2435  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2436 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [77/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeStridedSlice  )

Definition at line 2438 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2439 {
2440  class TestStridedSliceQuantization : public TestLeakyReLuActivationQuantization
2441  {
2442  public:
2443  TestStridedSliceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2444  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2445 
2446  TestStridedSliceQuantization(const QuantizerOptions& options,
2447  const TensorShape& inputShape,
2448  const TensorShape& outputShape)
2449  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2450 
2451  virtual void VisitStridedSliceLayer(const IConnectableLayer* layer,
2452  const StridedSliceDescriptor& desc,
2453  const char* name = nullptr)
2454  {
2455  IgnoreUnused(desc, name);
2456  CheckForwardedQuantizationSettings(layer);
2457  }
2458  };
2459 
2460  INetworkPtr network = INetwork::Create();
2461 
2462  const TensorShape shape{3U};
2463  TensorInfo info(shape, DataType::Float32);
2464 
2465  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2466 
2467  // Add the layer under test
2468  StridedSliceDescriptor stridedSliceDesc;
2469  IConnectableLayer* stridedSlice = network->AddStridedSliceLayer(stridedSliceDesc);
2470 
2471  CompleteLeakyReluNetwork(network.get(), activation, stridedSlice, info);
2472 
2473  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2474  TestStridedSliceQuantization validatorQAsymmU8(shape, shape);
2475  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2476 
2477  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2478  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2479  TestStridedSliceQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2480  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2481 
2482  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2483  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2484  TestStridedSliceQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2485  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2486 
2487  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2488  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2489  TestStridedSliceQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2490  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2491 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [78/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeBatchToSpace  )

Definition at line 2493 of file QuantizerTest.cpp.

References CompleteLeakyReluNetwork(), INetworkQuantizer::Create(), INetwork::Create(), CreateStartOfLeakyReluNetwork(), Float32, IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2494 {
2495  class TestBatchToSpaceQuantization : public TestLeakyReLuActivationQuantization
2496  {
2497  public:
2498  TestBatchToSpaceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2499  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2500 
2501  TestBatchToSpaceQuantization(const QuantizerOptions& options,
2502  const TensorShape& inputShape,
2503  const TensorShape& outputShape)
2504  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2505 
2506  void VisitBatchToSpaceNdLayer(const IConnectableLayer* layer,
2507  const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor,
2508  const char* name = nullptr) override
2509  {
2510  IgnoreUnused(batchToSpaceNdDescriptor, name);
2511  CheckForwardedQuantizationSettings(layer);
2512  }
2513  };
2514 
2515  INetworkPtr network = INetwork::Create();
2516 
2517  const TensorShape shape{1U};
2518  TensorInfo info(shape, DataType::Float32);
2519 
2520  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2521 
2522  // Add the layer under test
2523  BatchToSpaceNdDescriptor descriptor;
2524  IConnectableLayer* batchToSpace = network->AddBatchToSpaceNdLayer(descriptor);
2525 
2526  CompleteLeakyReluNetwork(network.get(), activation, batchToSpace, info);
2527 
2528  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2529  TestBatchToSpaceQuantization validatorQAsymmU8(shape, shape);
2530  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2531 
2532  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2533  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2534  TestBatchToSpaceQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2535  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2536 
2537  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2538  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2539  TestBatchToSpaceQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2540  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2541 
2542  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2543  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2544  TestBatchToSpaceQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2545  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2546 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ BOOST_AUTO_TEST_CASE() [79/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizePrelu  )

Definition at line 2548 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IInputSlot::GetConnection(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2549 {
2550  class TestPreluQuantization : public TestQuantization
2551  {
2552  public:
2553  TestPreluQuantization(const TensorShape& inputShape,
2554  const TensorShape& alphaShape,
2555  const TensorShape& outputShape)
2556  : TestQuantization(inputShape, outputShape)
2557  , m_AlphaShape(alphaShape)
2558  {}
2559 
2560  TestPreluQuantization(const QuantizerOptions& options,
2561  const TensorShape& inputShape,
2562  const TensorShape& alphaShape,
2563  const TensorShape& outputShape)
2564  : TestQuantization(options, inputShape, outputShape)
2565  , m_AlphaShape(alphaShape)
2566  {}
2567 
2568  void VisitInputLayer(const IConnectableLayer* layer,
2569  LayerBindingId id,
2570  const char* name = nullptr) override
2571  {
2572  IgnoreUnused(id, name);
2573  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
2574 
2575  switch (id)
2576  {
2577  case 0: // Input
2578  BOOST_TEST(m_InputShape == info.GetShape());
2579  break;
2580  case 1: // Alpha
2581  BOOST_TEST(m_AlphaShape == info.GetShape());
2582  break;
2583  default:
2584  throw InvalidArgumentException("Invalid layer binding id for PReLU layer");
2585  }
2586 
2587  // Based off current default [-15.0f, 15.0f]
2588  TestQuantizationParams(info,
2589  { 30.0f / g_AsymmU8QuantizationBase, 128 }, // QASymmU8
2590  { 30.0f / g_AsymmS8QuantizationBase, 0}, // QASymmS8
2591  { 15.0f / g_SymmS8QuantizationBase, 0}, // QSymmS8
2592  { 15.0f / g_SymmS16QuantizationBase, 0 }); // QSymmS16
2593  }
2594 
2595  void VisitOutputLayer(const IConnectableLayer* layer,
2596  LayerBindingId id,
2597  const char* name = nullptr) override
2598  {
2599  IgnoreUnused(id, name);
2600  const TensorInfo& info = layer->GetInputSlot(0).GetConnection()->GetTensorInfo();
2601  BOOST_TEST(m_OutputShape == info.GetShape());
2602  }
2603 
2604  void VisitPreluLayer(const IConnectableLayer* layer,
2605  const char* name = nullptr) override
2606  {
2607  IgnoreUnused(name);
2608  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
2609  TestQuantizationParams(info,
2610  { 30.0f / g_AsymmU8QuantizationBase, 128 }, // QASymmU8
2611  { 30.0f / g_AsymmS8QuantizationBase, 0}, // QAsymmS8
2612  { 15.0f / g_SymmS8QuantizationBase, 0}, // QSymmS8
2613  { 15.0f / g_SymmS16QuantizationBase, 0 }); // QSymmS16
2614  }
2615 
2616  private:
2617  TensorShape m_AlphaShape;
2618  };
2619 
2620  INetworkPtr network = INetwork::Create();
2621 
2622  const TensorShape inputShape{ 4, 1, 2 };
2623  const TensorShape alphaShape{ 5, 4, 3, 1 };
2624  const TensorShape outputShape{ 5, 4, 3, 2 };
2625  TensorInfo inputInfo(inputShape, DataType::Float32);
2626  TensorInfo alphaInfo(alphaShape, DataType::Float32);
2627  TensorInfo outputInfo(outputShape, DataType::Float32);
2628 
2629  // Add the input layers
2630  IConnectableLayer* input = network->AddInputLayer(0);
2631  IConnectableLayer* alpha = network->AddInputLayer(1);
2632 
2633  // Add the layer under test
2634  IConnectableLayer* prelu = network->AddPreluLayer("prelu");
2635 
2636  // Add the output layers
2637  IConnectableLayer* output = network->AddOutputLayer(0);
2638 
2639  // Establish connections
2640  input->GetOutputSlot(0).Connect(prelu->GetInputSlot(0));
2641  alpha->GetOutputSlot(0).Connect(prelu->GetInputSlot(1));
2642  prelu->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2643 
2644  // Set tensor info
2645  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
2646  alpha->GetOutputSlot(0).SetTensorInfo(alphaInfo);
2647  prelu->GetOutputSlot(0).SetTensorInfo(outputInfo);
2648 
2649  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2650  TestPreluQuantization validatorQAsymmU8(inputShape, alphaShape, outputShape);
2651  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2652 
2653  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2654  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2655  TestPreluQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, alphaShape, outputShape);
2656  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2657 
2658  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2659  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2660  TestPreluQuantization validatorQSymmS8(qSymmS8Options, inputShape, alphaShape, outputShape);
2661  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2662 
2663  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2664  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2665  TestPreluQuantization validatorQSymmS16(qSymmS16options, inputShape, alphaShape, outputShape);
2666  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2667 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:202
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [80/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeTransposeConvolution2d  )

Definition at line 2749 of file QuantizerTest.cpp.

References TestQuantizeTransposeConvolution2d().

2750 {
2752 }
void TestQuantizeTransposeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [81/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeTransposeConvolution2dWithBiases  )

Definition at line 2754 of file QuantizerTest.cpp.

References TestQuantizeTransposeConvolution2d().

2755 {
2757 }
void TestQuantizeTransposeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [82/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeStack  )

Definition at line 2759 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2760 {
2761  class TestStackQuantization : public TestQuantization
2762  {
2763  public:
2764  TestStackQuantization(const TensorShape& inputShape,
2765  const TensorShape& outputShape)
2766  : TestQuantization(inputShape, outputShape) {}
2767 
2768  TestStackQuantization(const QuantizerOptions& options,
2769  const TensorShape& inputShape,
2770  const TensorShape& outputShape)
2771  : TestQuantization(options, inputShape, outputShape) {}
2772 
2773  void VisitInputLayer(const IConnectableLayer* layer,
2774  LayerBindingId id,
2775  const char* name = nullptr) override
2776  {
2777  IgnoreUnused(layer, id, name);
2778  }
2779  void VisitOutputLayer(const IConnectableLayer* layer,
2780  LayerBindingId id,
2781  const char* name = nullptr) override
2782  {
2783  IgnoreUnused(layer, id, name);
2784  }
2785 
2786  void VisitStackLayer(const IConnectableLayer* layer,
2787  const StackDescriptor& descriptor,
2788  const char* name = nullptr) override
2789  {
2790  IgnoreUnused(descriptor, name);
2791  TensorInfo outputInfo = layer->GetOutputSlot(0).GetTensorInfo();
2792 
2793  TestQuantizationParams(outputInfo,
2794  { 30.0f / g_AsymmU8QuantizationBase, 128 },
2795  { 30.0f / g_AsymmS8QuantizationBase, 0},
2796  { 15.0f / g_SymmS8QuantizationBase, 0},
2797  { 15.0f / g_SymmS16QuantizationBase, 0 });
2798  }
2799  };
2800 
2801  INetworkPtr network = INetwork::Create();
2802 
2803  IConnectableLayer* input0 = network->AddInputLayer(0);
2804  IConnectableLayer* input1 = network->AddInputLayer(1);
2805 
2806  const TensorShape inputShape{ 3, 4, 5 };
2807  const TensorShape outputShape{ 3, 4, 2, 5 };
2808 
2809  StackDescriptor descriptor(2, 2, inputShape);
2810  IConnectableLayer* stackLayer = network->AddStackLayer(descriptor);
2811 
2812  IConnectableLayer* output = network->AddOutputLayer(0);
2813 
2814  input0->GetOutputSlot(0).Connect(stackLayer->GetInputSlot(0));
2815  input1->GetOutputSlot(0).Connect(stackLayer->GetInputSlot(1));
2816  stackLayer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2817 
2818  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2819  TestStackQuantization validatorQAsymmU8(inputShape, outputShape);
2820  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2821 
2822  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2823  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2824  TestStackQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, inputShape);
2825  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2826 
2827  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2828  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2829  TestStackQuantization validatorQSymmS8(qSymmS8Options, inputShape, inputShape);
2830  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2831 
2832  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2833  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2834  TestStackQuantization validatorQSymmS16(qSymmS16options, inputShape, outputShape);
2835  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2836 }
const float g_AsymmU8QuantizationBase
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:202
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [83/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSlice  )

Definition at line 2838 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2839 {
2840  class TestSliceQuantization : public TestQuantization
2841  {
2842  public:
2843  TestSliceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2844  : TestQuantization(inputShape, outputShape)
2845  {}
2846 
2847  TestSliceQuantization(const QuantizerOptions& options,
2848  const TensorShape& inputShape,
2849  const TensorShape& outputShape)
2850  : TestQuantization(options, inputShape, outputShape)
2851  {}
2852 
2853  virtual void VisitSliceLayer(const IConnectableLayer* layer,
2854  const SliceDescriptor& desc,
2855  const char* name = nullptr)
2856  {
2857  IgnoreUnused(desc, name);
2858  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
2859 
2860  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
2861  const OffsetScalePair qAsymmS8Params{ 30.0f / g_AsymmS8QuantizationBase, 0 };
2862  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0 };
2863  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
2864 
2865  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
2866  }
2867  };
2868 
2869  TensorShape shape{ 3 };
2870  TensorInfo info(shape, DataType::Float32);
2871 
2872  INetworkPtr network = INetwork::Create();
2873 
2874  IConnectableLayer* inputLayer = network->AddInputLayer(0);
2875  IConnectableLayer* sliceLayer = network->AddSliceLayer(SliceDescriptor());
2876  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
2877 
2878  inputLayer->GetOutputSlot(0).Connect(sliceLayer->GetInputSlot(0));
2879  sliceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2880 
2881  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
2882  sliceLayer->GetOutputSlot(0).SetTensorInfo(info);
2883 
2884  // test QAsymmU8 quantization
2885  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2886  TestSliceQuantization validatorQAsymmU8(shape, shape);
2887  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2888 
2889  // test QASymmS8 quantization
2890  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2891  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2892  TestSliceQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2893  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2894 
2895  // test QSymmS8 quantization
2896  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2897  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2898  TestSliceQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2899  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2900 
2901  // test QSymmS16 quantization
2902  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2903  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2904  TestSliceQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2905  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2906 }
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
const float g_SymmS8QuantizationBase
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
const float g_SymmS16QuantizationBase
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
const float g_AsymmS8QuantizationBase

◆ BOOST_AUTO_TEST_CASE() [84/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeInf  )

Definition at line 2923 of file QuantizerTest.cpp.

References SetupQuantize().

2924 {
2925  BOOST_CHECK_EQUAL(SetupQuantize(std::numeric_limits<float>::infinity())[0], 255);
2926 }
std::vector< uint8_t > SetupQuantize(float value)

◆ BOOST_AUTO_TEST_CASE() [85/90]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeNegativeInf  )

Definition at line 2928 of file QuantizerTest.cpp.

References IInputSlot::GetConnection(), TensorInfo::GetDataType(), GetDataTypeName(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, and SetupQuantize().

2929 {
2930  BOOST_CHECK_EQUAL(SetupQuantize(-1 * std::numeric_limits<float>::infinity())[0], 0);
2931 }
std::vector< uint8_t > SetupQuantize(float value)

◆ BOOST_AUTO_TEST_CASE() [86/90]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeFloat32  )

Definition at line 3028 of file QuantizerTest.cpp.

References Float32, and PreserveTypeTestImpl().

3029 {
3030  PreserveTypeTestImpl(DataType::Float32);
3031 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [87/90]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeQAsymmU8  )

Definition at line 3033 of file QuantizerTest.cpp.

References PreserveTypeTestImpl(), and QAsymmU8.

3034 {
3035  PreserveTypeTestImpl(DataType::QAsymmU8);
3036 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [88/90]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeQsymm8  )

Definition at line 3038 of file QuantizerTest.cpp.

References PreserveTypeTestImpl(), and QSymmS8.

3039 {
3040  PreserveTypeTestImpl(DataType::QSymmS8);
3041 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [89/90]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeQsymm16  )

Definition at line 3043 of file QuantizerTest.cpp.

References PreserveTypeTestImpl(), and QSymmS16.

3044 {
3045  PreserveTypeTestImpl(DataType::QSymmS16);
3046 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [90/90]

armnn::BOOST_AUTO_TEST_CASE ( TestConnectionPreservationAfterDynamicQuant  )

Definition at line 3048 of file QuantizerTest.cpp.

References BOOST_AUTO_TEST_SUITE_END(), IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IInputSlot::GetConnection(), IConnectableLayer::GetGuid(), IConnectableLayer::GetInputSlot(), GetInputTensorInfo(), IConnectableLayer::GetName(), IConnectableLayer::GetOutputSlot(), IOutputSlot::GetOwningLayerGuid(), ActivationDescriptor::m_Function, ReLu, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

3049 {
3050  class TestConnectionPreservation : public LayerVisitorBase<VisitorNoThrowPolicy>
3051  {
3052  public:
3053  TestConnectionPreservation(const Graph& graph)
3054  : LayerVisitorBase<VisitorNoThrowPolicy>()
3055  , m_Graph(graph)
3056  {}
3057 
3058  void VisitAdditionLayer(const IConnectableLayer* layer, const char*) override
3059  {
3060  CheckLayerName(layer->GetInputSlot(0).GetConnection()->GetOwningLayerGuid(), "reLU1");
3061  CheckLayerName(layer->GetInputSlot(1).GetConnection()->GetOwningLayerGuid(), "reLU2");
3062  }
3063 
3064  void CheckLayerName(LayerGuid guid, std::string expectedName)
3065  {
3066  bool guidFound = false;
3067  for (Layer* layer : m_Graph)
3068  {
3069  if (layer->GetGuid() == guid)
3070  {
3071  BOOST_CHECK_EQUAL(layer->GetName(), expectedName.c_str());
3072  guidFound = true;
3073  break;
3074  }
3075  }
3076  if (!guidFound)
3077  {
3078  BOOST_FAIL("No layer matching the GUID was found");
3079  }
3080  }
3081 
3082  private:
3083  Graph m_Graph;
3084  };
3085 
3086  INetworkPtr network = INetwork::Create();
3087 
3088  IConnectableLayer* inputLayer = network->AddInputLayer(0,"inputLayer1");
3089  armnn::ActivationDescriptor ReLUDesc;
3090  ReLUDesc.m_Function = ActivationFunction::ReLu;
3091 
3092  IConnectableLayer* reLULayer1 = network->AddActivationLayer(ReLUDesc, "reLU1");
3093  IConnectableLayer* reLULayer2 = network->AddActivationLayer(ReLUDesc, "reLU2");
3094  IConnectableLayer* addLayer1 = network->AddAdditionLayer("addLayer1");
3095  IConnectableLayer* outputLayer = network->AddOutputLayer(0,"outPutLayer1");
3096 
3097  inputLayer->GetOutputSlot(0).Connect(reLULayer1->GetInputSlot(0));
3098  reLULayer1->GetOutputSlot(0).Connect(reLULayer2->GetInputSlot(0));
3099  reLULayer1->GetOutputSlot(0).Connect(addLayer1->GetInputSlot(0));
3100  reLULayer2->GetOutputSlot(0).Connect(addLayer1->GetInputSlot(1));
3101  addLayer1->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
3102 
3103  inputLayer->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
3104  reLULayer1->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
3105  reLULayer2->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
3106  addLayer1->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
3107 
3108  TestConnectionPreservation visitor1(PolymorphicDowncast<const Network*>(network.get())->GetGraph());
3109  VisitLayersTopologically(network.get(), visitor1);
3110 
3112 
3113  armnn::TensorInfo tensorInfo = GetInputTensorInfo(PolymorphicDowncast<const Network*>(network.get()));
3114 
3115  std::vector<float> inputData({0, 2, 0, 4});
3116  armnn::ConstTensor inputTensor(tensorInfo, inputData.data());
3117 
3118  InputTensors inputTensors;
3119  inputTensors.push_back(std::make_pair(0, inputTensor));
3120  quantizer->Refine(inputTensors);
3121 
3122  INetworkPtr quantNetwork = quantizer->ExportNetwork();
3123 
3124  TestConnectionPreservation visitor2(PolymorphicDowncast<const Network*>(quantNetwork.get())->GetGraph());
3125  VisitLayersTopologically(quantNetwork.get(), visitor2);
3126 }
std::unique_ptr< class INetworkQuantizer, void(*)(INetworkQuantizer *quantizer)> INetworkQuantizerPtr
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:340
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
profiling::ProfilingGuid LayerGuid
Define LayerGuid type.
Definition: Types.hpp:267
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
TensorInfo GetInputTensorInfo(const Network *network)
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square, Elu).
Definition: Descriptors.hpp:43
static INetworkQuantizerPtr Create(INetwork *inputNetwork, const QuantizerOptions &options=QuantizerOptions())
Create Quantizer object wrapped in unique_ptr.

◆ boost_test_print_type() [1/2]

std::ostream& armnn::boost_test_print_type ( std::ostream &  ostr,
const TensorInfo right 
)

Definition at line 14 of file TensorTest.cpp.

References TensorInfo::GetNumDimensions(), and TensorInfo::GetShape().

15 {
16  ostr << "TensorInfo[ "
17  << right.GetNumDimensions() << ","
18  << right.GetShape()[0] << ","
19  << right.GetShape()[1] << ","
20  << right.GetShape()[2] << ","
21  << right.GetShape()[3]
22  << " ]" << std::endl;
23  return ostr;
24 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191

◆ boost_test_print_type() [2/2]

std::ostream& armnn::boost_test_print_type ( std::ostream &  ostr,
const TensorShape shape 
)

Definition at line 26 of file TensorTest.cpp.

References BOOST_AUTO_TEST_SUITE(), and TensorShape::GetNumDimensions().

27 {
28  ostr << "TensorShape[ "
29  << shape.GetNumDimensions() << ","
30  << shape[0] << ","
31  << shape[1] << ","
32  << shape[2] << ","
33  << shape[3]
34  << " ]" << std::endl;
35  return ostr;
36 }
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174

◆ CalcLevel()

int armnn::CalcLevel ( const Event eventPtr)

Definition at line 234 of file Profiling.cpp.

References Event::GetName(), and Event::GetParentEvent().

Referenced by Profiler::AnalyzeEventsAndWriteResults().

235 {
236  int level=0;
237  while (eventPtr != nullptr)
238  {
239  eventPtr = eventPtr->GetParentEvent();
240  level++;
241  }
242  return level;
243 }

◆ CalculateEdgeStrategy()

EdgeStrategy armnn::CalculateEdgeStrategy ( BackendsMap backends,
ITensorHandleFactory::FactoryId  srcFactoryId,
const Layer layer,
const Layer connectedLayer,
TensorHandleFactoryRegistry registry,
bool  importEnabled 
)

Definition at line 857 of file Network.cpp.

References ARMNN_ASSERT_MSG, CopyToTarget, DirectCompatibility, ExportToTarget, Layer::GetBackendId(), ITensorHandleFactory::GetCapabilities(), ITensorHandleFactory::GetExportFlags(), TensorHandleFactoryRegistry::GetFactory(), ITensorHandleFactory::GetImportFlags(), Layer::GetType(), ITensorHandleFactory::LegacyFactoryId, Output, PaddingRequired, ITensorHandleFactory::SupportsMapUnmap(), and Undefined.

Referenced by SelectTensorHandleStrategy().

863 {
864  auto toBackend = backends.find(connectedLayer.GetBackendId());
865  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
866 
867  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
868 
869  // Legacy API check for backward compatibility
870  if (srcFactoryId == ITensorHandleFactory::LegacyFactoryId || dstPrefs.empty())
871  {
872  if (layer.GetBackendId() != connectedLayer.GetBackendId())
873  {
874  return EdgeStrategy::CopyToTarget;
875  }
876  else
877  {
878  return EdgeStrategy::DirectCompatibility;
879  }
880  }
881 
882  // TensorHandleFactory API present, so perform more sophisticated strategies.
883  // Dst Output layers don't require copy because they use import or map/unmap
884  if (connectedLayer.GetType() == LayerType::Output)
885  {
886  return EdgeStrategy::DirectCompatibility;
887  }
888 
889  // Search for direct match in prefs
890  for (auto&& pref : dstPrefs)
891  {
892  if (pref == srcFactoryId)
893  {
894  return EdgeStrategy::DirectCompatibility;
895  }
896  }
897 
898  // Search for export/import options
899  ITensorHandleFactory* srcFactory = registry.GetFactory(srcFactoryId);
900  if (srcFactory->GetExportFlags() != 0 && importEnabled)
901  {
902  for (auto&& pref : dstPrefs)
903  {
904  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
905 
906  // Handles cases when a destPref is not listed in TensorHandleFactoryRegistry
907  if (!dstFactory) {
908  continue;
909  }
910 
911  if ((dstFactory->GetImportFlags() & srcFactory->GetExportFlags()) != 0)
912  {
913  auto srcCapability = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::PaddingRequired);
914  auto dstCapability = dstFactory->GetCapabilities(&connectedLayer,
915  &connectedLayer,
916  CapabilityClass::PaddingRequired);
917  // Do not require memory copy if the source and destination do not require padding.
918  if (srcCapability.empty() && dstCapability.empty())
919  {
920  return EdgeStrategy::ExportToTarget;
921  }
922  }
923  }
924  }
925 
926  // Search for copy options via map/unmap
927  if (srcFactory->SupportsMapUnmap())
928  {
929  for (auto&& pref : dstPrefs)
930  {
931  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
932  if (dstFactory && dstFactory->SupportsMapUnmap())
933  {
934  return EdgeStrategy::CopyToTarget;
935  }
936  }
937  }
938 
939  return EdgeStrategy::Undefined;
940 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ CalculateSlotOption()

ITensorHandleFactory::FactoryId armnn::CalculateSlotOption ( BackendsMap backends,
OutputSlot outputSlot,
TensorHandleFactoryRegistry registry 
)

Definition at line 748 of file Network.cpp.

References ARMNN_ASSERT_MSG, Layer::GetBackendId(), OutputSlot::GetConnections(), TensorHandleFactoryRegistry::GetFactory(), IBackendInternal::GetHandleFactoryPreferences(), OutputSlot::GetOwningLayer(), Layer::GetType(), ITensorHandleFactory::LegacyFactoryId, Output, RequiresCopy(), and ITensorHandleFactory::SupportsMapUnmap().

Referenced by SelectTensorHandleStrategy().

751 {
752  // First ensure the from backends can support the TensorHandeAPI
753  Layer& layer = outputSlot.GetOwningLayer();
754  auto frmBackend = backends.find(layer.GetBackendId());
755  if (frmBackend == backends.end() ||
756  !frmBackend->second->SupportsTensorAllocatorAPI())
757  {
758  return ITensorHandleFactory::LegacyFactoryId;
759  }
760 
761  // Connections to Output Layers requires support for map/unmap on the TensorHandle.
762  bool requiresMapUnmap = false;
763  for (auto&& connection : outputSlot.GetConnections())
764  {
765  const Layer& connectedLayer = connection->GetOwningLayer();
766  if (connectedLayer.GetType() == LayerType::Output)
767  {
768  requiresMapUnmap = true;
769  }
770  }
771 
772  IBackendInternal* srcBackend = frmBackend->second.get();
773  auto srcPrefs = srcBackend->GetHandleFactoryPreferences();
774 
775  // Initialize the scores
776  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
777  for (auto&& pref : srcPrefs)
778  {
779  if (requiresMapUnmap) // Only consider factories that support map/unmap if required
780  {
781  ITensorHandleFactory* factory = registry.GetFactory(pref);
782  if (!factory->SupportsMapUnmap())
783  {
784  // The current tensor handle factory does not support the map/unmap strategy, move to the next one
785  continue;
786  }
787  }
788 
789  auto it = factoryScores.find(pref);
790  if (it == factoryScores.end())
791  {
792  // Add new score to the table
793  factoryScores[pref] = 0;
794  }
795  }
796 
797  // Score each handle factory based on how many times it requires copies on the slot connections
798  for (auto&& connection : outputSlot.GetConnections())
799  {
800  const Layer& connectedLayer = connection->GetOwningLayer();
801 
802  auto toBackend = backends.find(connectedLayer.GetBackendId());
803  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
804 
805  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
806  for (auto&& src : srcPrefs)
807  {
808  if (factoryScores.find(src) == factoryScores.end()) // Don't consider excluded factories
809  {
810  continue;
811  }
812 
813  for (auto&& dst : dstPrefs)
814  {
815  if (RequiresCopy(src, dst, registry))
816  {
817  // Copy avoided, increase the score
818  factoryScores[src]++;
819  break;
820  }
821  }
822  }
823  }
824 
825  // Find the lowest score
826  int minScore = std::numeric_limits<int>::max();
827  for (auto it : factoryScores)
828  {
829  minScore = std::min(minScore, it.second);
830  }
831 
832  // Collect factories matching the best(lowest) score
833  std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
834  for (auto it : factoryScores)
835  {
836  if (it.second == minScore)
837  {
838  optimalFactories.push_back(it.first);
839  }
840  }
841 
842  // For all compatible Factories matching the best score, find the preferred one for the current layer.
843  for (auto&& srcPref : srcPrefs)
844  {
845  for (auto&& comp : optimalFactories)
846  {
847  if (comp == srcPref)
848  {
849  return comp;
850  }
851  }
852  }
853 
854  return ITensorHandleFactory::LegacyFactoryId;
855 }
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:636
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ CalculateSlotOptionForInput()

ITensorHandleFactory::FactoryId armnn::CalculateSlotOptionForInput ( BackendsMap backends,
OutputSlot slot,
TensorHandleFactoryRegistry registry 
)

Definition at line 656 of file Network.cpp.

References ARMNN_ASSERT, ARMNN_ASSERT_MSG, CheckFlag(), Layer::GetBackendId(), OutputSlot::GetConnections(), TensorHandleFactoryRegistry::GetFactory(), ITensorHandleFactory::GetImportFlags(), OutputSlot::GetOwningLayer(), Layer::GetType(), Input, ITensorHandleFactory::LegacyFactoryId, Malloc, and ITensorHandleFactory::SupportsMapUnmap().

Referenced by SelectTensorHandleStrategy().

659 {
660  Layer& layer = slot.GetOwningLayer();
661  ARMNN_ASSERT(layer.GetType() == LayerType::Input);
662 
663  // Explicitly select the tensorhandle factory for InputLayer because the rules for it are slightly different. It
664  // doesn't matter which backend it is assigned to because they all use the same implementation, which
665  // requires Map/Unmap support. This means that, so long as the handle type supports map/unmap semantics, we can
666  // select a factory with maximum compatibility with the layers connected to the InputLayer.
667 
668  // First ensure the from backends can support the TensorHandeAPI
669  auto frmBackend = backends.find(layer.GetBackendId());
670  if (frmBackend == backends.end() ||
671  !frmBackend->second->SupportsTensorAllocatorAPI())
672  {
673  return ITensorHandleFactory::LegacyFactoryId;
674  }
675 
676  // Go through all connections to the output slot and determine the TensorHandleFactory which results in the
677  // fewest copies.
678  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
679  int topScore = 0;
680  ITensorHandleFactory::FactoryId topChoice = ITensorHandleFactory::LegacyFactoryId;
681 
682  for (auto&& connection : slot.GetConnections())
683  {
684  const Layer& connectedLayer = connection->GetOwningLayer();
685 
686  auto toBackend = backends.find(connectedLayer.GetBackendId());
687  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
688 
689  if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
690  {
691  // The destination backend does not support the tensor allocator API, move to the next one
692  continue;
693  }
694 
695  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
696  for (auto&& dst : dstPrefs)
697  {
698  // Input layers use the mem copy workload or import, so the selected factory must
699  // support either the map/unmap API or Import API
700  ITensorHandleFactory* factory = registry.GetFactory(dst);
701  if (!factory->SupportsMapUnmap() &&
702  !CheckFlag(factory->GetImportFlags(), MemorySource::Malloc)) // Just support cpu mem imports for now
703  {
704  // The current tensor handle factory does not support the map/unmap or import
705  // strategy, move to the next one
706  continue;
707  }
708 
709  auto it = factoryScores.find(dst);
710  if (it == factoryScores.end())
711  {
712  // Add new score to the table
713  factoryScores[dst] = 0;
714  if (topChoice == ITensorHandleFactory::LegacyFactoryId)
715  {
716  topChoice = dst;
717  }
718  }
719  else
720  {
721  // Increase the score
722  factoryScores[dst]++;
723 
724  // Track the best option
725  if (factoryScores[dst] > topScore)
726  {
727  topScore = factoryScores[dst];
728  topChoice = dst;
729  }
730  }
731  }
732  }
733 
734  return topChoice;
735 }
ITensorHandleFactory::FactoryId FactoryId
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
bool CheckFlag(MemorySourceFlags flags, MemorySource source)

◆ CalculateSlotOptionForOutput()

ITensorHandleFactory::FactoryId armnn::CalculateSlotOptionForOutput ( BackendsMap backends,
OutputSlot slot,
TensorHandleFactoryRegistry registry 
)

Definition at line 738 of file Network.cpp.

References ITensorHandleFactory::DeferredFactoryId, and IgnoreUnused().

Referenced by SelectTensorHandleStrategy().

741 {
742  IgnoreUnused(backends, slot, registry);
743  return ITensorHandleFactory::DeferredFactoryId;
744 }
void IgnoreUnused(Ts &&...)

◆ CheckFlag()

bool armnn::CheckFlag ( MemorySourceFlags  flags,
MemorySource  source 
)
inline

Definition at line 47 of file MemorySources.hpp.

Referenced by CalculateSlotOptionForInput(), and LoadedNetwork::EnqueueWorkload().

48 {
49  return (static_cast<MemorySourceFlags>(source) & flags) != 0;
50 }

◆ CheckLayerBindingId()

void armnn::CheckLayerBindingId ( LayerBindingId  visitorId,
LayerBindingId  id 
)

Definition at line 13 of file TestInputOutputLayerVisitor.hpp.

Referenced by TestInputLayerVisitor::VisitInputLayer(), and TestOutputLayerVisitor::VisitOutputLayer().

14 {
15  BOOST_CHECK_EQUAL(visitorId, id);
16 }

◆ CheckScaleSetOnQuantizedType()

bool armnn::CheckScaleSetOnQuantizedType ( Layer layer,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 111 of file Network.cpp.

References ARMNN_LOG, TensorInfo::GetDataType(), GetLayerTypeAsCString(), Layer::GetNameStr(), Layer::GetNumOutputSlots(), Layer::GetOutputSlot(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), OutputSlot::GetTensorInfo(), Layer::GetType(), info, QAsymmU8, ReportError(), TensorInfo::SetQuantizationOffset(), TensorInfo::SetQuantizationScale(), OutputSlot::SetTensorInfo(), Softmax, and warning.

Referenced by AssignBackends().

112 {
113  bool noErrors = true;
114  unsigned int numOutputs = layer->GetNumOutputSlots();
115  for (unsigned int i = 0; i < numOutputs; i++) {
116  OutputSlot& outputSlot = layer->GetOutputSlot(i);
117  TensorInfo info = outputSlot.GetTensorInfo();
118  if (DataType::QAsymmU8 == info.GetDataType()) {
119  if (0.f == info.GetQuantizationScale()) {
120  noErrors = false;
121  std::stringstream ss;
122  ss << "output " << i << " of layer " << GetLayerTypeAsCString(layer->GetType())
123  << " (" << layer->GetNameStr() << ") is of type"
124  << " Quantized 8 bit but its scale parameter has not been set";
125  ReportError(ss.str(), errMessages);
126  }
127  // Softmax under QuantisedAsymm8 must always be scale (1.0f/256.0f) and offset 0
128  if ((info.GetQuantizationScale() != (1.0f / 256.0f) ||
129  info.GetQuantizationOffset() != 0) &&
130  layer->GetType() == armnn::LayerType::Softmax)
131  {
132  std::stringstream ss;
133  ss << "Quantization parameters for Softmax layer (Scale: " <<
134  info.GetQuantizationScale() << " and Offset: " << info.GetQuantizationOffset() <<
135  ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
136  ARMNN_LOG(warning) << ss.str();
137  info.SetQuantizationScale((1.0f /256.0f));
138  info.SetQuantizationOffset(0);
139  outputSlot.SetTensorInfo(info);
140  }
141  }
142  }
143  return noErrors;
144 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:72
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163
char const * GetLayerTypeAsCString(LayerType type)

◆ CheckSupportRule()

bool armnn::CheckSupportRule ( rule,
Optional< std::string &>  reasonIfUnsupported,
const char *  reason 
)

Definition at line 38 of file LayerSupportRules.hpp.

References OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by RefLayerSupport::IsActivationSupported(), RefLayerSupport::IsAdditionSupported(), RefLayerSupport::IsArgMinMaxSupported(), RefLayerSupport::IsBatchNormalizationSupported(), RefLayerSupport::IsBatchToSpaceNdSupported(), RefLayerSupport::IsComparisonSupported(), RefLayerSupport::IsConcatSupported(), RefLayerSupport::IsConstantSupported(), RefLayerSupport::IsConvertBf16ToFp32Supported(), RefLayerSupport::IsConvertFp32ToBf16Supported(), RefLayerSupport::IsConvolution2dSupported(), RefLayerSupport::IsDebugSupported(), RefLayerSupport::IsDepthToSpaceSupported(), RefLayerSupport::IsDepthwiseConvolutionSupported(), RefLayerSupport::IsDequantizeSupported(), RefLayerSupport::IsDetectionPostProcessSupported(), RefLayerSupport::IsDivisionSupported(), RefLayerSupport::IsElementwiseUnarySupported(), RefLayerSupport::IsFakeQuantizationSupported(), RefLayerSupport::IsFillSupported(), RefLayerSupport::IsFloorSupported(), RefLayerSupport::IsFullyConnectedSupported(), RefLayerSupport::IsGatherSupported(), RefLayerSupport::IsInstanceNormalizationSupported(), RefLayerSupport::IsL2NormalizationSupported(), RefLayerSupport::IsLogicalBinarySupported(), RefLayerSupport::IsLogicalUnarySupported(), RefLayerSupport::IsLogSoftmaxSupported(), RefLayerSupport::IsLstmSupported(), RefLayerSupport::IsMaximumSupported(), RefLayerSupport::IsMeanSupported(), RefLayerSupport::IsMemCopySupported(), RefLayerSupport::IsMinimumSupported(), RefLayerSupport::IsMultiplicationSupported(), RefLayerSupport::IsNormalizationSupported(), RefLayerSupport::IsPadSupported(), RefLayerSupport::IsPermuteSupported(), RefLayerSupport::IsPooling2dSupported(), RefLayerSupport::IsPreluSupported(), RefLayerSupport::IsQuantizeSupported(), RefLayerSupport::IsRankSupported(), RefLayerSupport::IsReshapeSupported(), RefLayerSupport::IsResizeBilinearSupported(), RefLayerSupport::IsResizeSupported(), RefLayerSupport::IsSliceSupported(), RefLayerSupport::IsSoftmaxSupported(), RefLayerSupport::IsSpaceToBatchNdSupported(), RefLayerSupport::IsSpaceToDepthSupported(), RefLayerSupport::IsSplitterSupported(), RefLayerSupport::IsStackSupported(), RefLayerSupport::IsStridedSliceSupported(), RefLayerSupport::IsSubtractionSupported(), RefLayerSupport::IsTransposeConvolution2dSupported(), and RefLayerSupport::IsTransposeSupported().

39 {
40  bool supported = rule();
41  if (!supported && reason)
42  {
43  reasonIfUnsupported.value() += std::string(reason) + "\n"; // Append the reason on a new line
44  }
45  return supported;
46 }
ISubgraphViewConverter supported

◆ CheckTensorDataTypesEqual()

bool armnn::CheckTensorDataTypesEqual ( const TensorInfo input0,
const TensorInfo input1 
)

Definition at line 64 of file LayerSupport.cpp.

References TensorInfo::GetDataType().

Referenced by IsAdditionSupported().

65 {
66  return input0.GetDataType() == input1.GetDataType();
67 }

◆ ClAbsWorkloadValidate()

arm_compute::Status ClAbsWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 19 of file ClAbsWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

20 {
21  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  return arm_compute::CLAbsLayer::validate(&aclInput, &aclOutput);
25 }

◆ ClActivationWorkloadValidate()

arm_compute::Status ClActivationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ActivationDescriptor descriptor 
)

Definition at line 17 of file ClActivationWorkload.cpp.

Referenced by ClLayerSupport::IsActivationSupported().

20 {
21  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  const arm_compute::ActivationLayerInfo activationLayerInfo =
26 
27  return arm_compute::CLActivationLayer::validate(&aclInput,
28  &aclOutput,
29  activationLayerInfo);
30 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClAdditionValidate()

arm_compute::Status ClAdditionValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 42 of file ClAdditionWorkload.cpp.

Referenced by ClLayerSupport::IsAdditionSupported(), and ClBackend::OptimizeSubgraphView().

46 {
47  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
48  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
49  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
50 
51  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
52  activationDescriptor);
53 
54  const arm_compute::Status aclStatus = arm_compute::CLArithmeticAddition::validate(&aclInput0Info,
55  &aclInput1Info,
56  &aclOutputInfo,
57  g_AclConvertPolicy,
58  activationInfo);
59 
60  return aclStatus;
61 }
Status
enumeration
Definition: Types.hpp:26
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClArgMinMaxWorkloadValidate()

arm_compute::Status ClArgMinMaxWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ArgMinMaxDescriptor descriptor 
)

Definition at line 31 of file ClArgMinMaxWorkload.cpp.

Referenced by ClLayerSupport::IsArgMinMaxSupported().

34 {
35  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
36  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
37 
38  auto numDims = input.GetNumDimensions();
39  auto unsignedAxis = armnnUtils::GetUnsignedAxis(numDims, descriptor.m_Axis);
40  int aclAxis = armnn::numeric_cast<int>(CalcAclAxis(numDims, unsignedAxis));
41 
42  if (descriptor.m_Function == ArgMinMaxFunction::Max)
43  {
44  return arm_compute::CLArgMinMaxLayer::validate(&aclInput, aclAxis, &aclOutput,
45  arm_compute::ReductionOperation::ARG_IDX_MAX);
46  }
47  else
48  {
49  return arm_compute::CLArgMinMaxLayer::validate(&aclInput, aclAxis, &aclOutput,
50  arm_compute::ReductionOperation::ARG_IDX_MIN);
51  }
52 }
unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClBackendId()

constexpr const char* armnn::ClBackendId ( )

Definition at line 10 of file ClBackendId.hpp.

Referenced by ClBackend::GetIdStatic().

10 { return "GpuAcc"; }

◆ ClBatchNormalizationValidate()

arm_compute::Status ClBatchNormalizationValidate ( const TensorInfo input,
const TensorInfo output,
const TensorInfo mean,
const TensorInfo var,
const TensorInfo beta,
const TensorInfo gamma,
const BatchNormalizationDescriptor desc,
const ActivationDescriptor activationDescriptor 
)

Definition at line 19 of file ClBatchNormalizationFloatWorkload.cpp.

Referenced by ClLayerSupport::IsBatchNormalizationSupported(), and ClBackend::OptimizeSubgraphView().

27 {
28  const arm_compute::TensorInfo aclInputInfo =
29  armcomputetensorutils::BuildArmComputeTensorInfo(input, desc.m_DataLayout);
30  const arm_compute::TensorInfo aclOutputInfo =
31  armcomputetensorutils::BuildArmComputeTensorInfo(output, desc.m_DataLayout);
32  const arm_compute::TensorInfo aclMeanInfo =
33  armcomputetensorutils::BuildArmComputeTensorInfo(mean, desc.m_DataLayout);
34  const arm_compute::TensorInfo aclVarInfo =
35  armcomputetensorutils::BuildArmComputeTensorInfo(var, desc.m_DataLayout);
36  const arm_compute::TensorInfo aclBetaInfo =
37  armcomputetensorutils::BuildArmComputeTensorInfo(beta, desc.m_DataLayout);
38  const arm_compute::TensorInfo aclGammaInfo =
39  armcomputetensorutils::BuildArmComputeTensorInfo(gamma, desc.m_DataLayout);
40 
41  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
42  activationDescriptor);
43 
44  return arm_compute::CLBatchNormalizationLayer::validate(&aclInputInfo,
45  &aclOutputInfo,
46  &aclMeanInfo,
47  &aclVarInfo,
48  &aclBetaInfo,
49  &aclGammaInfo,
50  desc.m_Eps,
51  activationInfo);
52 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClBatchToSpaceNdWorkloadValidate()

arm_compute::Status ClBatchToSpaceNdWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const BatchToSpaceNdDescriptor desc 
)

Definition at line 47 of file ClBatchToSpaceNdWorkload.cpp.

References BatchToSpaceNdDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsBatchToSpaceNdSupported().

49  {
50  DataLayout dataLayout = desc.m_DataLayout;
51  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
52 
53  // ArmNN blockShape is [H, W] Cl asks for W, H
54  int32_t blockHeight = armnn::numeric_cast<int32_t>(desc.m_BlockShape[0]);
55  int32_t blockWidth = armnn::numeric_cast<int32_t>(desc.m_BlockShape[1]);
56 
57  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
58 
59  const arm_compute::Status aclStatus = arm_compute::CLBatchToSpaceLayer::validate(&aclInputInfo,
60  blockWidth,
61  blockHeight,
62  &aclOutputInfo);
63  return aclStatus;
64 }
DataLayout
Definition: Types.hpp:50
Status
enumeration
Definition: Types.hpp:26
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClComparisonWorkloadValidate()

arm_compute::Status ClComparisonWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ComparisonDescriptor descriptor 
)

Definition at line 24 of file ClComparisonWorkload.cpp.

Referenced by ClLayerSupport::IsComparisonSupported().

28 {
29  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
30  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
31  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
32 
33  const arm_compute::ComparisonOperation comparisonOperation = ConvertComparisonOperationToAcl(descriptor);
34 
35  const arm_compute::Status aclStatus = arm_compute::CLComparison::validate(&aclInput0Info,
36  &aclInput1Info,
37  &aclOutputInfo,
38  comparisonOperation);
39  return aclStatus;
40 }
ComparisonOperation
Definition: Types.hpp:78
Status
enumeration
Definition: Types.hpp:26
arm_compute::ComparisonOperation ConvertComparisonOperationToAcl(const ComparisonDescriptor &descriptor)

◆ ClConcatWorkloadValidate()

arm_compute::Status ClConcatWorkloadValidate ( const std::vector< const TensorInfo *> &  inputs,
const TensorInfo output,
const OriginsDescriptor descriptor 
)

Definition at line 28 of file ClConcatWorkload.cpp.

Referenced by ClLayerSupport::IsConcatSupported().

31 {
32  std::vector<arm_compute::TensorInfo> aclInputs;
33  for (const TensorInfo* input : inputs)
34  {
35  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(*input, armnn::DataLayout::NCHW);
36  aclInputs.emplace_back(aclInputInfo);
37  }
38  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
39  std::vector<const arm_compute::ITensorInfo*> aclInputPtrs;
40  for (arm_compute::ITensorInfo& input : aclInputs)
41  {
42  aclInputPtrs.emplace_back(&input);
43  }
44 
45  size_t aclAxis = CalcAxis(descriptor);
46  return arm_compute::CLConcatenateLayer::validate(aclInputPtrs, &aclOutputInfo, aclAxis);
47 }

◆ ClConstantWorkloadValidate()

arm_compute::Status ClConstantWorkloadValidate ( const TensorInfo output)

Definition at line 18 of file ClConstantWorkload.cpp.

Referenced by ClLayerSupport::IsConstantSupported().

19 {
20  const arm_compute::TensorInfo neonOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21 
22  std::array<arm_compute::DataType,8> supportedTypes = {
23  arm_compute::DataType::F16,
24  arm_compute::DataType::F32,
25  arm_compute::DataType::QASYMM8,
26  arm_compute::DataType::QASYMM8_SIGNED,
27  arm_compute::DataType::QSYMM16,
28  arm_compute::DataType::QSYMM8,
29  arm_compute::DataType::QSYMM8_PER_CHANNEL,
30  arm_compute::DataType::S32
31  };
32  auto it = std::find(begin(supportedTypes), end(supportedTypes), neonOutputInfo.data_type());
33 
34  if (it != end(supportedTypes))
35  {
36  return arm_compute::Status{};
37  }
38  else
39  {
40  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported DataType"};
41  }
42 }
Status
enumeration
Definition: Types.hpp:26

◆ ClConvertFp16ToFp32WorkloadValidate()

arm_compute::Status ClConvertFp16ToFp32WorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 35 of file ClConvertFp16ToFp32Workload.cpp.

References Float16, Float32, and TensorInfo::GetDataType().

Referenced by ClLayerSupport::IsConvertFp16ToFp32Supported().

36 {
37  if (input.GetDataType() != DataType::Float16)
38  {
39  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Input should be Float16");
40  }
41  if (output.GetDataType() != DataType::Float32)
42  {
43  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Output should be Float32");
44  }
45 
46  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
47  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
48 
49  const arm_compute::Status aclStatus = arm_compute::CLDepthConvertLayer::validate(
50  &aclInputInfo, &aclOutputInfo, g_AclConvertPolicy, 0);
51 
52  return aclStatus;
53 }
Status
enumeration
Definition: Types.hpp:26

◆ ClConvertFp32ToFp16WorkloadValidate()

arm_compute::Status ClConvertFp32ToFp16WorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 35 of file ClConvertFp32ToFp16Workload.cpp.

References Float16, Float32, and TensorInfo::GetDataType().

Referenced by ClLayerSupport::IsConvertFp32ToFp16Supported().

36 {
37  if (input.GetDataType() != DataType::Float32)
38  {
39  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Input should be Float32");
40  }
41  if (output.GetDataType() != DataType::Float16)
42  {
43  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Output should be Float16");
44  }
45 
46  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
47  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
48 
49  const arm_compute::Status aclStatus = arm_compute::CLDepthConvertLayer::validate(
50  &aclInputInfo, &aclOutputInfo, g_AclConvertPolicy, 0);
51 
52  return aclStatus;
53 }
Status
enumeration
Definition: Types.hpp:26

◆ ClConvolution2dWorkloadValidate()

arm_compute::Status ClConvolution2dWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const Convolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
bool  isFastMathEnabled,
const ActivationDescriptor activationDescriptor 
)

Definition at line 23 of file ClConvolution2dWorkload.cpp.

Referenced by ClLayerSupport::IsConvolution2dSupported(), and ClBackend::OptimizeSubgraphView().

30 {
31  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
32  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
33  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
34 
35  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(descriptor.m_DilationX,
36  descriptor.m_DilationY);
37 
38  arm_compute::TensorInfo aclBiasesInfo;
39  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
40 
41  if (descriptor.m_BiasEnabled)
42  {
43  ARMNN_ASSERT(biases.has_value());
44 
45  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
46  optionalAclBiasesInfo = &aclBiasesInfo;
47  }
48 
49  arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor);
50 
51  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
52  activationDescriptor);
53 
54  return arm_compute::CLConvolutionLayer::validate(&aclInputInfo,
55  &aclWeightsInfo,
56  optionalAclBiasesInfo,
57  &aclOutputInfo,
58  layerInfo,
59  arm_compute::WeightsInfo(),
60  aclDilationInfo,
61  activationInfo,
62  isFastMathEnabled);
63 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClDepthToSpaceWorkloadValidate()

arm_compute::Status ClDepthToSpaceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const DepthToSpaceDescriptor desc 
)

Definition at line 22 of file ClDepthToSpaceWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsDepthToSpaceSupported().

25 {
26  DataLayout dataLayout = desc.m_DataLayout;
27  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
28 
29  int32_t blockSize = armnn::numeric_cast<int32_t>(desc.m_BlockSize);
30 
31  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
32 
33  const arm_compute::Status aclStatus = arm_compute::CLDepthToSpaceLayer::validate(&aclInputInfo,
34  &aclOutputInfo,
35  blockSize);
36  return aclStatus;
37 }
DataLayout
Definition: Types.hpp:50
Status
enumeration
Definition: Types.hpp:26
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClDepthwiseConvolutionWorkloadValidate()

arm_compute::Status ClDepthwiseConvolutionWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const DepthwiseConvolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
const ActivationDescriptor activationDescriptor 
)

Definition at line 26 of file ClDepthwiseConvolutionWorkload.cpp.

Referenced by ClLayerSupport::IsDepthwiseConvolutionSupported(), ClLayerSupport::IsDilatedDepthwiseConvolutionSupported(), and ClBackend::OptimizeSubgraphView().

32 {
33  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
34  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
35 
36  // ArmNN's weight format is [ M, I, H, W ]
37  const unsigned int aclDepthMultiplier = weights.GetShape()[0];
38 
39  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
40  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
41  TensorInfo weightsPermuted = ConvertWeightTensorInfoFromArmnnToAcl(weights, descriptor.m_DataLayout);
42 
43  // Convert the weights into the compute library format
44  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weightsPermuted, descriptor.m_DataLayout);
45 
46  arm_compute::TensorInfo aclBiasesInfo;
47  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
48 
49  if (descriptor.m_BiasEnabled)
50  {
51  ARMNN_ASSERT(biases.has_value());
52 
53  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
54  optionalAclBiasesInfo = &aclBiasesInfo;
55  }
56 
57  const arm_compute::PadStrideInfo aclPadStrideInfo = BuildArmComputePadStrideInfo(descriptor);
58  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
59  descriptor.m_DilationX,
60  descriptor.m_DilationY);
61 
62  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
63  activationDescriptor);
64 
65  return arm_compute::CLDepthwiseConvolutionLayer::validate(&aclInputInfo,
66  &aclWeightsInfo,
67  optionalAclBiasesInfo,
68  &aclOutputInfo,
69  aclPadStrideInfo,
70  aclDepthMultiplier,
71  activationInfo,
72  aclDilationInfo);
73 
74 }
TensorInfo ConvertWeightTensorInfoFromArmnnToAcl(const TensorInfo &weightInfo, DataLayout dataLayout)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClDequantizeWorkloadValidate()

arm_compute::Status ClDequantizeWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 22 of file ClDequantizeWorkload.cpp.

Referenced by ClLayerSupport::IsDequantizeSupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
25  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
26 
27  return arm_compute::CLDequantizationLayer::validate(&aclInputInfo, &aclOutputInfo);
28 }

◆ ClDivisionWorkloadValidate()

arm_compute::Status ClDivisionWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 18 of file ClDivisionFloatWorkload.cpp.

Referenced by ClLayerSupport::IsDivisionSupported(), and ClBackend::OptimizeSubgraphView().

22 {
23  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
24  const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
25  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
26 
27  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
28  activationDescriptor);
29 
30  return arm_compute::CLArithmeticDivision::validate(&aclInput1, &aclInput2, &aclOutput, activationInfo);
31 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClExpWorkloadValidate()

arm_compute::Status ClExpWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 18 of file ClExpWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

19 {
20  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::CLExpLayer::validate(&aclInput, &aclOutput);
24 }

◆ ClFloorWorkloadValidate()

arm_compute::Status ClFloorWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 14 of file ClFloorFloatWorkload.cpp.

Referenced by ClLayerSupport::IsFloorSupported().

16 {
17  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
18  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
19 
20  return arm_compute::CLFloor::validate(&aclInput, &aclOutput);
21 }

◆ ClFullyConnectedWorkloadValidate()

arm_compute::Status ClFullyConnectedWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TensorInfo weights,
const TensorInfo biases,
const FullyConnectedDescriptor descriptor,
const ActivationDescriptor activationDescriptor 
)

Definition at line 19 of file ClFullyConnectedWorkload.cpp.

Referenced by ClLayerSupport::IsFullyConnectedSupported(), and ClBackend::OptimizeSubgraphView().

25 {
26  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
27  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
28  const arm_compute::TensorInfo aclWeights = BuildArmComputeTensorInfo(weights);
29 
30  arm_compute::TensorInfo aclBiases;
31  arm_compute::TensorInfo *optionalAclBiases = nullptr;
32  if (descriptor.m_BiasEnabled)
33  {
34  aclBiases = BuildArmComputeTensorInfo(biases);
35  optionalAclBiases = &aclBiases;
36  }
37 
38  const arm_compute::FullyConnectedLayerInfo fullyConnectedLayerInfo =
39  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor, activationDescriptor);
40 
41  return arm_compute::CLFullyConnectedLayer::validate(&aclInput,
42  &aclWeights,
43  optionalAclBiases,
44  &aclOutput,
45  fullyConnectedLayerInfo);
46 }
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)

◆ ClGatherWorkloadValidate()

arm_compute::Status ClGatherWorkloadValidate ( const TensorInfo input,
const TensorInfo indices,
const TensorInfo output,
const GatherDescriptor descriptor 
)

Definition at line 15 of file ClGatherWorkload.cpp.

Referenced by ClLayerSupport::IsGatherSupported().

19 {
20  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclIndices = BuildArmComputeTensorInfo(indices);
22  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
23 
24  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
25 
26  return arm_compute::CLGather::validate(&aclInput, &aclIndices, &aclOutput, aclAxis);
27 }
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...

◆ ClInstanceNormalizationWorkloadValidate()

arm_compute::Status ClInstanceNormalizationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const InstanceNormalizationDescriptor descriptor 
)

Definition at line 18 of file ClInstanceNormalizationWorkload.cpp.

Referenced by ClLayerSupport::IsInstanceNormalizationSupported().

21 {
22  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
23  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
24 
25  return arm_compute::CLInstanceNormalizationLayer::validate(&aclInputInfo,
26  &aclOutputInfo,
27  descriptor.m_Gamma,
28  descriptor.m_Beta,
29  descriptor.m_Eps);
30 }

◆ ClL2NormalizationWorkloadValidate()

arm_compute::Status ClL2NormalizationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const L2NormalizationDescriptor descriptor 
)

Definition at line 17 of file ClL2NormalizationFloatWorkload.cpp.

Referenced by ClLayerSupport::IsL2NormalizationSupported().

20 {
21  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
22  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
23 
24  int axis = (descriptor.m_DataLayout == DataLayout::NCHW) ? 2 : 0;
25 
26  return arm_compute::CLL2NormalizeLayer::validate(&aclInput, &aclOutput, axis, descriptor.m_Eps);
27 }

◆ ClLogicalAndWorkloadValidate()

arm_compute::Status ClLogicalAndWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 20 of file ClLogicalAndWorkload.cpp.

Referenced by ClLayerSupport::IsLogicalBinarySupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo0 = BuildArmComputeTensorInfo(input0);
25  const arm_compute::TensorInfo aclInputInfo1 = BuildArmComputeTensorInfo(input1);
26  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
27 
28  const arm_compute::Status aclStatus = arm_compute::CLLogicalAnd::validate(&aclInputInfo0,
29  &aclInputInfo1,
30  &aclOutputInfo);
31  return aclStatus;
32 }
Status
enumeration
Definition: Types.hpp:26

◆ ClLogicalNotWorkloadValidate()

arm_compute::Status ClLogicalNotWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 20 of file ClLogicalNotWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

22 {
23  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
25 
26  const arm_compute::Status aclStatus = arm_compute::CLLogicalNot::validate(&aclInputInfo,
27  &aclOutputInfo);
28  return aclStatus;
29 }
Status
enumeration
Definition: Types.hpp:26

◆ ClLogicalOrWorkloadValidate()

arm_compute::Status ClLogicalOrWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 20 of file ClLogicalOrWorkload.cpp.

Referenced by ClLayerSupport::IsLogicalBinarySupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo0 = BuildArmComputeTensorInfo(input0);
25  const arm_compute::TensorInfo aclInputInfo1 = BuildArmComputeTensorInfo(input1);
26  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
27 
28  const arm_compute::Status aclStatus = arm_compute::CLLogicalOr::validate(&aclInputInfo0,
29  &aclInputInfo1,
30  &aclOutputInfo);
31  return aclStatus;
32 }
Status
enumeration
Definition: Types.hpp:26

◆ ClLogSoftmaxWorkloadValidate()

arm_compute::Status ClLogSoftmaxWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const LogSoftmaxDescriptor descriptor 
)

Definition at line 17 of file ClLogSoftmaxWorkload.cpp.

Referenced by ClLayerSupport::IsLogSoftmaxSupported().

20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
25  return arm_compute::CLLogSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis);
26 }
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...

◆ ClLstmFloatWorkloadValidate()

arm_compute::Status ClLstmFloatWorkloadValidate ( const TensorInfo input,
const TensorInfo outputStateIn,
const TensorInfo cellStateIn,
const TensorInfo scratchBuffer,
const TensorInfo outputStateOut,
const TensorInfo cellStateOut,
const TensorInfo output,
const LstmDescriptor descriptor,
const LstmInputParamsInfo paramsInfo 
)

Definition at line 258 of file ClLstmFloatWorkload.cpp.

Referenced by ClLayerSupport::IsLstmSupported().

263 {
264  arm_compute::LSTMParams<arm_compute::ITensorInfo> lstm_params_info;
265 
266  // The inputs and the outputs
267  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
268  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
269  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
270  const arm_compute::TensorInfo aclScratchBufferInfo = BuildArmComputeTensorInfo(scratchBuffer);
271  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
272  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
273  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
274 
275  // Basic parameters
276  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
277  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
278  const arm_compute::TensorInfo aclInputToCellWeightsInfo
279  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
280  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
281  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
282  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
283  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
284  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
285  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
286  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
287  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
288  const arm_compute::TensorInfo aclForgetGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
289  const arm_compute::TensorInfo aclCellBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
290  const arm_compute::TensorInfo aclOutputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
291 
292  arm_compute::TensorInfo aclInputToInputWeightsInfo;
293  arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
294  arm_compute::TensorInfo aclCellToInputWeightsInfo;
295  arm_compute::TensorInfo aclInputGateBiasInfo;
296  arm_compute::TensorInfo aclProjectionWeightsInfo;
297  arm_compute::TensorInfo aclProjectionBiasInfo;
298  arm_compute::TensorInfo aclCellToForgetWeightsInfo;
299  arm_compute::TensorInfo aclCellToOutputWeightsInfo;
300  arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
301  arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
302  arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
303  arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
304 
305  if (!descriptor.m_CifgEnabled)
306  {
307  aclInputToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
308  aclRecurrentToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
309 
310  if (paramsInfo.m_CellToInputWeights != nullptr)
311  {
312  aclCellToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToInputWeights());
313  }
314  aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
315  lstm_params_info.set_cifg_params(&aclInputToInputWeightsInfo, &aclRecurrentToInputWeightsInfo,
316  paramsInfo.m_CellToInputWeights != nullptr ?
317  &aclCellToInputWeightsInfo: nullptr,
318  &aclInputGateBiasInfo);
319  }
320 
321  if (descriptor.m_ProjectionEnabled)
322  {
323  aclProjectionWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionWeights());
324 
325  if (paramsInfo.m_ProjectionBias != nullptr)
326  {
327  aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
328  }
329  lstm_params_info.set_projection_params(&aclProjectionWeightsInfo,
330  paramsInfo.m_ProjectionBias != nullptr ?
331  &aclProjectionBiasInfo: nullptr);
332  }
333 
334  if (descriptor.m_PeepholeEnabled)
335  {
336  aclCellToForgetWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToForgetWeights());
337  aclCellToOutputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToOutputWeights());
338  lstm_params_info.set_peephole_params(&aclCellToForgetWeightsInfo, &aclCellToOutputWeightsInfo);
339  }
340 
341  float cell_threshold = descriptor.m_ClippingThresCell;
342  float projection_threshold = descriptor.m_ClippingThresProj;
343 
344  // for preparing the object for the class ActivationLayerInfo, we need to consider 5 situations
345  arm_compute::ActivationLayerInfo activationLayerInfo;
346  if (descriptor.m_ActivationFunc == 0)
347  {
348  // no activation, do nothing
349  }
350  else if (descriptor.m_ActivationFunc == 1)
351  {
352  activationLayerInfo = arm_compute::ActivationLayerInfo(
353  arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
354  }
355  else if (descriptor.m_ActivationFunc == 3)
356  {
357  activationLayerInfo = arm_compute::ActivationLayerInfo(
358  arm_compute::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.0);
359  }
360  else if (descriptor.m_ActivationFunc == 4)
361  {
362  activationLayerInfo = arm_compute::ActivationLayerInfo(
363  arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0, 1.0);
364  }
365  else if (descriptor.m_ActivationFunc == 6)
366  {
367  activationLayerInfo = arm_compute::ActivationLayerInfo(
368  arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC);
369  }
370  else
371  {
372  throw armnn::Exception("Wrong Type of Activation Function!");
373  }
374 
375  if (descriptor.m_LayerNormEnabled)
376  {
377  if (!descriptor.m_CifgEnabled)
378  {
379  aclInputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputLayerNormWeights());
380  }
381 
382  aclForgetLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetLayerNormWeights());
383 
384  aclCellLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellLayerNormWeights());
385 
386  aclOutputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputLayerNormWeights());
387 
388  lstm_params_info.set_layer_normalization_params(descriptor.m_CifgEnabled ?
389  nullptr : &aclInputLayerNormWeightsInfo,
390  &aclForgetLayerNormWeightsInfo,
391  &aclCellLayerNormWeightsInfo,
392  &aclOutputLayerNormWeightsInfo);
393  }
394 
395  return arm_compute::CLLSTMLayer::validate(&aclInputInfo, &aclInputToForgetWeightsInfo,
396  &aclInputToCellWeightsInfo,
397  &aclInputToOutputWeightsInfo,
398  &aclRecurrentToForgetWeightsInfo,
399  &aclRecurrentToCellWeightsInfo,
400  &aclRecurrentToOutputWeightsInfo,
401  &aclForgetGateBiasInfo,
402  &aclCellBiasInfo,
403  &aclOutputGateBiasInfo,
404  &aclOutputStateInInfo, &aclCellStateInInfo,
405  &aclScratchBufferInfo, &aclOutputStateOutInfo,
406  &aclCellStateOutInfo, &aclOutputInfo,
407  lstm_params_info, activationLayerInfo,
408  cell_threshold, projection_threshold);
409 }
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46

◆ ClMaximumWorkloadValidate()

arm_compute::Status ClMaximumWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 24 of file ClMaximumWorkload.cpp.

Referenced by ClLayerSupport::IsMaximumSupported().

27 {
28  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
29  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
30  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
31 
32  const arm_compute::Status aclStatus = arm_compute::CLElementwiseMax::validate(&aclInput0Info,
33  &aclInput1Info,
34  &aclOutputInfo);
35 
36  return aclStatus;
37 }
Status
enumeration
Definition: Types.hpp:26

◆ ClMeanValidate()

arm_compute::Status ClMeanValidate ( const TensorInfo input,
const TensorInfo output,
const MeanDescriptor desc 
)

Definition at line 17 of file ClMeanWorkload.cpp.

Referenced by ClLayerSupport::IsMeanSupported().

20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
25  input.GetNumDimensions(),
26  desc.m_Axis);
27 
28  return arm_compute::CLReduceMean::validate(&aclInputInfo, coords, desc.m_KeepDims, &aclOutputInfo);
29 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ ClMinimumWorkloadValidate()

arm_compute::Status ClMinimumWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 24 of file ClMinimumWorkload.cpp.

Referenced by ClLayerSupport::IsMinimumSupported().

27 {
28  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
29  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
30  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
31 
32  const arm_compute::Status aclStatus = arm_compute::CLElementwiseMin::validate(&aclInput0Info,
33  &aclInput1Info,
34  &aclOutputInfo);
35 
36  return aclStatus;
37 }
Status
enumeration
Definition: Types.hpp:26

◆ ClMultiplicationWorkloadValidate()

arm_compute::Status ClMultiplicationWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 18 of file ClMultiplicationWorkload.cpp.

Referenced by ClLayerSupport::IsMultiplicationSupported(), and ClBackend::OptimizeSubgraphView().

22 {
23  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
24  const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
25  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
26 
27  auto convertPolicy = (IsQuantizedType(input0.GetDataType()) || IsQuantizedType(input1.GetDataType())) ?
28  arm_compute::ConvertPolicy::SATURATE :
29  arm_compute::ConvertPolicy::WRAP;
30 
31  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
32  activationDescriptor);
33 
34  // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it,
35  // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be
36  // ignored for F32 tensors.
37  return arm_compute::CLPixelWiseMultiplication::validate(&aclInput1,
38  &aclInput2,
39  &aclOutput,
40  1.0f,
41  convertPolicy,
42  arm_compute::RoundingPolicy::TO_ZERO,
43  activationInfo);
44 }
constexpr bool IsQuantizedType()
Definition: TypesUtils.hpp:249
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClNegWorkloadValidate()

arm_compute::Status ClNegWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 18 of file ClNegWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

19 {
20  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::CLNegLayer::validate(&aclInput, &aclOutput);
24 }

◆ ClNormalizationWorkloadValidate()

arm_compute::Status ClNormalizationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const NormalizationDescriptor descriptor 
)

Definition at line 19 of file ClNormalizationFloatWorkload.cpp.

Referenced by ClLayerSupport::IsNormalizationSupported().

22 {
23  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
24  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
25 
26  arm_compute::NormalizationLayerInfo layerInfo = BuildArmComputeNormalizationLayerInfo(descriptor);
27 
28  return arm_compute::CLNormalizationLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo);
29 }

◆ ClPadValidate()

arm_compute::Status ClPadValidate ( const TensorInfo input,
const TensorInfo output,
const PadDescriptor descriptor 
)

Definition at line 45 of file ClPadWorkload.cpp.

Referenced by ClLayerSupport::IsPadSupported().

48 {
49  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
50  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
51 
52  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
53 
54  std::reverse_copy(std::begin(descriptor.m_PadList),
55  std::end(descriptor.m_PadList),
56  std::begin(reversed_PadList));
57 
58  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
59 
60  const arm_compute::Status aclStatus = arm_compute::CLPadLayer::validate(&aclInputInfo,
61  &aclOutputInfo,
62  padList);
63 
64  return aclStatus;
65 }
Status
enumeration
Definition: Types.hpp:26

◆ ClPermuteWorkloadValidate()

arm_compute::Status ClPermuteWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const PermuteDescriptor descriptor 
)

Definition at line 17 of file ClPermuteWorkload.cpp.

Referenced by ClLayerSupport::IsPermuteSupported().

20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23  const armnn::PermutationVector& mappings = descriptor.m_DimMappings;
24 
25  return arm_compute::CLPermute::validate(&aclInputInfo, &aclOutputInfo,
26  armcomputetensorutils::BuildArmComputePermutationVector(mappings));
27 }

◆ ClPooling2dWorkloadValidate()

arm_compute::Status ClPooling2dWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const Pooling2dDescriptor descriptor 
)

Definition at line 18 of file ClPooling2dWorkload.cpp.

Referenced by ClLayerSupport::IsPooling2dSupported().

21 {
22  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
23  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
24 
25  arm_compute::PoolingLayerInfo layerInfo = BuildArmComputePoolingLayerInfo(descriptor);
26 
27  return arm_compute::CLPoolingLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo);
28 }

◆ ClPreluWorkloadValidate()

arm_compute::Status ClPreluWorkloadValidate ( const TensorInfo input,
const TensorInfo alpha,
const TensorInfo output 
)

Definition at line 16 of file ClPreluWorkload.cpp.

Referenced by ClLayerSupport::IsPreluSupported().

19 {
20  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclAlpha = armcomputetensorutils::BuildArmComputeTensorInfo(alpha);
22  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  return arm_compute::CLPReluLayer::validate(&aclInput,
25  &aclAlpha,
26  &aclOutput);
27 }

◆ ClQLstmWorkloadValidate()

arm_compute::Status ClQLstmWorkloadValidate ( const TensorInfo input,
const TensorInfo cellStateIn,
const TensorInfo outputStateIn,
const TensorInfo cellStateOut,
const TensorInfo outputStateOut,
const TensorInfo output,
const QLstmDescriptor descriptor,
const LstmInputParamsInfo paramsInfo 
)

Definition at line 234 of file ClQLstmWorkload.cpp.

Referenced by ClLayerSupport::IsQLstmSupported().

242 {
243  arm_compute::LSTMParams<arm_compute::ITensorInfo> aclParamsInfo;
244 
245  // Input/Output tensor info
246  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
247  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
248  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
249 
250  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
251  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
252  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
253 
254  // Mandatory tensor info
255  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
256  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
257  const arm_compute::TensorInfo aclInputToCellWeightsInfo
258  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
259  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
260  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
261  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
262  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
263  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
264  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
265  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
266  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
267  const arm_compute::TensorInfo aclForgetGateBiasInfo
268  = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
269  const arm_compute::TensorInfo aclCellBiasInfo
270  = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
271  const arm_compute::TensorInfo aclOutputGateBiasInfo
272  = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
273 
274  // Optional tensor info
275  arm_compute::TensorInfo aclInputToInputWeightsInfo;
276  arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
277 
278  arm_compute::TensorInfo aclCellToInputWeightsInfo;
279  arm_compute::TensorInfo aclCellToForgetWeightsInfo;
280  arm_compute::TensorInfo aclCellToOutputWeightsInfo;
281 
282  arm_compute::TensorInfo aclInputGateBiasInfo;
283 
284  arm_compute::TensorInfo aclProjectionWeightsInfo;
285  arm_compute::TensorInfo aclProjectionBiasInfo;
286 
287  arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
288  arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
289  arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
290  arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
291 
292  // Create tensor info for optional params if they are enabled
293  if (descriptor.m_PeepholeEnabled)
294  {
295  if (!descriptor.m_CifgEnabled)
296  {
297  aclCellToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToInputWeights());
298  }
299 
300  aclCellToForgetWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToForgetWeights());
301  aclCellToOutputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToOutputWeights());
302 
303  // Set peephole params info
304  aclParamsInfo.set_peephole_params(&aclCellToForgetWeightsInfo,
305  &aclCellToOutputWeightsInfo);
306  }
307 
308  if (descriptor.m_ProjectionEnabled)
309  {
310  aclProjectionWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionWeights());
311 
312  if (paramsInfo.m_ProjectionBias != nullptr)
313  {
314  aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionBias());
315  }
316 
317  // Set projection params info
318  aclParamsInfo.set_projection_params(
319  &aclProjectionWeightsInfo,
320  paramsInfo.m_ProjectionBias != nullptr ? &aclProjectionBiasInfo : nullptr);
321  }
322 
323  if (descriptor.m_LayerNormEnabled)
324  {
325  if (!descriptor.m_CifgEnabled)
326  {
327  aclInputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputLayerNormWeights());
328  }
329 
330  aclForgetLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetLayerNormWeights());
331  aclCellLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellLayerNormWeights());
332  aclOutputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputLayerNormWeights());
333 
334  // Set layer norm params info
335  aclParamsInfo.set_layer_normalization_params(
336  paramsInfo.m_InputLayerNormWeights != nullptr ? &aclInputLayerNormWeightsInfo : nullptr,
337  &aclForgetLayerNormWeightsInfo,
338  &aclCellLayerNormWeightsInfo,
339  &aclOutputLayerNormWeightsInfo);
340  }
341 
342  if (!descriptor.m_CifgEnabled)
343  {
344  aclInputToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
345  aclRecurrentToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
346  aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
347 
348  // Set CIFG params info
349  aclParamsInfo.set_cifg_params(
350  &aclInputToInputWeightsInfo,
351  &aclRecurrentToInputWeightsInfo,
352  paramsInfo.m_CellToInputWeights != nullptr ? &aclCellToInputWeightsInfo : nullptr,
353  &aclInputGateBiasInfo);
354  }
355 
356  // Set scalar descriptor params
357  aclParamsInfo.set_cell_clip_params(descriptor.m_CellClip);
358  aclParamsInfo.set_projection_clip_params(descriptor.m_ProjectionClip);
359  aclParamsInfo.set_hidden_state_params(descriptor.m_HiddenStateZeroPoint, descriptor.m_HiddenStateScale);
360  aclParamsInfo.set_matmul_scale_params(descriptor.m_InputIntermediateScale,
361  descriptor.m_ForgetIntermediateScale,
362  descriptor.m_CellIntermediateScale,
363  descriptor.m_OutputIntermediateScale);
364 
365  // QLSTM CL validate
366  return arm_compute::CLQLSTMLayer::validate(&aclInputInfo,
367  &aclInputToForgetWeightsInfo,
368  &aclInputToCellWeightsInfo,
369  &aclInputToOutputWeightsInfo,
370  &aclRecurrentToForgetWeightsInfo,
371  &aclRecurrentToCellWeightsInfo,
372  &aclRecurrentToOutputWeightsInfo,
373  &aclForgetGateBiasInfo,
374  &aclCellBiasInfo,
375  &aclOutputGateBiasInfo,
376  &aclCellStateInInfo,
377  &aclOutputStateInInfo,
378  &aclCellStateOutInfo,
379  &aclOutputStateOutInfo,
380  &aclOutputInfo,
381  aclParamsInfo);
382 }

◆ ClQuantizedLstmWorkloadValidate()

arm_compute::Status ClQuantizedLstmWorkloadValidate ( const TensorInfo input,
const TensorInfo previousCellStateIn,
const TensorInfo previousOutputIn,
const TensorInfo cellStateOut,
const TensorInfo output,
const QuantizedLstmInputParamsInfo paramsInfo 
)

Definition at line 18 of file ClQuantizedLstmWorkload.cpp.

Referenced by ClLayerSupport::IsQuantizedLstmSupported().

22 {
23  // Inputs
24  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
25  const arm_compute::TensorInfo aclPreviousCellStateInInfo = BuildArmComputeTensorInfo(previousCellStateIn);
26  const arm_compute::TensorInfo aclPreviousOutputInInfo = BuildArmComputeTensorInfo(previousOutputIn);
27 
28  // Outputs
29  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
30  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
31 
32  // Basic parameters
33  const arm_compute::TensorInfo aclInputToInputWeightsInfo
34  = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
35  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
36  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
37  const arm_compute::TensorInfo aclInputToCellWeightsInfo
38  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
39  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
40  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
41  const arm_compute::TensorInfo aclRecurrentToInputWeightsInfo
42  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
43  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
44  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
45  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
46  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
47  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
48  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
49  const arm_compute::TensorInfo aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
50  const arm_compute::TensorInfo aclForgetGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
51  const arm_compute::TensorInfo aclCellBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
52  const arm_compute::TensorInfo aclOutputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
53 
54  return arm_compute::CLLSTMLayerQuantized::validate(&aclInputInfo, &aclInputToInputWeightsInfo,
55  &aclInputToForgetWeightsInfo, &aclInputToCellWeightsInfo,
56  &aclInputToOutputWeightsInfo, &aclRecurrentToInputWeightsInfo,
57  &aclRecurrentToForgetWeightsInfo, &aclRecurrentToCellWeightsInfo,
58  &aclRecurrentToOutputWeightsInfo, &aclInputGateBiasInfo,
59  &aclForgetGateBiasInfo, &aclCellBiasInfo, &aclOutputGateBiasInfo,
60  &aclPreviousCellStateInInfo, &aclPreviousOutputInInfo,
61  &aclCellStateOutInfo, &aclOutputInfo);
62 }

◆ ClQuantizeWorkloadValidate()

arm_compute::Status ClQuantizeWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 22 of file ClQuantizeWorkload.cpp.

Referenced by ClLayerSupport::IsQuantizeSupported().

24 {
25  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
26  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
27 
28  return arm_compute::CLQuantizationLayer::validate(&aclInputInfo,
29  &aclOutputInfo);
30 }

◆ ClReshapeWorkloadValidate()

arm_compute::Status ClReshapeWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 15 of file ClReshapeWorkload.cpp.

Referenced by ClLayerSupport::IsReshapeSupported().

17 {
18  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
19  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
20 
21  return arm_compute::CLReshapeLayer::validate(&aclInputInfo, &aclOutputInfo);
22 }

◆ ClResizeWorkloadValidate()

arm_compute::Status ClResizeWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ResizeDescriptor descriptor 
)

Definition at line 22 of file ClResizeWorkload.cpp.

Referenced by ClLayerSupport::IsResizeSupported().

25 {
26  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
27  arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
28 
29  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(descriptor.m_DataLayout);
30  aclInputInfo.set_data_layout(aclDataLayout);
31  aclOutputInfo.set_data_layout(aclDataLayout);
32 
33  arm_compute::InterpolationPolicy aclInterpolationPolicy =
35 
36  arm_compute::SamplingPolicy samplingPolicy = descriptor.m_HalfPixelCenters ? arm_compute::SamplingPolicy::CENTER :
37  arm_compute::SamplingPolicy::TOP_LEFT;
38 
39  return arm_compute::CLScale::validate(&aclInputInfo,
40  &aclOutputInfo,
41  arm_compute::ScaleKernelInfo(aclInterpolationPolicy,
42  arm_compute::BorderMode::REPLICATE,
43  arm_compute::PixelValue(0.f),
44  samplingPolicy,
45  true,
46  descriptor.m_AlignCorners));
47 }
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
DataLayout
Definition: Types.hpp:50

◆ ClRsqrtWorkloadValidate()

arm_compute::Status ClRsqrtWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 18 of file ClRsqrtWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

19 {
20  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::CLRsqrtLayer::validate(&aclInput, &aclOutput);
24 }

◆ ClSliceWorkloadValidate()

arm_compute::Status ClSliceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SliceDescriptor descriptor 
)

Definition at line 18 of file ClSliceWorkload.cpp.

Referenced by ClLayerSupport::IsSliceSupported().

21 {
22  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
23  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
24 
27 
28  std::tie(starts, ends) = SetClSliceData(descriptor.m_Begin, descriptor.m_Size);
29 
30  return arm_compute::CLSlice::validate(&aclInput, &aclOutput, starts, ends);
31 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
auto SetClSliceData(const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)

◆ ClSoftmaxWorkloadValidate()

arm_compute::Status ClSoftmaxWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SoftmaxDescriptor descriptor 
)

Definition at line 17 of file ClSoftmaxWorkload.cpp.

Referenced by ClLayerSupport::IsSoftmaxSupported().

20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
25  return arm_compute::CLSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis);
26 }
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...

◆ ClSpaceToBatchNdWorkloadValidate()

arm_compute::Status ClSpaceToBatchNdWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SpaceToBatchNdDescriptor descriptor 
)

Definition at line 23 of file ClSpaceToBatchNdWorkload.cpp.

Referenced by ClLayerSupport::IsSpaceToBatchNdSupported().

26 {
27  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
28  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
29 
30  // ArmNN blockShape is [H, W] Cl asks for W, H
31  int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
32  int32_t blockWidth = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[1]);
33 
34  arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(
35  descriptor.m_PadList[1].first, descriptor.m_PadList[0].first);
36  arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(
37  descriptor.m_PadList[1].second, descriptor.m_PadList[0].second);
38 
39  return arm_compute::CLSpaceToBatchLayer::validate(&aclInputInfo,
40  blockWidth,
41  blockHeight,
42  paddingLeftTop,
43  paddingRightBottom,
44  &aclOutputInfo);
45 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClSpaceToDepthWorkloadValidate()

arm_compute::Status ClSpaceToDepthWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SpaceToDepthDescriptor desc 
)

Definition at line 45 of file ClSpaceToDepthWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsSpaceToDepthSupported().

48 {
49  DataLayout dataLayout = desc.m_DataLayout;
50  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
51 
52  int32_t blockSize = armnn::numeric_cast<int32_t>(desc.m_BlockSize);
53 
54  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
55 
56  const arm_compute::Status aclStatus = arm_compute::CLSpaceToDepthLayer::validate(&aclInputInfo,
57  &aclOutputInfo,
58  blockSize);
59  return aclStatus;
60 }
DataLayout
Definition: Types.hpp:50
Status
enumeration
Definition: Types.hpp:26
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClSplitterWorkloadValidate()

arm_compute::Status ClSplitterWorkloadValidate ( const TensorInfo input,
const std::vector< std::reference_wrapper< TensorInfo >> &  outputs,
unsigned int  splitAxis 
)

Definition at line 32 of file ClSplitterWorkload.cpp.

Referenced by ClLayerSupport::IsSplitterSupported().

35 {
36  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
37 
38  size_t numOutputs = outputs.size();
39 
40  std::vector<arm_compute::TensorInfo> aclOutputs;
41  aclOutputs.reserve(numOutputs);
42 
43  std::vector<arm_compute::ITensorInfo*> aclOutputPtr;
44  aclOutputPtr.reserve(numOutputs);
45 
46  for (size_t i = 0u; i < outputs.size(); ++i)
47  {
48  aclOutputs.emplace_back(BuildArmComputeTensorInfo(outputs[i]));
49  aclOutputPtr.emplace_back(&aclOutputs.back());
50  }
51 
52  unsigned int aclAxis = CalcAclAxis(input.GetNumDimensions(), splitAxis);
53  return arm_compute::CLSplit::validate(&aclInputInfo, aclOutputPtr, aclAxis);
54 }

◆ ClStackWorkloadValidate()

arm_compute::Status ClStackWorkloadValidate ( const std::vector< const TensorInfo *> &  inputs,
const TensorInfo output,
const StackDescriptor descriptor 
)

Definition at line 29 of file ClStackWorkload.cpp.

Referenced by ClLayerSupport::IsStackSupported().

32 {
33  std::vector<arm_compute::ITensorInfo*> aclInputPtrs;
34  arm_compute::TensorInfo aclInputInfo;
35  for (const TensorInfo* input : inputs)
36  {
37  aclInputInfo = BuildArmComputeTensorInfo(*input);
38  aclInputPtrs.emplace_back(&aclInputInfo);
39  }
40  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
41 
42  int aclAxis = CalcAxis(descriptor.m_Axis, descriptor.m_InputShape.GetNumDimensions());
43 
44  return arm_compute::CLStackLayer::validate(aclInputPtrs, aclAxis, &aclOutputInfo);
45 }

◆ ClStridedSliceWorkloadValidate()

arm_compute::Status ClStridedSliceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const StridedSliceDescriptor descriptor 
)

Definition at line 27 of file ClStridedSliceWorkload.cpp.

Referenced by ClLayerSupport::IsStridedSliceSupported().

30 {
31  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
32  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
33 
37 
38  std::tie(starts, ends, strides) = SetClStridedSliceData(descriptor.m_Begin, descriptor.m_End, descriptor.m_Stride);
39 
40  auto numDimensions = armnn::numeric_cast<int>(input.GetNumDimensions());
41  int32_t begin_mask = ConvertMaskToACLFormat(descriptor.m_BeginMask, numDimensions);
42  int32_t end_mask = ConvertMaskToACLFormat(descriptor.m_EndMask, numDimensions);
43  int32_t shrink_axis_mask = ConvertMaskToACLFormat(descriptor.m_ShrinkAxisMask, numDimensions);
44 
45  return arm_compute::CLStridedSlice::validate(&aclInputInfo,
46  &aclOutputInfo,
47  starts,
48  ends,
49  strides,
50  begin_mask,
51  end_mask,
52  shrink_axis_mask);
53 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
int32_t ConvertMaskToACLFormat(int32_t mask, int32_t numDim)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
auto SetClStridedSliceData(const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)

◆ ClSubtractionValidate()

arm_compute::Status ClSubtractionValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 42 of file ClSubtractionWorkload.cpp.

Referenced by ClLayerSupport::IsSubtractionSupported(), and ClBackend::OptimizeSubgraphView().

46 {
47  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
48  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
49  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
50 
51  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
52  activationDescriptor);
53 
54  const arm_compute::Status aclStatus = arm_compute::CLArithmeticSubtraction::validate(&aclInput0Info,
55  &aclInput1Info,
56  &aclOutputInfo,
57  g_AclConvertPolicy,
58  activationInfo);
59 
60  return aclStatus;
61 }
Status
enumeration
Definition: Types.hpp:26
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClTensorHandleFactoryId()

constexpr const char* armnn::ClTensorHandleFactoryId ( )

Definition at line 15 of file ClTensorHandleFactory.hpp.

Referenced by ClTensorHandleFactory::GetIdStatic().

15 { return "Arm/Cl/TensorHandleFactory"; }

◆ ClTransposeConvolution2dWorkloadValidate()

arm_compute::Status ClTransposeConvolution2dWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TransposeConvolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases 
)

Definition at line 26 of file ClTransposeConvolution2dWorkload.cpp.

Referenced by ClLayerSupport::IsTransposeConvolution2dSupported().

31 {
32  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
33  arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
34  arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
35 
36  arm_compute::TensorInfo aclBiasesInfo;
37  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
38 
39  if (descriptor.m_BiasEnabled)
40  {
41  ARMNN_ASSERT(biases.has_value());
42 
43  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
44  optionalAclBiasesInfo = &aclBiasesInfo;
45  }
46 
47  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(descriptor);
48 
49  return arm_compute::CLDeconvolutionLayer::validate(&aclInputInfo,
50  &aclWeightsInfo,
51  optionalAclBiasesInfo,
52  &aclOutputInfo,
53  padStrideInfo);
54 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ClTransposeWorkloadValidate()

arm_compute::Status ClTransposeWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TransposeDescriptor descriptor 
)

Definition at line 17 of file ClTransposeWorkload.cpp.

Referenced by ClLayerSupport::IsTransposeSupported().

20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23  const armnn::PermutationVector& mappings = descriptor.m_DimMappings;
24 
25  return arm_compute::CLPermute::validate(&aclInputInfo, &aclOutputInfo,
26  armcomputetensorutils::BuildArmComputeTransposeVector(mappings));
27 }

◆ Combine() [1/2]

MemorySourceFlags armnn::Combine ( Arg  sourceA,
Arg  sourceB 
)

Definition at line 36 of file MemorySources.hpp.

Referenced by Combine().

37 {
38  return static_cast<MemorySourceFlags>(sourceA) | static_cast<MemorySourceFlags>(sourceB);
39 }
unsigned int MemorySourceFlags

◆ Combine() [2/2]

MemorySourceFlags armnn::Combine ( Arg  source,
Args...  rest 
)

Definition at line 42 of file MemorySources.hpp.

References Combine().

43 {
44  return static_cast<MemorySourceFlags>(source) | Combine(rest...);
45 }
MemorySourceFlags Combine(Arg source, Args... rest)
unsigned int MemorySourceFlags

◆ CompatibleTypes()

bool armnn::CompatibleTypes ( DataType  )

Definition at line 17 of file CompatibleTypes.hpp.

18 {
19  return false;
20 }

◆ CompatibleTypes< BFloat16 >()

bool armnn::CompatibleTypes< BFloat16 > ( DataType  dataType)
inline

Definition at line 35 of file CompatibleTypes.hpp.

References BFloat16.

36 {
37  return dataType == DataType::BFloat16;
38 }

◆ CompatibleTypes< float >()

bool armnn::CompatibleTypes< float > ( DataType  dataType)
inline

Definition at line 23 of file CompatibleTypes.hpp.

References Float32.

24 {
25  return dataType == DataType::Float32;
26 }

◆ CompatibleTypes< Half >()

bool armnn::CompatibleTypes< Half > ( DataType  dataType)
inline

Definition at line 29 of file CompatibleTypes.hpp.

References Float16.

30 {
31  return dataType == DataType::Float16;
32 }

◆ CompatibleTypes< int16_t >()

bool armnn::CompatibleTypes< int16_t > ( DataType  dataType)
inline

Definition at line 57 of file CompatibleTypes.hpp.

References QSymmS16.

58 {
59  return dataType == DataType::QSymmS16;
60 }

◆ CompatibleTypes< int32_t >()

bool armnn::CompatibleTypes< int32_t > ( DataType  dataType)
inline

Definition at line 63 of file CompatibleTypes.hpp.

References Signed32.

64 {
65  return dataType == DataType::Signed32;
66 }

◆ CompatibleTypes< int8_t >()

bool armnn::CompatibleTypes< int8_t > ( DataType  dataType)
inline

Definition at line 47 of file CompatibleTypes.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, QAsymmS8, QSymmS8, and QuantizedSymm8PerAxis.

48 {
50  return dataType == DataType::QSymmS8
51  || dataType == DataType::QuantizedSymm8PerAxis
52  || dataType == DataType::QAsymmS8;
54 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ CompatibleTypes< uint8_t >()

bool armnn::CompatibleTypes< uint8_t > ( DataType  dataType)
inline

Definition at line 41 of file CompatibleTypes.hpp.

References Boolean, and QAsymmU8.

42 {
43  return dataType == DataType::Boolean || dataType == DataType::QAsymmU8;
44 }

◆ CompleteLeakyReluNetwork()

void armnn::CompleteLeakyReluNetwork ( INetwork network,
IConnectableLayer activation,
IConnectableLayer layerUnderTest,
const TensorInfo info 
)

Definition at line 1676 of file QuantizerTest.cpp.

References INetwork::AddOutputLayer(), IOutputSlot::Connect(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), and IOutputSlot::SetTensorInfo().

Referenced by BOOST_AUTO_TEST_CASE().

1680 {
1681  // Add the output Layer
1682  IConnectableLayer* output = network->AddOutputLayer(3);
1683 
1684  // Establish connections
1685  activation->GetOutputSlot(0).Connect(layerUnderTest->GetInputSlot(0));
1686  layerUnderTest->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1687 
1688  //Set TensorInfo
1689  layerUnderTest->GetOutputSlot(0).SetTensorInfo(info);
1690 }

◆ ComputeAclAxis()

int armnn::ComputeAclAxis ( const int &  armnnAxis,
const armnn::TensorInfo tensor 
)
inline

Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank, rank)

Definition at line 230 of file ArmComputeUtils.hpp.

References ARMNN_ASSERT, and TensorInfo::GetNumDimensions().

Referenced by ClGatherWorkload::ClGatherWorkload(), ClLogSoftmaxWorkload::ClLogSoftmaxWorkload(), ClSoftmaxWorkload::ClSoftmaxWorkload(), NeonGatherWorkload::NeonGatherWorkload(), NeonLogSoftmaxWorkload::NeonLogSoftmaxWorkload(), and NeonSoftmaxWorkload::NeonSoftmaxWorkload().

231 {
232  int rank = static_cast<int>(tensor.GetNumDimensions());
233 
234  ARMNN_ASSERT(rank != 0);
235  ARMNN_ASSERT((-1 * rank) <= armnnAxis);
236  ARMNN_ASSERT(armnnAxis < rank);
237 
238  int sign = (armnnAxis < 0) ? -1 : 1;
239  int aclAxis = sign * rank - 1 - armnnAxis;
240 
241  return aclAxis;
242 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191

◆ ComputePositiveAxis()

unsigned int armnn::ComputePositiveAxis ( const int &  axis,
const armnn::TensorInfo tensor 
)
inline

Function to convert axis to its positive equivalent value.

[-rank, rank) –> [0, rank)

Definition at line 246 of file ArmComputeUtils.hpp.

References ARMNN_ASSERT, and TensorInfo::GetNumDimensions().

247 {
248  int rank = static_cast<int>(tensor.GetNumDimensions());
249 
250  ARMNN_ASSERT(rank != 0);
251  ARMNN_ASSERT((-1 * rank) <= axis);
252  ARMNN_ASSERT(axis < rank);
253 
254  int positiveAxis = (axis < 0) ? rank + axis : axis;
255  return static_cast<unsigned int>(positiveAxis);
256 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191

◆ ComputeSoftmaxAclAxis()

T armnn::ComputeSoftmaxAclAxis ( const SoftmaxDescriptor softmaxDesc,
const armnn::TensorInfo tensor 
)
inline

Definition at line 191 of file ArmComputeUtils.hpp.

References ARMNN_ASSERT, TensorInfo::GetNumDimensions(), and SoftmaxDescriptor::m_Axis.

192 {
193  // Detect the Android default value of -1 and return the ACL default value of 0.
194  if (softmaxDesc.m_Axis == -1)
195  {
196  return 0;
197  }
198 
199  unsigned int dim = tensor.GetNumDimensions();
200 
201  ARMNN_ASSERT(dim != 0);
202 
203  // Currently ArmNN support axis 1.
204  auto aclAxis = (static_cast<T>(dim) - 1);
205  aclAxis = aclAxis > 0 ? aclAxis -1 : aclAxis;
206 
207  return aclAxis;
208 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191

◆ ComputeSplitAxis()

std::set<unsigned int> armnn::ComputeSplitAxis ( const armnn::SplitterDescriptor desc,
const TensorShape input 
)
inline

Definition at line 210 of file ArmComputeUtils.hpp.

References ViewsDescriptor::GetNumDimensions(), ViewsDescriptor::GetNumViews(), and ViewsDescriptor::GetViewSizes().

Referenced by ClSplitterWorkload::ClSplitterWorkload(), SplitterLayer::CreateWorkload(), ClLayerSupport::IsSplitterSupported(), NeonLayerSupport::IsSplitterSupported(), and NeonSplitterWorkload::NeonSplitterWorkload().

211 {
212  unsigned int numSplit = desc.GetNumViews();
213  unsigned int numDimensions = desc.GetNumDimensions();
214  std::set<unsigned int> splitAxis;
215 
216  for (unsigned int i = 0; i < numSplit; ++i)
217  {
218  for (unsigned int dimIdx = 0; dimIdx < numDimensions; ++dimIdx)
219  {
220  if (desc.GetViewSizes(i)[dimIdx] != input[dimIdx])
221  {
222  splitAxis.insert(dimIdx);
223  }
224  }
225  }
226  return splitAxis;
227 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.

◆ Concatenate()

void Concatenate ( const ConcatQueueDescriptor data)

Definition at line 14 of file Concatenate.cpp.

References ARMNN_ASSERT, TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), GetTensorInfo(), QueueDescriptor::m_Inputs, ConcatQueueDescriptor::ViewOrigin::m_Origin, QueueDescriptor::m_Outputs, ConcatQueueDescriptor::m_ViewOrigins, and MaxNumOfTensorDimensions.

Referenced by RefConcatWorkload::Execute().

15 {
16  const TensorInfo& outputInfo0 = GetTensorInfo(data.m_Outputs[0]);
17 
18  std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputInfo0, data.m_Outputs[0]->Map());
19  Encoder<float>& encoder = *encoderPtr;
20 
21  for (unsigned int index = 0 ; index < outputInfo0.GetNumElements(); ++index)
22  {
23  unsigned int indices[MaxNumOfTensorDimensions] = { 0 };
24 
25  unsigned int indexRemainder = index;
26  unsigned int dimensionStride = outputInfo0.GetNumElements();
27 
28  for (unsigned int i = 0; i < outputInfo0.GetNumDimensions(); i++)
29  {
30  dimensionStride /= outputInfo0.GetShape()[i];
31  indices[i] = indexRemainder / dimensionStride; // Use integer division to round down.
32  indexRemainder -= indices[i] * dimensionStride;
33  }
34 
35  for (unsigned int viewIdx = 0; viewIdx < data.m_ViewOrigins.size(); ++viewIdx)
36  {
37  ConcatQueueDescriptor::ViewOrigin const& view = data.m_ViewOrigins[viewIdx];
38 
39  //Split view extents are defined by the size of (the corresponding) input tensor.
40  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[viewIdx]);
41  ARMNN_ASSERT(inputInfo.GetNumDimensions() == outputInfo0.GetNumDimensions());
42 
43  // Check all dimensions to see if this element is inside the given input view.
44  bool insideView = true;
45  for (unsigned int i = 0; i < inputInfo.GetNumDimensions(); i++)
46  {
47  if (indices[i] < view.m_Origin[i])
48  {
49  insideView = false;
50  }
51  if (indices[i] >= view.m_Origin[i] + inputInfo.GetShape()[i])
52  {
53  insideView = false;
54  }
55  }
56 
57  if (insideView)
58  {
59  std::unique_ptr<Decoder<float>> decoderPtr =
60  MakeDecoder<float>(inputInfo, data.m_Inputs[viewIdx]->Map());
61  Decoder<float>& decoder = *decoderPtr;
62  unsigned int inIndex = 0;
63  unsigned int dimensionStride = 1;
64 
65  for (unsigned int i = inputInfo.GetNumDimensions(); i-- > 0;)
66  {
67  inIndex += dimensionStride * (indices[i] - view.m_Origin[i]);
68  dimensionStride *= inputInfo.GetShape()[i];
69  }
70  decoder += inIndex;
71  encoder.Set(decoder.Get());
72 
73  //What should we do if input views overlap on the output tensor?
74  //We could error, take the average, or shm else...
75  //For now just stop after finding first view (input) that matches.
76  break;
77  }
78  }
79  ++encoder;
80  }
81 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ ConditionalThrow() [1/2]

void armnn::ConditionalThrow ( bool  condition,
const std::string &  message 
)

Definition at line 159 of file Exceptions.hpp.

160 {
161  if (!condition)
162  {
163  throw ExceptionType(message);
164  }
165 }

◆ ConditionalThrow() [2/2]

void armnn::ConditionalThrow ( bool  condition)

Definition at line 168 of file Exceptions.hpp.

169 {
170  if (!condition)
171  {
172  throw ExceptionType();
173  }
174 }

◆ ConditionalThrowIfNotEqual()

void armnn::ConditionalThrowIfNotEqual ( const std::string &  message,
const ComparedType &  leftHandSide,
const ComparedType &  rightHandSide 
)

ComparedType must support: operator==(const ComparedType&) operator<<(ostream&, const ComparedType&)

Definition at line 183 of file Exceptions.hpp.

186 {
187  if (!(leftHandSide == rightHandSide))
188  {
189  std::stringstream ss;
190  ss << message << " : " << leftHandSide << " != " << rightHandSide;
191  throw ExceptionType(ss.str());
192  }
193 }

◆ ConfigureLogging()

void ConfigureLogging ( bool  printToStandardOutput,
bool  printToDebugOutput,
LogSeverity  severity 
)

Configures the logging behaviour of the ARMNN library.

printToStandardOutput: Set to true if log messages should be printed to the standard output. printToDebugOutput: Set to true if log messages be printed to a platform-specific debug output (where supported). severity: All log messages that are at this severity level or higher will be printed, others will be ignored.

Definition at line 10 of file Utils.cpp.

References SetAllLoggingSinks(), SetLogFilter(), and Trace.

Referenced by ConfigureLoggingTest(), armnn::test::InferenceTestMain(), LogLevelSwapper::LogLevelSwapper(), main(), and LogLevelSwapper::~LogLevelSwapper().

11 {
12  SetAllLoggingSinks(printToStandardOutput, printToDebugOutput, false);
13  SetLogFilter(severity);
14 }
void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured)
Definition: Logging.cpp:142
void SetLogFilter(LogSeverity level)
Definition: Logging.cpp:24

◆ ConfigureTuner()

void armnn::ConfigureTuner ( arm_compute::CLTuner &  tuner,
TuningLevel  level 
)

Definition at line 114 of file ClBackendContext.cpp.

References Exhaustive, None, Normal, and Rapid.

Referenced by ClBackendContext::ClBackendContext().

115 {
116  tuner.set_tune_new_kernels(true); // Turn on tuning initially.
117 
118  switch (level)
119  {
120  case TuningLevel::Rapid:
121  tuner.set_tuner_mode(arm_compute::CLTunerMode::RAPID);
122  break;
123  case TuningLevel::Normal:
124  tuner.set_tuner_mode(arm_compute::CLTunerMode::NORMAL);
125  break;
126  case TuningLevel::Exhaustive:
127  tuner.set_tuner_mode(arm_compute::CLTunerMode::EXHAUSTIVE);
128  break;
129  case TuningLevel::None:
130  default:
131  tuner.set_tune_new_kernels(false); // Turn off tuning. Set to "use" only mode.
132  break;
133  }
134 }

◆ ConvertActivationDescriptorToAclActivationLayerInfo() [1/2]

arm_compute::ActivationLayerInfo armnn::ConvertActivationDescriptorToAclActivationLayerInfo ( const ActivationDescriptor actDesc)
inline

◆ ConvertActivationDescriptorToAclActivationLayerInfo() [2/2]

arm_compute::ActivationLayerInfo armnn::ConvertActivationDescriptorToAclActivationLayerInfo ( const ActivationDescriptor activationDescPtr)
inline

Definition at line 82 of file ArmComputeUtils.hpp.

References ConvertActivationDescriptorToAclActivationLayerInfo().

83 {
84  if (activationDescPtr != nullptr)
85  {
86  return ConvertActivationDescriptorToAclActivationLayerInfo(static_cast<ActivationDescriptor>(
87  *activationDescPtr));
88  }
89  return arm_compute::ActivationLayerInfo();
90 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor *activationDescPtr)

◆ ConvertActivationFunctionToAclActivationFunction()

arm_compute::ActivationLayerInfo::ActivationFunction armnn::ConvertActivationFunctionToAclActivationFunction ( ActivationFunction  armnnFunction)
inline

Definition at line 51 of file ArmComputeUtils.hpp.

References Abs, BoundedReLu, Elu, HardSwish, LeakyReLu, Linear, ReLu, Sigmoid, SoftReLu, Sqrt, Square, and TanH.

Referenced by ConvertActivationDescriptorToAclActivationLayerInfo().

52 {
53  using AclActivationFunction = arm_compute::ActivationLayerInfo::ActivationFunction;
54 
55  switch (armnnFunction)
56  {
57  case ActivationFunction::Linear: return AclActivationFunction::LINEAR;
58  // Arm compute's 'logistic' function is non-parameterized, so it is exactly a sigmoid function.
59  case ActivationFunction::Sigmoid: return AclActivationFunction::LOGISTIC;
60  case ActivationFunction::ReLu: return AclActivationFunction::RELU;
61  case ActivationFunction::BoundedReLu: return AclActivationFunction::LU_BOUNDED_RELU;
62  case ActivationFunction::SoftReLu: return AclActivationFunction::SOFT_RELU;
63  case ActivationFunction::LeakyReLu: return AclActivationFunction::LEAKY_RELU;
64  case ActivationFunction::Abs: return AclActivationFunction::ABS;
65  case ActivationFunction::Sqrt: return AclActivationFunction::SQRT;
66  case ActivationFunction::Square: return AclActivationFunction::SQUARE;
67  case ActivationFunction::TanH: return AclActivationFunction::TANH;
68  case ActivationFunction::Elu: return AclActivationFunction::ELU;
69  case ActivationFunction::HardSwish: return AclActivationFunction::HARD_SWISH;
70  default: throw InvalidArgumentException("Unsupported activation function");
71  }
72 }
ActivationFunction
Definition: Types.hpp:56

◆ ConvertAdditionalInfoToAclActivationLayerInfo()

arm_compute::ActivationLayerInfo armnn::ConvertAdditionalInfoToAclActivationLayerInfo ( const QueueDescriptor queueDescriptor)
inline

Definition at line 93 of file ArmComputeUtils.hpp.

References ConvertActivationDescriptorToAclActivationLayerInfo(), and QueueDescriptor::GetAdditionalInformation().

Referenced by ClAdditionWorkload::ClAdditionWorkload(), ClDivisionFloatWorkload::ClDivisionFloatWorkload(), ClMultiplicationWorkload::ClMultiplicationWorkload(), ClSubtractionWorkload::ClSubtractionWorkload(), NeonAdditionWorkload::NeonAdditionWorkload(), NeonDivisionWorkload::NeonDivisionWorkload(), NeonMultiplicationWorkload::NeonMultiplicationWorkload(), and NeonSubtractionWorkload::NeonSubtractionWorkload().

94 {
95  const ActivationDescriptor* activationDescPtr = queueDescriptor.GetAdditionalInformation<ActivationDescriptor>();
96 
97  if (activationDescPtr != nullptr)
98  {
99  return ConvertActivationDescriptorToAclActivationLayerInfo(static_cast<ActivationDescriptor>(
100  *activationDescPtr));
101  }
102  return arm_compute::ActivationLayerInfo();
103 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor *activationDescPtr)

◆ ConvertBf16ToFp32Weight()

LayerT* armnn::ConvertBf16ToFp32Weight ( Layer l)

Definition at line 147 of file Network.cpp.

References BFloat16, FloatingPointConverter::ConvertBFloat16ToFloat32(), Convolution2d, Float32, FullyConnected, TensorInfo::GetDataType(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), and info.

148 {
149  LayerT* layer = PolymorphicDowncast<LayerT*>(l);
150  if ((layer->GetType() == LayerType::Convolution2d || layer->GetType() == LayerType::FullyConnected)
151  && layer->m_Weight)
152  {
153  const TensorInfo& info = layer->m_Weight->GetTensorInfo();
154 
155  if (info.GetDataType() == DataType::BFloat16)
156  {
157  std::vector<float> newValues(info.GetNumElements());
158 
160  layer->m_Weight->template GetTensor<armnn::BFloat16>(), info.GetNumElements(), newValues.data());
161 
162  TensorInfo newInfo(info.GetShape(), DataType::Float32);
163  ConstTensor newInput(newInfo, newValues);
164  layer->m_Weight.reset(new ScopedCpuTensorHandle(newInput));
165  }
166  }
167  return layer;
168 }
static void ConvertBFloat16ToFloat32(const void *srcBFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > &rBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.

◆ ConvertComparisonOperationToAcl()

arm_compute::ComparisonOperation armnn::ConvertComparisonOperationToAcl ( const ComparisonDescriptor descriptor)
inline

Definition at line 105 of file ArmComputeUtils.hpp.

References Equal, Greater, GreaterOrEqual, Less, LessOrEqual, ComparisonDescriptor::m_Operation, and NotEqual.

Referenced by ClComparisonWorkload::ClComparisonWorkload(), and NeonComparisonWorkload::NeonComparisonWorkload().

106 {
107  switch (descriptor.m_Operation)
108  {
109  case ComparisonOperation::Greater: return arm_compute::ComparisonOperation::Greater;
110  case ComparisonOperation::GreaterOrEqual: return arm_compute::ComparisonOperation::GreaterEqual;
111  case ComparisonOperation::Less: return arm_compute::ComparisonOperation::Less;
112  case ComparisonOperation::LessOrEqual: return arm_compute::ComparisonOperation::LessEqual;
113  case ComparisonOperation::Equal: return arm_compute::ComparisonOperation::Equal;
114  case ComparisonOperation::NotEqual: return arm_compute::ComparisonOperation::NotEqual;
115  default: throw InvalidArgumentException("Unsupported comparison function");
116  }
117 }

◆ ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo() [1/2]

arm_compute::FullyConnectedLayerInfo armnn::ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo ( const FullyConnectedDescriptor fullyConnectedDesc,
const ActivationDescriptor activationDesc 
)
inline

Definition at line 158 of file ArmComputeUtils.hpp.

References ConvertActivationDescriptorToAclActivationLayerInfo(), and FullyConnectedDescriptor::m_TransposeWeightMatrix.

160 {
161  arm_compute::FullyConnectedLayerInfo fc_info;
162  fc_info.transpose_weights = fullyConnectedDesc.m_TransposeWeightMatrix;
163  fc_info.activation_info = ConvertActivationDescriptorToAclActivationLayerInfo(activationDesc);
164  return fc_info;
165 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor *activationDescPtr)

◆ ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo() [2/2]

arm_compute::FullyConnectedLayerInfo armnn::ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo ( const FullyConnectedDescriptor fullyConnectedDesc,
arm_compute::ActivationLayerInfo  activationLayerInfo 
)
inline

Definition at line 168 of file ArmComputeUtils.hpp.

References FullyConnectedDescriptor::m_TransposeWeightMatrix.

170 {
171  arm_compute::FullyConnectedLayerInfo fc_info;
172  fc_info.transpose_weights = fullyConnectedDesc.m_TransposeWeightMatrix;
173  fc_info.activation_info = activationLayerInfo;
174  return fc_info;
175 }

◆ ConvertLogSeverity()

constexpr LogSeverity armnn::ConvertLogSeverity ( BoostLogSeverityMapping  severity)

Definition at line 157 of file Logging.hpp.

158 {
159  return static_cast<LogSeverity>(severity);
160 }
LogSeverity
Definition: Utils.hpp:12

◆ ConvertMaskToACLFormat()

int32_t ConvertMaskToACLFormat ( int32_t  mask,
int32_t  numDim 
)

Definition at line 193 of file WorkloadUtils.cpp.

Referenced by ClStridedSliceWorkload::ClStridedSliceWorkload(), GatherTensorHandlePairs(), and NeonStridedSliceWorkload::NeonStridedSliceWorkload().

194 {
195  int32_t reversedMask = 0;
196  for (unsigned int i = 0; i < armnn::numeric_cast<unsigned int>(numDim); ++i)
197  {
198  // Check if bit set in mask for each dimension
199  int32_t bit = (mask & 1 << i) != 0;
200  // Increment the new mask with the bits reversed
201  reversedMask += (bit << std::max(numDim-(armnn::numeric_cast<int>(i)+1), 0));
202  }
203 
204  return reversedMask;
205 }

◆ ConvertNormalizationAlgorithmChannelToAclNormType()

arm_compute::NormType armnn::ConvertNormalizationAlgorithmChannelToAclNormType ( NormalizationAlgorithmChannel  channelType)
inline

Definition at line 146 of file ArmComputeUtils.hpp.

References Across, and Within.

147 {
148  using arm_compute::NormType;
149  switch (channelType)
150  {
151  case NormalizationAlgorithmChannel::Across: return NormType::CROSS_MAP;
152  case NormalizationAlgorithmChannel::Within: return NormType::IN_MAP_2D;
153  default: throw InvalidArgumentException("Unsupported normalization algorithm channel type");
154  }
155 }

◆ ConvertOutputShapeRoundingToAclDimensionRoundingType()

arm_compute::DimensionRoundingType armnn::ConvertOutputShapeRoundingToAclDimensionRoundingType ( OutputShapeRounding  rounding)
inline

Definition at line 132 of file ArmComputeUtils.hpp.

References Ceiling, and Floor.

134 {
135  using arm_compute::DimensionRoundingType;
136 
137  switch (rounding)
138  {
139  case OutputShapeRounding::Ceiling: return DimensionRoundingType::CEIL;
140  case OutputShapeRounding::Floor: return DimensionRoundingType::FLOOR;
141  default: throw InvalidArgumentException("Unsupported Output Shape Rounding type");
142  }
143 }

◆ ConvertPoolingAlgorithmToAclPoolingType()

arm_compute::PoolingType armnn::ConvertPoolingAlgorithmToAclPoolingType ( PoolingAlgorithm  poolingAlgorithm)
inline

Definition at line 119 of file ArmComputeUtils.hpp.

References Average, L2, and Max.

120 {
121  using arm_compute::PoolingType;
122 
123  switch (poolingAlgorithm)
124  {
125  case PoolingAlgorithm::Max: return PoolingType::MAX;
126  case PoolingAlgorithm::Average: return PoolingType::AVG;
127  case PoolingAlgorithm::L2: return PoolingType::L2;
128  default: throw InvalidArgumentException("Unsupported pooling algorithm");
129  }
130 }

◆ ConvertResizeMethodToAclInterpolationPolicy()

arm_compute::InterpolationPolicy armnn::ConvertResizeMethodToAclInterpolationPolicy ( ResizeMethod  resizeMethod)
inline

Definition at line 177 of file ArmComputeUtils.hpp.

References Bilinear, and NearestNeighbor.

178 {
179  switch (resizeMethod)
180  {
181  case ResizeMethod::Bilinear:
182  return arm_compute::InterpolationPolicy::BILINEAR;
183  case ResizeMethod::NearestNeighbor:
184  return arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR;
185  default:
186  throw InvalidArgumentException("Unsupported resize method");
187  }
188 }

◆ ConvertWeightTensorFromArmnnToAcl()

armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl ( const ConstCpuTensorHandle weightTensor,
DataLayout  dataLayout,
void *  permuteBuffer 
)

Definition at line 133 of file WorkloadUtils.cpp.

References ARMNN_ASSERT_MSG, ARMNN_FALLTHROUGH, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, Float16, Float32, BaseTensor< MemoryType >::GetDataType(), BaseTensor< MemoryType >::GetInfo(), TensorInfo::GetShape(), ConstCpuTensorHandle::GetTensorInfo(), NCHW, NHWC, PermuteTensor(), QAsymmS8, QAsymmU8, QSymmS8, QuantizedSymm8PerAxis, and ReshapeWeightsForAcl().

Referenced by ClDepthwiseConvolutionWorkload::ClDepthwiseConvolutionWorkload(), GatherTensorHandlePairs(), and NeonDepthwiseConvolutionWorkload::NeonDepthwiseConvolutionWorkload().

136 {
137  ARMNN_ASSERT_MSG(weightTensor, "Invalid input tensor");
138  ARMNN_ASSERT_MSG(permuteBuffer, "Invalid permute buffer");
139 
140  auto multiplier = weightTensor->GetTensorInfo().GetShape()[0];
141  auto inputChannels = weightTensor->GetTensorInfo().GetShape()[1];
142 
143  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
144  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
145 
146  // 1. Permute the weights if necessary
147  // If the data layout is NCHW no permutation is necessary, as a reshape to [ 1, I * M, H, W ] can be better done
148  // starting from the current shape of [ M, I, H, W ]
149  // If no permutation is necessary, leave the permutation vector empty
150  PermutationVector permutationVector{};
151  if (dataLayout == DataLayout::NHWC)
152  {
153  // The data layout is NHWC, then permute the weights from [ M, I, H, W ] to [ H, W, I, M ]
154  permutationVector = { 3, 2, 0, 1 };
155  }
156  ConstTensor weightPermuted = PermuteTensor(weightTensor, permutationVector, permuteBuffer);
157 
158  // Shuffle the weights data to obtain the channel order needed used by Acl
159  if (multiplier > 1 && inputChannels > 1 && dataLayout == DataLayout::NCHW)
160  {
161  switch (weightPermuted.GetDataType())
162  {
163  case DataType::Float32:
164  weightPermuted = ReorderWeightChannelsForAcl<float>(weightPermuted, dataLayout, permuteBuffer);
165  break;
166  case DataType::Float16:
167  weightPermuted =
168  ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
169  break;
170  case DataType::QAsymmS8:
171  case DataType::QAsymmU8:
172  weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
173  break;
175  case DataType::QuantizedSymm8PerAxis:
177  case DataType::QSymmS8:
178  weightPermuted = ReorderWeightChannelsForAcl<int8_t>(weightPermuted, dataLayout, permuteBuffer);
179  break;
181  default:
182  break;
183  }
184  }
185 
186  // 2. Reshape the weights
187  ReshapeWeightsForAcl(weightPermuted.GetInfo(), dataLayout);
188 
189  // 3. Return both the tensor and the allocated storage to ensure that the data stays alive
190  return weightPermuted;
191 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
armnn::ConstTensor PermuteTensor(const ConstCpuTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35
void ReshapeWeightsForAcl(TensorInfo &weightInfo, DataLayout dataLayout)

◆ ConvertWeightTensorInfoFromArmnnToAcl()

TensorInfo ConvertWeightTensorInfoFromArmnnToAcl ( const TensorInfo weightInfo,
DataLayout  dataLayout 
)

Definition at line 110 of file WorkloadUtils.cpp.

References NHWC, armnnUtils::Permuted(), and ReshapeWeightsForAcl().

Referenced by GatherTensorHandlePairs().

111 {
112  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
113  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
114 
115  // 1. Permute the weights if necessary
116  // If the data layout is NCHW no permutation is necessary, as a reshape to [ 1, I * M, H, W ] can be better done
117  // starting from the current shape of [ M, I, H, W ]
118  TensorInfo weightPermutedInfo(weightInfo);
119  if (dataLayout == DataLayout::NHWC)
120  {
121  // The data layout is NHWC, then permute the weights from [ M, I, H, W ] to [ H, W, I, M ]
122  PermutationVector permutationVector{ 3, 2, 0, 1 };
123  weightPermutedInfo = armnnUtils::Permuted(weightInfo, permutationVector);
124  }
125 
126  // 2. Reshape the weights
127  ReshapeWeightsForAcl(weightPermutedInfo, dataLayout);
128 
129  // 3. Return the permuted weight info
130  return weightPermutedInfo;
131 }
void ReshapeWeightsForAcl(TensorInfo &weightInfo, DataLayout dataLayout)
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98

◆ Convolve()

void Convolve ( const TensorShape rInputShape,
Decoder< float > &  rInputDecoder,
const TensorShape rOutputShape,
Encoder< float > &  rOutputEncoder,
const TensorShape rFilterShape,
Decoder< float > &  rFilterDecoder,
bool  biasEnabled,
Decoder< float > *  pBiasDecoder,
DataLayout  dataLayout,
unsigned int  paddingTop,
unsigned int  paddingLeft,
unsigned int  xStride,
unsigned int  yStride,
unsigned int  xDilation,
unsigned int  yDilation,
bool  depthwise 
)

Definition at line 71 of file ConvImpl.cpp.

References Decoder< IType >::DecodeTensor(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetDataLayout(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetWidthIndex(), NHWC, and Encoder< IType >::Set().

Referenced by RefDepthwiseConvolution2dWorkload::Execute(), and RefConvolution2dWorkload::Execute().

87 {
88  if (biasEnabled && !pBiasDecoder)
89  {
90  throw InvalidArgumentException("Bias is enabled but the bias data is invalid");
91  }
92  const armnnUtils::DataLayoutIndexed dataLayoutIndexed(dataLayout);
93 
94  const unsigned int channelsIndex = dataLayoutIndexed.GetChannelsIndex();
95  const unsigned int heightIndex = dataLayoutIndexed.GetHeightIndex();
96  const unsigned int widthIndex = dataLayoutIndexed.GetWidthIndex();
97 
98  const unsigned int depthMultiplier = depthwise ? rFilterShape[0] : 1;
99  const unsigned int inputChannels = depthwise ? rFilterShape[1] : rFilterShape[channelsIndex];
100  const unsigned int outputChannels = depthwise ? inputChannels * depthMultiplier : rFilterShape[0];
101 
102  const unsigned int batchSize = rOutputShape[0];
103  const unsigned int outputHeight = rOutputShape[heightIndex];
104  const unsigned int outputWidth = rOutputShape[widthIndex];
105  const unsigned int inputHeight = rInputShape[heightIndex];
106  const unsigned int inputWidth = rInputShape[widthIndex];
107 
108  const unsigned int filterHeight = depthwise ? rFilterShape[2] : rFilterShape[heightIndex];
109  const unsigned int filterWidth = depthwise ? rFilterShape[3] : rFilterShape[widthIndex];
110 
111  const std::vector<float> inputVec = rInputDecoder.DecodeTensor(rInputShape);
112  const std::vector<float> filterVec = rFilterDecoder.DecodeTensor(rFilterShape, depthMultiplier, depthwise);
113 
114  const TensorShape biasShape{outputChannels};
115  const std::vector<float> biasVec = biasEnabled ? pBiasDecoder->DecodeTensor(biasShape) : std::vector<float>();
116 
117  unsigned int depthwiseMultiplierIdx = 0;
118  for (unsigned int batchIdx = 0; batchIdx < batchSize; batchIdx++)
119  {
120  for (unsigned int cOutput = 0; cOutput < outputChannels; cOutput++)
121  {
122  for (unsigned int yOutput = 0; yOutput < outputHeight; yOutput++)
123  {
124  for (unsigned int xOutput = 0; xOutput < outputWidth; xOutput++)
125  {
126  // This loop goes over each output element.
127  float sum = 0.0f;
128 
129  // For depthwise, each output channel corresponds to exactly one input channel.
130  // For normal, must loop over each input channel.
131  for (unsigned int cInput = 0; cInput < (depthwise ? 1 : inputChannels); cInput++)
132  {
133  if (depthwise)
134  {
135  depthwiseMultiplierIdx = 0;
136  cInput = cOutput / depthMultiplier;
137  depthwiseMultiplierIdx = cOutput % depthMultiplier;
138  }
139 
140  for (unsigned int yFilter = 0; yFilter < filterHeight; yFilter++)
141  {
142  for (unsigned int xFilter = 0; xFilter < filterWidth; xFilter++)
143  {
144  // This loop goes over each input element for each output element.
145  unsigned int filterIndex = 0;
146 
147  // Since dimensionality of kernel depends on depthwiseness, so does index.
148  if (depthwise)
149  {
150  filterIndex = depthwiseMultiplierIdx * filterWidth * filterHeight * inputChannels +
151  cInput * filterWidth * filterHeight +
152  yFilter * filterWidth +
153  xFilter;
154  }
155  else
156  {
157  // Keep this implementation, as using DataLayoutIndexed::GetIndex causes great
158  // performance regression.
159  if (dataLayoutIndexed.GetDataLayout() == DataLayout::NHWC)
160  {
161  filterIndex = cOutput * filterHeight * filterWidth * inputChannels +
162  yFilter * filterWidth * inputChannels +
163  xFilter * inputChannels +
164  cInput;
165  }
166  else
167  {
168  filterIndex = cOutput * filterWidth * filterHeight * inputChannels +
169  cInput * filterWidth * filterHeight +
170  yFilter * filterWidth +
171  xFilter;
172  }
173  }
174 
175  unsigned int yInput = yOutput * yStride + yFilter * yDilation;
176  unsigned int xInput = xOutput * xStride + xFilter * xDilation;
177 
178  float inputValue;
179 
180  // Check if we're in the padding.
181  if (yInput < paddingTop || yInput >= inputHeight + paddingTop ||
182  xInput < paddingLeft || xInput >= inputWidth + paddingLeft)
183  {
184  inputValue = 0.0f;
185  }
186  else
187  {
188  unsigned int inputIndex = 0;
189 
190  // Keep this implementation, as using DataLayoutIndexed::GetIndex causes great
191  // performance regression.
192  if (dataLayoutIndexed.GetDataLayout() == DataLayout::NHWC)
193  {
194  inputIndex = batchIdx * inputHeight * inputWidth * inputChannels +
195  (yInput - paddingTop) * inputWidth * inputChannels +
196  (xInput - paddingLeft) * inputChannels +
197  cInput;
198  }
199  else
200  {
201  inputIndex = batchIdx * inputWidth * inputHeight * inputChannels +
202  inputWidth * inputHeight * cInput +
203  inputWidth * (yInput - paddingTop) +
204  xInput - paddingLeft;
205  }
206  inputValue = inputVec[inputIndex];
207  }
208 
209  sum += filterVec[filterIndex] * inputValue;
210  }
211  }
212  }
213 
214  if (biasEnabled)
215  {
216  sum += biasVec[cOutput];
217  }
218 
219  unsigned int outIdx;
220  if (dataLayoutIndexed.GetDataLayout() == DataLayout::NHWC)
221  {
222  outIdx = batchIdx * outputHeight * outputWidth * outputChannels +
223  yOutput * outputWidth * outputChannels +
224  xOutput * outputChannels +
225  cOutput;
226  }
227  else
228  {
229  outIdx = batchIdx * outputHeight * outputWidth * outputChannels +
230  cOutput * outputHeight * outputWidth +
231  yOutput * outputWidth +
232  xOutput;
233  }
234 
235  rOutputEncoder[outIdx];
236  rOutputEncoder.Set(sum);
237  }
238  }
239  }
240  }
241 }
virtual void Set(IType right)=0
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, const unsigned int channelMultiplier=1, bool isDepthwise=false)=0
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...

◆ CopyArmComputeClTensorData()

void armnn::CopyArmComputeClTensorData ( arm_compute::CLTensor &  dstTensor,
const T *  srcData 
)

Definition at line 30 of file ClWorkloadUtils.hpp.

References ARMNN_SCOPED_PROFILING_EVENT_CL.

Referenced by ClConstantWorkload::Execute().

31 {
32  {
33  ARMNN_SCOPED_PROFILING_EVENT_CL("MapClTensorForWriting");
34  dstTensor.map(true);
35  }
36 
37  {
38  ARMNN_SCOPED_PROFILING_EVENT_CL("CopyToClTensor");
39  armcomputetensorutils::CopyArmComputeITensorData<T>(srcData, dstTensor);
40  }
41 
42  dstTensor.unmap();
43 }
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)

◆ CopyArmComputeTensorData()

void armnn::CopyArmComputeTensorData ( arm_compute::Tensor &  dstTensor,
const T *  srcData 
)

Definition at line 29 of file NeonWorkloadUtils.hpp.

Referenced by InitializeArmComputeTensorData().

30 {
31  InitialiseArmComputeTensorEmpty(dstTensor);
32  CopyArmComputeITensorData(srcData, dstTensor);
33 }

◆ CopyTensorContentsGeneric()

void armnn::CopyTensorContentsGeneric ( const ITensorHandle srcTensor,
ITensorHandle dstTensor,
CopyFunc  copy 
)

Definition at line 47 of file WorkloadUtils.hpp.

References ARMNN_ASSERT, ARMNN_SCOPED_PROFILING_EVENT, TensorShape::GetNumDimensions(), ITensorHandle::GetShape(), ITensorHandle::GetStrides(), IgnoreUnused(), ITensorHandle::Map(), MaxNumOfTensorDimensions, Undefined, and ITensorHandle::Unmap().

Referenced by NeonConvertBf16ToFp32Workload::Execute(), NeonConvertFp32ToFp16Workload::Execute(), NeonConvertFp32ToBf16Workload::Execute(), NeonConvertFp16ToFp32Workload::Execute(), and CopyMemGenericWorkload::Execute().

48 {
49  // For ease of understanding, names are assigned to the dimensions
50  // of the tensor as if NHWC, however this routine works with any 5D tensor
51  static_assert(MaxNumOfTensorDimensions == 5, "Please update CopyTensorContents");
52 
53  TensorShape srcStrides = srcTensor->GetStrides();
54  const TensorShape& srcShape = srcTensor->GetShape();
55  const auto srcSize = srcTensor->GetStrides()[0] * srcShape[0];
56  IgnoreUnused(srcSize); // Only used for asserts
57  TensorShape dstStrides = dstTensor->GetStrides();
58  const TensorShape& dstShape = dstTensor->GetShape();
59  const auto dstSize = dstTensor->GetStrides()[0] * dstShape[0];
60  IgnoreUnused(dstSize); // Only used for asserts
61 
62  size_t srcDepth = 1;
63  size_t srcBatches = 1;
64  size_t srcHeight = 1;
65  size_t srcWidth = 1;
66  size_t srcChannels = 1;
67  AssignValues(srcShape.GetNumDimensions(),
68  0,
69  srcShape,
70  srcChannels,
71  srcWidth,
72  srcHeight,
73  srcBatches,
74  srcDepth);
75 
76  size_t srcDepthStride = 0;
77  size_t srcBatchStride = 0;
78  size_t srcHeightStride = 0;
79  size_t srcWidthStride = 0;
80  size_t srcChannelStride = 0;
81  AssignValues(srcStrides.GetNumDimensions(),
82  0,
83  srcStrides,
84  srcChannelStride,
85  srcWidthStride,
86  srcHeightStride,
87  srcBatchStride,
88  srcDepthStride);
89 
90  size_t dstDepth = 1;
91  size_t dstBatches = 1;
92  size_t dstHeight = 1;
93  size_t dstWidth = 1;
94  size_t dstChannels = 1;
95  AssignValues(dstShape.GetNumDimensions(),
96  0,
97  dstShape,
98  dstChannels,
99  dstWidth,
100  dstHeight,
101  dstBatches,
102  dstDepth);
103 
104  size_t dstDepthStride = 0;
105  size_t dstBatchStride = 0;
106  size_t dstHeightStride = 0;
107  size_t dstWidthStride = 0;
108  size_t dstChannelStride = 0;
109  AssignValues(dstStrides.GetNumDimensions(),
110  0,
111  dstStrides,
112  dstChannelStride,
113  dstWidthStride,
114  dstHeightStride,
115  dstBatchStride,
116  dstDepthStride);
117 
118  const unsigned char* srcDataStart;
119  unsigned char* dstDataStart;
120  {
121  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Synchronize buffers");
122  srcDataStart = static_cast<const uint8_t*>(srcTensor->Map());
123  dstDataStart = static_cast<uint8_t*>(dstTensor->Map());
124  }
125 
126  size_t copyLength = std::min(srcChannels * srcChannelStride, dstChannels * dstChannelStride);
127  size_t copyWidth = std::min(srcWidth, dstWidth);
128  size_t copyHeight = std::min(srcHeight, dstHeight);
129  size_t copyBatches = std::min(srcBatches, dstBatches);
130  size_t copyDepth = std::min(srcDepth, dstDepth);
131 
132  // Coalesce inner dimensions where possible
133  // to reduce overheard calling copy() and to
134  // allow for memory bandwidth optimisations
135  if (copyLength == srcWidthStride &&
136  copyLength == dstWidthStride)
137  {
138  // There is no special padding between rows,
139  // and sizes are compatible, so copy whole rows
140  copyLength *= copyWidth;
141  copyWidth = 1;
142 
143  if (copyLength == srcHeightStride &&
144  copyLength == dstHeightStride)
145  {
146  // There is no special padding between batches
147  // and sizes are compatible so copy whole batches
148  copyLength *= copyHeight;
149  copyHeight = 1;
150  }
151  }
152 
153  const unsigned char* srcData = srcDataStart;
154  unsigned char* dstData = dstDataStart;
155  for (unsigned int d = 0; d < copyDepth; ++d)
156  {
157  auto srcPtrDepth = srcData;
158  auto dstPtrDepth = dstData;
159  for (unsigned int b = 0; b < copyBatches; ++b)
160  {
161  auto srcPtrBatch = srcData;
162  auto dstPtrBatch = dstData;
163  for (unsigned int h = 0; h < copyHeight; ++h)
164  {
165  auto srcPtrChannel = srcData;
166  auto dstPtrChannel = dstData;
167  for (unsigned int w = 0; w < copyWidth; ++w)
168  {
169  ARMNN_ASSERT(srcData >= srcDataStart && srcData + copyLength <= srcDataStart + srcSize);
170  ARMNN_ASSERT(dstData >= dstDataStart && dstData + copyLength <= dstDataStart + dstSize);
171  copy(dstData, srcData, copyLength);
172  dstData += dstWidthStride;
173  srcData += srcWidthStride;
174  }
175  dstData += (static_cast<long>(dstHeightStride) - (dstData - dstPtrChannel));
176  srcData += (static_cast<long>(srcHeightStride) - (srcData - srcPtrChannel));
177  }
178  dstData += (static_cast<long>(dstBatchStride) - (dstData - dstPtrBatch));
179  srcData += (static_cast<long>(srcBatchStride) - (srcData - srcPtrBatch));
180  }
181  dstData += (static_cast<long>(dstDepthStride) - (dstData - dstPtrDepth));
182  srcData += (static_cast<long>(srcDepthStride) - (srcData - srcPtrDepth));
183  }
184 
185  srcTensor->Unmap();
186  dstTensor->Unmap();
187 }
void IgnoreUnused(Ts &&...)
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:175
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ CreateAclNormalizationLayerInfoForL2Normalization()

arm_compute::NormalizationLayerInfo armnn::CreateAclNormalizationLayerInfoForL2Normalization ( const armnn::TensorInfo tensorInfo,
armnn::DataLayout  dataLayout 
)
inline

Definition at line 18 of file ArmComputeUtils.hpp.

References TensorInfo::GetShape(), and NCHW.

20 {
21  unsigned int depthDimension = dataLayout == armnn::DataLayout::NCHW ? 1 : 3;
22  const unsigned int depth = tensorInfo.GetShape()[depthDimension];
23 
24  // At the time of writing, {CL|Neon}L2Normalization performs the reduction only along dimension 0. This version of
25  // L2 Normalization always performs the reduction along the depth axis, though. Thus, we repurpose
26  // {CL|Neon}NormalizationLayers to act as depthwise L2 normalizations by carefully chosing the normalization
27  // parameters.
28  //
29  // Please refer to both the reference implementation of the normalization layer and the implementation of
30  // {CL|Neon}NormalizationLayer when checking the derivations for the parameter values below.
31 
32  // Make sure normalization covers the entire depth range. ACL requires the normalization size to be odd.
33  // CL: This does not result in extra kernel threads not doing any work: See usage of the RADIUS parameter in
34  // ACL's normalization_layer_cross_map() CL function.
35  const uint32_t normSize = depth * 2u + 1u;
36 
37  // See ACL's NormalizationLayerInfo::scale_coeff() definition.
38  // For the reference implementation, to make alpha_ become 1, we'd have to use alpha = normSize instead.
39  const float alpha = 1.0f;
40 
41  // Don't offset the reduction.
42  const float kappa = 0.0f;
43 
44  // pow(reduction, -0.5) = 1 / sqrt(reduction)
45  const float beta = 0.5f;
46 
47  return arm_compute::NormalizationLayerInfo(arm_compute::NormType::CROSS_MAP, normSize, alpha, beta, kappa, false);
48 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187

◆ CreateDescriptorForConcatenation()

OriginsDescriptor armnn::CreateDescriptorForConcatenation ( TensorShapeIt  first,
TensorShapeIt  last,
unsigned int  concatenationDimension 
)

Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing concatenation of a number of input tensors.

Definition at line 253 of file Descriptors.hpp.

References OriginsDescriptor::SetConcatAxis(), and OriginsDescriptor::SetViewOriginCoord().

Referenced by BOOST_AUTO_TEST_CASE(), ConcatDifferentInputOutputQParamTest(), CreateDescriptorForConcat(), and CreateMergerDescriptorForConcatenation().

256 {
257  auto numInputs = std::distance(first, last);
258 
259  if (numInputs < 2)
260  {
261  throw InvalidArgumentException("Concatenation requires at least 2 inputs");
262  }
263 
264  const auto& firstInputShape = *first;
265 
266  const unsigned int numDimensions = firstInputShape.GetNumDimensions();
267  for (auto it = first + 1; it != last; ++it)
268  {
269  if (it->GetNumDimensions() != numDimensions)
270  {
271  throw InvalidArgumentException("All inputs to concatenation must have the same number of dimensions");
272  }
273  }
274 
275  if (concatenationDimension >= numDimensions)
276  {
277  throw InvalidArgumentException("concatenationDimension must be between 0 and the number of dimensions.");
278  }
279 
280  for (auto it = first; it != last; ++it)
281  {
282  for (unsigned int d = 0; d < numDimensions; ++d)
283  {
284  const bool dimSizeOk = (d == concatenationDimension) || (firstInputShape[d] == (*it)[d]);
285  if (!dimSizeOk)
286  {
287  throw InvalidArgumentException("All inputs to concatenation must be the same size along all dimensions "
288  " except the concatenation dimension");
289  }
290  }
291  }
292 
293  OriginsDescriptor viewsDescriptor(static_cast<uint32_t>(numInputs), numDimensions);
294  viewsDescriptor.SetConcatAxis(concatenationDimension);
295 
296  uint32_t viewIndex = 0u;
297  uint32_t coordAlongConcatDim = 0u;
298  for (auto it = first; it != last; ++it)
299  {
300  const auto& inputShape = *it;
301 
302  for (unsigned int i = 0; i < concatenationDimension; ++i)
303  {
304  viewsDescriptor.SetViewOriginCoord(viewIndex, i, 0);
305  }
306 
307  viewsDescriptor.SetViewOriginCoord(viewIndex, concatenationDimension, coordAlongConcatDim);
308  unsigned int dimSize = inputShape[concatenationDimension];
309  coordAlongConcatDim += dimSize;
310 
311 
312  for (unsigned int i = concatenationDimension + 1; i < numDimensions; ++i)
313  {
314  viewsDescriptor.SetViewOriginCoord(viewIndex, i, 0);
315  }
316 
317  ++viewIndex;
318  }
319 
320  return viewsDescriptor;
321 }

◆ CreateMergerDescriptorForConcatenation()

OriginsDescriptor armnn::CreateMergerDescriptorForConcatenation ( TensorShapeIt  first,
TensorShapeIt  last,
unsigned int  concatenationDimension 
)

Definition at line 243 of file Descriptors.hpp.

References CreateDescriptorForConcatenation().

246 {
247  return CreateDescriptorForConcatenation(first, last, concatenationDimension);
248 }
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...

◆ CreateNetworkWithActivationLayer()

INetworkPtr armnn::CreateNetworkWithActivationLayer ( const ActivationDescriptor descriptor,
const TensorShape shape 
)

Definition at line 296 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, and IOutputSlot::SetTensorInfo().

Referenced by BOOST_AUTO_TEST_CASE().

297 {
298  INetworkPtr network = INetwork::Create();
299 
300  // Add the layers
301  IConnectableLayer* input0 = network->AddInputLayer(0);
302  IConnectableLayer* activation = network->AddActivationLayer(descriptor);
303  IConnectableLayer* output = network->AddOutputLayer(2);
304 
305  // Establish connections
306  input0->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
307  activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
308 
309  // Set TensorInfo
310  TensorInfo info(shape, DataType::Float32);
311  input0->GetOutputSlot(0).SetTensorInfo(info);
312  activation->GetOutputSlot(0).SetTensorInfo(info);
313 
314  return network;
315 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ CreateNetworkWithFullyConnectedLayer()

INetworkPtr armnn::CreateNetworkWithFullyConnectedLayer ( const bool  biasEnabled,
const TensorShape inputShape,
const TensorShape outputShape 
)

Definition at line 1061 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, FullyConnectedDescriptor::m_BiasEnabled, and IOutputSlot::SetTensorInfo().

Referenced by ValidateFullyConnectedLayer().

1064 {
1065  FullyConnectedDescriptor desc;
1066  desc.m_BiasEnabled = biasEnabled;
1067  INetworkPtr network = INetwork::Create();
1068 
1069  const TensorInfo info(inputShape, DataType::Float32);
1070  const TensorInfo outputInfo(outputShape, DataType::Float32);
1071 
1072  std::vector<float> weightsData{-1.0f, 1.5f, 2.0f};
1073  ConstTensor weights(info, weightsData);
1074 
1075  // Add the layers
1076  IConnectableLayer* input0 = network->AddInputLayer(0);
1077  IConnectableLayer* fullyConnected;
1078  Optional<ConstTensor> optionalBias;
1079  std::vector<float> biasData{10.0f, 20.0f, 30.0f};
1080  if (desc.m_BiasEnabled)
1081  {
1082  ConstTensor bias(info, biasData);
1083  optionalBias = Optional<ConstTensor>(bias);
1084  }
1085  fullyConnected = network->AddFullyConnectedLayer(desc, weights, optionalBias);
1086  IConnectableLayer* output = network->AddOutputLayer(1);
1087 
1088  // Establish connections
1089  input0->GetOutputSlot(0).Connect(fullyConnected->GetInputSlot(0));
1090  fullyConnected->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1091 
1092  // Set TensorInfo
1093  input0->GetOutputSlot(0).SetTensorInfo(info);
1094  fullyConnected->GetOutputSlot(0).SetTensorInfo(outputInfo);
1095 
1096  return network;
1097 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ CreateNetworkWithInputOutputLayers()

INetworkPtr armnn::CreateNetworkWithInputOutputLayers ( )

Definition at line 317 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, and IOutputSlot::SetTensorInfo().

Referenced by BOOST_AUTO_TEST_CASE().

318 {
319  INetworkPtr network = INetwork::Create();
320 
321  // Add input/output layers
322  IConnectableLayer* inputLayer = network->AddInputLayer(0);
323  IConnectableLayer* output = network->AddOutputLayer(1);
324 
325  // Establish connections
326  inputLayer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
327 
328  // Set TensorInfo
329  TensorShape shape{8U};
330  TensorInfo info(shape, DataType::Float32);
331  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
332 
333  return network;
334 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ CreateNetworkWithSoftmaxLayer()

INetworkPtr armnn::CreateNetworkWithSoftmaxLayer ( const SoftmaxDescriptor descriptor,
const TensorShape shape 
)

Definition at line 1538 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, and IOutputSlot::SetTensorInfo().

Referenced by BOOST_AUTO_TEST_CASE().

1539 {
1540  INetworkPtr network = INetwork::Create();
1541 
1542  // Add the layers
1543  IConnectableLayer* input0 = network->AddInputLayer(0);
1544  IConnectableLayer* softmax = network->AddSoftmaxLayer(descriptor);
1545  IConnectableLayer* output = network->AddOutputLayer(2);
1546 
1547  // Establish connections
1548  input0->GetOutputSlot(0).Connect(softmax->GetInputSlot(0));
1549  softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1550 
1551  // Set TensorInfo
1552  TensorInfo info(shape, DataType::Float32);
1553  input0->GetOutputSlot(0).SetTensorInfo(info);
1554  softmax->GetOutputSlot(0).SetTensorInfo(info);
1555 
1556  return network;
1557 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ CreateQuantizedConst()

ConstTensor CreateQuantizedConst ( const ConstTensor tensor,
std::vector< uint8_t > &  backing 
)

Definition at line 15 of file NetworkQuantizerUtils.cpp.

References ARMNN_ASSERT_MSG, Float32, TensorInfo::GetDataType(), BaseTensor< MemoryType >::GetInfo(), BaseTensor< MemoryType >::GetMemoryArea(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), QAsymmU8, and QuantizeConstant().

Referenced by QuantizeConstant(), QuantizerVisitor::VisitBatchNormalizationLayer(), QuantizerVisitor::VisitConstantLayer(), QuantizerVisitor::VisitConvolution2dLayer(), QuantizerVisitor::VisitDepthwiseConvolution2dLayer(), QuantizerVisitor::VisitFullyConnectedLayer(), and QuantizerVisitor::VisitTransposeConvolution2dLayer().

16 {
17  float scale = 0.0f;
18  int offset = 0;
19 
20  // Reserve the backing memory
21  backing.resize(tensor.GetInfo().GetNumElements());
22 
23  DataType type = tensor.GetInfo().GetDataType();
24  switch(type)
25  {
26  case DataType::Float32:
27  {
28  QuantizeConstant(static_cast<const float*>(tensor.GetMemoryArea()),
29  backing.data(),
30  backing.size(),
31  scale,
32  offset);
33  }
34  break;
35  default:
36  ARMNN_ASSERT_MSG(false, "Can't quantize unsupported data type");
37  }
38 
39  TensorInfo qInfo(tensor.GetInfo().GetShape(), DataType::QAsymmU8, scale, offset);
40  return ConstTensor(qInfo, backing);
41 }
DataType
Definition: Types.hpp:32
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
void QuantizeConstant(const srcType *src, uint8_t *dst, size_t numElements, float &scale, int &offset)

◆ CreateStartOfLeakyReluNetwork()

IConnectableLayer* armnn::CreateStartOfLeakyReluNetwork ( INetwork network,
const TensorInfo info 
)

Definition at line 1655 of file QuantizerTest.cpp.

References INetwork::AddActivationLayer(), INetwork::AddInputLayer(), IOutputSlot::Connect(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), LeakyReLu, ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, and IOutputSlot::SetTensorInfo().

Referenced by BOOST_AUTO_TEST_CASE().

1656 {
1657  ActivationDescriptor activationDescriptor;
1658  activationDescriptor.m_Function = ActivationFunction::LeakyReLu;
1659  activationDescriptor.m_A = 3.5f;
1660  activationDescriptor.m_B = -10.0f;
1661 
1662  // Add the layers
1663  IConnectableLayer* input0 = network->AddInputLayer(0);
1664  IConnectableLayer* activation = network->AddActivationLayer(activationDescriptor);
1665 
1666  // Establish connections
1667  input0->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
1668 
1669  // Set TensorInfo
1670  input0->GetOutputSlot(0).SetTensorInfo(info);
1671  activation->GetOutputSlot(0).SetTensorInfo(info);
1672 
1673  return activation;
1674 }

◆ CreateSupportedBackends()

BackendsMap CreateSupportedBackends ( TensorHandleFactoryRegistry handleFactoryRegistry,
BackendSettings backendSettings 
)

Definition at line 518 of file Network.cpp.

References ARMNN_ASSERT, BackendRegistryInstance(), and BackendSettings::m_SupportedBackends.

Referenced by Optimize().

520 {
521  BackendsMap backends;
522  auto const& backendRegistry = BackendRegistryInstance();
523  for (auto&& selectedBackend : backendSettings.m_SupportedBackends)
524  {
525  auto backendFactory = backendRegistry.GetFactory(selectedBackend);
526  auto backendObjPtr = backendFactory();
527  ARMNN_ASSERT(backendObjPtr);
528 
529  backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
530 
531  backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
532  }
533 
534  return backends;
535 }
BackendRegistry & BackendRegistryInstance()
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:325

◆ Debug()

void Debug ( const TensorInfo inputInfo,
const T *  inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Definition at line 18 of file Debug.cpp.

References Debug< BFloat16 >(), Debug< float >(), Debug< Half >(), Debug< int16_t >(), Debug< int32_t >(), Debug< int8_t >(), Debug< uint8_t >(), TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), and TensorInfo::GetShape().

Referenced by RefDebugWorkload< DataType >::Execute().

23 {
24  const unsigned int numDims = inputInfo.GetNumDimensions();
25  const unsigned int numElements = inputInfo.GetNumElements();
26  const TensorShape& inputShape = inputInfo.GetShape();
27 
28  std::vector<unsigned int> strides(numDims, 0);
29  strides[numDims - 1] = inputShape[numDims - 1];
30 
31  for (unsigned int i = 2; i <= numDims; i++)
32  {
33  strides[numDims - i] = strides[numDims - i + 1] * inputShape[numDims - i];
34  }
35 
36  std::cout << "{ ";
37  std::cout << "\"layerGuid\": " << guid << ", ";
38  std::cout << "\"layerName\": \"" << layerName << "\", ";
39  std::cout << "\"outputSlot\": " << slotIndex << ", ";
40  std::cout << "\"shape\": ";
41 
42  std::cout << "[";
43  for (unsigned int i = 0; i < numDims; i++)
44  {
45  std::cout << inputShape[i];
46  if (i != numDims - 1)
47  {
48  std::cout << ", ";
49  }
50  }
51  std::cout << "], ";
52 
53  std::cout << "\"min\": "
54  << static_cast<float>(*std::min_element(inputData, inputData + numElements)) << ", ";
55 
56  std::cout << "\"max\": "
57  << static_cast<float>(*std::max_element(inputData, inputData + numElements)) << ", ";
58 
59  std::cout << "\"data\": ";
60 
61  for (unsigned int i = 0; i < numElements; i++)
62  {
63  for (unsigned int j = 0; j < numDims; j++)
64  {
65  if (i % strides[j] == 0)
66  {
67  std::cout << "[" ;
68  }
69  }
70 
71  std::cout << static_cast<float>(inputData[i]);
72 
73  for (unsigned int j = 0; j < numDims; j++)
74  {
75  if ((i+1) % strides[j] == 0)
76  {
77  std::cout << "]" ;
78  }
79  }
80 
81  if (i != numElements - 1)
82  {
83  std::cout << ", ";
84  }
85  }
86 
87  std::cout << " }" << std::endl;
88 }

◆ Debug< BFloat16 >()

template void armnn::Debug< BFloat16 > ( const TensorInfo inputInfo,
const BFloat16 inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ Debug< float >()

template void armnn::Debug< float > ( const TensorInfo inputInfo,
const float *  inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ Debug< Half >()

template void armnn::Debug< Half > ( const TensorInfo inputInfo,
const Half inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ Debug< int16_t >()

template void armnn::Debug< int16_t > ( const TensorInfo inputInfo,
const int16_t *  inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ Debug< int32_t >()

template void armnn::Debug< int32_t > ( const TensorInfo inputInfo,
const int32_t *  inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ Debug< int8_t >()

template void armnn::Debug< int8_t > ( const TensorInfo inputInfo,
const int8_t *  inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ Debug< uint8_t >()

template void armnn::Debug< uint8_t > ( const TensorInfo inputInfo,
const uint8_t *  inputData,
LayerGuid  guid,
const std::string &  layerName,
unsigned int  slotIndex 
)

Referenced by Debug().

◆ DepthToSpace()

void DepthToSpace ( const TensorInfo inputInfo,
const DepthToSpaceDescriptor descriptor,
const void *  inputData,
void *  outputData,
unsigned int  dataTypeSize 
)

Definition at line 18 of file DepthToSpace.cpp.

References ARMNN_ASSERT, DepthToSpace(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), TensorShape::GetNumElements(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, NCHW, and armnnUtils::Permute().

Referenced by BOOST_AUTO_TEST_CASE(), and DepthToSpace().

23 {
24  const unsigned int blockSize = descriptor.m_BlockSize;
25  ARMNN_ASSERT(blockSize != 0u);
26 
27  const TensorShape& inputShape = inputInfo.GetShape();
28  const unsigned int batches = inputShape[0];
29 
30  armnnUtils::DataLayoutIndexed dataLayoutIndexed(descriptor.m_DataLayout);
31  const unsigned int inDepth = inputShape[dataLayoutIndexed.GetChannelsIndex()];
32  const unsigned int inHeight = inputShape[dataLayoutIndexed.GetHeightIndex()];
33  const unsigned int inWidth = inputShape[dataLayoutIndexed.GetWidthIndex()];
34 
35  const unsigned int outDepth = inDepth / (blockSize * blockSize);
36 
37  // The 4D input data can be interpreted as 6D (implicitly reshaped) as follows:
38  //
39  // [batch, block size, block size, inDepth, inHeight, inWidth] for NCHW and
40  // [batch, inHeight, inWidth, blockSize, blockSize, outDepth] for NHWC.
41  //
42  // DepthToSpace can then be implemented as a permutation in 6D resulting in
43  // the following shapes:
44  //
45  // [batch, outDepth, inHeight, blockSize, inWidth, blockSize] for NCHW and
46  // [batch, inHeight, blockSize, inWidth, blockSize, outDepth] for NHWC.
47  //
48  // NOTE:
49  // Since 6D tensors are not currently supported, in practice we need to handle each
50  // batch separately and execute 5D permutations
51 
52  TensorShape permDestShape;
53  PermutationVector permVector{};
54  if (descriptor.m_DataLayout == DataLayout::NCHW)
55  {
56  permDestShape = TensorShape({ outDepth, inHeight, blockSize, inWidth, blockSize });
57  permVector = { 2, 4, 0, 1, 3 };
58  }
59  else
60  {
61  permDestShape = TensorShape({ inHeight, blockSize, inWidth, blockSize, outDepth });
62  permVector = { 0, 2, 1, 3, 4 };
63  }
64 
65  const unsigned int numElementsPerBatch = inputShape.GetNumElements() / batches;
66 
67  for (unsigned int batchIndex = 0u; batchIndex < batches; ++batchIndex)
68  {
69  const uintptr_t batchDataOffset = batchIndex * (numElementsPerBatch * dataTypeSize);
70 
71  armnnUtils::Permute(permDestShape,
72  permVector,
73  static_cast<const void*>(reinterpret_cast<const uint8_t*>(inputData) + batchDataOffset),
74  static_cast<void*>(reinterpret_cast<uint8_t*>(outputData) + batchDataOffset),
75  dataTypeSize);
76  }
77 }
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified...
Definition: Tensor.cpp:181
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).

◆ Dequantize() [1/4]

void Dequantize ( Decoder< float > &  inputDecoder,
Encoder< float > &  outputEncoder,
const TensorInfo inputInfo,
const TensorInfo outputInfo 
)

Definition at line 13 of file Dequantize.cpp.

References ARMNN_ASSERT, Decoder< IType >::Get(), TensorInfo::GetNumElements(), IgnoreUnused(), and Encoder< IType >::Set().

17 {
18  IgnoreUnused(outputInfo);
19  ARMNN_ASSERT(inputInfo.GetNumElements() == outputInfo.GetNumElements());
20  for (unsigned int i = 0; i < inputInfo.GetNumElements(); i++)
21  {
22  // inputDecoder.Get() dequantizes the data element from whatever
23  // type is given by inputInfo to fp32 (If MakeDecoder supports that dequantization)
24  // outputEncoder.Set() transforms the data element to whatever type is
25  // given by outputInfo (if MakeEncoder supports that transformation)
26  outputEncoder.Set(inputDecoder.Get());
27  ++outputEncoder;
28  ++inputDecoder;
29  }
30 }
virtual void Set(IType right)=0
void IgnoreUnused(Ts &&...)
virtual IType Get() const =0
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ Dequantize() [2/4]

std::vector<float> armnn::Dequantize ( const T *  quant,
const TensorInfo info 
)

u8 helpers

Definition at line 89 of file RefWorkloadUtils.hpp.

References Dequantize(), TensorInfo::GetNumElements(), TensorInfo::GetQuantizationOffset(), and TensorInfo::GetQuantizationScale().

90 {
91  std::vector<float> ret(info.GetNumElements());
92  for (size_t i = 0; i < info.GetNumElements(); i++)
93  {
94  ret[i] = armnn::Dequantize(quant[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
95  }
96  return ret;
97 }
float Dequantize(QuantizedType value, float scale, int32_t offset)
Dequantize an 8-bit data type into a floating point data type.
Definition: TypesUtils.cpp:46

◆ Dequantize() [3/4]

void armnn::Dequantize ( const T *  inputData,
float *  outputData,
const TensorInfo info 
)
inline

Definition at line 100 of file RefWorkloadUtils.hpp.

References TensorInfo::GetNumElements(), TensorInfo::GetQuantizationOffset(), and TensorInfo::GetQuantizationScale().

101 {
102  for (unsigned int i = 0; i < info.GetNumElements(); i++)
103  {
104  outputData[i] = Dequantize<T>(inputData[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
105  }
106 }

◆ Dequantize() [4/4]

float Dequantize ( QuantizedType  value,
float  scale,
int32_t  offset 
)

Dequantize an 8-bit data type into a floating point data type.

Parameters
value- The value to dequantize.
scale- The scale (must be non-zero).
offset- The offset.
Returns
- The dequantized value calculated as (value-offset)*scale.

Definition at line 46 of file TypesUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE(), SelectiveQuantizer< T, DoQuantize >::Dequantize(), Dequantize(), and TensorPrinter::operator()().

47 {
48  static_assert(IsQuantizedType<QuantizedType>(), "Not an integer type.");
49  ARMNN_ASSERT(scale != 0.f);
50  ARMNN_ASSERT(!IsNan(value));
51  return (armnn::numeric_cast<float>(value - offset)) * scale;
52 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ DetectionPostProcess()

void DetectionPostProcess ( const TensorInfo boxEncodingsInfo,
const TensorInfo scoresInfo,
const TensorInfo anchorsInfo,
const TensorInfo detectionBoxesInfo,
const TensorInfo detectionClassesInfo,
const TensorInfo detectionScoresInfo,
const TensorInfo numDetectionsInfo,
const DetectionPostProcessDescriptor desc,
Decoder< float > &  boxEncodings,
Decoder< float > &  scores,
Decoder< float > &  anchors,
float *  detectionBoxes,
float *  detectionClasses,
float *  detectionScores,
float *  numDetections 
)

Definition at line 140 of file DetectionPostProcess.cpp.

References AllocateOutputData(), anchors(), ARMNN_ASSERT, boxEncodings(), GenerateRangeK(), Decoder< IType >::Get(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), IgnoreUnused(), DetectionPostProcessDescriptor::m_DetectionsPerClass, DetectionPostProcessDescriptor::m_MaxClassesPerDetection, DetectionPostProcessDescriptor::m_MaxDetections, DetectionPostProcessDescriptor::m_NmsIouThreshold, DetectionPostProcessDescriptor::m_NmsScoreThreshold, DetectionPostProcessDescriptor::m_NumClasses, DetectionPostProcessDescriptor::m_ScaleH, DetectionPostProcessDescriptor::m_ScaleW, DetectionPostProcessDescriptor::m_ScaleX, DetectionPostProcessDescriptor::m_ScaleY, DetectionPostProcessDescriptor::m_UseRegularNms, NonMaxSuppression(), numeric_cast(), scores(), and TopKSort().

Referenced by DetectionPostProcessTestImpl().

155 {
156  IgnoreUnused(anchorsInfo, detectionClassesInfo, detectionScoresInfo, numDetectionsInfo);
157 
158  // Transform center-size format which is (ycenter, xcenter, height, width) to box-corner format,
159  // which represents the lower left corner and the upper right corner (ymin, xmin, ymax, xmax)
160  std::vector<float> boxCorners(boxEncodingsInfo.GetNumElements());
161 
162  const unsigned int numBoxes = boxEncodingsInfo.GetShape()[1];
163  const unsigned int numScores = scoresInfo.GetNumElements();
164 
165  for (unsigned int i = 0; i < numBoxes; ++i)
166  {
167  // Y
168  float boxEncodingY = boxEncodings.Get();
169  float anchorY = anchors.Get();
170 
171  ++boxEncodings;
172  ++anchors;
173 
174  // X
175  float boxEncodingX = boxEncodings.Get();
176  float anchorX = anchors.Get();
177 
178  ++boxEncodings;
179  ++anchors;
180 
181  // H
182  float boxEncodingH = boxEncodings.Get();
183  float anchorH = anchors.Get();
184 
185  ++boxEncodings;
186  ++anchors;
187 
188  // W
189  float boxEncodingW = boxEncodings.Get();
190  float anchorW = anchors.Get();
191 
192  ++boxEncodings;
193  ++anchors;
194 
195  float yCentre = boxEncodingY / desc.m_ScaleY * anchorH + anchorY;
196  float xCentre = boxEncodingX / desc.m_ScaleX * anchorW + anchorX;
197 
198  float halfH = 0.5f * expf(boxEncodingH / desc.m_ScaleH) * anchorH;
199  float halfW = 0.5f * expf(boxEncodingW / desc.m_ScaleW) * anchorW;
200 
201  unsigned int indexY = i * 4;
202  unsigned int indexX = indexY + 1;
203  unsigned int indexH = indexX + 1;
204  unsigned int indexW = indexH + 1;
205 
206  // ymin
207  boxCorners[indexY] = yCentre - halfH;
208  // xmin
209  boxCorners[indexX] = xCentre - halfW;
210  // ymax
211  boxCorners[indexH] = yCentre + halfH;
212  // xmax
213  boxCorners[indexW] = xCentre + halfW;
214 
215  ARMNN_ASSERT(boxCorners[indexY] < boxCorners[indexH]);
216  ARMNN_ASSERT(boxCorners[indexX] < boxCorners[indexW]);
217  }
218 
219  unsigned int numClassesWithBg = desc.m_NumClasses + 1;
220 
221  // Decode scores
222  std::vector<float> decodedScores;
223  decodedScores.reserve(numScores);
224 
225  for (unsigned int i = 0u; i < numScores; ++i)
226  {
227  decodedScores.emplace_back(scores.Get());
228  ++scores;
229  }
230 
231  // Perform Non Max Suppression.
232  if (desc.m_UseRegularNms)
233  {
234  // Perform Regular NMS.
235  // For each class, perform NMS and select max detection numbers of the highest score across all classes.
236  std::vector<float> classScores(numBoxes);
237 
238  std::vector<unsigned int> selectedBoxesAfterNms;
239  selectedBoxesAfterNms.reserve(numBoxes);
240 
241  std::vector<float> selectedScoresAfterNms;
242  selectedBoxesAfterNms.reserve(numScores);
243 
244  std::vector<unsigned int> selectedClasses;
245 
246  for (unsigned int c = 0; c < desc.m_NumClasses; ++c)
247  {
248  // For each boxes, get scores of the boxes for the class c.
249  for (unsigned int i = 0; i < numBoxes; ++i)
250  {
251  classScores[i] = decodedScores[i * numClassesWithBg + c + 1];
252  }
253  std::vector<unsigned int> selectedIndices = NonMaxSuppression(numBoxes,
254  boxCorners,
255  classScores,
256  desc.m_NmsScoreThreshold,
257  desc.m_DetectionsPerClass,
258  desc.m_NmsIouThreshold);
259 
260  for (unsigned int i = 0; i < selectedIndices.size(); ++i)
261  {
262  selectedBoxesAfterNms.push_back(selectedIndices[i]);
263  selectedScoresAfterNms.push_back(classScores[selectedIndices[i]]);
264  selectedClasses.push_back(c);
265  }
266  }
267 
268  // Select max detection numbers of the highest score across all classes
269  unsigned int numSelected = armnn::numeric_cast<unsigned int>(selectedBoxesAfterNms.size());
270  unsigned int numOutput = std::min(desc.m_MaxDetections, numSelected);
271 
272  // Sort the max scores among the selected indices.
273  std::vector<unsigned int> outputIndices = GenerateRangeK(numSelected);
274  TopKSort(numOutput, outputIndices.data(), selectedScoresAfterNms.data(), numSelected);
275 
276  AllocateOutputData(detectionBoxesInfo.GetShape()[1], numOutput, boxCorners, outputIndices,
277  selectedBoxesAfterNms, selectedClasses, selectedScoresAfterNms,
278  detectionBoxes, detectionScores, detectionClasses, numDetections);
279  }
280  else
281  {
282  // Perform Fast NMS.
283  // Select max scores of boxes and perform NMS on max scores,
284  // select max detection numbers of the highest score
285  unsigned int numClassesPerBox = std::min(desc.m_MaxClassesPerDetection, desc.m_NumClasses);
286  std::vector<float> maxScores;
287  std::vector<unsigned int>boxIndices;
288  std::vector<unsigned int>maxScoreClasses;
289 
290  for (unsigned int box = 0; box < numBoxes; ++box)
291  {
292  unsigned int scoreIndex = box * numClassesWithBg + 1;
293 
294  // Get the max scores of the box.
295  std::vector<unsigned int> maxScoreIndices = GenerateRangeK(desc.m_NumClasses);
296  TopKSort(numClassesPerBox, maxScoreIndices.data(),
297  decodedScores.data() + scoreIndex, desc.m_NumClasses);
298 
299  for (unsigned int i = 0; i < numClassesPerBox; ++i)
300  {
301  maxScores.push_back(decodedScores[scoreIndex + maxScoreIndices[i]]);
302  maxScoreClasses.push_back(maxScoreIndices[i]);
303  boxIndices.push_back(box);
304  }
305  }
306 
307  // Perform NMS on max scores
308  std::vector<unsigned int> selectedIndices = NonMaxSuppression(numBoxes, boxCorners, maxScores,
309  desc.m_NmsScoreThreshold,
310  desc.m_MaxDetections,
311  desc.m_NmsIouThreshold);
312 
313  unsigned int numSelected = armnn::numeric_cast<unsigned int>(selectedIndices.size());
314  unsigned int numOutput = std::min(desc.m_MaxDetections, numSelected);
315 
316  AllocateOutputData(detectionBoxesInfo.GetShape()[1], numOutput, boxCorners, selectedIndices,
317  boxIndices, maxScoreClasses, maxScores,
318  detectionBoxes, detectionScores, detectionClasses, numDetections);
319  }
320 }
armnn::TensorInfo anchorsInfo({ 6, 4 }, armnn::DataType::Float32)
std::vector< float > boxEncodings({ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f })
std::vector< unsigned int > GenerateRangeK(unsigned int k)
void IgnoreUnused(Ts &&...)
virtual IType Get() const =0
void TopKSort(unsigned int k, unsigned int *indices, const float *values, unsigned int numElement)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void AllocateOutputData(unsigned int numOutput, unsigned int numSelected, const std::vector< float > &boxCorners, const std::vector< unsigned int > &outputIndices, const std::vector< unsigned int > &selectedBoxes, const std::vector< unsigned int > &selectedClasses, const std::vector< float > &selectedScores, float *detectionBoxes, float *detectionScores, float *detectionClasses, float *numDetections)
std::vector< float > scores({ 0.0f, 0.9f, 0.8f, 0.0f, 0.75f, 0.72f, 0.0f, 0.6f, 0.5f, 0.0f, 0.93f, 0.95f, 0.0f, 0.5f, 0.4f, 0.0f, 0.3f, 0.2f })
armnn::TensorInfo scoresInfo({ 1, 6, 3 }, armnn::DataType::Float32)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
std::vector< unsigned int > NonMaxSuppression(unsigned int numBoxes, const std::vector< float > &boxCorners, const std::vector< float > &scores, float nmsScoreThreshold, unsigned int maxDetection, float nmsIouThreshold)
unsigned int GetNumElements() const
Definition: Tensor.hpp:192
std::vector< float > anchors({ 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 100.5f, 1.0f, 1.0f })

◆ ExtractJsonObjects()

void armnn::ExtractJsonObjects ( unsigned int  inferenceIndex,
const Event parentEvent,
JsonChildObject parentObject,
std::map< const Event *, std::vector< const Event *>>  descendantsMap 
)

Definition at line 284 of file Profiling.cpp.

References JsonChildObject::AddChild(), JsonChildObject::AddMeasurement(), ARMNN_ASSERT, Event, JsonChildObject::GetChild(), Event::GetMeasurements(), Measurement, JsonChildObject::NumChildren(), JsonChildObject::SetType(), and JsonChildObject::SetUnit().

Referenced by Profiler::Print().

288 {
289  ARMNN_ASSERT(parentEvent);
290  std::vector<Measurement> instrumentMeasurements = parentEvent->GetMeasurements();
291  unsigned int childIdx=0;
292  for(size_t measurementIndex = 0; measurementIndex < instrumentMeasurements.size(); ++measurementIndex, ++childIdx)
293  {
294  if (inferenceIndex == 0)
295  {
296  // Only add kernel measurement once, in case of multiple inferences
297  JsonChildObject measurementObject{instrumentMeasurements[measurementIndex].m_Name};
298  measurementObject.SetUnit(instrumentMeasurements[measurementIndex].m_Unit);
299  measurementObject.SetType(JsonObjectType::Measurement);
300 
301  ARMNN_ASSERT(parentObject.NumChildren() == childIdx);
302  parentObject.AddChild(measurementObject);
303  }
304 
305  parentObject.GetChild(childIdx).AddMeasurement(instrumentMeasurements[measurementIndex].m_Value);
306  }
307 
308 
309  auto childEventsIt = descendantsMap.find(parentEvent);
310  if (childEventsIt != descendantsMap.end())
311  {
312  for (auto childEvent : childEventsIt->second)
313  {
314  if (inferenceIndex == 0)
315  {
316  // Only add second level once, in case of multiple inferences
317  JsonChildObject childObject{childEvent->GetName()};
318  childObject.SetType(JsonObjectType::Event);
319  parentObject.AddChild(childObject);
320  }
321 
322  // Recursively process children. In reality this won't be very deep recursion. ~4-6 levels deep.
323  ExtractJsonObjects(inferenceIndex, childEvent, parentObject.GetChild(childIdx), descendantsMap);
324 
325  childIdx++;
326  }
327  }
328 }
void ExtractJsonObjects(unsigned int inferenceIndex, const Event *parentEvent, JsonChildObject &parentObject, std::map< const Event *, std::vector< const Event *>> descendantsMap)
Definition: Profiling.cpp:284
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ FakeQuantization()

void armnn::FakeQuantization ( const float *  inputData,
float *  outputData,
uint32_t  numElements,
float  min,
float  max 
)

Definition at line 17 of file RefFakeQuantizationFloat32Workload.cpp.

References numeric_cast().

18 {
19  float scale = (max - min) / 255.f;
20  int32_t offset = armnn::numeric_cast<int32_t>((-min * 255.f) / (max - min));
21 
22  for (uint32_t i = 0; i < numElements; i++)
23  {
24  outputData[i] = static_cast<float>(armnn::Quantize<uint8_t>(inputData[i], scale, offset));
25  }
26 
27 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ FalseFunc()

bool armnn::FalseFunc ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 62 of file LayerSupportCommon.hpp.

References IgnoreUnused().

63 {
64  IgnoreUnused(reasonIfUnsupported);
65  IgnoreUnused(params...);
66  return false;
67 }
void IgnoreUnused(Ts &&...)

◆ FalseFuncF16()

bool armnn::FalseFuncF16 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 70 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

71 {
72  IgnoreUnused(params...);
73  SetValueChecked(reasonIfUnsupported, "Layer is not supported with float16 data type");
74  return false;
75 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseFuncF32()

bool armnn::FalseFuncF32 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 78 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

79 {
80  IgnoreUnused(params...);
81  SetValueChecked(reasonIfUnsupported, "Layer is not supported with float32 data type");
82  return false;
83 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseFuncI32()

bool armnn::FalseFuncI32 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 94 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

95 {
96  IgnoreUnused(params...);
97  SetValueChecked(reasonIfUnsupported, "Layer is not supported with int32 data type");
98  return false;
99 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseFuncU8()

bool armnn::FalseFuncU8 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 86 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

87 {
88  IgnoreUnused(params...);
89  SetValueChecked(reasonIfUnsupported, "Layer is not supported with 8-bit data type");
90  return false;
91 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseInputFuncF16()

bool armnn::FalseInputFuncF16 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 110 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

111 {
112  IgnoreUnused(params...);
113  SetValueChecked(reasonIfUnsupported, "Layer is not supported with float16 data type input");
114  return false;
115 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseInputFuncF32()

bool armnn::FalseInputFuncF32 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 102 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

103 {
104  IgnoreUnused(params...);
105  SetValueChecked(reasonIfUnsupported, "Layer is not supported with float32 data type input");
106  return false;
107 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseOutputFuncF16()

bool armnn::FalseOutputFuncF16 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 126 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

127 {
128  IgnoreUnused(params...);
129  SetValueChecked(reasonIfUnsupported, "Layer is not supported with float16 data type output");
130  return false;
131 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ FalseOutputFuncF32()

bool armnn::FalseOutputFuncF32 ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 118 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

119 {
120  IgnoreUnused(params...);
121  SetValueChecked(reasonIfUnsupported, "Layer is not supported with float32 data type output");
122  return false;
123 }
void IgnoreUnused(Ts &&...)
void SetValueChecked(Optional< T &> optionalRef, V &&val)

◆ Fill()

void Fill ( Encoder< float > &  output,
const TensorShape desiredOutputShape,
const float  value 
)

Creates a tensor and fills it with a scalar value.

Definition at line 13 of file Fill.cpp.

References TensorShape::GetNumElements(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

16 {
17  for(unsigned int i = 0; i < desiredOutputShape.GetNumElements(); ++i)
18  {
19  output[i];
20  output.Set(value);
21  }
22 }
virtual void Set(IType right)=0

◆ FindKernelMeasurements()

std::vector<Measurement> armnn::FindKernelMeasurements ( const Event event)

Definition at line 63 of file Profiling.cpp.

References ARMNN_ASSERT, FindMeasurement(), Event::GetMeasurements(), Measurement::m_Value, and WallClockTimer::WALL_CLOCK_TIME.

64 {
65  ARMNN_ASSERT(event != nullptr);
66 
67  std::vector<Measurement> measurements;
68 
69  // Search through the measurements.
70  for (const auto& measurement : event->GetMeasurements())
71  {
72  if (measurement.m_Name.rfind("OpenClKernelTimer", 0) == 0
73  || measurement.m_Name.rfind("NeonKernelTimer", 0) == 0)
74  {
75  // Measurement found.
76  measurements.push_back(measurement);
77  }
78  }
79 
80  return measurements;
81 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ FindMeasurement()

Measurement armnn::FindMeasurement ( const std::string &  name,
const Event event 
)

Definition at line 44 of file Profiling.cpp.

References ARMNN_ASSERT, and Event::GetMeasurements().

Referenced by Profiler::AnalyzeEventSequenceAndWriteResults(), and FindKernelMeasurements().

45 {
46 
47  ARMNN_ASSERT(event != nullptr);
48 
49  // Search though the measurements.
50  for (const auto& measurement : event->GetMeasurements())
51  {
52  if (measurement.m_Name == name)
53  {
54  // Measurement found.
55  return measurement;
56  }
57  }
58 
59  // Measurement not found.
60  return Measurement{ "", 0.f, Measurement::Unit::TIME_MS };
61 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ForEachLayerInput()

void armnn::ForEachLayerInput ( LayerSelectionInfo::LayerInfoContainer &  layerInfos,
LayerSelectionInfo &  layerInfo,
Delegate  function 
)

Definition at line 263 of file SubgraphViewSelector.cpp.

References ARMNN_ASSERT_MSG, and Layer::GetInputSlots().

Referenced by AssignSplitId(), and IsReadyForSplitAssignment().

266 {
267  Layer& layer = *layerInfo.m_Layer;
268 
269  for (auto inputSlot : layer.GetInputSlots())
270  {
271  auto connectedInput = PolymorphicDowncast<OutputSlot*>(inputSlot.GetConnection());
272  ARMNN_ASSERT_MSG(connectedInput, "Dangling input slot detected.");
273  Layer& inputLayer = connectedInput->GetOwningLayer();
274 
275  auto parentInfo = layerInfos.find(&inputLayer);
276  if (parentInfo != layerInfos.end())
277  {
278  function(parentInfo->second);
279  }
280  }
281 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ ForEachLayerOutput()

void armnn::ForEachLayerOutput ( LayerSelectionInfo::LayerInfoContainer &  layerInfos,
LayerSelectionInfo &  layerInfo,
Delegate  function 
)

Definition at line 284 of file SubgraphViewSelector.cpp.

References Layer::GetOutputSlots().

Referenced by SubgraphViewSelector::SelectSubgraphs().

287 {
288  Layer& layer= *layerInfo.m_Layer;
289 
290  for (auto& outputSlot : layer.GetOutputSlots())
291  {
292  for (auto& output : outputSlot.GetConnections())
293  {
294  Layer& childLayer = output->GetOwningLayer();
295 
296  auto childInfo = layerInfos.find(&childLayer);
297  if (childInfo != layerInfos.end())
298  {
299  function(childInfo->second);
300  }
301  }
302  }
303 }

◆ FullyConnected()

void FullyConnected ( const TensorShape rInputShape,
Decoder< float > &  rInputDecoder,
const TensorShape rOutputShape,
Encoder< float > &  rOutputEncoder,
const TensorShape rWeightsShape,
Decoder< float > &  rWeightDecoder,
Decoder< float > &  rBiasDecoder,
const bool  biasEnabled,
const unsigned int  K,
const bool  transposeWeights 
)

Performs a matrix multiplication and optionally adds a bias.

Definition at line 13 of file FullyConnected.cpp.

References Decoder< IType >::DecodeTensor(), and Encoder< IType >::Set().

23 {
24  // Perform FullyConnected implementation
25  unsigned int outputSize = rOutputShape[1];
26 
27  const std::vector<float> decodedInputs = rInputDecoder.DecodeTensor(rInputShape);
28  const std::vector<float> decodedWeights = rWeightDecoder.DecodeTensor(rWeightsShape);
29 
30  const TensorShape biasShape{outputSize};
31  const std::vector<float> decodedBiases = biasEnabled ? rBiasDecoder.DecodeTensor(biasShape) : std::vector<float>();
32 
33 
34  for (unsigned int n = 0; n < rInputShape[0]; n++)
35  {
36  for (unsigned int channelOutput = 0; channelOutput < outputSize; channelOutput++)
37  {
38  float outval = 0.f;
39 
40  for (unsigned int channelInput = 0; channelInput < K; channelInput++)
41  {
42  float weight;
43  if (transposeWeights)
44  {
45  weight = decodedWeights[channelOutput * K + channelInput];
46  }
47  else
48  {
49  weight = decodedWeights[channelInput * outputSize + channelOutput];
50  }
51 
52  outval += weight * decodedInputs[n * K + channelInput];
53  }
54 
55  if (biasEnabled)
56  {
57  outval += decodedBiases[channelOutput];
58  }
59 
60  rOutputEncoder[n * outputSize + channelOutput];
61  rOutputEncoder.Set(outval);
62  }
63  }
64 }
virtual void Set(IType right)=0
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, const unsigned int channelMultiplier=1, bool isDepthwise=false)=0

◆ FuseLayerWithoutParameters()

LayerType* armnn::FuseLayerWithoutParameters ( OptimizationViews optimizationViews,
LayerType baseLayer,
ActivationLayer activationLayer,
ActivationDescriptor activationDesc,
std::string  name 
)

Definition at line 64 of file ArmComputeSubgraphUtils.hpp.

References Graph::AddLayer(), OptimizationViews::AddSubstitution(), CreateInputsFrom(), CreateOutputsFrom(), and OptimizationViews::GetGraph().

69 {
70  LayerType* replacementLayer = optimizationViews.GetGraph().AddLayer<LayerType>(name.c_str());
71 
72  replacementLayer->SetAdditionalInfoForObject(std::make_shared<ActivationDescriptor>(activationDesc));
73 
74  SubgraphView substitutionSubgraph(CreateInputsFrom({baseLayer}),
75  CreateOutputsFrom({activationLayer}),
76  {baseLayer, activationLayer});
77  SubgraphView replacementSubgraph(replacementLayer);
78 
79  optimizationViews.AddSubstitution({substitutionSubgraph, replacementSubgraph});
80  return replacementLayer;
81 }
SubgraphView::InputSlots CreateInputsFrom(const std::vector< Layer *> &layers)
SubgraphView::OutputSlots CreateOutputsFrom(const std::vector< Layer *> &layers)

◆ FuseLayerWithParameters()

LayerType* armnn::FuseLayerWithParameters ( OptimizationViews optimizationViews,
LayerType baseLayer,
ActivationLayer activationLayer,
ActivationDescriptor activationDesc,
std::string  name 
)

Definition at line 84 of file ArmComputeSubgraphUtils.hpp.

References Graph::AddLayer(), OptimizationViews::AddSubstitution(), CreateInputsFrom(), CreateOutputsFrom(), and OptimizationViews::GetGraph().

Referenced by FuseLayerWithWeightsAndBiases().

89 {
90  LayerType* replacementLayer = optimizationViews.GetGraph().AddLayer<LayerType>(baseLayer->GetParameters(),
91  name.c_str());
92 
93  replacementLayer->SetAdditionalInfoForObject(std::make_shared<ActivationDescriptor>(activationDesc));
94 
95  SubgraphView substitutionSubgraph(CreateInputsFrom({baseLayer}),
96  CreateOutputsFrom({activationLayer}),
97  {baseLayer, activationLayer});
98  SubgraphView replacementSubgraph(replacementLayer);
99 
100  optimizationViews.AddSubstitution({substitutionSubgraph, replacementSubgraph});
101  return replacementLayer;
102 }
SubgraphView::InputSlots CreateInputsFrom(const std::vector< Layer *> &layers)
SubgraphView::OutputSlots CreateOutputsFrom(const std::vector< Layer *> &layers)

◆ FuseLayerWithWeightsAndBiases()

LayerType* armnn::FuseLayerWithWeightsAndBiases ( OptimizationViews optimizationViews,
LayerType baseLayer,
ActivationLayer activationLayer,
ActivationDescriptor activationDesc,
std::string  name 
)

Definition at line 105 of file ArmComputeSubgraphUtils.hpp.

References FuseLayerWithParameters().

110 {
111  LayerType* replacementLayer = FuseLayerWithParameters(optimizationViews,
112  baseLayer,
113  activationLayer,
114  activationDesc,
115  name);
116 
117  replacementLayer->m_Weight = std::move(baseLayer->m_Weight);
118  replacementLayer->m_Bias = std::move(baseLayer->m_Bias);
119 
120  return replacementLayer;
121 }
LayerType * FuseLayerWithParameters(OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)

◆ Gather()

void Gather ( const TensorInfo paramsInfo,
const TensorInfo indicesInfo,
const TensorInfo outputInfo,
Decoder< float > &  params,
const int32_t *  indices,
Encoder< float > &  output,
const int32_t  axis 
)

Definition at line 17 of file Gather.cpp.

References ARMNN_ASSERT, Decoder< IType >::Get(), TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), IgnoreUnused(), numeric_cast(), and Encoder< IType >::Set().

24 {
25  IgnoreUnused(outputInfo);
26  IgnoreUnused(axis);
27 
28  const TensorShape& paramsShape = paramsInfo.GetShape();
29 
30  unsigned int paramsProduct = 1;
31  for (unsigned int i = 1; i < paramsInfo.GetNumDimensions(); ++i)
32  {
33  paramsProduct = paramsProduct * paramsShape[i];
34  }
35 
36  unsigned int outIndex = 0;
37  for (unsigned int i = 0; i < indicesInfo.GetNumElements(); ++i)
38  {
39  unsigned int indx = armnn::numeric_cast<unsigned int>(indices[i]);
40 
41  ARMNN_ASSERT(indices[i] >= 0 && indx < paramsShape[0]);
42 
43  unsigned int startOffset = indx * paramsProduct;
44  unsigned int endOffset = startOffset + paramsProduct;
45 
46  for (unsigned int j = startOffset; j < endOffset; ++j)
47  {
48  params[j];
49  float outputValue = params.Get();
50  output[outIndex];
51  output.Set(outputValue);
52  ++outIndex;
53  }
54  }
55 
56  ARMNN_ASSERT(outIndex == outputInfo.GetNumElements());
57 }
virtual void Set(IType right)=0
void IgnoreUnused(Ts &&...)
virtual IType Get() const =0
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ GatherTensorHandlePairs()

void armnn::GatherTensorHandlePairs ( const DescriptorType &  descriptor,
std::vector< std::pair< SrcTensorHandleType *, DstTensorHandleType *>> &  tensorHandlePairs 
)

Definition at line 190 of file WorkloadUtils.hpp.

References ConvertMaskToACLFormat(), ConvertWeightTensorFromArmnnToAcl(), ConvertWeightTensorInfoFromArmnnToAcl(), PermuteTensor(), and ReshapeWeightsForAcl().

Referenced by CopyMemGenericWorkload::CopyMemGenericWorkload(), NeonConvertBf16ToFp32Workload::NeonConvertBf16ToFp32Workload(), NeonConvertFp16ToFp32Workload::NeonConvertFp16ToFp32Workload(), NeonConvertFp32ToBf16Workload::NeonConvertFp32ToBf16Workload(), and NeonConvertFp32ToFp16Workload::NeonConvertFp32ToFp16Workload().

192 {
193  const unsigned int numInputs = static_cast<unsigned int>(descriptor.m_Inputs.size());
194  tensorHandlePairs.reserve(numInputs);
195 
196  for (unsigned int i = 0; i < numInputs; ++i)
197  {
198  SrcTensorHandleType* const srcTensorHandle =
199  PolymorphicDowncast<SrcTensorHandleType*>(descriptor.m_Inputs[i]);
200  DstTensorHandleType* const dstTensorHandle =
201  PolymorphicDowncast<DstTensorHandleType*>(descriptor.m_Outputs[i]);
202 
203  tensorHandlePairs.emplace_back(srcTensorHandle, dstTensorHandle);
204  }
205 }

◆ GenerateRangeK()

std::vector<unsigned int> armnn::GenerateRangeK ( unsigned int  k)

Definition at line 17 of file DetectionPostProcess.cpp.

Referenced by DetectionPostProcess(), and NonMaxSuppression().

18 {
19  std::vector<unsigned int> range(k);
20  std::iota(range.begin(), range.end(), 0);
21  return range;
22 }

◆ GetActivationFunctionAsCString()

constexpr char const* armnn::GetActivationFunctionAsCString ( ActivationFunction  activation)

Definition at line 27 of file TypesUtils.hpp.

References Abs, BoundedReLu, Elu, HardSwish, LeakyReLu, Linear, ReLu, Sigmoid, SoftReLu, Sqrt, Square, and TanH.

Referenced by StringifyLayerParameters< ActivationDescriptor >::Serialize().

28 {
29  switch (activation)
30  {
31  case ActivationFunction::Sigmoid: return "Sigmoid";
32  case ActivationFunction::TanH: return "TanH";
33  case ActivationFunction::Linear: return "Linear";
34  case ActivationFunction::ReLu: return "ReLu";
35  case ActivationFunction::BoundedReLu: return "BoundedReLu";
36  case ActivationFunction::SoftReLu: return "SoftReLu";
37  case ActivationFunction::LeakyReLu: return "LeakyReLu";
38  case ActivationFunction::Abs: return "Abs";
39  case ActivationFunction::Sqrt: return "Sqrt";
40  case ActivationFunction::Square: return "Square";
41  case ActivationFunction::Elu: return "Elu";
42  case ActivationFunction::HardSwish: return "HardSwish";
43  default: return "Unknown";
44  }
45 }

◆ GetArgMinMaxFunctionAsCString()

constexpr char const* armnn::GetArgMinMaxFunctionAsCString ( ArgMinMaxFunction  function)

Definition at line 47 of file TypesUtils.hpp.

References Max, and Min.

48 {
49  switch (function)
50  {
51  case ArgMinMaxFunction::Max: return "Max";
52  case ArgMinMaxFunction::Min: return "Min";
53  default: return "Unknown";
54  }
55 }

◆ GetBiasDataType()

DataType GetBiasDataType ( DataType  inputDataType)

Definition at line 25 of file WorkloadData.cpp.

References ARMNN_ASSERT_MSG, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, CHECK_LOCATION, TensorInfo::GetDataType(), GetDataTypeName(), TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetQuantizationDim(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::GetQuantizationScales(), TensorInfo::GetShape(), OptionalBase::has_value(), TensorInfo::HasMultipleQuantizationScales(), TensorInfo::HasPerAxisQuantization(), info, TensorInfo::IsQuantized(), IsQuantized8BitType(), TensorInfo::IsTypeSpaceMatch(), WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, OptionalReferenceSwitch< IsReference, T >::value(), and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by BOOST_AUTO_TEST_CASE(), CompareDepthwiseConvolution2dTestImpl(), FullyConnectedQueueDescriptor::Validate(), Convolution2dQueueDescriptor::Validate(), DepthwiseConvolution2dQueueDescriptor::Validate(), and TransposeConvolution2dQueueDescriptor::Validate().

26 {
27  switch (inputDataType)
28  {
29  case DataType::Float16:
30  return DataType::Float16;
31  case DataType::BFloat16:
32  case DataType::Float32:
33  return DataType::Float32;
34  case DataType::QAsymmS8:
35  return DataType::Signed32;
36  case DataType::QAsymmU8:
37  return DataType::Signed32;
38  case DataType::QSymmS8:
39  return DataType::Signed32;
40  case DataType::QSymmS16:
41  return DataType::Signed32;
42  default:
43  ARMNN_ASSERT_MSG(false, "Invalid input data type");
44  return DataType::Float32;
45  }
46 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ GetBiasTypeFromWeightsType()

armnn::Optional<armnn::DataType> armnn::GetBiasTypeFromWeightsType ( armnn::Optional< armnn::DataType weightsType)
inline

Definition at line 14 of file LayerSupportRules.hpp.

References ARMNN_ASSERT_MSG, Float16, Float32, QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, Signed32, and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by BiasAndWeightsTypesCompatible::BiasAndWeightsTypesCompatible(), BiasAndWeightsTypesMatch::BiasAndWeightsTypesMatch(), and FullyConnectedTest().

15 {
16  if (!weightsType)
17  {
18  return weightsType;
19  }
20 
21  switch(weightsType.value())
22  {
25  return weightsType;
31  default:
32  ARMNN_ASSERT_MSG(false, "GetBiasTypeFromWeightsType(): Unsupported data type.");
33  }
34  return armnn::EmptyOptional();
35 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32

◆ GetComparisonOperationAsCString()

constexpr char const* armnn::GetComparisonOperationAsCString ( ComparisonOperation  operation)

Definition at line 57 of file TypesUtils.hpp.

References Equal, Greater, GreaterOrEqual, Less, LessOrEqual, and NotEqual.

Referenced by RefComparisonWorkload::Execute().

58 {
59  switch (operation)
60  {
61  case ComparisonOperation::Equal: return "Equal";
62  case ComparisonOperation::Greater: return "Greater";
63  case ComparisonOperation::GreaterOrEqual: return "GreaterOrEqual";
64  case ComparisonOperation::Less: return "Less";
65  case ComparisonOperation::LessOrEqual: return "LessOrEqual";
66  case ComparisonOperation::NotEqual: return "NotEqual";
67  default: return "Unknown";
68  }
69 }

◆ GetComputeDeviceAsCString()

constexpr char const* armnn::GetComputeDeviceAsCString ( Compute  compute)

Deprecated function that will be removed together with the Compute enum.

Definition at line 34 of file BackendId.hpp.

References CpuAcc, CpuRef, and GpuAcc.

Referenced by BOOST_AUTO_TEST_CASE(), GetSuitableBackendRegistered(), and operator<<().

35 {
36  switch (compute)
37  {
38  case armnn::Compute::CpuRef: return "CpuRef";
39  case armnn::Compute::CpuAcc: return "CpuAcc";
40  case armnn::Compute::GpuAcc: return "GpuAcc";
41  default: return "Unknown";
42  }
43 }
CPU Execution: Reference C++ kernels.
GPU Execution: OpenCL: ArmCompute.
CPU Execution: NEON: ArmCompute.

◆ GetDataLayoutName()

◆ GetDataTypeName()

constexpr const char* armnn::GetDataTypeName ( DataType  dataType)

Definition at line 180 of file TypesUtils.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, Boolean, Float16, Float32, QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, Signed32, and Signed64.

Referenced by AttemptBackendAssignment(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), GetBiasDataType(), TfLiteParser::GetBuffer(), RefPermuteWorkload< DataType >::GetName(), RefTransposeWorkload< DataType >::GetName(), RefDebugWorkload< DataType >::GetName(), armnnUtils::GetPerAxisParams(), and VerifyTensorInfoDataType().

181 {
182  switch (dataType)
183  {
184  case DataType::Float16: return "Float16";
185  case DataType::Float32: return "Float32";
186  case DataType::Signed64: return "Signed64";
187  case DataType::QAsymmU8: return "QAsymmU8";
188  case DataType::QAsymmS8: return "QAsymmS8";
189  case DataType::QSymmS8: return "QSymmS8";
191  case DataType::QuantizedSymm8PerAxis: return "QSymm8PerAxis";
193  case DataType::QSymmS16: return "QSymm16";
194  case DataType::Signed32: return "Signed32";
195  case DataType::Boolean: return "Boolean";
196  case DataType::BFloat16: return "BFloat16";
197 
198  default:
199  return "Unknown";
200  }
201 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ GetDataTypeSize()

constexpr unsigned int armnn::GetDataTypeSize ( DataType  dataType)

Definition at line 126 of file TypesUtils.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, Boolean, Float16, Float32, QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, Signed32, and Signed64.

Referenced by BOOST_AUTO_TEST_CASE(), armnnTfParser::ConvertTfTensorDataType(), RefStridedSliceWorkload::Execute(), RefDepthToSpaceWorkload::Execute(), RefSliceWorkload::Execute(), TensorInfo::GetNumBytes(), GetUnpaddedTensorStrides(), and PermuteTensor().

127 {
128  switch (dataType)
129  {
130  case DataType::BFloat16:
131  case DataType::Float16: return 2U;
132  case DataType::Float32:
133  case DataType::Signed32: return 4U;
134  case DataType::Signed64: return 8U;
135  case DataType::QAsymmU8: return 1U;
136  case DataType::QAsymmS8: return 1U;
137  case DataType::QSymmS8: return 1U;
139  case DataType::QuantizedSymm8PerAxis: return 1U;
141  case DataType::QSymmS16: return 2U;
142  case DataType::Boolean: return 1U;
143  default: return 0U;
144  }
145 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ GetEventPtr() [1/2]

const Event* armnn::GetEventPtr ( const Event ptr)

Definition at line 110 of file Profiling.cpp.

Referenced by Profiler::AnalyzeEventSequenceAndWriteResults().

110 { return ptr;}

◆ GetEventPtr() [2/2]

const Event* armnn::GetEventPtr ( const std::unique_ptr< Event > &  ptr)

Definition at line 111 of file Profiling.cpp.

111 {return ptr.get(); }

◆ GetILayerSupportByBackendId()

std::shared_ptr< ILayerSupport > GetILayerSupportByBackendId ( const armnn::BackendId backend)

Convenience function to retrieve the ILayerSupport for a backend.

Definition at line 14 of file BackendHelper.cpp.

References BackendRegistryInstance(), BackendRegistry::GetFactory(), and BackendRegistry::IsBackendRegistered().

15 {
16  BackendRegistry& backendRegistry = armnn::BackendRegistryInstance();
17 
18  if (!backendRegistry.IsBackendRegistered(backend))
19  {
20  return nullptr;
21  }
22 
23  auto factoryFunc = backendRegistry.GetFactory(backend);
24  auto backendObject = factoryFunc();
25  return backendObject->GetLayerSupport();
26 }
BackendRegistry & BackendRegistryInstance()

◆ GetInputTensorData()

const DataType* armnn::GetInputTensorData ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 35 of file RefWorkloadUtils.hpp.

References ITensorHandle::Map().

36 {
37  const ITensorHandle* tensorHandle = data.m_Inputs[idx];
38  return reinterpret_cast<const DataType*>(tensorHandle->Map());
39 }
DataType
Definition: Types.hpp:32

◆ GetInputTensorDataBFloat16()

const BFloat16* armnn::GetInputTensorDataBFloat16 ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 73 of file RefWorkloadUtils.hpp.

Referenced by RefConvertBf16ToFp32Workload::Execute().

74 {
75  return GetInputTensorData<BFloat16>(idx, data);
76 }

◆ GetInputTensorDataFloat()

const float* armnn::GetInputTensorDataFloat ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 49 of file RefWorkloadUtils.hpp.

Referenced by RefConvertFp32ToBf16Workload::Execute(), RefFakeQuantizationFloat32Workload::Execute(), and RefConvertFp32ToFp16Workload::Execute().

50 {
51  return GetInputTensorData<float>(idx, data);
52 }

◆ GetInputTensorDataHalf()

const Half* armnn::GetInputTensorDataHalf ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 61 of file RefWorkloadUtils.hpp.

Referenced by RefConvertFp16ToFp32Workload::Execute().

62 {
63  return GetInputTensorData<Half>(idx, data);
64 }

◆ GetInputTensorInfo()

TensorInfo armnn::GetInputTensorInfo ( const Network network)

Definition at line 336 of file QuantizerTest.cpp.

References ARMNN_ASSERT_MSG, Network::GetGraph(), and Graph::GetInputLayers().

Referenced by BOOST_AUTO_TEST_CASE(), BoundedReLuUint8UpperAndLowerBoundTest(), and LoadedNetwork::~LoadedNetwork().

337 {
338  for (auto&& inputLayer : network->GetGraph().GetInputLayers())
339  {
340  ARMNN_ASSERT_MSG(inputLayer->GetNumOutputSlots() == 1, "Input layer should have exactly 1 output slot");
341  return inputLayer->GetOutputSlot(0).GetTensorInfo();
342  }
343  throw InvalidArgumentException("Network has no input layers");
344 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ GetLayerTypeAsCString()

const char * GetLayerTypeAsCString ( LayerType  type)

Definition at line 13 of file InternalTypes.cpp.

References ARMNN_ASSERT_MSG, and LIST_OF_LAYER_TYPE.

Referenced by AttemptBackendAssignment(), CheckScaleSetOnQuantizedType(), Layer::InferOutputShapes(), Graph::InferTensorInfos(), Graph::Print(), ReturnWithError(), Layer::SerializeLayerParameters(), Graph::SerializeToDot(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), and Layer::VerifyLayerConnections().

14 {
15  switch (type)
16  {
17 #define X(name) case LayerType::name: return #name;
19 #undef X
20  default:
21  ARMNN_ASSERT_MSG(false, "Unknown layer type");
22  return "Unknown";
23  }
24 }
#define LIST_OF_LAYER_TYPE
This list uses X macro technique.
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ GetLogicalBinaryOperationAsCString()

constexpr char const* armnn::GetLogicalBinaryOperationAsCString ( LogicalBinaryOperation  operation)

Definition at line 85 of file TypesUtils.hpp.

References LogicalAnd, and LogicalOr.

Referenced by RefLogicalBinaryWorkload::Execute().

86 {
87  switch (operation)
88  {
89  case LogicalBinaryOperation::LogicalAnd: return "LogicalAnd";
90  case LogicalBinaryOperation::LogicalOr: return "LogicalOr";
91  default: return "Unknown";
92  }
93 }

◆ GetNormalizationAlgorithmChannelAsCString()

constexpr const char* armnn::GetNormalizationAlgorithmChannelAsCString ( NormalizationAlgorithmChannel  channel)

Definition at line 213 of file TypesUtils.hpp.

References Across, and Within.

Referenced by StringifyLayerParameters< NormalizationDescriptor >::Serialize().

214 {
215  switch (channel)
216  {
217  case NormalizationAlgorithmChannel::Across: return "Across";
218  case NormalizationAlgorithmChannel::Within: return "Within";
219  default: return "Unknown";
220  }
221 }

◆ GetNormalizationAlgorithmMethodAsCString()

constexpr const char* armnn::GetNormalizationAlgorithmMethodAsCString ( NormalizationAlgorithmMethod  method)

Definition at line 223 of file TypesUtils.hpp.

References LocalBrightness, and LocalContrast.

Referenced by StringifyLayerParameters< NormalizationDescriptor >::Serialize().

224 {
225  switch (method)
226  {
227  case NormalizationAlgorithmMethod::LocalBrightness: return "LocalBrightness";
228  case NormalizationAlgorithmMethod::LocalContrast: return "LocalContrast";
229  default: return "Unknown";
230  }
231 }

◆ GetOffset()

unsigned int armnn::GetOffset ( const TensorShape shape,
unsigned int  b,
unsigned int  h,
unsigned int  w,
unsigned int  c,
const DataLayoutIndexed dataLayout 
)

Definition at line 15 of file SpaceToBatchNd.cpp.

References DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetDataLayout(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetWidthIndex(), and NHWC.

Referenced by SpaceToBatchNd(), and SpaceToDepth().

21 {
22  if (dataLayout.GetDataLayout() == DataLayout::NHWC)
23  {
24  return ((b * shape[dataLayout.GetHeightIndex()] + h) * shape[dataLayout.GetWidthIndex()] + w) *
25  shape[dataLayout.GetChannelsIndex()] + c;
26  }
27  else
28  {
29  return ((b * shape[dataLayout.GetChannelsIndex()] + c) * shape[dataLayout.GetHeightIndex()] + h) *
30  shape[dataLayout.GetWidthIndex()] + w;
31  }
32 }
unsigned int GetWidthIndex() const
unsigned int GetHeightIndex() const
armnn::DataLayout GetDataLayout() const
unsigned int GetChannelsIndex() const

◆ GetOutputShapeRoundingAsCString()

constexpr char const* armnn::GetOutputShapeRoundingAsCString ( OutputShapeRounding  rounding)

Definition at line 106 of file TypesUtils.hpp.

References Ceiling, and Floor.

Referenced by StringifyLayerParameters< Pooling2dDescriptor >::Serialize().

107 {
108  switch (rounding)
109  {
110  case OutputShapeRounding::Ceiling: return "Ceiling";
111  case OutputShapeRounding::Floor: return "Floor";
112  default: return "Unknown";
113  }
114 }

◆ GetOutputTensorData()

DataType* armnn::GetOutputTensorData ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 42 of file RefWorkloadUtils.hpp.

References ITensorHandle::Map().

43 {
44  ITensorHandle* tensorHandle = data.m_Outputs[idx];
45  return reinterpret_cast<DataType*>(tensorHandle->Map());
46 }
DataType
Definition: Types.hpp:32

◆ GetOutputTensorDataBFloat16()

BFloat16* armnn::GetOutputTensorDataBFloat16 ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 79 of file RefWorkloadUtils.hpp.

Referenced by RefConvertFp32ToBf16Workload::Execute().

80 {
81  return GetOutputTensorData<BFloat16>(idx, data);
82 }

◆ GetOutputTensorDataFloat()

float* armnn::GetOutputTensorDataFloat ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 55 of file RefWorkloadUtils.hpp.

Referenced by RefConvertBf16ToFp32Workload::Execute(), RefFakeQuantizationFloat32Workload::Execute(), and RefConvertFp16ToFp32Workload::Execute().

56 {
57  return GetOutputTensorData<float>(idx, data);
58 }

◆ GetOutputTensorDataHalf()

Half* armnn::GetOutputTensorDataHalf ( unsigned int  idx,
const PayloadType &  data 
)

Definition at line 67 of file RefWorkloadUtils.hpp.

Referenced by RefConvertFp32ToFp16Workload::Execute().

68 {
69  return GetOutputTensorData<Half>(idx, data);
70 }

◆ GetPaddingMethodAsCString()

constexpr char const* armnn::GetPaddingMethodAsCString ( PaddingMethod  method)

Definition at line 116 of file TypesUtils.hpp.

References Exclude, and IgnoreValue.

Referenced by StringifyLayerParameters< Pooling2dDescriptor >::Serialize().

117 {
118  switch (method)
119  {
120  case PaddingMethod::Exclude: return "Exclude";
121  case PaddingMethod::IgnoreValue: return "IgnoreValue";
122  default: return "Unknown";
123  }
124 }

◆ GetPoolingAlgorithmAsCString()

constexpr char const* armnn::GetPoolingAlgorithmAsCString ( PoolingAlgorithm  pooling)

Definition at line 95 of file TypesUtils.hpp.

References Average, L2, and Max.

Referenced by StringifyLayerParameters< Pooling2dDescriptor >::Serialize().

96 {
97  switch (pooling)
98  {
99  case PoolingAlgorithm::Average: return "Average";
100  case PoolingAlgorithm::Max: return "Max";
101  case PoolingAlgorithm::L2: return "L2";
102  default: return "Unknown";
103  }
104 }

◆ GetProfilerEventSequenceSize()

size_t armnn::GetProfilerEventSequenceSize ( armnn::Profiler profiler)

Definition at line 22 of file ProfilerTests.cpp.

References BOOST_AUTO_TEST_SUITE(), ProfilerManager::GetInstance(), ProfilerManager::GetProfiler(), and ProfilerManager::RegisterProfiler().

Referenced by BOOST_AUTO_TEST_CASE().

23 {
24  if (!profiler)
25  {
26  return static_cast<size_t>(-1);
27  }
28 
29  return profiler->m_EventSequence.size();
30 }

◆ GetProfilingService()

profiling::ProfilingService & GetProfilingService ( armnn::Runtime runtime)

Definition at line 25 of file TestUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), CheckRelatedLayers(), and VerifyPostOptimisationStructureTestImpl().

26 {
27  return runtime->m_ProfilingService;
28 }

◆ GetResizeMethodAsCString()

constexpr const char* armnn::GetResizeMethodAsCString ( ResizeMethod  method)

Definition at line 233 of file TypesUtils.hpp.

References Bilinear, and NearestNeighbor.

Referenced by StringifyLayerParameters< ResizeDescriptor >::Serialize().

234 {
235  switch (method)
236  {
237  case ResizeMethod::Bilinear: return "Bilinear";
238  case ResizeMethod::NearestNeighbor: return "NearestNeighbour";
239  default: return "Unknown";
240  }
241 }

◆ GetStatusAsCString()

constexpr char const* armnn::GetStatusAsCString ( Status  status)

Definition at line 17 of file TypesUtils.hpp.

References Failure, and Success.

Referenced by operator<<().

18 {
19  switch (status)
20  {
21  case armnn::Status::Success: return "Status::Success";
22  case armnn::Status::Failure: return "Status::Failure";
23  default: return "Unknown";
24  }
25 }

◆ GetTensorInfo()

const TensorInfo& armnn::GetTensorInfo ( const ITensorHandle tensorHandle)
inline

float32 helpers

Definition at line 26 of file RefWorkloadUtils.hpp.

References RefTensorHandle::GetTensorInfo().

Referenced by BatchNormImpl(), Concatenate(), RefStridedSliceWorkload::Execute(), RefDepthToSpaceWorkload::Execute(), RefConvertBf16ToFp32Workload::Execute(), RefFakeQuantizationFloat32Workload::Execute(), RefSpaceToDepthWorkload::Execute(), RefFillWorkload::Execute(), RefSpaceToBatchNdWorkload::Execute(), RefFloorWorkload::Execute(), RefConvertFp16ToFp32Workload::Execute(), RefLogSoftmaxWorkload::Execute(), RefConvertFp32ToBf16Workload::Execute(), RefConvertFp32ToFp16Workload::Execute(), RefPadWorkload::Execute(), RefActivationWorkload::Execute(), RefReshapeWorkload::Execute(), RefResizeBilinearWorkload::Execute(), RefResizeWorkload::Execute(), RefSoftmaxWorkload::Execute(), RefStackWorkload::Execute(), RefBatchNormalizationWorkload::Execute(), RefBatchToSpaceNdWorkload::Execute(), RefSliceWorkload::Execute(), RefInstanceNormalizationWorkload::Execute(), RefDetectionPostProcessWorkload::Execute(), RefArgMinMaxWorkload::Execute(), RefPreluWorkload::Execute(), RefDequantizeWorkload::Execute(), RefL2NormalizationWorkload::Execute(), RefNormalizationWorkload::Execute(), RefRankWorkload::Execute(), RefLstmWorkload::Execute(), RefMeanWorkload::Execute(), RefPooling2dWorkload::Execute(), RefQLstmWorkload::Execute(), RefElementwiseUnaryWorkload::Execute(), RefGatherWorkload::Execute(), RefComparisonWorkload::Execute(), RefLogicalBinaryWorkload::Execute(), RefLogicalUnaryWorkload::Execute(), RefTransposeWorkload< DataType >::Execute(), RefPermuteWorkload< DataType >::Execute(), RefElementwiseWorkload< Functor, ParentDescriptor, DebugString >::Execute(), RefDebugWorkload< DataType >::Execute(), OutputSlot::GetNumConnections(), InstanceNorm(), OutputSlot::MoveAllConnections(), RefQuantizeWorkload::PostAllocationConfigure(), RefDepthwiseConvolution2dWorkload::PostAllocationConfigure(), RefConvolution2dWorkload::PostAllocationConfigure(), RefComparisonWorkload::PostAllocationConfigure(), RefLogicalUnaryWorkload::PostAllocationConfigure(), RefConstantWorkload::PostAllocationConfigure(), RefElementwiseUnaryWorkload::PostAllocationConfigure(), RefLogicalBinaryWorkload::PostAllocationConfigure(), RefTransposeConvolution2dWorkload::PostAllocationConfigure(), RefFullyConnectedWorkload::PostAllocationConfigure(), RefElementwiseWorkload< Functor, ParentDescriptor, DebugString >::PostAllocationConfigure(), PreluImpl(), Split(), Splitter(), Stack(), SwitchLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

27 {
28  // We know that reference workloads use RefTensorHandles for inputs and outputs
29  const RefTensorHandle* refTensorHandle =
30  PolymorphicDowncast<const RefTensorHandle*>(tensorHandle);
31  return refTensorHandle->GetTensorInfo();
32 }

◆ GetTimeDuration()

std::chrono::duration<double, std::milli> armnn::GetTimeDuration ( std::chrono::high_resolution_clock::time_point  start_time)
inline

Definition at line 19 of file Timer.hpp.

References GetTimeNow().

Referenced by InferenceModel< IParser, TDataType >::InferenceModel(), InferenceModel< IParser, TDataType >::Run(), Runtime::Runtime(), and Runtime::~Runtime().

21 {
22  return std::chrono::duration<double, std::milli>(GetTimeNow() - start_time);
23 }
std::chrono::high_resolution_clock::time_point GetTimeNow()
Definition: Timer.hpp:14

◆ GetTimeNow()

std::chrono::high_resolution_clock::time_point armnn::GetTimeNow ( )
inline

Definition at line 14 of file Timer.hpp.

Referenced by GetTimeDuration(), InferenceModel< IParser, TDataType >::InferenceModel(), InferenceModel< IParser, TDataType >::Run(), Runtime::Runtime(), and Runtime::~Runtime().

15 {
16  return std::chrono::high_resolution_clock::now();
17 }

◆ GetUnaryOperationAsCString()

constexpr char const* armnn::GetUnaryOperationAsCString ( UnaryOperation  operation)

Definition at line 71 of file TypesUtils.hpp.

References Abs, Exp, LogicalNot, Neg, Rsqrt, and Sqrt.

Referenced by RefElementwiseUnaryWorkload::Execute(), and RefLogicalUnaryWorkload::Execute().

72 {
73  switch (operation)
74  {
75  case UnaryOperation::Abs: return "Abs";
76  case UnaryOperation::Exp: return "Exp";
77  case UnaryOperation::Sqrt: return "Sqrt";
78  case UnaryOperation::Rsqrt: return "Rsqrt";
79  case UnaryOperation::Neg: return "Neg";
80  case UnaryOperation::LogicalNot: return "LogicalNot";
81  default: return "Unknown";
82  }
83 }

◆ GetUnpaddedTensorStrides()

TensorShape GetUnpaddedTensorStrides ( const TensorInfo tensorInfo)

Definition at line 15 of file CpuTensorHandle.cpp.

References TensorInfo::GetDataType(), GetDataTypeSize(), and TensorInfo::GetShape().

Referenced by RefTensorHandle::GetStrides(), SampleTensorHandle::GetStrides(), and ConstCpuTensorHandle::GetStrides().

16 {
17  TensorShape shape(tensorInfo.GetShape());
18  auto size = GetDataTypeSize(tensorInfo.GetDataType());
19  auto runningSize = size;
20  std::vector<unsigned int> strides(shape.GetNumDimensions());
21  auto lastIdx = shape.GetNumDimensions()-1;
22  for (unsigned int i=0; i < lastIdx ; i++)
23  {
24  strides[lastIdx-i] = runningSize;
25  runningSize *= shape[lastIdx-i];
26  }
27  strides[0] = runningSize;
28  return TensorShape(shape.GetNumDimensions(), strides.data());
29 }
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:126

◆ IgnoreUnused()

void armnn::IgnoreUnused ( Ts &&  ...)
inline

Definition at line 14 of file IgnoreUnused.hpp.

Referenced by ConvertFp32ToFp16Layer::Accept(), ConvertBf16ToFp32Layer::Accept(), ConvertFp16ToFp32Layer::Accept(), ConvertFp32ToBf16Layer::Accept(), DebugLayer::Accept(), FakeQuantizationLayer::Accept(), MapLayer::Accept(), MemCopyLayer::Accept(), MemImportLayer::Accept(), UnmapLayer::Accept(), PreCompiledLayer::Accept(), IInferenceTestCaseProvider::AddCommandLineOptions(), AdditionAfterMaxPoolTest(), AdditionBroadcast1ElementTestImpl(), AdditionBroadcastTestImpl(), ArgMinMax(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BoundedReLuTestCommon(), BoundedReLuUint8UpperAndLowerBoundTest(), armnnTfParser::CalculatePaddedOutputTensorInfo(), CalculateSlotOptionForOutput(), ParserFlatbuffersSerializeFixture::CheckTensors(), ClassifierTestCase< TTestCaseDatabase, TModel >::ClassifierTestCase(), ClContextControl::ClContextControl(), SpaceToBatchNdLayer::Clone(), SpaceToDepthLayer::Clone(), CompareActivationTestImpl(), CompareAdditionTest(), CompareBatchNormTest(), CompareMultiplicationTest(), ConcatDifferentInputOutputQParamTest(), ConcatTest(), ConcatUint16Test(), ConcatUint8DifferentQParamsTest(), ConcatUint8Test(), ConstantLinearActivationTestCommon(), ConvertBf16ToFp32Test(), ConvertFp32ToBf16Test(), armnnTfParser::ConvertTfTensorDataType(), Convolution2d3x3Stride2x2BFloat16SmallValueTest(), Convolution2d3x3Stride2x2BFloat16Test(), CopyTensorContentsGeneric(), NeonWorkloadFactory::CreateAbs(), ClWorkloadFactory::CreateAbs(), RefWorkloadFactory::CreateAbs(), MockBackend::CreateBackendProfilingContext(), ClWorkloadFactory::CreateEqual(), NeonWorkloadFactory::CreateEqual(), RefWorkloadFactory::CreateEqual(), ClWorkloadFactory::CreateGreater(), NeonWorkloadFactory::CreateGreater(), RefWorkloadFactory::CreateGreater(), ClWorkloadFactory::CreateRsqrt(), NeonWorkloadFactory::CreateRsqrt(), RefWorkloadFactory::CreateRsqrt(), RefTensorHandleFactory::CreateSubTensorHandle(), SampleDynamicTensorHandleFactory::CreateSubTensorHandle(), SampleDynamicWorkloadFactory::CreateSubTensorHandle(), RefWorkloadFactory::CreateSubTensorHandle(), RefTensorHandleFactory::CreateTensorHandle(), SampleDynamicTensorHandleFactory::CreateTensorHandle(), ClWorkloadFactory::CreateTensorHandle(), RefWorkloadFactory::CreateTensorHandle(), ITensorHandleFactory::CreateTensorHandle(), OutputLayer::CreateTensorHandles(), InputLayer::CreateWorkload(), MapLayer::CreateWorkload(), MemCopyLayer::CreateWorkload(), MemImportLayer::CreateWorkload(), OutputLayer::CreateWorkload(), MergeLayer::CreateWorkload(), UnmapLayer::CreateWorkload(), StandInLayer::CreateWorkload(), QASymm8Decoder::DecodeTensor(), QASymmS8Decoder::DecodeTensor(), QSymmS8Decoder::DecodeTensor(), QSymm16Decoder::DecodeTensor(), BFloat16Decoder::DecodeTensor(), Float16Decoder::DecodeTensor(), Float32Decoder::DecodeTensor(), ScaledInt32Decoder::DecodeTensor(), Int32Decoder::DecodeTensor(), Int32ToInt32tDecoder::DecodeTensor(), BooleanDecoder::DecodeTensor(), BooleanDecoderBool::DecodeTensor(), Dequantize(), SelectiveQuantizer< T, false >::Dequantize(), SelectiveQuantizer< armnn::Half, false >::Dequantize(), SelectiveQuantizer< armnn::BFloat16, false >::Dequantize(), Graph::DetachObservable(), DetectionPostProcess(), DivisionByZeroTest(), Profiler::EndEvent(), LoadedNetwork::EnqueueWorkload(), RefStridedSliceWorkload::Execute(), ExecutionFrame::ExecuteWorkloads(), exit_capture(), FakeQuantizationTest(), FalseFunc(), FalseFuncF16(), FalseFuncF32(), FalseFuncI32(), FalseFuncU8(), FalseInputFuncF16(), FalseInputFuncF32(), FalseOutputFuncF16(), FalseOutputFuncF32(), Gather(), NeonTensorHandleFactory::GetCapabilities(), ITensorHandleFactory::GetCapabilities(), MockCounterDirectory::GetCounter(), MockCounterDirectory::GetCounterSet(), MockCounterDirectory::GetDevice(), GetImageDataInArmNnLayoutAsNormalizedFloats(), Deserializer::GetNetworkInputBindingInfo(), Deserializer::GetNetworkOutputBindingInfo(), Deserializer::GetNormalizationDescriptor(), LoadedNetwork::GetOutputTensorInfo(), Deserializer::GetPoolingDescriptor(), MockProfilingConnectionFactory::GetProfilingConnection(), ITensorHandle::Import(), SliceLayer::InferOutputShapes(), StackLayer::InferOutputShapes(), StandInLayer::InferOutputShapes(), ReshapeLayer::InferOutputShapes(), SplitterLayer::InferOutputShapes(), NeonLayerSupport::IsActivationSupported(), MockImportLayerSupport::IsAdditionSupported(), RefLayerSupport::IsArgMinMaxSupported(), RefLayerSupport::IsBatchNormalizationSupported(), RefLayerSupport::IsBatchToSpaceNdSupported(), RefLayerSupport::IsComparisonSupported(), RefLayerSupport::IsConcatSupported(), NeonLayerSupport::IsConvertBf16ToFp32Supported(), NeonLayerSupport::IsConvertFp16ToFp32Supported(), NeonLayerSupport::IsConvertFp32ToBf16Supported(), NeonLayerSupport::IsConvertFp32ToFp16Supported(), RefLayerSupport::IsConvolution2dSupported(), RefLayerSupport::IsDepthToSpaceSupported(), RefLayerSupport::IsDepthwiseConvolutionSupported(), RefLayerSupport::IsDetectionPostProcessSupported(), RefLayerSupport::IsElementwiseUnarySupported(), RefLayerSupport::IsFakeQuantizationSupported(), ClLayerSupport::IsFillSupported(), NeonLayerSupport::IsFillSupported(), RefLayerSupport::IsFillSupported(), NeonLayerSupport::IsFloorSupported(), RefLayerSupport::IsFloorSupported(), MockImportLayerSupport::IsInputSupported(), RefLayerSupport::IsInstanceNormalizationSupported(), RefLayerSupport::IsL2NormalizationSupported(), ClLayerSupport::IsLogicalBinarySupported(), RefLayerSupport::IsLogicalBinarySupported(), RefLayerSupport::IsLogicalUnarySupported(), RefLayerSupport::IsLogSoftmaxSupported(), RefLayerSupport::IsLstmSupported(), RefLayerSupport::IsNormalizationSupported(), ProfilingStateMachine::IsOneOfStates(), MockImportLayerSupport::IsOutputSupported(), RefLayerSupport::IsPadSupported(), RefLayerSupport::IsPermuteSupported(), RefLayerSupport::IsPooling2dSupported(), RefLayerSupport::IsQLstmSupported(), RefLayerSupport::IsRankSupported(), ClLayerSupport::IsReshapeSupported(), NeonLayerSupport::IsReshapeSupported(), RefLayerSupport::IsReshapeSupported(), RefLayerSupport::IsResizeSupported(), RefLayerSupport::IsSliceSupported(), RefLayerSupport::IsSoftmaxSupported(), RefLayerSupport::IsSpaceToBatchNdSupported(), RefLayerSupport::IsSpaceToDepthSupported(), ClLayerSupport::IsSplitterSupported(), NeonLayerSupport::IsSplitterSupported(), RefLayerSupport::IsSplitterSupported(), RefLayerSupport::IsStackSupported(), RefLayerSupport::IsStridedSliceSupported(), RefLayerSupport::IsTransposeConvolution2dSupported(), RefLayerSupport::IsTransposeSupported(), Layer::Layer(), LogSoftmax(), MaximumSimpleTest(), MinimumBroadcast1ElementTest1(), StubCommandHandler::operator()(), TestFunctorA::operator()(), armnnTfParser::OutputShapeOfExpandDims(), TfLiteParser::OutputShapeOfSqueeze(), armnnTfParser::OutputShapeOfSqueeze(), Pad2dTestCommon(), Pad3dTestCommon(), Pad4dTestCommon(), PermuteInputsForConcat(), PermuteTensorData(), PreluTest(), IInferenceTestCaseProvider::ProcessCommandLineOptions(), YoloTestCase< Model >::ProcessResult(), SelectiveQuantizer< T, false >::Quantize(), SelectiveQuantizer< armnn::Half, false >::Quantize(), SelectiveQuantizer< armnn::BFloat16, false >::Quantize(), RankTest(), MockProfilingConnection::ReadPacket(), TestProfilingConnectionArmnnError::ReadPacket(), TestProfilingConnectionBadAckPacket::ReadPacket(), CounterDirectory::RegisterCounter(), MockCounterDirectory::RegisterCounter(), OptimizeInverseConversionsImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), SquashEqualSiblingsImpl< Comparable >::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), ConvertConstants< Converter, Predicate >::Run(), MockSendCounterPacket::SendCounterDirectoryPacket(), MockSendCounterPacket::SendPeriodicCounterCapturePacket(), MockSendCounterPacket::SendPeriodicCounterSelectionPacket(), ILocalPacketHandler::SetConnection(), TypedIterator< const float, Decoder< float > >::SetIndex(), SetLogFilter(), SimpleActivationTest(), SimpleConvertFp16ToFp32Test(), SimpleConvertFp32ToFp16Test(), SimpleConvolution2d3x3NhwcTestCommon(), SimpleConvolution2d3x3Stride2x2TestCommon(), SimpleConvolution2dNhwcTestImpl(), SimpleConvolution2dTestImpl(), SimpleFillTest(), SimpleFloorTest(), SimplePermuteTestImpl(), SimpleTransposeTestImpl(), Slice(), SqrtNNTest(), OpenClTimer::Start(), Graph::SubstituteSubgraph(), TestDynamicBackendId(), TestQuantizeConvolution2d(), TestQuantizeDepthwiseConvolution2d(), TestQuantizeTransposeConvolution2d(), TfParser::TfParser(), TrueFunc(), ValidateFullyConnectedLayer(), DynamicQuantizationVisitor::VisitAbsLayer(), SerializerVisitor::VisitAbsLayer(), StaticRangeVisitor::VisitActivationLayer(), SerializerVisitor::VisitActivationLayer(), DynamicQuantizationVisitor::VisitActivationLayer(), StaticRangeVisitor::VisitAdditionLayer(), DynamicQuantizationVisitor::VisitAdditionLayer(), SerializerVisitor::VisitAdditionLayer(), DynamicQuantizationVisitor::VisitArgMinMaxLayer(), SerializerVisitor::VisitArgMinMaxLayer(), StaticRangeVisitor::VisitBatchNormalizationLayer(), DynamicQuantizationVisitor::VisitBatchNormalizationLayer(), SerializerVisitor::VisitBatchNormalizationLayer(), SerializerVisitor::VisitBatchToSpaceNdLayer(), StaticRangeVisitor::VisitBatchToSpaceNdLayer(), DynamicQuantizationVisitor::VisitBatchToSpaceNdLayer(), SerializerVisitor::VisitComparisonLayer(), StaticRangeVisitor::VisitConcatLayer(), SerializerVisitor::VisitConcatLayer(), DynamicQuantizationVisitor::VisitConcatLayer(), StaticRangeVisitor::VisitConstantLayer(), SerializerVisitor::VisitConstantLayer(), DynamicQuantizationVisitor::VisitConstantLayer(), StaticRangeVisitor::VisitConvolution2dLayer(), DynamicQuantizationVisitor::VisitConvolution2dLayer(), SerializerVisitor::VisitConvolution2dLayer(), SerializerVisitor::VisitDepthToSpaceLayer(), StaticRangeVisitor::VisitDepthwiseConvolution2dLayer(), DynamicQuantizationVisitor::VisitDepthwiseConvolution2dLayer(), SerializerVisitor::VisitDepthwiseConvolution2dLayer(), SerializerVisitor::VisitDequantizeLayer(), SerializerVisitor::VisitDetectionPostProcessLayer(), SerializerVisitor::VisitDivisionLayer(), SerializerVisitor::VisitElementwiseUnaryLayer(), SerializerVisitor::VisitEqualLayer(), SerializerVisitor::VisitFillLayer(), SerializerVisitor::VisitFloorLayer(), StaticRangeVisitor::VisitFullyConnectedLayer(), DynamicQuantizationVisitor::VisitFullyConnectedLayer(), SerializerVisitor::VisitFullyConnectedLayer(), SerializerVisitor::VisitGatherLayer(), SerializerVisitor::VisitGreaterLayer(), OverrideInputRangeVisitor::VisitInputLayer(), InputLayerVisitor::VisitInputLayer(), DynamicQuantizationVisitor::VisitInputLayer(), SerializerVisitor::VisitInputLayer(), SerializerVisitor::VisitInstanceNormalizationLayer(), SerializerVisitor::VisitL2NormalizationLayer(), VisitLayersTopologically(), SerializerVisitor::VisitLogicalBinaryLayer(), SerializerVisitor::VisitLogSoftmaxLayer(), SerializerVisitor::VisitLstmLayer(), SerializerVisitor::VisitMaximumLayer(), SerializerVisitor::VisitMeanLayer(), SerializerVisitor::VisitMergeLayer(), SerializerVisitor::VisitMinimumLayer(), SerializerVisitor::VisitMultiplicationLayer(), DynamicQuantizationVisitor::VisitNormalizationLayer(), SerializerVisitor::VisitNormalizationLayer(), DynamicQuantizationVisitor::VisitOutputLayer(), SerializerVisitor::VisitOutputLayer(), SerializerVisitor::VisitPadLayer(), StaticRangeVisitor::VisitPermuteLayer(), DynamicQuantizationVisitor::VisitPermuteLayer(), SerializerVisitor::VisitPermuteLayer(), StaticRangeVisitor::VisitPooling2dLayer(), DynamicQuantizationVisitor::VisitPooling2dLayer(), SerializerVisitor::VisitPooling2dLayer(), SerializerVisitor::VisitPreluLayer(), SerializerVisitor::VisitQLstmLayer(), SerializerVisitor::VisitQuantizedLstmLayer(), SerializerVisitor::VisitQuantizeLayer(), SerializerVisitor::VisitRankLayer(), StaticRangeVisitor::VisitReshapeLayer(), DynamicQuantizationVisitor::VisitReshapeLayer(), SerializerVisitor::VisitReshapeLayer(), StaticRangeVisitor::VisitResizeBilinearLayer(), DynamicQuantizationVisitor::VisitResizeBilinearLayer(), SerializerVisitor::VisitResizeBilinearLayer(), StaticRangeVisitor::VisitResizeLayer(), SerializerVisitor::VisitResizeLayer(), SerializerVisitor::VisitRsqrtLayer(), SerializerVisitor::VisitSliceLayer(), StaticRangeVisitor::VisitSoftmaxLayer(), DynamicQuantizationVisitor::VisitSoftmaxLayer(), SerializerVisitor::VisitSoftmaxLayer(), StaticRangeVisitor::VisitSpaceToBatchNdLayer(), DynamicQuantizationVisitor::VisitSpaceToBatchNdLayer(), SerializerVisitor::VisitSpaceToBatchNdLayer(), SerializerVisitor::VisitSpaceToDepthLayer(), StaticRangeVisitor::VisitSplitterLayer(), DynamicQuantizationVisitor::VisitSplitterLayer(), SerializerVisitor::VisitSplitterLayer(), SerializerVisitor::VisitStackLayer(), SerializerVisitor::VisitStandInLayer(), StaticRangeVisitor::VisitStridedSliceLayer(), DynamicQuantizationVisitor::VisitStridedSliceLayer(), SerializerVisitor::VisitStridedSliceLayer(), SerializerVisitor::VisitSubtractionLayer(), SerializerVisitor::VisitSwitchLayer(), SerializerVisitor::VisitTransposeConvolution2dLayer(), SerializerVisitor::VisitTransposeLayer(), MockProfilingServiceStatus::WaitForProfilingServiceActivation(), TestProfilingConnectionBase::WritePacket(), Graph::LayerInGraph< InputLayer >::~LayerInGraph(), Graph::LayerInGraph< OutputLayer >::~LayerInGraph(), and ScopedProfilingEvent::~ScopedProfilingEvent().

14 {}

◆ InitializeArmComputeClTensorData()

void armnn::InitializeArmComputeClTensorData ( arm_compute::CLTensor &  clTensor,
const ConstCpuTensorHandle handle 
)
inline

Definition at line 90 of file ClWorkloadUtils.hpp.

References ARMNN_ASSERT.

92 {
93  ARMNN_ASSERT(handle);
94 
95  armcomputetensorutils::InitialiseArmComputeTensorEmpty(clTensor);
96  switch(handle->GetTensorInfo().GetDataType())
97  {
98  case DataType::Float16:
99  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<armnn::Half>());
100  break;
101  case DataType::Float32:
102  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<float>());
103  break;
104  case DataType::QAsymmU8:
105  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<uint8_t>());
106  break;
108  case DataType::QuantizedSymm8PerAxis:
110  case DataType::QAsymmS8:
111  case DataType::QSymmS8:
112  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int8_t>());
113  break;
114  case DataType::QSymmS16:
115  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int16_t>());
116  break;
118  case DataType::Signed32:
119  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int32_t>());
120  break;
121  default:
122  ARMNN_ASSERT_MSG(false, "Unexpected tensor type.");
123  }
124 };
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void CopyArmComputeClTensorData(arm_compute::CLTensor &dstTensor, const T *srcData)
half_float::half Half
Definition: Half.hpp:16

◆ InitializeArmComputeTensorData()

void armnn::InitializeArmComputeTensorData ( arm_compute::Tensor &  tensor,
const ConstCpuTensorHandle handle 
)
inline

Definition at line 35 of file NeonWorkloadUtils.hpp.

References ARMNN_ASSERT, ARMNN_ASSERT_MSG, ARMNN_FALLTHROUGH, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, CopyArmComputeTensorData(), Float16, Float32, ConstCpuTensorHandle::GetConstTensor(), TensorInfo::GetDataType(), ConstCpuTensorHandle::GetTensorInfo(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, and Signed32.

37 {
38  ARMNN_ASSERT(handle);
39 
40  switch(handle->GetTensorInfo().GetDataType())
41  {
42  case DataType::Float16:
43  CopyArmComputeTensorData(tensor, handle->GetConstTensor<armnn::Half>());
44  break;
45  case DataType::Float32:
46  CopyArmComputeTensorData(tensor, handle->GetConstTensor<float>());
47  break;
48  case DataType::QAsymmU8:
49  CopyArmComputeTensorData(tensor, handle->GetConstTensor<uint8_t>());
50  break;
52  case DataType::QuantizedSymm8PerAxis:
54  case DataType::QSymmS8:
55  case DataType::QAsymmS8:
56  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int8_t>());
57  break;
59  case DataType::Signed32:
60  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int32_t>());
61  break;
62  case DataType::QSymmS16:
63  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int16_t>());
64  break;
65  default:
66  ARMNN_ASSERT_MSG(false, "Unexpected tensor type.");
67  }
68 };
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void CopyArmComputeTensorData(arm_compute::Tensor &dstTensor, const T *srcData)
half_float::half Half
Definition: Half.hpp:16

◆ InsertConvertBf16ToFp32LayersBefore()

std::vector< ConvertBf16ToFp32Layer * > InsertConvertBf16ToFp32LayersBefore ( Graph graph,
Layer layer,
bool  expectCorrectInputType 
)

Definition at line 51 of file NetworkUtils.cpp.

References Layer::BeginInputSlots(), BFloat16, Layer::EndInputSlots(), Float32, InputSlot::GetConnectedOutputSlot(), TensorInfo::GetDataType(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetNumInputSlots(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), Graph::InsertNewLayer(), TensorInfo::SetDataType(), and OutputSlot::SetTensorInfo().

Referenced by AttemptBackendAssignment().

54 {
55  std::vector<ConvertBf16ToFp32Layer*> convertLayers;
56  convertLayers.reserve(layer.GetNumInputSlots());
57 
58  // Insert a ConvertBf16ToFp32Layer before each input slot
59  for (auto&& inputSlot = layer.BeginInputSlots(); inputSlot != layer.EndInputSlots(); ++inputSlot)
60  {
61  bool allowInsert = true;
62  if (expectCorrectInputType)
63  {
64  // Only insert ConvertBf16ToFp32Layer before BF16 input slots
65  OutputSlot* connectedOutputSlot = inputSlot->GetConnectedOutputSlot();
66  allowInsert =
67  connectedOutputSlot && connectedOutputSlot->GetTensorInfo().GetDataType() == DataType::BFloat16;
68  }
69 
70  if (allowInsert)
71  {
72  const std::string name =
73  std::string("convert_bf16_to_fp32-" + std::to_string(inputSlot->GetSlotIndex()) + "-") +
74  layer.GetName();
75  ConvertBf16ToFp32Layer* convertLayer =
76  graph.InsertNewLayer<ConvertBf16ToFp32Layer>(*inputSlot, name.c_str());
77 
78  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
79  convertInfo.SetDataType(DataType::Float32);
80 
81  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
82 
83  convertLayers.emplace_back(convertLayer);
84  }
85  }
86 
87  return convertLayers;
88 }

◆ InsertConvertFp16ToFp32LayersBefore()

std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore ( Graph graph,
Layer layer,
bool  expectCorrectInputType 
)

Definition at line 129 of file NetworkUtils.cpp.

References Layer::BeginInputSlots(), Layer::EndInputSlots(), Float16, Float32, InputSlot::GetConnectedOutputSlot(), TensorInfo::GetDataType(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetNumInputSlots(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), Graph::InsertNewLayer(), TensorInfo::SetDataType(), and OutputSlot::SetTensorInfo().

Referenced by AttemptBackendAssignment(), BOOST_AUTO_TEST_CASE(), and ConvertFp32NetworkToFp16Impl::Run().

132 {
133  std::vector<ConvertFp16ToFp32Layer*> convertLayers;
134  convertLayers.reserve(layer.GetNumInputSlots());
135 
136  // Insert a ConvertFp16ToFp32Layer before each input slot
137  for (auto&& inputSlot = layer.BeginInputSlots(); inputSlot != layer.EndInputSlots(); ++inputSlot)
138  {
139  bool allowInsert = true;
140  if (expectCorrectInputType)
141  {
142  // Only insert ConvertFp16ToFp32Layer before FP16 input slots
143  OutputSlot* connectedOutputSlot = inputSlot->GetConnectedOutputSlot();
144  allowInsert =
145  connectedOutputSlot && connectedOutputSlot->GetTensorInfo().GetDataType() == DataType::Float16;
146  }
147 
148  if (allowInsert)
149  {
150  const std::string name =
151  std::string("convert_fp16_to_fp32-" + std::to_string(inputSlot->GetSlotIndex()) + "-") +
152  layer.GetName();
153  ConvertFp16ToFp32Layer* convertLayer =
154  graph.InsertNewLayer<ConvertFp16ToFp32Layer>(*inputSlot, name.c_str());
155 
156  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
157  convertInfo.SetDataType(DataType::Float32);
158 
159  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
160 
161  convertLayers.emplace_back(convertLayer);
162  }
163  }
164 
165  return convertLayers;
166 }

◆ InsertConvertFp32ToBf16LayersAfter()

std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersAfter ( Graph graph,
Layer layer 
)

Definition at line 168 of file NetworkUtils.cpp.

References BFloat16, Float32, InputSlot::GetConnectedOutputSlot(), TensorInfo::GetDataType(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetNumOutputSlots(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), Graph::InsertNewLayer(), TensorInfo::SetDataType(), and OutputSlot::SetTensorInfo().

Referenced by AttemptBackendAssignment().

169 {
170  const unsigned int numOutputSlots = layer.GetNumOutputSlots();
171 
172  std::vector<ConvertFp32ToBf16Layer*> convertLayers;
173  convertLayers.reserve(numOutputSlots);
174 
175  // Update Bf16 output slots to FP32 on current layer
176  ChangeOutputBf16ToFp32(layer);
177 
178  // Insert a ConvertFp32ToBf16Layer after each FP32 output slot
179  for (unsigned int slotIndex = 0u; slotIndex < numOutputSlots; ++slotIndex)
180  {
181  OutputSlot& outputSlot = layer.GetOutputSlot(slotIndex);
182  if(outputSlot.GetTensorInfo().GetDataType() == DataType::Float32)
183  {
184  const std::string name =
185  std::string("convert_fp32_to_bf16-" + std::to_string(slotIndex) + "-") + layer.GetName();
186  ConvertFp32ToBf16Layer* convertLayer =
187  graph.InsertNewLayer<ConvertFp32ToBf16Layer>(outputSlot, name.c_str());
188 
189  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
190  convertInfo.SetDataType(DataType::BFloat16);
191 
192  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
193 
194  convertLayers.emplace_back(convertLayer);
195  }
196  }
197 
198  return convertLayers;
199 }

◆ InsertConvertFp32ToBf16LayersBefore()

std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersBefore ( Graph graph,
Layer layer,
bool  expectCorrectInputType 
)

Definition at line 90 of file NetworkUtils.cpp.

References Layer::BeginInputSlots(), BFloat16, Layer::EndInputSlots(), Float32, InputSlot::GetConnectedOutputSlot(), TensorInfo::GetDataType(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetNumInputSlots(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), Graph::InsertNewLayer(), TensorInfo::SetDataType(), and OutputSlot::SetTensorInfo().

Referenced by ConvertFp32NetworkToBf16Impl::Run().

93 {
94  std::vector<ConvertFp32ToBf16Layer*> convertLayers;
95  convertLayers.reserve(layer.GetNumInputSlots());
96 
97  // Insert a ConvertFp32ToBf16Layer before each input slot
98  for (auto&& inputSlot = layer.BeginInputSlots(); inputSlot != layer.EndInputSlots(); ++inputSlot)
99  {
100  bool allowInsert = true;
101  if (expectCorrectInputType)
102  {
103  // Only insert ConvertFp32ToBf16Layer before FP32 input slots
104  OutputSlot* connectedOutputSlot = inputSlot->GetConnectedOutputSlot();
105  allowInsert =
106  connectedOutputSlot && connectedOutputSlot->GetTensorInfo().GetDataType() == DataType::Float32;
107  }
108 
109  if (allowInsert)
110  {
111  const std::string name =
112  std::string("convert_fp32_to_bf16-" + std::to_string(inputSlot->GetSlotIndex()) + "-") +
113  layer.GetName();
114  ConvertFp32ToBf16Layer* convertLayer =
115  graph.InsertNewLayer<ConvertFp32ToBf16Layer>(*inputSlot, name.c_str());
116 
117  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
118  convertInfo.SetDataType(DataType::BFloat16);
119 
120  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
121 
122  convertLayers.emplace_back(convertLayer);
123  }
124  }
125 
126  return convertLayers;
127 }

◆ InsertConvertFp32ToFp16LayersAfter()

std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter ( Graph graph,
Layer layer 
)

Definition at line 201 of file NetworkUtils.cpp.

References Float16, Float32, InputSlot::GetConnectedOutputSlot(), TensorInfo::GetDataType(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetNumOutputSlots(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), Graph::InsertNewLayer(), TensorInfo::SetDataType(), and OutputSlot::SetTensorInfo().

Referenced by AttemptBackendAssignment(), BOOST_AUTO_TEST_CASE(), and ConvertFp32NetworkToFp16Impl::Run().

202 {
203  const unsigned int numOutputSlots = layer.GetNumOutputSlots();
204 
205  std::vector<ConvertFp32ToFp16Layer*> convertLayers;
206  convertLayers.reserve(numOutputSlots);
207 
208  // Update FP16 output slots to FP32 on current layer
209  ChangeOutputFp16ToFp32(layer);
210 
211  // Insert a ConvertFp32ToFp16Layer after each FP32 output slot
212  for (unsigned int slotIndex = 0u; slotIndex < numOutputSlots; ++slotIndex)
213  {
214  OutputSlot& outputSlot = layer.GetOutputSlot(slotIndex);
215  if(outputSlot.GetTensorInfo().GetDataType() == DataType::Float32)
216  {
217  const std::string name =
218  std::string("convert_fp32_to_fp16-" + std::to_string(slotIndex) + "-") + layer.GetName();
219  ConvertFp32ToFp16Layer* convertLayer =
220  graph.InsertNewLayer<ConvertFp32ToFp16Layer>(outputSlot, name.c_str());
221 
222  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
223  convertInfo.SetDataType(DataType::Float16);
224 
225  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
226 
227  convertLayers.emplace_back(convertLayer);
228  }
229  }
230 
231  return convertLayers;
232 }

◆ InsertDebugLayerAfter()

std::vector< DebugLayer * > InsertDebugLayerAfter ( Graph graph,
Layer layer 
)

Definition at line 234 of file NetworkUtils.cpp.

References ARMNN_ASSERT, Layer::BeginOutputSlots(), CpuRef, Layer::EndOutputSlots(), InputSlot::GetConnectedOutputSlot(), Layer::GetInputSlot(), Layer::GetNameStr(), Layer::GetNumOutputSlots(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), Graph::InsertNewLayer(), Layer::SetBackendId(), and OutputSlot::SetTensorInfo().

Referenced by DynamicQuantizationVisitor::FinishVisit(), and AddDebugImpl::Run().

235 {
236  std::vector<DebugLayer*> debugLayers;
237  debugLayers.reserve(layer.GetNumOutputSlots());
238 
239  // Connect a DebugLayer to each output slot of the layer
240  for (auto outputSlot = layer.BeginOutputSlots(); outputSlot != layer.EndOutputSlots(); ++outputSlot)
241  {
242  const std::string debugName = std::string("DebugLayerAfter") + layer.GetNameStr();
243 
244  DebugLayer* debugLayer =
245  graph.InsertNewLayer<DebugLayer>(*outputSlot, debugName.c_str());
246 
247  // Sets output tensor info for the debug layer.
248  ARMNN_ASSERT(debugLayer->GetInputSlot(0).GetConnectedOutputSlot() == &(*outputSlot));
249  TensorInfo debugInfo = debugLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
250 
251  debugLayer->GetOutputSlot().SetTensorInfo(debugInfo);
252 
253  // NOTE: It is OK to do this because DebugLayer is only supported on CpuRef
254  debugLayer->SetBackendId(Compute::CpuRef);
255 
256  debugLayers.emplace_back(debugLayer);
257  }
258 
259  return debugLayers;
260 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ InstanceNorm()

void InstanceNorm ( const InstanceNormalizationQueueDescriptor data,
Decoder< float > &  inputDecoder,
Encoder< float > &  outputEncoder 
)

Definition at line 18 of file InstanceNorm.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), TensorInfo::GetShape(), GetTensorInfo(), DataLayoutIndexed::GetWidthIndex(), InstanceNormalizationDescriptor::m_Beta, InstanceNormalizationDescriptor::m_DataLayout, InstanceNormalizationDescriptor::m_Eps, InstanceNormalizationDescriptor::m_Gamma, QueueDescriptor::m_Inputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Encoder< IType >::Set().

Referenced by RefInstanceNormalizationWorkload::Execute().

21 {
22  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]);
23  const TensorShape inputShape = inputInfo.GetShape();
24 
25  armnnUtils::DataLayoutIndexed dataLayout(data.m_Parameters.m_DataLayout);
26 
27  unsigned int inputBatches = inputShape[0];
28  unsigned int inputHeight = inputShape[dataLayout.GetHeightIndex()];
29  unsigned int inputWidth = inputShape[dataLayout.GetWidthIndex()];
30  unsigned int inputChannels = inputShape[dataLayout.GetChannelsIndex()];
31 
32  float beta = data.m_Parameters.m_Beta;
33  float eps = data.m_Parameters.m_Eps;
34  float gamma = data.m_Parameters.m_Gamma;
35 
36  for (unsigned int n = 0; n < inputBatches; ++n)
37  {
38  for (unsigned int c = 0; c < inputChannels; ++c)
39  {
40  float mean = 0, var = 0;
41 
42  //Calculate Mean
43  for (unsigned int h = 0; h < inputHeight; h++)
44  {
45  for (unsigned int w = 0; w < inputWidth; w++)
46  {
47  unsigned int index = dataLayout.GetIndex(inputShape, n, c, h, w);
48 
49  inputDecoder[index];
50  float value = inputDecoder.Get();
51  mean += value;
52  }
53  }
54  mean /= static_cast<float>(inputHeight * inputWidth);
55 
56  //Calculate Variance
57  for (unsigned int h = 0; h < inputHeight; h++)
58  {
59  for (unsigned int w = 0; w < inputWidth; w++)
60  {
61  unsigned int index = dataLayout.GetIndex(inputShape, n, c, h, w);
62 
63  inputDecoder[index];
64  float value = inputDecoder.Get();
65  var += (value - mean) * (value - mean);
66  }
67  }
68  var /= static_cast<float>(inputHeight * inputWidth);
69 
70  // Apply Instance Normalisation
71  for (unsigned int h = 0; h < inputHeight; ++h)
72  {
73  for (unsigned int w = 0; w < inputWidth; ++w)
74  {
75  unsigned int index = dataLayout.GetIndex(inputShape, n, c, h, w);
76  inputDecoder[index];
77  outputEncoder[index];
78  outputEncoder.Set((inputDecoder.Get() - mean) * gamma / std::sqrt ( var + eps) + beta);
79  }
80 
81  }
82  }
83  }
84 }
virtual void Set(IType right)=0
virtual IType Get() const =0
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38

◆ IntersectionOverUnion()

float IntersectionOverUnion ( const float *  boxI,
const float *  boxJ 
)

Definition at line 30 of file DetectionPostProcess.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and NonMaxSuppression().

31 {
32  // Box-corner format: ymin, xmin, ymax, xmax.
33  const int yMin = 0;
34  const int xMin = 1;
35  const int yMax = 2;
36  const int xMax = 3;
37  float areaI = (boxI[yMax] - boxI[yMin]) * (boxI[xMax] - boxI[xMin]);
38  float areaJ = (boxJ[yMax] - boxJ[yMin]) * (boxJ[xMax] - boxJ[xMin]);
39  float yMinIntersection = std::max(boxI[yMin], boxJ[yMin]);
40  float xMinIntersection = std::max(boxI[xMin], boxJ[xMin]);
41  float yMaxIntersection = std::min(boxI[yMax], boxJ[yMax]);
42  float xMaxIntersection = std::min(boxI[xMax], boxJ[xMax]);
43  float areaIntersection = std::max(yMaxIntersection - yMinIntersection, 0.0f) *
44  std::max(xMaxIntersection - xMinIntersection, 0.0f);
45  float areaUnion = areaI + areaJ - areaIntersection;
46  return areaIntersection / areaUnion;
47 }

◆ IsActivationSupported()

bool IsActivationSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const ActivationDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 69 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

Referenced by BOOST_AUTO_TEST_CASE().

75 {
76  FORWARD_LAYER_SUPPORT_FUNC(backend, IsActivationSupported, input, output, descriptor);
77 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsActivationSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsAdditionSupported()

bool IsAdditionSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 79 of file LayerSupport.cpp.

References CheckTensorDataTypesEqual(), and FORWARD_LAYER_SUPPORT_FUNC.

85 {
86  if(!CheckTensorDataTypesEqual(input0, input1))
87  {
88  return false;
89  }
90 
91  FORWARD_LAYER_SUPPORT_FUNC(backend, IsAdditionSupported, input0, input1, output);
92 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsAdditionSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
bool CheckTensorDataTypesEqual(const TensorInfo &input0, const TensorInfo &input1)

◆ IsArgMinMaxSupported()

bool armnn::IsArgMinMaxSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const ArgMinMaxDescriptor descriptor,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 94 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

100 {
101  FORWARD_LAYER_SUPPORT_FUNC(backend, IsArgMinMaxSupported, input, output, descriptor);
102 }
bool IsArgMinMaxSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsBatchNormalizationSupported()

bool IsBatchNormalizationSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const TensorInfo mean,
const TensorInfo var,
const TensorInfo beta,
const TensorInfo gamma,
const BatchNormalizationDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 104 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

114 {
117  input,
118  output,
119  mean,
120  var,
121  beta,
122  gamma,
123  descriptor);
124 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsBatchNormalizationSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsBatchToSpaceNdSupported()

bool IsBatchToSpaceNdSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const BatchToSpaceNdDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 126 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

132 {
135  input,
136  output,
137  descriptor);
138 }
bool IsBatchToSpaceNdSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsBFloat16()

bool armnn::IsBFloat16 ( const WorkloadInfo info)

Definition at line 54 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug(), RefWorkloadFactory::CreatePermute(), and RefWorkloadFactory::CreateTranspose().

55 {
56  return IsDataType<DataType::BFloat16>(info);
57 }

◆ IsConcatSupported() [1/2]

bool armnn::IsConcatSupported ( const BackendId backend,
const std::vector< const TensorInfo *>  inputs,
const TensorInfo output,
const OriginsDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by IsConcatSupported().

◆ IsConcatSupported() [2/2]

bool armnn::IsConcatSupported ( const BackendId backend,
std::vector< const TensorInfo *>  inputs,
const TensorInfo output,
const OriginsDescriptor descriptor,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 140 of file LayerSupport.cpp.

References ARMNN_ASSERT, FORWARD_LAYER_SUPPORT_FUNC, and IsConcatSupported().

146 {
147  ARMNN_ASSERT(inputs.size() > 0);
148 
149  FORWARD_LAYER_SUPPORT_FUNC(backend, IsConcatSupported, inputs, output, descriptor);
150 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
bool IsConcatSupported(const BackendId &backend, std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ IsConstantSupported()

bool IsConstantSupported ( const BackendId backend,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 152 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

156 {
158 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsConstantSupported(const BackendId &backend, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsConvertFp16ToFp32Supported()

bool IsConvertFp16ToFp32Supported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 160 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

165 {
167 }
bool IsConvertFp16ToFp32Supported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsConvertFp32ToFp16Supported()

bool IsConvertFp32ToFp16Supported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 169 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

174 {
176 }
bool IsConvertFp32ToFp16Supported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsConvolution2dSupported()

bool IsConvolution2dSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const Convolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 178 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

186 {
187  FORWARD_LAYER_SUPPORT_FUNC(backend, IsConvolution2dSupported, input, output, descriptor, weights, biases);
188 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsConvolution2dSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsDataType()

bool armnn::IsDataType ( const WorkloadInfo info)

Definition at line 33 of file RefWorkloadFactory.cpp.

References WorkloadInfo::m_InputTensorInfos, and WorkloadInfo::m_OutputTensorInfos.

34 {
35  auto checkType = [](const TensorInfo& tensorInfo) {return tensorInfo.GetDataType() == ArmnnType;};
36  auto it = std::find_if(std::begin(info.m_InputTensorInfos), std::end(info.m_InputTensorInfos), checkType);
37  if (it != std::end(info.m_InputTensorInfos))
38  {
39  return true;
40  }
41  it = std::find_if(std::begin(info.m_OutputTensorInfos), std::end(info.m_OutputTensorInfos), checkType);
42  if (it != std::end(info.m_OutputTensorInfos))
43  {
44  return true;
45  }
46  return false;
47 }

◆ IsDebugSupported()

bool IsDebugSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 190 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

195 {
196  FORWARD_LAYER_SUPPORT_FUNC(backend, IsDebugSupported, input, output);
197 }
bool IsDebugSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsDepthwiseConvolutionSupported()

bool IsDepthwiseConvolutionSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const DepthwiseConvolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 199 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, DepthwiseConvolution2dDescriptor::m_DilationX, and DepthwiseConvolution2dDescriptor::m_DilationY.

207 {
208  if (descriptor.m_DilationX == 1 && descriptor.m_DilationY == 1)
209  {
210  // Pre 19.05 ArmNN did not have the dilation parameters.
211  // This version of IsDepthwiseConvolutionSupported is called for backwards-compatibility
214  input,
215  output,
216  descriptor,
217  weights,
218  biases);
219  }
220  else
221  {
223  IsDilatedDepthwiseConvolutionSupported,
224  input,
225  output,
226  descriptor,
227  weights,
228  biases);
229  }
230 }
bool IsDepthwiseConvolutionSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsDequantizeSupported()

bool IsDequantizeSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 232 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and IsDetectionPostProcessSupported().

237 {
238  FORWARD_LAYER_SUPPORT_FUNC(backend, IsDequantizeSupported, input, output);
239 }
bool IsDequantizeSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsDetectionPostProcessSupported()

bool armnn::IsDetectionPostProcessSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const DetectionPostProcessDescriptor descriptor,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Referenced by IsDequantizeSupported().

◆ IsDivisionSupported()

bool IsDivisionSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 248 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

254 {
255  FORWARD_LAYER_SUPPORT_FUNC(backend, IsDivisionSupported, input0, input1, output);
256 }
bool IsDivisionSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsEqualSupported()

bool IsEqualSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 258 of file LayerSupport.cpp.

References Equal, and FORWARD_LAYER_SUPPORT_FUNC.

264 {
266  IsComparisonSupported,
267  input0,
268  input1,
269  output,
270  ComparisonDescriptor(ComparisonOperation::Equal));
271 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsFakeQuantizationSupported()

bool IsFakeQuantizationSupported ( const BackendId backend,
const TensorInfo input,
const FakeQuantizationDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 273 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

278 {
279  FORWARD_LAYER_SUPPORT_FUNC(backend, IsFakeQuantizationSupported, input, descriptor);
280 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsFakeQuantizationSupported(const BackendId &backend, const TensorInfo &input, const FakeQuantizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsFloat16()

bool armnn::IsFloat16 ( const WorkloadInfo info)

Definition at line 59 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

60 {
61  return IsDataType<DataType::Float16>(info);
62 }

◆ IsFloorSupported()

bool IsFloorSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 282 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, TensorInfo::GetDataType(), and TensorInfo::GetShape().

287 {
288  // By definition (that is, regardless of compute device), shapes and data type must match.
289  if (input.GetShape() != output.GetShape() || input.GetDataType() != output.GetDataType())
290  {
291  return false;
292  }
293 
294  FORWARD_LAYER_SUPPORT_FUNC(backend, IsFloorSupported, input, output);
295 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsFloorSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsFullyConnectedSupported()

bool IsFullyConnectedSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const TensorInfo weights,
const TensorInfo biases,
const FullyConnectedDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 296 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

304 {
305  FORWARD_LAYER_SUPPORT_FUNC(backend, IsFullyConnectedSupported, input, output, weights, biases, descriptor);
306 }
bool IsFullyConnectedSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsGatherSupported() [1/2]

bool armnn::IsGatherSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 309 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

Referenced by IsGatherSupported().

315 {
316  const GatherDescriptor descriptor{};
317  FORWARD_LAYER_SUPPORT_FUNC(backend, IsGatherSupported, input0, input1, output, descriptor);
318 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsGatherSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const GatherDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ IsGatherSupported() [2/2]

bool armnn::IsGatherSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const GatherDescriptor descriptor,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 320 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and IsGatherSupported().

327 {
328  FORWARD_LAYER_SUPPORT_FUNC(backend, IsGatherSupported, input0, input1, output, descriptor);
329 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsGatherSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const GatherDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ IsGreaterSupported()

bool IsGreaterSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 331 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and Greater.

337 {
339  IsComparisonSupported,
340  input0,
341  input1,
342  output,
343  ComparisonDescriptor(ComparisonOperation::Greater));
344 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsInputSupported()

bool IsInputSupported ( const BackendId backend,
const TensorInfo input,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 346 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

Referenced by BOOST_AUTO_TEST_CASE().

350 {
352 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsInputSupported(const BackendId &backend, const TensorInfo &input, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsL2NormalizationSupported()

bool IsL2NormalizationSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const L2NormalizationDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 355 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

361 {
362  FORWARD_LAYER_SUPPORT_FUNC(backend, IsL2NormalizationSupported, input, output, descriptor);
363 }
bool IsL2NormalizationSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsLstmSupported()

bool IsLstmSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo outputStateIn,
const TensorInfo cellStateIn,
const TensorInfo scratchBuffer,
const TensorInfo outputStateOut,
const TensorInfo cellStateOut,
const TensorInfo output,
const LstmDescriptor descriptor,
const LstmInputParamsInfo paramsInfo,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 365 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

372 {
373  FORWARD_LAYER_SUPPORT_FUNC(backend, IsLstmSupported, input, outputStateIn, cellStateIn,
374  scratchBuffer, outputStateOut, cellStateOut,
375  output, descriptor, paramsInfo);
376 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsLstmSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsMaximumSupported()

bool IsMaximumSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnSupported = nullptr,
size_t  reasonIfUnSupportedMaxLength = 0 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 378 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

384 {
385  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMaximumSupported, input0, input1, output);
386 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsMaximumSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnSupported=nullptr, size_t reasonIfUnSupportedMaxLength=0)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsMeanSupported()

bool IsMeanSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const MeanDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 388 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

394 {
395  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMeanSupported, input, output, descriptor);
396 }
bool IsMeanSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const MeanDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsMemCopySupported()

bool IsMemCopySupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 398 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

403 {
404  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMemCopySupported, input, output);
405 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsMemCopySupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsMemImportSupported()

bool armnn::IsMemImportSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 407 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

412 {
413  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMemImportSupported, input, output);
414 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsMemImportSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ IsMergerSupported() [1/2]

bool armnn::IsMergerSupported ( const BackendId backend,
const std::vector< const TensorInfo *>  inputs,
const TensorInfo output,
const OriginsDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by IsMergerSupported().

◆ IsMergerSupported() [2/2]

bool armnn::IsMergerSupported ( const BackendId backend,
std::vector< const TensorInfo *>  inputs,
const TensorInfo output,
const OriginsDescriptor descriptor,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 427 of file LayerSupport.cpp.

References ARMNN_ASSERT, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, FORWARD_LAYER_SUPPORT_FUNC, and IsMergerSupported().

433 {
434  ARMNN_ASSERT(inputs.size() > 0);
435 
437  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMergerSupported, inputs, output, descriptor);
439 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsMergerSupported(const BackendId &backend, std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ IsMergeSupported()

bool IsMergeSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 416 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

422 {
423  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMergeSupported, input0, input1, output);
424 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsMergeSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsMinimumSupported()

bool IsMinimumSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 441 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

447 {
448  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMinimumSupported, input0, input1, output);
449 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsMinimumSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsMultiplicationSupported()

bool IsMultiplicationSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 451 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

457 {
458  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMultiplicationSupported, input0, input1, output);
459 }
bool IsMultiplicationSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsNormalizationSupported()

bool IsNormalizationSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const NormalizationDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 461 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

467 {
468  FORWARD_LAYER_SUPPORT_FUNC(backend, IsNormalizationSupported, input, output, descriptor);
469 }
bool IsNormalizationSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsOperationQueueDescriptor() [1/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const QueueDescriptorType &  )

Definition at line 18 of file RefWorkloadFactory.hpp.

18 { return true; }

◆ IsOperationQueueDescriptor() [2/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const MemCopyQueueDescriptor )

Definition at line 21 of file RefWorkloadFactory.hpp.

21 { return false; }

◆ IsOperationQueueDescriptor() [3/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const ConstantQueueDescriptor )

Definition at line 24 of file RefWorkloadFactory.hpp.

24 { return false; }

◆ IsOperationQueueDescriptor() [4/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const PermuteQueueDescriptor )

Definition at line 27 of file RefWorkloadFactory.hpp.

27 { return false; }

◆ IsOutputSupported()

bool IsOutputSupported ( const BackendId backend,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 471 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

Referenced by BOOST_AUTO_TEST_CASE().

475 {
477 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsOutputSupported(const BackendId &backend, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsPadSupported()

bool IsPadSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const PadDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 479 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

485 {
486 
487  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPadSupported, input, output, descriptor);
488 }
bool IsPadSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsPermuteSupported()

bool IsPermuteSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const PermuteDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 531 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

537 {
538  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPermuteSupported, input, output, descriptor);
539 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsPermuteSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const PermuteDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsPooling2dSupported()

bool IsPooling2dSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const Pooling2dDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 541 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

547 {
548  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPooling2dSupported, input, output, descriptor);
549 }
bool IsPooling2dSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const Pooling2dDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsPreCompiledSupported()

bool armnn::IsPreCompiledSupported ( const BackendId backend,
const TensorInfo input,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsPreluSupported()

bool IsPreluSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo alpha,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 551 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

557 {
558  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPreluSupported, input, alpha, output);
559 }
bool IsPreluSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &alpha, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsQAsymmS8()

bool armnn::IsQAsymmS8 ( const WorkloadInfo info)

Definition at line 74 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug(), RefWorkloadFactory::CreatePermute(), and RefWorkloadFactory::CreateTranspose().

75 {
76  return IsDataType<DataType::QAsymmS8>(info);
77 }

◆ IsQAsymmU8()

bool armnn::IsQAsymmU8 ( const WorkloadInfo info)

Definition at line 79 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

80 {
81  return IsDataType<DataType::QAsymmU8>(info);
82 }

◆ IsQLstmSupported()

bool armnn::IsQLstmSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo previousOutputIn,
const TensorInfo previousCellStateIn,
const TensorInfo outputStateOut,
const TensorInfo cellStateOut,
const TensorInfo output,
const QLstmDescriptor descriptor,
const LstmInputParamsInfo paramsInfo,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 499 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

511 {
512  FORWARD_LAYER_SUPPORT_FUNC(backend, IsQLstmSupported, input, previousOutputIn, previousCellStateIn,
513  outputStateOut, cellStateOut, output, descriptor, paramsInfo);
514 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsQLstmSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &previousOutputIn, const TensorInfo &previousCellStateIn, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ IsQSymmS16()

bool armnn::IsQSymmS16 ( const WorkloadInfo info)

Definition at line 64 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug(), RefWorkloadFactory::CreatePermute(), and RefWorkloadFactory::CreateTranspose().

65 {
66  return IsDataType<DataType::QSymmS16>(info);
67 }

◆ IsQSymmS8()

bool armnn::IsQSymmS8 ( const WorkloadInfo info)

Definition at line 69 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

70 {
71  return IsDataType<DataType::QSymmS8>(info);
72 }

◆ IsQuantized8BitType()

constexpr bool armnn::IsQuantized8BitType ( DataType  dataType)

Definition at line 254 of file TypesUtils.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, QAsymmS8, QAsymmU8, QSymmS8, and QuantizedSymm8PerAxis.

Referenced by GetBiasDataType(), RefLayerSupport::IsConvolution2dSupported(), RefLayerSupport::IsDepthwiseConvolutionSupported(), IsQuantizedType(), and RefLayerSupport::IsTransposeConvolution2dSupported().

255 {
257  return dataType == DataType::QAsymmU8 ||
258  dataType == DataType::QAsymmS8 ||
259  dataType == DataType::QSymmS8 ||
260  dataType == DataType::QuantizedSymm8PerAxis;
262 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ IsQuantizedLstmSupported()

bool IsQuantizedLstmSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo previousCellStateIn,
const TensorInfo previousOutputIn,
const TensorInfo cellStateOut,
const TensorInfo output,
const QuantizedLstmInputParamsInfo paramsInfo,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 516 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

526 {
527  FORWARD_LAYER_SUPPORT_FUNC(backend, IsQuantizedLstmSupported, input, previousCellStateIn, previousOutputIn,
528  cellStateOut, output, paramsInfo);
529 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsQuantizedLstmSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &previousCellStateIn, const TensorInfo &previousOutputIn, const TensorInfo &cellStateOut, const TensorInfo &output, const QuantizedLstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsQuantizedType() [1/2]

◆ IsQuantizedType() [2/2]

constexpr bool armnn::IsQuantizedType ( DataType  dataType)

Definition at line 264 of file TypesUtils.hpp.

References IsQuantized8BitType(), and QSymmS16.

265 {
266  return dataType == DataType::QSymmS16 || IsQuantized8BitType(dataType);
267 }
constexpr bool IsQuantized8BitType(DataType dataType)
Definition: TypesUtils.hpp:254

◆ IsQuantizeSupported()

bool armnn::IsQuantizeSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 490 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

495 {
496  FORWARD_LAYER_SUPPORT_FUNC(backend, IsQuantizeSupported, input, output);
497 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsQuantizeSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ IsReadyForSplitAssignment()

bool armnn::IsReadyForSplitAssignment ( LayerSelectionInfo::LayerInfoContainer &  layerInfos,
LayerSelectionInfo &  layerInfo 
)

Definition at line 370 of file SubgraphViewSelector.cpp.

References ForEachLayerInput().

Referenced by SubgraphViewSelector::SelectSubgraphs().

371 {
372  bool ready = true;
373  ForEachLayerInput(layerInfos, layerInfo,
374  [&ready](LayerSelectionInfo& parentInfo)
375  {
376  if (!parentInfo.m_IsProcessed)
377  {
378  ready = false;
379  }
380  });
381  return ready;
382 }
void ForEachLayerInput(LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo, Delegate function)

◆ IsReshapeSupported() [1/2]

bool armnn::IsReshapeSupported ( const BackendId backend,
const TensorInfo input,
const ReshapeDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by IsReshapeSupported().

◆ IsReshapeSupported() [2/2]

bool armnn::IsReshapeSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const ReshapeDescriptor descriptor,
char *  reasonIfUnsupported,
size_t  reasonIfUnsupportedMaxLength 
)

Definition at line 561 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and IsReshapeSupported().

567 {
568  FORWARD_LAYER_SUPPORT_FUNC(backend, IsReshapeSupported, input, output, descriptor);
569 }
bool IsReshapeSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ReshapeDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsResizeBilinearSupported()

bool IsResizeBilinearSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 582 of file LayerSupport.cpp.

References Bilinear, FORWARD_LAYER_SUPPORT_FUNC, IsResizeSupported(), ResizeDescriptor::m_Method, ResizeDescriptor::m_TargetHeight, and ResizeDescriptor::m_TargetWidth.

587 {
588  ResizeDescriptor descriptor;
589  descriptor.m_Method = ResizeMethod::Bilinear;
590 
591  const TensorShape& outputShape = output.GetShape();
592  descriptor.m_TargetWidth = outputShape[3];
593  descriptor.m_TargetHeight = outputShape[2];
594 
595  FORWARD_LAYER_SUPPORT_FUNC(backend, IsResizeSupported, input, output, descriptor);
596 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsResizeSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsResizeSupported()

bool IsResizeSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const ResizeDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 571 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

Referenced by IsResizeBilinearSupported().

577 {
578  FORWARD_LAYER_SUPPORT_FUNC(backend, IsResizeSupported, input, output, descriptor);
579 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsResizeSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsRsqrtSupported()

bool IsRsqrtSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 598 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and Rsqrt.

603 {
605  IsElementwiseUnarySupported,
606  input,
607  output,
608  ElementwiseUnaryDescriptor(UnaryOperation::Rsqrt));
609 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsSigned32()

bool armnn::IsSigned32 ( const WorkloadInfo info)

Definition at line 49 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

50 {
51  return IsDataType<DataType::Signed32>(info);
52 }

◆ IsSoftmaxSupported()

bool IsSoftmaxSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const SoftmaxDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 611 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

617 {
618  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSoftmaxSupported, input, output, descriptor);
619 }
bool IsSoftmaxSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsSpaceToBatchNdSupported()

bool IsSpaceToBatchNdSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const SpaceToBatchNdDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 621 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

627 {
628  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSpaceToBatchNdSupported, input, output, descriptor);
629 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsSpaceToBatchNdSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const SpaceToBatchNdDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsSpaceToDepthSupported()

bool IsSpaceToDepthSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const SpaceToDepthDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 631 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

637 {
638  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSpaceToDepthSupported, input, output, descriptor);
639 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsSpaceToDepthSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const SpaceToDepthDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsSplitterSupported() [1/2]

bool IsSplitterSupported ( const BackendId backend,
const TensorInfo input,
const ViewsDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Definition at line 642 of file LayerSupport.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, and FORWARD_LAYER_SUPPORT_FUNC.

Referenced by IsSplitterSupported().

647 {
649  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSplitterSupported, input, descriptor);
651 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
bool IsSplitterSupported(const BackendId &backend, const TensorInfo &input, const ViewsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)

◆ IsSplitterSupported() [2/2]

bool IsSplitterSupported ( const BackendId backend,
const TensorInfo input,
const std::vector< std::reference_wrapper< TensorInfo >> &  outputs,
const ViewsDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 653 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and IsSplitterSupported().

659 {
660  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSplitterSupported, input, outputs, descriptor);
661 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsSplitterSupported(const BackendId &backend, const TensorInfo &input, const ViewsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)

◆ IsStackSupported()

bool armnn::IsStackSupported ( const BackendId backend,
const std::vector< const TensorInfo *>  inputs,
const TensorInfo output,
const StackDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsStridedSliceSupported()

bool IsStridedSliceSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const StridedSliceDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 663 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

669 {
670  FORWARD_LAYER_SUPPORT_FUNC(backend, IsStridedSliceSupported, input, output, descriptor);
671 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsStridedSliceSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsSubtractionSupported()

bool IsSubtractionSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 673 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

679 {
680  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSubtractionSupported, input0, input1, output);
681 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsSubtractionSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsSupportedForDataTypeGeneric()

bool armnn::IsSupportedForDataTypeGeneric ( Optional< std::string &>  reasonIfUnsupported,
DataType  dataType,
Float16Func  float16FuncPtr,
Float32Func  float32FuncPtr,
Uint8Func  uint8FuncPtr,
Int32Func  int32FuncPtr,
BooleanFunc  booleanFuncPtr,
Params &&...  params 
)

Definition at line 27 of file LayerSupportCommon.hpp.

References Boolean, Float16, Float32, QAsymmU8, and Signed32.

Referenced by RefLayerSupport::IsConvertFp16ToFp32Supported(), RefLayerSupport::IsConvertFp32ToFp16Supported(), and NeonLayerSupport::IsFloorSupported().

35 {
36  switch(dataType)
37  {
38  case DataType::Float16:
39  return float16FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
40  case DataType::Float32:
41  return float32FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
42  case DataType::QAsymmU8:
43  return uint8FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
44  case DataType::Signed32:
45  return int32FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
46  case DataType::Boolean:
47  return booleanFuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
48  default:
49  return false;
50  }
51 }

◆ IsSwitchSupported()

bool IsSwitchSupported ( const BackendId backend,
const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output0,
const TensorInfo output1,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Definition at line 683 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

690 {
691  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSwitchSupported, input0, input1, output0, output1);
692 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsSwitchSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output0, const TensorInfo &output1, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ IsTransposeConvolution2dSupported()

bool armnn::IsTransposeConvolution2dSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const TransposeConvolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

◆ LayerEnumOf() [1/66]

constexpr LayerType armnn::LayerEnumOf ( const T *  = nullptr)

◆ LayerEnumOf() [2/66]

constexpr LayerType armnn::LayerEnumOf ( const ActivationLayer )

Definition at line 102 of file LayersFwd.hpp.

◆ LayerEnumOf() [3/66]

constexpr LayerType armnn::LayerEnumOf ( const AdditionLayer )

Definition at line 103 of file LayersFwd.hpp.

◆ LayerEnumOf() [4/66]

constexpr LayerType armnn::LayerEnumOf ( const ArgMinMaxLayer )

Definition at line 104 of file LayersFwd.hpp.

◆ LayerEnumOf() [5/66]

constexpr LayerType armnn::LayerEnumOf ( const BatchNormalizationLayer )

Definition at line 105 of file LayersFwd.hpp.

◆ LayerEnumOf() [6/66]

constexpr LayerType armnn::LayerEnumOf ( const BatchToSpaceNdLayer )

Definition at line 106 of file LayersFwd.hpp.

◆ LayerEnumOf() [7/66]

constexpr LayerType armnn::LayerEnumOf ( const ComparisonLayer )

Definition at line 107 of file LayersFwd.hpp.

◆ LayerEnumOf() [8/66]

constexpr LayerType armnn::LayerEnumOf ( const ConcatLayer )

Definition at line 108 of file LayersFwd.hpp.

◆ LayerEnumOf() [9/66]

constexpr LayerType armnn::LayerEnumOf ( const ConstantLayer )

Definition at line 109 of file LayersFwd.hpp.

◆ LayerEnumOf() [10/66]

constexpr LayerType armnn::LayerEnumOf ( const ConvertBf16ToFp32Layer )

Definition at line 110 of file LayersFwd.hpp.

◆ LayerEnumOf() [11/66]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp16ToFp32Layer )

Definition at line 111 of file LayersFwd.hpp.

◆ LayerEnumOf() [12/66]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp32ToBf16Layer )

Definition at line 112 of file LayersFwd.hpp.

◆ LayerEnumOf() [13/66]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp32ToFp16Layer )

Definition at line 113 of file LayersFwd.hpp.

◆ LayerEnumOf() [14/66]

constexpr LayerType armnn::LayerEnumOf ( const Convolution2dLayer )

Definition at line 114 of file LayersFwd.hpp.

◆ LayerEnumOf() [15/66]

constexpr LayerType armnn::LayerEnumOf ( const DebugLayer )

Definition at line 115 of file LayersFwd.hpp.

◆ LayerEnumOf() [16/66]

constexpr LayerType armnn::LayerEnumOf ( const DepthToSpaceLayer )

Definition at line 116 of file LayersFwd.hpp.

◆ LayerEnumOf() [17/66]

constexpr LayerType armnn::LayerEnumOf ( const DepthwiseConvolution2dLayer )

Definition at line 117 of file LayersFwd.hpp.

◆ LayerEnumOf() [18/66]

constexpr LayerType armnn::LayerEnumOf ( const DequantizeLayer )

Definition at line 118 of file LayersFwd.hpp.

◆ LayerEnumOf() [19/66]

constexpr LayerType armnn::LayerEnumOf ( const DetectionPostProcessLayer )

Definition at line 119 of file LayersFwd.hpp.

◆ LayerEnumOf() [20/66]

constexpr LayerType armnn::LayerEnumOf ( const DivisionLayer )

Definition at line 120 of file LayersFwd.hpp.

◆ LayerEnumOf() [21/66]

constexpr LayerType armnn::LayerEnumOf ( const ElementwiseUnaryLayer )

Definition at line 121 of file LayersFwd.hpp.

◆ LayerEnumOf() [22/66]

constexpr LayerType armnn::LayerEnumOf ( const FakeQuantizationLayer )

Definition at line 122 of file LayersFwd.hpp.

◆ LayerEnumOf() [23/66]

constexpr LayerType armnn::LayerEnumOf ( const FillLayer )

Definition at line 123 of file LayersFwd.hpp.

◆ LayerEnumOf() [24/66]

constexpr LayerType armnn::LayerEnumOf ( const FloorLayer )

Definition at line 124 of file LayersFwd.hpp.

◆ LayerEnumOf() [25/66]

constexpr LayerType armnn::LayerEnumOf ( const FullyConnectedLayer )

Definition at line 125 of file LayersFwd.hpp.

◆ LayerEnumOf() [26/66]

constexpr LayerType armnn::LayerEnumOf ( const GatherLayer )

Definition at line 126 of file LayersFwd.hpp.

◆ LayerEnumOf() [27/66]

constexpr LayerType armnn::LayerEnumOf ( const InputLayer )

Definition at line 127 of file LayersFwd.hpp.

◆ LayerEnumOf() [28/66]

constexpr LayerType armnn::LayerEnumOf ( const InstanceNormalizationLayer )

Definition at line 128 of file LayersFwd.hpp.

◆ LayerEnumOf() [29/66]

constexpr LayerType armnn::LayerEnumOf ( const L2NormalizationLayer )

Definition at line 129 of file LayersFwd.hpp.

◆ LayerEnumOf() [30/66]

constexpr LayerType armnn::LayerEnumOf ( const LogicalBinaryLayer )

Definition at line 130 of file LayersFwd.hpp.

◆ LayerEnumOf() [31/66]

constexpr LayerType armnn::LayerEnumOf ( const LogSoftmaxLayer )

Definition at line 131 of file LayersFwd.hpp.

◆ LayerEnumOf() [32/66]

constexpr LayerType armnn::LayerEnumOf ( const LstmLayer )

Definition at line 132 of file LayersFwd.hpp.

◆ LayerEnumOf() [33/66]

constexpr LayerType armnn::LayerEnumOf ( const MapLayer )

Definition at line 133 of file LayersFwd.hpp.

◆ LayerEnumOf() [34/66]

constexpr LayerType armnn::LayerEnumOf ( const MaximumLayer )

Definition at line 134 of file LayersFwd.hpp.

◆ LayerEnumOf() [35/66]

constexpr LayerType armnn::LayerEnumOf ( const MeanLayer )

Definition at line 135 of file LayersFwd.hpp.

◆ LayerEnumOf() [36/66]

constexpr LayerType armnn::LayerEnumOf ( const MemCopyLayer )

Definition at line 136 of file LayersFwd.hpp.

◆ LayerEnumOf() [37/66]

constexpr LayerType armnn::LayerEnumOf ( const MemImportLayer )

Definition at line 137 of file LayersFwd.hpp.

◆ LayerEnumOf() [38/66]

constexpr LayerType armnn::LayerEnumOf ( const MergeLayer )

Definition at line 138 of file LayersFwd.hpp.

◆ LayerEnumOf() [39/66]

constexpr LayerType armnn::LayerEnumOf ( const MinimumLayer )

Definition at line 139 of file LayersFwd.hpp.

◆ LayerEnumOf() [40/66]

constexpr LayerType armnn::LayerEnumOf ( const MultiplicationLayer )

Definition at line 140 of file LayersFwd.hpp.

◆ LayerEnumOf() [41/66]

constexpr LayerType armnn::LayerEnumOf ( const NormalizationLayer )

Definition at line 141 of file LayersFwd.hpp.

◆ LayerEnumOf() [42/66]

constexpr LayerType armnn::LayerEnumOf ( const OutputLayer )

Definition at line 142 of file LayersFwd.hpp.

◆ LayerEnumOf() [43/66]

constexpr LayerType armnn::LayerEnumOf ( const PadLayer )

Definition at line 143 of file LayersFwd.hpp.

◆ LayerEnumOf() [44/66]

constexpr LayerType armnn::LayerEnumOf ( const PermuteLayer )

Definition at line 144 of file LayersFwd.hpp.

◆ LayerEnumOf() [45/66]

constexpr LayerType armnn::LayerEnumOf ( const Pooling2dLayer )

Definition at line 145 of file LayersFwd.hpp.

◆ LayerEnumOf() [46/66]

constexpr LayerType armnn::LayerEnumOf ( const PreCompiledLayer )

Definition at line 146 of file LayersFwd.hpp.

◆ LayerEnumOf() [47/66]

constexpr LayerType armnn::LayerEnumOf ( const PreluLayer )

Definition at line 147 of file LayersFwd.hpp.

◆ LayerEnumOf() [48/66]

constexpr LayerType armnn::LayerEnumOf ( const QuantizeLayer )

Definition at line 148 of file LayersFwd.hpp.

◆ LayerEnumOf() [49/66]

constexpr LayerType armnn::LayerEnumOf ( const QLstmLayer )

Definition at line 149 of file LayersFwd.hpp.

◆ LayerEnumOf() [50/66]

constexpr LayerType armnn::LayerEnumOf ( const QuantizedLstmLayer )

Definition at line 150 of file LayersFwd.hpp.

◆ LayerEnumOf() [51/66]

constexpr LayerType armnn::LayerEnumOf ( const RankLayer )

Definition at line 151 of file LayersFwd.hpp.

◆ LayerEnumOf() [52/66]

constexpr LayerType armnn::LayerEnumOf ( const ReshapeLayer )

Definition at line 152 of file LayersFwd.hpp.

◆ LayerEnumOf() [53/66]

constexpr LayerType armnn::LayerEnumOf ( const ResizeLayer )

Definition at line 153 of file LayersFwd.hpp.

◆ LayerEnumOf() [54/66]

constexpr LayerType armnn::LayerEnumOf ( const SliceLayer )

Definition at line 154 of file LayersFwd.hpp.

◆ LayerEnumOf() [55/66]

constexpr LayerType armnn::LayerEnumOf ( const SoftmaxLayer )

Definition at line 155 of file LayersFwd.hpp.

◆ LayerEnumOf() [56/66]

constexpr LayerType armnn::LayerEnumOf ( const SpaceToBatchNdLayer )

Definition at line 156 of file LayersFwd.hpp.

◆ LayerEnumOf() [57/66]

constexpr LayerType armnn::LayerEnumOf ( const SpaceToDepthLayer )

Definition at line 157 of file LayersFwd.hpp.

◆ LayerEnumOf() [58/66]

constexpr LayerType armnn::LayerEnumOf ( const SplitterLayer )

Definition at line 158 of file LayersFwd.hpp.

◆ LayerEnumOf() [59/66]

constexpr LayerType armnn::LayerEnumOf ( const StackLayer )

Definition at line 159 of file LayersFwd.hpp.

◆ LayerEnumOf() [60/66]

constexpr LayerType armnn::LayerEnumOf ( const StandInLayer )

Definition at line 160 of file LayersFwd.hpp.

◆ LayerEnumOf() [61/66]

constexpr LayerType armnn::LayerEnumOf ( const StridedSliceLayer )

Definition at line 161 of file LayersFwd.hpp.

◆ LayerEnumOf() [62/66]

constexpr LayerType armnn::LayerEnumOf ( const SubtractionLayer )

Definition at line 162 of file LayersFwd.hpp.

◆ LayerEnumOf() [63/66]

constexpr LayerType armnn::LayerEnumOf ( const SwitchLayer )

Definition at line 163 of file LayersFwd.hpp.

◆ LayerEnumOf() [64/66]

constexpr LayerType armnn::LayerEnumOf ( const TransposeLayer )

Definition at line 164 of file LayersFwd.hpp.

◆ LayerEnumOf() [65/66]

constexpr LayerType armnn::LayerEnumOf ( const TransposeConvolution2dLayer )

Definition at line 165 of file LayersFwd.hpp.

◆ LayerEnumOf() [66/66]

constexpr LayerType armnn::LayerEnumOf ( const UnmapLayer )

Definition at line 166 of file LayersFwd.hpp.

◆ LevelToString()

std::string armnn::LevelToString ( LogSeverity  level)
inline

Definition at line 14 of file Logging.hpp.

References Debug, Error, Fatal, Info, Trace, and Warning.

Referenced by ScopedRecord::ScopedRecord().

15 {
16  switch(level)
17  {
18  case LogSeverity::Trace:
19  return "Trace";
20  case LogSeverity::Debug:
21  return "Debug";
22  case LogSeverity::Info:
23  return "Info";
24  case LogSeverity::Warning:
25  return "Warning";
26  case LogSeverity::Error:
27  return "Error";
28  case LogSeverity::Fatal:
29  return "Fatal";
30  default:
31  return "Log";
32  }
33 }
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:18

◆ LogSoftmax()

void LogSoftmax ( Decoder< float > &  input,
Encoder< float > &  output,
const TensorInfo inputInfo,
const LogSoftmaxDescriptor descriptor 
)

Definition at line 29 of file LogSoftmax.cpp.

References ARMNN_ASSERT_MSG, Decoder< IType >::Get(), TensorShape::GetNumDimensions(), TensorInfo::GetNumDimensions(), armnnUtils::GetNumElementsBetween(), TensorInfo::GetShape(), IgnoreUnused(), SoftmaxDescriptor::m_Axis, SoftmaxDescriptor::m_Beta, numeric_cast(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

33 {
34  const unsigned int numDimensions = inputInfo.GetNumDimensions();
35 
36  bool axisIsValid = ValidateAxis(descriptor.m_Axis, numDimensions);
37  ARMNN_ASSERT_MSG(axisIsValid,
38  "Axis index is not in range [-numDimensions, numDimensions).");
39  IgnoreUnused(axisIsValid);
40 
41  unsigned int uAxis = descriptor.m_Axis < 0 ?
42  numDimensions - armnn::numeric_cast<unsigned int>(std::abs(descriptor.m_Axis)) :
43  armnn::numeric_cast<unsigned int>(descriptor.m_Axis);
44 
45  const TensorShape& inputShape = inputInfo.GetShape();
46  const unsigned int outerSize = armnnUtils::GetNumElementsBetween(inputShape, 0, uAxis);
47  const unsigned int axisSize = inputShape[uAxis];
48  const unsigned int innerSize = armnnUtils::GetNumElementsBetween(inputShape,
49  uAxis + 1,
50  inputShape.GetNumDimensions());
51 
52  for (unsigned int outer = 0; outer < outerSize; ++outer)
53  {
54  for (unsigned int inner = 0; inner < innerSize; ++inner)
55  {
56  // Find max
57  input[outer * axisSize * innerSize + inner];
58  float maxValue = input.Get();
59  for (unsigned int i = 1u; i < axisSize; ++i)
60  {
61  input[(outer * axisSize + i) * innerSize + inner];
62  maxValue = std::max(maxValue, input.Get());
63  }
64 
65  // Compute sum
66  float sum = 0.0f;
67  for (unsigned int i = 0u; i < axisSize; ++i)
68  {
69  input[(outer * axisSize + i) * innerSize + inner];
70  sum += std::exp((input.Get() - maxValue) * descriptor.m_Beta);
71  }
72 
73  // Compute log sum
74  const float logSum = std::log(sum);
75 
76  // Compute result
77  for (unsigned int i = 0u; i < axisSize; ++i)
78  {
79  const unsigned int index = (outer * axisSize + i) * innerSize + inner;
80 
81  input [index];
82  output[index];
83 
84  output.Set((input.Get() - maxValue) * descriptor.m_Beta - logSum);
85  }
86  }
87  }
88 }
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
virtual void Set(IType right)=0
void IgnoreUnused(Ts &&...)
virtual IType Get() const =0
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ LowerString()

std::string armnn::LowerString ( std::string  value)

Definition at line 61 of file ClBackendContext.cpp.

62 {
63  std::transform(value.begin(), value.end(), value.begin(),
64  [](unsigned char c){ return std::tolower(c); });
65 
66  return value;
67 }

◆ MakeDecoder() [1/4]

std::unique_ptr<Decoder<T> > armnn::MakeDecoder ( const TensorInfo info,
const void *  data = nullptr 
)
inline

Definition at line 70 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, Boolean, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, and Signed32.

71 {
72  switch(info.GetDataType())
73  {
76  {
77  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
78  return std::make_unique<QSymm8PerAxisDecoder>(
79  static_cast<const int8_t*>(data),
80  params.second,
81  params.first);
82  }
84  case DataType::QAsymmS8:
85  {
86  return std::make_unique<QASymmS8Decoder>(
87  static_cast<const int8_t*>(data),
88  info.GetQuantizationScale(),
89  info.GetQuantizationOffset());
90  }
91  case DataType::QAsymmU8:
92  {
93  return std::make_unique<QASymm8Decoder>(
94  static_cast<const uint8_t*>(data),
95  info.GetQuantizationScale(),
96  info.GetQuantizationOffset());
97  }
98  case DataType::QSymmS16:
99  {
100  return std::make_unique<QSymm16Decoder>(
101  static_cast<const int16_t*>(data),
102  info.GetQuantizationScale(),
103  info.GetQuantizationOffset());
104  }
105  case DataType::BFloat16:
106  {
107  return std::make_unique<BFloat16Decoder>(static_cast<const BFloat16*>(data));
108  }
109  case DataType::Float16:
110  {
111  return std::make_unique<Float16Decoder>(static_cast<const Half*>(data));
112  }
113  case DataType::Float32:
114  {
115  return std::make_unique<Float32Decoder>(static_cast<const float*>(data));
116  }
117  case DataType::Signed32:
118  {
119  return MakeSigned32Decoder(info, data);
120  }
121  case DataType::QSymmS8:
122  {
123  if (info.HasPerAxisQuantization())
124  {
125  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
126  return std::make_unique<QSymm8PerAxisDecoder>(
127  static_cast<const int8_t*>(data),
128  params.second,
129  params.first);
130  }
131  else
132  {
133  return std::make_unique<QSymmS8Decoder>(
134  static_cast<const int8_t*>(data),
135  info.GetQuantizationScale(),
136  info.GetQuantizationOffset());
137  }
138  }
140  {
141  return std::make_unique<BooleanDecoder>(static_cast<const uint8_t*>(data));
142  }
143  default:
144  {
145  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
146  break;
147  }
148  }
149  return nullptr;
150 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:16

◆ MakeDecoder() [2/4]

std::unique_ptr<Decoder<float> > armnn::MakeDecoder ( const TensorInfo info,
const void *  data 
)
inline

Definition at line 70 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, Boolean, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, and Signed32.

71 {
72  switch(info.GetDataType())
73  {
76  {
77  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
78  return std::make_unique<QSymm8PerAxisDecoder>(
79  static_cast<const int8_t*>(data),
80  params.second,
81  params.first);
82  }
84  case DataType::QAsymmS8:
85  {
86  return std::make_unique<QASymmS8Decoder>(
87  static_cast<const int8_t*>(data),
88  info.GetQuantizationScale(),
89  info.GetQuantizationOffset());
90  }
91  case DataType::QAsymmU8:
92  {
93  return std::make_unique<QASymm8Decoder>(
94  static_cast<const uint8_t*>(data),
95  info.GetQuantizationScale(),
96  info.GetQuantizationOffset());
97  }
98  case DataType::QSymmS16:
99  {
100  return std::make_unique<QSymm16Decoder>(
101  static_cast<const int16_t*>(data),
102  info.GetQuantizationScale(),
103  info.GetQuantizationOffset());
104  }
105  case DataType::BFloat16:
106  {
107  return std::make_unique<BFloat16Decoder>(static_cast<const BFloat16*>(data));
108  }
109  case DataType::Float16:
110  {
111  return std::make_unique<Float16Decoder>(static_cast<const Half*>(data));
112  }
113  case DataType::Float32:
114  {
115  return std::make_unique<Float32Decoder>(static_cast<const float*>(data));
116  }
117  case DataType::Signed32:
118  {
119  return MakeSigned32Decoder(info, data);
120  }
121  case DataType::QSymmS8:
122  {
123  if (info.HasPerAxisQuantization())
124  {
125  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
126  return std::make_unique<QSymm8PerAxisDecoder>(
127  static_cast<const int8_t*>(data),
128  params.second,
129  params.first);
130  }
131  else
132  {
133  return std::make_unique<QSymmS8Decoder>(
134  static_cast<const int8_t*>(data),
135  info.GetQuantizationScale(),
136  info.GetQuantizationOffset());
137  }
138  }
140  {
141  return std::make_unique<BooleanDecoder>(static_cast<const uint8_t*>(data));
142  }
143  default:
144  {
145  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
146  break;
147  }
148  }
149  return nullptr;
150 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:16

◆ MakeDecoder() [3/4]

std::unique_ptr<Decoder<bool> > armnn::MakeDecoder ( const TensorInfo info,
const void *  data 
)
inline

Definition at line 153 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, Boolean, and TensorInfo::GetDataType().

154 {
155  switch(info.GetDataType())
156  {
157  case DataType::Boolean:
158  {
159  return std::make_unique<BooleanDecoderBool>(static_cast<const uint8_t*>(data));
160  }
161  default:
162  {
163  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
164  break;
165  }
166  }
167  return nullptr;
168 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeDecoder() [4/4]

std::unique_ptr<Decoder<int32_t> > armnn::MakeDecoder ( const TensorInfo info,
const void *  data 
)
inline

Definition at line 171 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, TensorInfo::GetDataType(), and Signed32.

172 {
173  switch(info.GetDataType())
174  {
175  case DataType::Signed32:
176  {
177  return std::make_unique<Int32ToInt32tDecoder>(static_cast<const int32_t*>(data));
178  }
179  default:
180  {
181  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
182  break;
183  }
184  }
185  return nullptr;
186 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeEncoder() [1/4]

std::unique_ptr<Encoder<T> > armnn::MakeEncoder ( const TensorInfo info,
void *  data = nullptr 
)
inline

Definition at line 21 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, Boolean, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, and Signed32.

22 {
23  switch(info.GetDataType())
24  {
27  {
28  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
29  return std::make_unique<QSymm8PerAxisEncoder>(
30  static_cast<int8_t*>(data),
31  params.second,
32  params.first);
33  }
36  {
37  return std::make_unique<QASymmS8Encoder>(
38  static_cast<int8_t*>(data),
39  info.GetQuantizationScale(),
40  info.GetQuantizationOffset());
41  }
43  {
44  return std::make_unique<QASymm8Encoder>(
45  static_cast<uint8_t*>(data),
46  info.GetQuantizationScale(),
47  info.GetQuantizationOffset());
48  }
49  case DataType::QSymmS8:
50  {
51  if (info.HasPerAxisQuantization())
52  {
53  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
54  return std::make_unique<QSymm8PerAxisEncoder>(
55  static_cast<int8_t*>(data),
56  params.second,
57  params.first);
58  }
59  else
60  {
61  return std::make_unique<QSymmS8Encoder>(
62  static_cast<int8_t*>(data),
63  info.GetQuantizationScale(),
64  info.GetQuantizationOffset());
65  }
66  }
68  {
69  return std::make_unique<QSymm16Encoder>(
70  static_cast<int16_t*>(data),
71  info.GetQuantizationScale(),
72  info.GetQuantizationOffset());
73  }
75  {
76  return std::make_unique<Int32Encoder>(static_cast<int32_t*>(data));
77  }
79  {
80  return std::make_unique<BFloat16Encoder>(static_cast<armnn::BFloat16*>(data));
81  }
83  {
84  return std::make_unique<Float16Encoder>(static_cast<Half*>(data));
85  }
87  {
88  return std::make_unique<Float32Encoder>(static_cast<float*>(data));
89  }
90  default:
91  {
92  ARMNN_ASSERT_MSG(false, "Unsupported target Data Type!");
93  break;
94  }
95  }
96  return nullptr;
97 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:16

◆ MakeEncoder() [2/4]

std::unique_ptr<Encoder<float> > armnn::MakeEncoder ( const TensorInfo info,
void *  data 
)
inline

Definition at line 21 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, BFloat16, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, QuantizedSymm8PerAxis, and Signed32.

22 {
23  switch(info.GetDataType())
24  {
27  {
28  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
29  return std::make_unique<QSymm8PerAxisEncoder>(
30  static_cast<int8_t*>(data),
31  params.second,
32  params.first);
33  }
36  {
37  return std::make_unique<QASymmS8Encoder>(
38  static_cast<int8_t*>(data),
39  info.GetQuantizationScale(),
40  info.GetQuantizationOffset());
41  }
43  {
44  return std::make_unique<QASymm8Encoder>(
45  static_cast<uint8_t*>(data),
46  info.GetQuantizationScale(),
47  info.GetQuantizationOffset());
48  }
49  case DataType::QSymmS8:
50  {
51  if (info.HasPerAxisQuantization())
52  {
53  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
54  return std::make_unique<QSymm8PerAxisEncoder>(
55  static_cast<int8_t*>(data),
56  params.second,
57  params.first);
58  }
59  else
60  {
61  return std::make_unique<QSymmS8Encoder>(
62  static_cast<int8_t*>(data),
63  info.GetQuantizationScale(),
64  info.GetQuantizationOffset());
65  }
66  }
68  {
69  return std::make_unique<QSymm16Encoder>(
70  static_cast<int16_t*>(data),
71  info.GetQuantizationScale(),
72  info.GetQuantizationOffset());
73  }
75  {
76  return std::make_unique<Int32Encoder>(static_cast<int32_t*>(data));
77  }
79  {
80  return std::make_unique<BFloat16Encoder>(static_cast<armnn::BFloat16*>(data));
81  }
83  {
84  return std::make_unique<Float16Encoder>(static_cast<Half*>(data));
85  }
87  {
88  return std::make_unique<Float32Encoder>(static_cast<float*>(data));
89  }
90  default:
91  {
92  ARMNN_ASSERT_MSG(false, "Unsupported target Data Type!");
93  break;
94  }
95  }
96  return nullptr;
97 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:16

◆ MakeEncoder() [3/4]

std::unique_ptr<Encoder<bool> > armnn::MakeEncoder ( const TensorInfo info,
void *  data 
)
inline

Definition at line 100 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, Boolean, and TensorInfo::GetDataType().

101 {
102  switch(info.GetDataType())
103  {
105  {
106  return std::make_unique<BooleanEncoder>(static_cast<uint8_t*>(data));
107  }
108  default:
109  {
110  ARMNN_ASSERT_MSG(false, "Cannot encode from boolean. Not supported target Data Type!");
111  break;
112  }
113  }
114  return nullptr;
115 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeEncoder() [4/4]

std::unique_ptr<Encoder<int32_t> > armnn::MakeEncoder ( const TensorInfo info,
void *  data 
)
inline

Definition at line 118 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, TensorInfo::GetDataType(), and Signed32.

119 {
120  switch(info.GetDataType())
121  {
122  case DataType::Signed32:
123  {
124  return std::make_unique<Int32ToInt32tEncoder>(static_cast<int32_t*>(data));
125  }
126  default:
127  {
128  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
129  break;
130  }
131  }
132  return nullptr;
133 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeInfo()

arm_compute::DetectionPostProcessLayerInfo armnn::MakeInfo ( const DetectionPostProcessDescriptor desc)

Definition at line 17 of file NeonDetectionPostProcessWorkload.cpp.

References DetectionPostProcessDescriptor::m_DetectionsPerClass, DetectionPostProcessDescriptor::m_MaxClassesPerDetection, DetectionPostProcessDescriptor::m_MaxDetections, DetectionPostProcessDescriptor::m_NmsIouThreshold, DetectionPostProcessDescriptor::m_NmsScoreThreshold, DetectionPostProcessDescriptor::m_NumClasses, and DetectionPostProcessDescriptor::m_UseRegularNms.

Referenced by NeonDetectionPostProcessValidate().

18 {
19  return arm_compute::DetectionPostProcessLayerInfo(desc.m_MaxDetections,
20  desc.m_MaxClassesPerDetection,
21  desc.m_NmsScoreThreshold,
22  desc.m_NmsIouThreshold,
23  desc.m_NumClasses,
24  { desc.m_ScaleX,
25  desc.m_ScaleY,
26  desc.m_ScaleW,
27  desc.m_ScaleH },
28  desc.m_UseRegularNms,
29  desc.m_DetectionsPerClass);
30 }

◆ MakeOptimizations()

Optimizer::Optimizations armnn::MakeOptimizations ( Args &&...  args)

Definition at line 43 of file Optimizer.hpp.

References Append().

Referenced by AddBroadcastReshapeLayerOptimizerTest(), BOOST_AUTO_TEST_CASE(), and Optimize().

44 {
45  Optimizer::Optimizations optimizations;
46 
47  Append(optimizations, std::forward<Args>(args)...);
48 
49  return optimizations;
50 }
void Append(Optimizer::Optimizations &optimizations, Front &&front, Others &&... others)
Definition: Optimizer.hpp:36

◆ MakeOptional()

Optional<T> armnn::MakeOptional ( Args &&...  args)

Utility template that constructs an object of type T in-place and wraps it inside an Optional<T> object.

Definition at line 305 of file Optional.hpp.

References CONSTRUCT_IN_PLACE.

306 {
307  return Optional<T>(CONSTRUCT_IN_PLACE, std::forward<Args>(args)...);
308 }
#define CONSTRUCT_IN_PLACE
Definition: Optional.hpp:41

◆ MakeTransformIterator()

constexpr TransformIterator<Function, Iterator> armnn::MakeTransformIterator ( Iterator  i,
Function  f 
)

Definition at line 77 of file TransformIterator.hpp.

78 {
79  return TransformIterator<Function, Iterator>(i, f);
80 }

◆ Mean()

void Mean ( const armnn::TensorInfo inputInfo,
const armnn::TensorInfo outputInfo,
const std::vector< unsigned int > &  axis,
Decoder< float > &  input,
Encoder< float > &  output 
)

Definition at line 71 of file Mean.cpp.

References ARMNN_ASSERT, Decoder< IType >::Get(), TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), NextIndex(), numeric_cast(), ReducedOutputOffset(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

76 {
77 
78  unsigned int inputNumDims = inputInfo.GetNumDimensions();
79  unsigned int outputNumDims = outputInfo.GetNumDimensions();
80 
81  armnn::TensorShape outputDims = outputInfo.GetShape();
82  armnn::TensorShape inputDims = inputInfo.GetShape();
83 
84  // Initialise output data.
85  unsigned int numOutputs = 1;
86  for (unsigned int idx = 0; idx < outputNumDims; ++idx)
87  {
88  numOutputs *= outputDims[idx];
89  }
90 
91  std::vector<float> tempSum(numOutputs);
92  for (unsigned int idx = 0; idx < numOutputs; ++idx)
93  {
94  output[idx];
95  output.Set(0.0f);
96  tempSum[idx] = 0.0f;
97  }
98 
99  // Initialise temp index.
100  std::vector<unsigned int> tempIndex(inputNumDims);
101  for (unsigned int idx = 0; idx < inputNumDims; ++idx)
102  {
103  tempIndex[idx] = 0;
104  }
105 
106  std::vector<unsigned int> resolvedAxis = axis;
107  if (resolvedAxis.empty())
108  {
109  for (unsigned int idx = 0; idx < inputNumDims; ++idx)
110  {
111  resolvedAxis.push_back(idx);
112  }
113  }
114  auto numResolvedAxis = armnn::numeric_cast<unsigned int>(resolvedAxis.size());
115 
116  // Iterates through input_data and sum up the reduced axis.
117  for (bool hasNext = true; hasNext; hasNext = NextIndex(inputNumDims, inputDims, tempIndex))
118  {
119  unsigned int inputOffset = ReducedOutputOffset(inputNumDims, inputDims, tempIndex, 0, {});
120  unsigned int outputOffset = ReducedOutputOffset(inputNumDims, inputDims, tempIndex,
121  numResolvedAxis, resolvedAxis);
122  input[inputOffset];
123  tempSum[outputOffset] += input.Get();
124  }
125 
126  // Takes average by num of elements added to get mean.
127  size_t numElementsInAxis = 1;
128  for (unsigned int idx = 0; idx < numResolvedAxis; ++idx)
129  {
130  unsigned int current = inputDims[resolvedAxis[idx]];
131  ARMNN_ASSERT(armnn::numeric_cast<float>(current) <
132  (std::numeric_limits<float>::max() / armnn::numeric_cast<float>(numElementsInAxis)));
133  numElementsInAxis *= current;
134  }
135  if (numElementsInAxis > 0) {
136  for (unsigned int idx = 0; idx < numOutputs; ++idx)
137  {
138  output[idx];
139  output.Set(tempSum[idx] / armnn::numeric_cast<float>(numElementsInAxis));
140  }
141  }
142 }
bool NextIndex(const unsigned int numDims, const armnn::TensorShape &dims, std::vector< unsigned int > &current)
Definition: Mean.cpp:18
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
unsigned int ReducedOutputOffset(const unsigned int numDims, const armnn::TensorShape &dims, std::vector< unsigned int > &index, const unsigned int numAxis, const std::vector< unsigned int > &axis)
Definition: Mean.cpp:39
virtual void Set(IType right)=0
virtual IType Get() const =0
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191

◆ MockBackendId()

constexpr const char* armnn::MockBackendId ( )

Definition at line 11 of file MockBackendId.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), MockBackend::GetIdStatic(), and MockBackend::OptimizeSubgraphView().

11 { return "MockAcc"; }

◆ MockImportBackendId()

constexpr const char* armnn::MockImportBackendId ( )

Definition at line 12 of file MockImportBackend.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), and MockImportBackend::GetIdStatic().

12 { return "MockRef"; }

◆ NeonAbsWorkloadValidate()

arm_compute::Status NeonAbsWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 17 of file NeonAbsWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

18 {
19  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
20  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21 
22  return arm_compute::NEAbsLayer::validate(&aclInput, &aclOutput);
23 }

◆ NeonActivationWorkloadValidate()

arm_compute::Status NeonActivationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ActivationDescriptor descriptor 
)

Definition at line 17 of file NeonActivationWorkload.cpp.

Referenced by NeonLayerSupport::IsActivationSupported().

20 {
21  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  const arm_compute::ActivationLayerInfo activationLayerInfo =
26 
27  return arm_compute::NEActivationLayer::validate(&aclInput,
28  &aclOutput,
29  activationLayerInfo);
30 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonAdditionWorkloadValidate()

arm_compute::Status NeonAdditionWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 20 of file NeonAdditionWorkload.cpp.

Referenced by NeonLayerSupport::IsAdditionSupported(), and NeonBackend::OptimizeSubgraphView().

24 {
25  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
26  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
27  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
28 
29  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
30  activationDescriptor);
31 
32  return arm_compute::NEArithmeticAddition::validate(&aclInput0,
33  &aclInput1,
34  &aclOutput,
35  arm_compute::ConvertPolicy::SATURATE,
36  activationInfo);
37 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonArgMinMaxWorkloadValidate()

arm_compute::Status NeonArgMinMaxWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ArgMinMaxDescriptor descriptor 
)

Definition at line 31 of file NeonArgMinMaxWorkload.cpp.

Referenced by NeonLayerSupport::IsArgMinMaxSupported().

34 {
35  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
36  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
37 
38  auto numDims = input.GetNumDimensions();
39  auto unsignedAxis = armnnUtils::GetUnsignedAxis(numDims, descriptor.m_Axis);
40  int aclAxis = armnn::numeric_cast<int>(CalcAclAxis(numDims, unsignedAxis));
41 
42  if (descriptor.m_Function == ArgMinMaxFunction::Max)
43  {
44  return arm_compute::NEArgMinMaxLayer::validate(&aclInput, aclAxis, &aclOutput,
45  arm_compute::ReductionOperation::ARG_IDX_MAX);
46  }
47  else
48  {
49  return arm_compute::NEArgMinMaxLayer::validate(&aclInput, aclAxis, &aclOutput,
50  arm_compute::ReductionOperation::ARG_IDX_MIN);
51  }
52 }
unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonBackendId()

constexpr const char* armnn::NeonBackendId ( )

Definition at line 10 of file NeonBackendId.hpp.

Referenced by NeonBackend::GetIdStatic().

10 { return "CpuAcc"; }

◆ NeonBatchNormalizationValidate()

arm_compute::Status NeonBatchNormalizationValidate ( const TensorInfo input,
const TensorInfo output,
const TensorInfo mean,
const TensorInfo var,
const TensorInfo beta,
const TensorInfo gamma,
const BatchNormalizationDescriptor descriptor,
const ActivationDescriptor activationDescriptor 
)

Definition at line 24 of file NeonBatchNormalizationWorkload.cpp.

Referenced by NeonLayerSupport::IsBatchNormalizationSupported(), and NeonBackend::OptimizeSubgraphView().

32 {
33  const arm_compute::TensorInfo aclInputInfo =
34  armcomputetensorutils::BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
35  const arm_compute::TensorInfo aclOutputInfo =
36  armcomputetensorutils::BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
37  const arm_compute::TensorInfo aclMeanInfo =
38  armcomputetensorutils::BuildArmComputeTensorInfo(mean, descriptor.m_DataLayout);
39  const arm_compute::TensorInfo aclVarInfo =
40  armcomputetensorutils::BuildArmComputeTensorInfo(var, descriptor.m_DataLayout);
41  const arm_compute::TensorInfo aclBetaInfo =
42  armcomputetensorutils::BuildArmComputeTensorInfo(beta, descriptor.m_DataLayout);
43  const arm_compute::TensorInfo aclGammaInfo =
44  armcomputetensorutils::BuildArmComputeTensorInfo(gamma, descriptor.m_DataLayout);
45 
46  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
47  activationDescriptor);
48 
49  return arm_compute::NEBatchNormalizationLayer::validate(&aclInputInfo,
50  &aclOutputInfo,
51  &aclMeanInfo,
52  &aclVarInfo,
53  &aclBetaInfo,
54  &aclGammaInfo,
55  descriptor.m_Eps,
56  activationInfo);
57 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonBatchToSpaceNdWorkloadValidate()

arm_compute::Status NeonBatchToSpaceNdWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const BatchToSpaceNdDescriptor desc 
)

Definition at line 20 of file NeonBatchToSpaceNdWorkload.cpp.

Referenced by NeonLayerSupport::IsBatchToSpaceNdSupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, desc.m_DataLayout);
25  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, desc.m_DataLayout);
26 
27  // ArmNN blockShape is [H, W] Cl asks for W, H
28  int32_t blockHeight = armnn::numeric_cast<int32_t>(desc.m_BlockShape[0]);
29  int32_t blockWidth = armnn::numeric_cast<int32_t>(desc.m_BlockShape[1]);
30 
31  const arm_compute::Status aclStatus = arm_compute::NEBatchToSpaceLayer::validate(&aclInputInfo,
32  blockWidth,
33  blockHeight,
34  &aclOutputInfo);
35  return aclStatus;
36 }
Status
enumeration
Definition: Types.hpp:26
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonComparisonWorkloadValidate()

arm_compute::Status NeonComparisonWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ComparisonDescriptor descriptor 
)

Definition at line 16 of file NeonComparisonWorkload.cpp.

Referenced by NeonLayerSupport::IsComparisonSupported().

20 {
21  const arm_compute::TensorInfo aclInput0 = BuildArmComputeTensorInfo(input0);
22  const arm_compute::TensorInfo aclInput1 = BuildArmComputeTensorInfo(input1);
23  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
24 
25  const arm_compute::ComparisonOperation comparisonOperation = ConvertComparisonOperationToAcl(descriptor);
26 
27  const arm_compute::Status aclStatus = arm_compute::NEElementwiseComparison::validate(&aclInput0,
28  &aclInput1,
29  &aclOutput,
30  comparisonOperation);
31  return aclStatus;
32 }
ComparisonOperation
Definition: Types.hpp:78
Status
enumeration
Definition: Types.hpp:26
arm_compute::ComparisonOperation ConvertComparisonOperationToAcl(const ComparisonDescriptor &descriptor)

◆ NeonConcatWorkloadValidate()

arm_compute::Status NeonConcatWorkloadValidate ( const std::vector< const TensorInfo *> &  inputs,
const TensorInfo output,
const OriginsDescriptor descriptor 
)

Definition at line 27 of file NeonConcatWorkload.cpp.

Referenced by NeonLayerSupport::IsConcatSupported().

31 {
32  std::vector<arm_compute::TensorInfo> aclInputs;
33  for (const TensorInfo* input : inputs)
34  {
35  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(*input, armnn::DataLayout::NCHW);
36  aclInputs.emplace_back(aclInputInfo);
37  }
38  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
39  std::vector<const arm_compute::ITensorInfo*> aclInputPtrs;
40  for (arm_compute::ITensorInfo& input : aclInputs)
41  {
42  aclInputPtrs.emplace_back(&input);
43  }
44 
45  size_t aclAxis = CalcAxis(descriptor);
46  return arm_compute::NEConcatenateLayer::validate(aclInputPtrs, &aclOutputInfo, aclAxis);
47 }

◆ NeonConstantWorkloadValidate()

arm_compute::Status NeonConstantWorkloadValidate ( const TensorInfo output)

Definition at line 20 of file NeonConstantWorkload.cpp.

Referenced by NeonLayerSupport::IsConstantSupported().

21 {
22  const arm_compute::TensorInfo neonOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  std::array<arm_compute::DataType,9> supportedTypes = {
25  arm_compute::DataType::BFLOAT16,
26  arm_compute::DataType::F16,
27  arm_compute::DataType::F32,
28  arm_compute::DataType::QASYMM8,
29  arm_compute::DataType::QASYMM8_SIGNED,
30  arm_compute::DataType::QSYMM16,
31  arm_compute::DataType::QSYMM8,
32  arm_compute::DataType::QSYMM8_PER_CHANNEL,
33  arm_compute::DataType::S32
34  };
35  auto it = std::find(begin(supportedTypes), end(supportedTypes), neonOutputInfo.data_type());
36 
37  if (it != end(supportedTypes))
38  {
39  return arm_compute::Status{};
40  }
41  else
42  {
43  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported DataType"};
44  }
45 }
Status
enumeration
Definition: Types.hpp:26

◆ NeonConvolution2dWorkloadValidate()

arm_compute::Status NeonConvolution2dWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const Convolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
bool  isFastMathEnabled,
const ActivationDescriptor activationDescriptor 
)

Definition at line 24 of file NeonConvolution2dWorkload.cpp.

Referenced by NeonLayerSupport::IsConvolution2dSupported(), and NeonBackend::OptimizeSubgraphView().

31 {
32  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
33  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
34  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
35 
36  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(descriptor.m_DilationX,
37  descriptor.m_DilationY);
38 
39  arm_compute::TensorInfo aclBiasesInfo;
40  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
41 
42  if (descriptor.m_BiasEnabled)
43  {
44  ARMNN_ASSERT(biases.has_value());
45 
46  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
47  optionalAclBiasesInfo = &aclBiasesInfo;
48  }
49 
50  arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor);
51 
52  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
53  activationDescriptor);
54 
55  return arm_compute::NEConvolutionLayer::validate(&aclInputInfo,
56  &aclWeightsInfo,
57  optionalAclBiasesInfo,
58  &aclOutputInfo,
59  layerInfo,
60  arm_compute::WeightsInfo(),
61  aclDilationInfo,
62  activationInfo,
63  isFastMathEnabled);
64 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonDepthToSpaceWorkloadValidate()

arm_compute::Status NeonDepthToSpaceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const DepthToSpaceDescriptor descriptor 
)

Definition at line 19 of file NeonDepthToSpaceWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by NeonLayerSupport::IsDepthToSpaceSupported().

22 {
23  DataLayout dataLayout = descriptor.m_DataLayout;
24  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout);
25  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout);
26 
27  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize);
28 
29  return arm_compute::NEDepthToSpaceLayer::validate(&aclInput, &aclOutput, blockSize);
30 }
DataLayout
Definition: Types.hpp:50
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonDepthwiseConvolutionWorkloadValidate()

arm_compute::Status NeonDepthwiseConvolutionWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const DepthwiseConvolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases,
const ActivationDescriptor activationDescriptor 
)

Definition at line 29 of file NeonDepthwiseConvolutionWorkload.cpp.

Referenced by NeonLayerSupport::IsDepthwiseConvolutionSupported(), NeonLayerSupport::IsDilatedDepthwiseConvolutionSupported(), and NeonBackend::OptimizeSubgraphView().

35 {
36  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
37  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
38 
39  // ArmNN's weight format is [ M, I, H, W ]
40  const unsigned int aclDepthMultiplier = weights.GetShape()[0];
41 
42  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
43  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
44  TensorInfo weightsPermuted = ConvertWeightTensorInfoFromArmnnToAcl(weights, descriptor.m_DataLayout);
45 
46  // Convert the weights into the compute library format
47  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weightsPermuted, descriptor.m_DataLayout);
48 
49  arm_compute::TensorInfo aclBiasesInfo;
50  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
51 
52  if (descriptor.m_BiasEnabled)
53  {
54  ARMNN_ASSERT(biases.has_value());
55 
56  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
57  optionalAclBiasesInfo = &aclBiasesInfo;
58  }
59 
60  arm_compute::PadStrideInfo aclPadStrideInfo = BuildArmComputePadStrideInfo(descriptor);
61  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
62  descriptor.m_DilationX,descriptor.m_DilationY);
63 
64  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
65  activationDescriptor);
66 
67  return arm_compute::NEDepthwiseConvolutionLayer::validate(&aclInputInfo,
68  &aclWeightsInfo,
69  optionalAclBiasesInfo,
70  &aclOutputInfo,
71  aclPadStrideInfo,
72  aclDepthMultiplier,
73  activationInfo,
74  aclDilationInfo);
75 }
bool m_BiasEnabled
Enable/disable bias.
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
TensorInfo ConvertWeightTensorInfoFromArmnnToAcl(const TensorInfo &weightInfo, DataLayout dataLayout)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_DilationY
Dilation factor value for height dimension.
uint32_t m_DilationX
Dilation factor value for width dimension.
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonDequantizeWorkloadValidate()

arm_compute::Status NeonDequantizeWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 22 of file NeonDequantizeWorkload.cpp.

Referenced by NeonLayerSupport::IsDequantizeSupported().

24 {
25  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
26  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
27 
28  return arm_compute::NEDequantizationLayer::validate(&aclInput, &aclOutput);
29 }

◆ NeonDetectionPostProcessValidate()

arm_compute::Status NeonDetectionPostProcessValidate ( const TensorInfo boxEncodings,
const TensorInfo scores,
const TensorInfo anchors,
const TensorInfo detectionBoxes,
const TensorInfo detectionClasses,
const TensorInfo detectionScores,
const TensorInfo numDetections,
const DetectionPostProcessDescriptor desc 
)

Definition at line 32 of file NeonDetectionPostProcessWorkload.cpp.

References info, and MakeInfo().

40 {
41  arm_compute::DetectionPostProcessLayerInfo info = MakeInfo(desc);
42 
43  const arm_compute::TensorInfo aclBoxEncodings =
44  armcomputetensorutils::BuildArmComputeTensorInfo(boxEncodings);
45 
46  const arm_compute::TensorInfo aclScores =
47  armcomputetensorutils::BuildArmComputeTensorInfo(scores);
48 
49  const arm_compute::TensorInfo aclAnchors =
50  armcomputetensorutils::BuildArmComputeTensorInfo(anchors);
51 
52  arm_compute::TensorInfo aclDetectionBoxes =
53  armcomputetensorutils::BuildArmComputeTensorInfo(detectionBoxes);
54 
55  arm_compute::TensorInfo aclDetectionClasses =
56  armcomputetensorutils::BuildArmComputeTensorInfo(detectionClasses);
57 
58  arm_compute::TensorInfo aclDetectionScores =
59  armcomputetensorutils::BuildArmComputeTensorInfo(detectionScores);
60 
61  arm_compute::TensorInfo aclNumDetections =
62  armcomputetensorutils::BuildArmComputeTensorInfo(numDetections);
63 
64  return arm_compute::NEDetectionPostProcessLayer::validate(
65  &aclBoxEncodings,
66  &aclScores,
67  &aclAnchors,
68  &aclDetectionBoxes,
69  &aclDetectionClasses,
70  &aclDetectionScores,
71  &aclNumDetections,
72  info);
73 }
std::vector< float > boxEncodings({ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f })
std::vector< float > scores({ 0.0f, 0.9f, 0.8f, 0.0f, 0.75f, 0.72f, 0.0f, 0.6f, 0.5f, 0.0f, 0.93f, 0.95f, 0.0f, 0.5f, 0.4f, 0.0f, 0.3f, 0.2f })
arm_compute::DetectionPostProcessLayerInfo MakeInfo(const DetectionPostProcessDescriptor &desc)
std::vector< float > anchors({ 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 100.5f, 1.0f, 1.0f })

◆ NeonDivisionWorkloadValidate()

arm_compute::Status NeonDivisionWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 18 of file NeonDivisionWorkload.cpp.

Referenced by NeonLayerSupport::IsDivisionSupported(), and NeonBackend::OptimizeSubgraphView().

22 {
23  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
24  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
25  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
26 
27  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
28  activationDescriptor);
29 
30  return arm_compute::NEElementwiseDivision::validate(&aclInput0,
31  &aclInput1,
32  &aclOutput,
33  activationInfo);
34 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonExpWorkloadValidate()

arm_compute::Status NeonExpWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 17 of file NeonExpWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

18 {
19  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
20  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21 
22  return arm_compute::NEExpLayer::validate(&aclInput, &aclOutput);
23 }

◆ NeonFullyConnectedWorkloadValidate()

arm_compute::Status NeonFullyConnectedWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TensorInfo weights,
const TensorInfo biases,
const FullyConnectedDescriptor descriptor,
const ActivationDescriptor activationDescriptor 
)

Definition at line 23 of file NeonFullyConnectedWorkload.cpp.

References BoundedReLu, ActivationDescriptor::m_Function, and ReLu.

Referenced by NeonLayerSupport::IsFullyConnectedSupported(), and NeonBackend::OptimizeSubgraphView().

29 {
30  if (activationDescriptor)
31  {
32  std::vector<ActivationFunction> activations = {ActivationFunction::ReLu, ActivationFunction::BoundedReLu};
33  if (std::find(activations.begin(), activations.end(), activationDescriptor->m_Function) == activations.end())
34  {
35  return arm_compute::Status{
36  arm_compute::ErrorCode::RUNTIME_ERROR, "NeonFullyConnectedWorkload :Unsupported Activation Function"};
37  }
38  }
39 
40  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
41  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
42  const arm_compute::TensorInfo aclWeights = BuildArmComputeTensorInfo(weights);
43 
44  arm_compute::TensorInfo aclBiases;
45  arm_compute::TensorInfo *optionalAclBiases = nullptr;
46  if (descriptor.m_BiasEnabled)
47  {
48  aclBiases = BuildArmComputeTensorInfo(biases);
49  optionalAclBiases = &aclBiases;
50  }
51 
52  const arm_compute::FullyConnectedLayerInfo fullyConnectedLayerInfo =
53  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor, activationDescriptor);
54 
55  return arm_compute::NEFullyConnectedLayer::validate(&aclInput,
56  &aclWeights,
57  optionalAclBiases,
58  &aclOutput,
59  fullyConnectedLayerInfo);
60 }
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
Status
enumeration
Definition: Types.hpp:26

◆ NeonGatherWorkloadValidate()

arm_compute::Status NeonGatherWorkloadValidate ( const TensorInfo input,
const TensorInfo indices,
const TensorInfo output,
const GatherDescriptor descriptor 
)

Definition at line 13 of file NeonGatherWorkload.cpp.

Referenced by NeonLayerSupport::IsGatherSupported().

17 {
18  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
19  const arm_compute::TensorInfo aclIndices = BuildArmComputeTensorInfo(indices);
20  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
21 
22  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
23 
24  return arm_compute::NEGather::validate(&aclInput, &aclIndices, &aclOutput, aclAxis);
25 }
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...

◆ NeonInstanceNormalizationWorkloadValidate()

arm_compute::Status NeonInstanceNormalizationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const InstanceNormalizationDescriptor descriptor 
)

Definition at line 19 of file NeonInstanceNormalizationWorkload.cpp.

Referenced by NeonLayerSupport::IsInstanceNormalizationSupported().

22 {
23  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
24  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
25 
26  return arm_compute::NEInstanceNormalizationLayer::validate(&aclInputInfo,
27  &aclOutputInfo,
28  descriptor.m_Gamma,
29  descriptor.m_Beta,
30  descriptor.m_Eps);
31 }

◆ NeonL2NormalizationWorkloadValidate()

arm_compute::Status NeonL2NormalizationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const L2NormalizationDescriptor descriptor 
)

Definition at line 19 of file NeonL2NormalizationFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsL2NormalizationSupported().

22 {
23  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
24  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
25 
26  int axis = (descriptor.m_DataLayout == DataLayout::NCHW) ? 2 : 0;
27 
28  return arm_compute::NEL2NormalizeLayer::validate(&aclInput, &aclOutput, axis, descriptor.m_Eps);
29 }

◆ NeonLogicalAndWorkloadValidate()

arm_compute::Status NeonLogicalAndWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 18 of file NeonLogicalAndWorkload.cpp.

Referenced by NeonLayerSupport::IsLogicalBinarySupported().

21 {
22  const arm_compute::TensorInfo aclInputInfo0 = BuildArmComputeTensorInfo(input0);
23  const arm_compute::TensorInfo aclInputInfo1 = BuildArmComputeTensorInfo(input1);
24  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
25 
26  const arm_compute::Status aclStatus = arm_compute::NELogicalAnd::validate(&aclInputInfo0,
27  &aclInputInfo1,
28  &aclOutputInfo);
29  return aclStatus;
30 }
Status
enumeration
Definition: Types.hpp:26

◆ NeonLogicalNotWorkloadValidate()

arm_compute::Status NeonLogicalNotWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 19 of file NeonLogicalNotWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

21 {
22  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
23  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
24 
25  const arm_compute::Status aclStatus = arm_compute::NELogicalNot::validate(&aclInputInfo,
26  &aclOutputInfo);
27  return aclStatus;
28 }
Status
enumeration
Definition: Types.hpp:26

◆ NeonLogicalOrWorkloadValidate()

arm_compute::Status NeonLogicalOrWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 18 of file NeonLogicalOrWorkload.cpp.

Referenced by NeonLayerSupport::IsLogicalBinarySupported().

21 {
22  const arm_compute::TensorInfo aclInputInfo0 = BuildArmComputeTensorInfo(input0);
23  const arm_compute::TensorInfo aclInputInfo1 = BuildArmComputeTensorInfo(input1);
24  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
25 
26  const arm_compute::Status aclStatus = arm_compute::NELogicalOr::validate(&aclInputInfo0,
27  &aclInputInfo1,
28  &aclOutputInfo);
29  return aclStatus;
30 }
Status
enumeration
Definition: Types.hpp:26

◆ NeonLogSoftmaxWorkloadValidate()

arm_compute::Status NeonLogSoftmaxWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const LogSoftmaxDescriptor descriptor 
)

Definition at line 19 of file NeonLogSoftmaxWorkload.cpp.

Referenced by NeonLayerSupport::IsLogSoftmaxSupported().

22 {
23  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
26  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
27  return arm_compute::NELogSoftmaxLayer::validate(&aclInputInfo,
28  &aclOutputInfo,
29  descriptor.m_Beta,
30  aclAxis);
31 }
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...

◆ NeonLstmFloatWorkloadValidate()

arm_compute::Status NeonLstmFloatWorkloadValidate ( const TensorInfo input,
const TensorInfo outputStateIn,
const TensorInfo cellStateIn,
const TensorInfo scratchBuffer,
const TensorInfo outputStateOut,
const TensorInfo cellStateOut,
const TensorInfo output,
const LstmDescriptor descriptor,
const LstmInputParamsInfo paramsInfo 
)

Definition at line 273 of file NeonLstmFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsLstmSupported().

282 {
283  arm_compute::LSTMParams<arm_compute::ITensorInfo> lstm_params_info;
284 
285  // The inputs and outputs
286  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
287  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
288  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
289  const arm_compute::TensorInfo aclScratchBufferInfo = BuildArmComputeTensorInfo(scratchBuffer);
290  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
291  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
292  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
293 
294  // Basic parameters
295  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
296  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
297  const arm_compute::TensorInfo aclInputToCellWeightsInfo
298  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
299  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
300  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
301  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
302  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
303  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
304  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
305  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
306  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
307  const arm_compute::TensorInfo aclForgetGateBiasInfo
308  = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
309  const arm_compute::TensorInfo aclCellBiasInfo
310  = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
311  const arm_compute::TensorInfo aclOutputGateBiasInfo
312  = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
313 
314  arm_compute::TensorInfo aclInputToInputWeightsInfo;
315  arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
316  arm_compute::TensorInfo aclCellToInputWeightsInfo;
317  arm_compute::TensorInfo aclInputGateBiasInfo;
318  arm_compute::TensorInfo aclProjectionWeightsInfo;
319  arm_compute::TensorInfo aclProjectionBiasInfo;
320  arm_compute::TensorInfo aclCellToForgetWeightsInfo;
321  arm_compute::TensorInfo aclCellToOutputWeightsInfo;
322 
323  arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
324  arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
325  arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
326  arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
327 
328 
329  if (!descriptor.m_CifgEnabled)
330  {
331  if (descriptor.m_PeepholeEnabled)
332  {
333  aclCellToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToInputWeights());
334  }
335  aclInputToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
336  aclRecurrentToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
337  aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
338 
339  lstm_params_info.set_cifg_params(&aclInputToInputWeightsInfo, &aclRecurrentToInputWeightsInfo,
340  descriptor.m_PeepholeEnabled ? &aclCellToInputWeightsInfo : nullptr,
341  &aclInputGateBiasInfo);
342  }
343 
344  if (descriptor.m_ProjectionEnabled)
345  {
346  if (paramsInfo.m_ProjectionBias != nullptr)
347  {
348  aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionBias());
349  }
350  aclProjectionWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionWeights());
351 
352  lstm_params_info.set_projection_params(&aclProjectionWeightsInfo,
353  paramsInfo.m_ProjectionBias != nullptr ?
354  &aclProjectionBiasInfo : nullptr);
355  }
356 
357  if (descriptor.m_PeepholeEnabled)
358  {
359  aclCellToForgetWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToForgetWeights());
360  aclCellToOutputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToOutputWeights());
361 
362  lstm_params_info.set_peephole_params(&aclCellToForgetWeightsInfo, &aclCellToOutputWeightsInfo);
363  }
364 
365  if (descriptor.m_LayerNormEnabled)
366  {
367  if (!descriptor.m_CifgEnabled)
368  {
369  aclInputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputLayerNormWeights());
370  }
371  aclForgetLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetLayerNormWeights());
372  aclCellLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellLayerNormWeights());
373  aclOutputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputLayerNormWeights());
374 
375  lstm_params_info.set_layer_normalization_params(descriptor.m_CifgEnabled ?
376  nullptr : &aclInputLayerNormWeightsInfo,
377  &aclForgetLayerNormWeightsInfo,
378  &aclCellLayerNormWeightsInfo,
379  &aclOutputLayerNormWeightsInfo);
380  }
381 
382  float cell_threshold = descriptor.m_ClippingThresCell;
383  float projection_threshold = descriptor.m_ClippingThresProj;
384 
385  // for preparing the object for the class ActivationLayerInfo, we need to consider 5 situations
386  arm_compute::ActivationLayerInfo activationLayerInfo;
387  switch (descriptor.m_ActivationFunc)
388  {
389  case 0:
390  // no activation, do nothing
391  break;
392  case 1:
393  activationLayerInfo = arm_compute::ActivationLayerInfo(
394  arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
395  break;
396  case 3:
397  activationLayerInfo = arm_compute::ActivationLayerInfo(
398  arm_compute::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.0);
399  break;
400  case 4:
401  activationLayerInfo = arm_compute::ActivationLayerInfo(
402  arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0, 1.0);
403  break;
404  case 6:
405  activationLayerInfo = arm_compute::ActivationLayerInfo(
406  arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC);
407  break;
408  default:
409  throw armnn::Exception("Wrong Type of Activation Function!");
410  }
411 
412  return arm_compute::NELSTMLayer::validate(&aclInputInfo,
413  &aclInputToForgetWeightsInfo,
414  &aclInputToCellWeightsInfo,
415  &aclInputToOutputWeightsInfo,
416  &aclRecurrentToForgetWeightsInfo,
417  &aclRecurrentToCellWeightsInfo,
418  &aclRecurrentToOutputWeightsInfo,
419  &aclForgetGateBiasInfo,
420  &aclCellBiasInfo,
421  &aclOutputGateBiasInfo,
422  &aclOutputStateInInfo,
423  &aclCellStateInInfo,
424  &aclScratchBufferInfo,
425  &aclOutputStateOutInfo,
426  &aclCellStateOutInfo,
427  &aclOutputInfo,
428  lstm_params_info,
429  activationLayerInfo,
430  cell_threshold,
431  projection_threshold);
432 }
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46

◆ NeonMaximumWorkloadValidate()

arm_compute::Status NeonMaximumWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Definition at line 14 of file NeonMaximumWorkload.cpp.

Referenced by NeonLayerSupport::IsMaximumSupported().

17 {
18  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
19  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
20  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21 
22  return arm_compute::NEElementwiseMax::validate(&aclInput0,
23  &aclInput1,
24  &aclOutput);
25 }

◆ NeonMeanWorkloadValidate()

arm_compute::Status NeonMeanWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const MeanDescriptor desc 
)

Definition at line 18 of file NeonMeanWorkload.cpp.

Referenced by NeonLayerSupport::IsMeanSupported().

21 {
22  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
23  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
24 
25  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
26  input.GetNumDimensions(),
27  desc.m_Axis);
28 
29  return arm_compute::NEReduceMean::validate(&aclInputInfo, coords, desc.m_KeepDims, &aclOutputInfo);
30 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ NeonMinimumWorkloadValidate()

arm_compute::Status NeonMinimumWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output 
)

Validate function for validating the inputs and output.

Parameters
[in]input0The input0 value to be validated.
[in]input1The input1 value to be validated.
[in]outputThe output value to be validated.

Definition at line 15 of file NeonMinimumWorkload.cpp.

Referenced by NeonLayerSupport::IsMinimumSupported().

18 {
19  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
20  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::NEElementwiseMin::validate(&aclInput0,
24  &aclInput1,
25  &aclOutput);
26 }

◆ NeonMultiplicationWorkloadValidate()

arm_compute::Status NeonMultiplicationWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 19 of file NeonMultiplicationWorkload.cpp.

Referenced by NeonLayerSupport::IsMultiplicationSupported(), and NeonBackend::OptimizeSubgraphView().

23 {
24  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
25  const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
26  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
27 
28  auto convertPolicy = (IsQuantizedType(input0.GetDataType()) || IsQuantizedType(input1.GetDataType())) ?
29  arm_compute::ConvertPolicy::SATURATE :
30  arm_compute::ConvertPolicy::WRAP;
31 
32  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
33  activationDescriptor);
34 
35  // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it,
36  // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be
37  // ignored for F32 tensors.
38  return arm_compute::NEPixelWiseMultiplication::validate(&aclInput1,
39  &aclInput2,
40  &aclOutput,
41  1.0f,
42  convertPolicy,
43  arm_compute::RoundingPolicy::TO_ZERO,
44  activationInfo);
45 }
constexpr bool IsQuantizedType()
Definition: TypesUtils.hpp:249
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonNegWorkloadValidate()

arm_compute::Status NeonNegWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 17 of file NeonNegWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

18 {
19  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
20  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21 
22  return arm_compute::NENegLayer::validate(&aclInput, &aclOutput);
23 }

◆ NeonNormalizationWorkloadValidate()

arm_compute::Status NeonNormalizationWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const NormalizationDescriptor descriptor 
)

Definition at line 48 of file NeonNormalizationFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsNormalizationSupported().

51 {
52  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
53  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
54 
55  arm_compute::NormalizationLayerInfo normalizationInfo = BuildArmComputeNormalizationLayerInfo(descriptor);
56 
57  return arm_compute::NENormalizationLayer::validate(&aclInput, &aclOutput, normalizationInfo);
58 }

◆ NeonPadWorkloadValidate()

arm_compute::Status NeonPadWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const PadDescriptor descriptor 
)

Definition at line 48 of file NeonPadWorkload.cpp.

Referenced by NeonLayerSupport::IsPadSupported().

51 {
52  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
53  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
54 
55  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
56 
57  std::reverse_copy(std::begin(descriptor.m_PadList),
58  std::end(descriptor.m_PadList),
59  std::begin(reversed_PadList));
60 
61  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
62 
63  return arm_compute::NEPadLayer::validate(&aclInputInfo, &aclOutputInfo, padList);
64 }

◆ NeonPermuteWorkloadValidate()

arm_compute::Status NeonPermuteWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const PermuteDescriptor descriptor 
)

Definition at line 15 of file NeonPermuteWorkload.cpp.

Referenced by NeonLayerSupport::IsPermuteSupported().

18 {
19  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
20  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21  const armnn::PermutationVector& mappings = descriptor.m_DimMappings;
22 
23  return arm_compute::NEPermute::validate(&aclInputInfo, &aclOutputInfo,
24  armcomputetensorutils::BuildArmComputePermutationVector(mappings));
25 }

◆ NeonPooling2dWorkloadValidate()

arm_compute::Status NeonPooling2dWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const Pooling2dDescriptor descriptor 
)

Definition at line 22 of file NeonPooling2dWorkload.cpp.

Referenced by NeonLayerSupport::IsPooling2dSupported().

25 {
26  const arm_compute::TensorInfo aclInputInfo =
27  BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
28  const arm_compute::TensorInfo aclOutputInfo =
29  BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
30 
31  arm_compute::PoolingLayerInfo layerInfo = BuildArmComputePoolingLayerInfo(descriptor);
32 
33  return arm_compute::NEPoolingLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo);
34 }

◆ NeonPreluWorkloadValidate()

arm_compute::Status NeonPreluWorkloadValidate ( const TensorInfo input,
const TensorInfo alpha,
const TensorInfo output 
)

Definition at line 17 of file NeonPreluWorkload.cpp.

Referenced by NeonLayerSupport::IsPreluSupported().

20 {
21  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclAlpha = armcomputetensorutils::BuildArmComputeTensorInfo(alpha);
23  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
24 
25  return arm_compute::NEPReluLayer::validate(&aclInput,
26  &aclAlpha,
27  &aclOutput);
28 }

◆ NeonQLstmWorkloadValidate()

arm_compute::Status NeonQLstmWorkloadValidate ( const TensorInfo input,
const TensorInfo cellStateIn,
const TensorInfo outputStateIn,
const TensorInfo cellStateOut,
const TensorInfo outputStateOut,
const TensorInfo output,
const QLstmDescriptor descriptor,
const LstmInputParamsInfo paramsInfo 
)

Definition at line 236 of file NeonQLstmWorkload.cpp.

Referenced by NeonLayerSupport::IsQLstmSupported().

244 {
245  arm_compute::LSTMParams<arm_compute::ITensorInfo> aclParamsInfo;
246 
247  // Input/Output tensor info
248  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
249  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
250  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
251 
252  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
253  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
254  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
255 
256  // Mandatory tensor info
257  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
258  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
259  const arm_compute::TensorInfo aclInputToCellWeightsInfo
260  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
261  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
262  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
263  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
264  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
265  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
266  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
267  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
268  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
269  const arm_compute::TensorInfo aclForgetGateBiasInfo
270  = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
271  const arm_compute::TensorInfo aclCellBiasInfo
272  = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
273  const arm_compute::TensorInfo aclOutputGateBiasInfo
274  = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
275 
276  // Optional tensor info
277  arm_compute::TensorInfo aclInputToInputWeightsInfo;
278  arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
279 
280  arm_compute::TensorInfo aclCellToInputWeightsInfo;
281  arm_compute::TensorInfo aclCellToForgetWeightsInfo;
282  arm_compute::TensorInfo aclCellToOutputWeightsInfo;
283 
284  arm_compute::TensorInfo aclInputGateBiasInfo;
285 
286  arm_compute::TensorInfo aclProjectionWeightsInfo;
287  arm_compute::TensorInfo aclProjectionBiasInfo;
288 
289  arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
290  arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
291  arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
292  arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
293 
294  // Create tensor info for optional params if they are enabled
295  if (descriptor.m_PeepholeEnabled)
296  {
297  if (!descriptor.m_CifgEnabled)
298  {
299  aclCellToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToInputWeights());
300  }
301 
302  aclCellToForgetWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToForgetWeights());
303  aclCellToOutputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToOutputWeights());
304 
305  // Set peephole params info
306  aclParamsInfo.set_peephole_params(&aclCellToForgetWeightsInfo,
307  &aclCellToOutputWeightsInfo);
308  }
309 
310  if (descriptor.m_ProjectionEnabled)
311  {
312  aclProjectionWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionWeights());
313 
314  if (paramsInfo.m_ProjectionBias != nullptr)
315  {
316  aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionBias());
317  }
318 
319  // Set projection params info
320  aclParamsInfo.set_projection_params(
321  &aclProjectionWeightsInfo,
322  paramsInfo.m_ProjectionBias != nullptr ? &aclProjectionBiasInfo : nullptr);
323  }
324 
325  if (descriptor.m_LayerNormEnabled)
326  {
327  if (!descriptor.m_CifgEnabled)
328  {
329  aclInputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputLayerNormWeights());
330  }
331 
332  aclForgetLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetLayerNormWeights());
333  aclCellLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellLayerNormWeights());
334  aclOutputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputLayerNormWeights());
335 
336  // Set layer norm params info
337  aclParamsInfo.set_layer_normalization_params(
338  paramsInfo.m_InputLayerNormWeights != nullptr ? &aclInputLayerNormWeightsInfo : nullptr,
339  &aclForgetLayerNormWeightsInfo,
340  &aclCellLayerNormWeightsInfo,
341  &aclOutputLayerNormWeightsInfo);
342  }
343 
344  if (!descriptor.m_CifgEnabled)
345  {
346  aclInputToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
347  aclRecurrentToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
348  aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
349 
350  // Set CIFG params info
351  aclParamsInfo.set_cifg_params(
352  &aclInputToInputWeightsInfo,
353  &aclRecurrentToInputWeightsInfo,
354  paramsInfo.m_CellToInputWeights != nullptr ? &aclCellToInputWeightsInfo : nullptr,
355  &aclInputGateBiasInfo);
356  }
357 
358  // Set scalar descriptor params
359  aclParamsInfo.set_cell_clip_params(descriptor.m_CellClip);
360  aclParamsInfo.set_projection_clip_params(descriptor.m_ProjectionClip);
361  aclParamsInfo.set_hidden_state_params(descriptor.m_HiddenStateZeroPoint, descriptor.m_HiddenStateScale);
362  aclParamsInfo.set_matmul_scale_params(descriptor.m_InputIntermediateScale,
363  descriptor.m_ForgetIntermediateScale,
364  descriptor.m_CellIntermediateScale,
365  descriptor.m_OutputIntermediateScale);
366 
367  // QLSTM NEON validate
368  return arm_compute::NEQLSTMLayer::validate(&aclInputInfo,
369  &aclInputToForgetWeightsInfo,
370  &aclInputToCellWeightsInfo,
371  &aclInputToOutputWeightsInfo,
372  &aclRecurrentToForgetWeightsInfo,
373  &aclRecurrentToCellWeightsInfo,
374  &aclRecurrentToOutputWeightsInfo,
375  &aclForgetGateBiasInfo,
376  &aclCellBiasInfo,
377  &aclOutputGateBiasInfo,
378  &aclCellStateInInfo,
379  &aclOutputStateInInfo,
380  &aclCellStateOutInfo,
381  &aclOutputStateOutInfo,
382  &aclOutputInfo,
383  aclParamsInfo);
384 }

◆ NeonQuantizedLstmWorkloadValidate()

arm_compute::Status NeonQuantizedLstmWorkloadValidate ( const TensorInfo input,
const TensorInfo cellStateIn,
const TensorInfo outputStateIn,
const TensorInfo cellStateOut,
const TensorInfo outputStateOut,
const QuantizedLstmInputParamsInfo paramsInfo 
)

Definition at line 130 of file NeonQuantizedLstmWorkload.cpp.

Referenced by NeonLayerSupport::IsQuantizedLstmSupported().

136 {
137  // The inputs and outputs
138  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
139  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
140  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
141  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
142  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
143 
144  // Basic parameters
145  const arm_compute::TensorInfo aclInputToInputWeightsInfo
146  = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
147  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
148  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
149  const arm_compute::TensorInfo aclInputToCellWeightsInfo
150  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
151  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
152  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
153 
154  const arm_compute::TensorInfo aclRecurrentToInputWeightsInfo
155  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
156  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
157  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
158  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
159  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
160  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
161  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
162 
163  const arm_compute::TensorInfo aclInputGateBiasInfo
164  = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
165  const arm_compute::TensorInfo aclForgetGateBiasInfo
166  = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
167  const arm_compute::TensorInfo aclCellBiasInfo
168  = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
169  const arm_compute::TensorInfo aclOutputGateBiasInfo
170  = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
171 
172  return arm_compute::NELSTMLayerQuantized::validate(&aclInputInfo,
173  &aclInputToInputWeightsInfo,
174  &aclInputToForgetWeightsInfo,
175  &aclInputToCellWeightsInfo,
176  &aclInputToOutputWeightsInfo,
177  &aclRecurrentToInputWeightsInfo,
178  &aclRecurrentToForgetWeightsInfo,
179  &aclRecurrentToCellWeightsInfo,
180  &aclRecurrentToOutputWeightsInfo,
181  &aclInputGateBiasInfo,
182  &aclForgetGateBiasInfo,
183  &aclCellBiasInfo,
184  &aclOutputGateBiasInfo,
185  &aclCellStateInInfo,
186  &aclOutputStateInInfo,
187  &aclCellStateOutInfo,
188  &aclOutputStateOutInfo);
189 }

◆ NeonQuantizeWorkloadValidate()

arm_compute::Status NeonQuantizeWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 18 of file NeonQuantizeWorkload.cpp.

Referenced by NeonLayerSupport::IsQuantizeSupported().

19 {
20  const arm_compute::TensorInfo neonInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo neonOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::NEQuantizationLayer::validate(&neonInputInfo, &neonOutputInfo);
24 }

◆ NeonReshapeWorkloadValidate()

arm_compute::Status NeonReshapeWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 17 of file NeonReshapeWorkload.cpp.

Referenced by NeonLayerSupport::IsReshapeSupported().

19 {
20  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::NEReshapeLayer::validate(&aclInputInfo, &aclOutputInfo);
24 }

◆ NeonResizeWorkloadValidate()

arm_compute::Status NeonResizeWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ResizeDescriptor descriptor 
)

Definition at line 22 of file NeonResizeWorkload.cpp.

Referenced by NeonLayerSupport::IsResizeSupported().

25 {
26  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
27  arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
28 
29  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(descriptor.m_DataLayout);
30  aclInputInfo.set_data_layout(aclDataLayout);
31  aclOutputInfo.set_data_layout(aclDataLayout);
32 
33  arm_compute::InterpolationPolicy aclInterpolationPolicy =
35 
36  arm_compute::SamplingPolicy samplingPolicy = descriptor.m_HalfPixelCenters ? arm_compute::SamplingPolicy::CENTER :
37  arm_compute::SamplingPolicy::TOP_LEFT;
38 
39  bool usePadding = false;
40 
41  return arm_compute::NEScale::validate(&aclInputInfo,
42  &aclOutputInfo,
43  arm_compute::ScaleKernelInfo(aclInterpolationPolicy,
44  arm_compute::BorderMode::REPLICATE,
45  arm_compute::PixelValue(0.f),
46  samplingPolicy,
47  usePadding,
48  descriptor.m_AlignCorners));
49 
50 }
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
DataLayout
Definition: Types.hpp:50

◆ NeonRsqrtWorkloadValidate()

arm_compute::Status NeonRsqrtWorkloadValidate ( const TensorInfo input,
const TensorInfo output 
)

Definition at line 18 of file NeonRsqrtWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

19 {
20  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::NERsqrtLayer::validate(&aclInput, &aclOutput);
24 }

◆ NeonSliceWorkloadValidate()

arm_compute::Status NeonSliceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SliceDescriptor descriptor 
)

Definition at line 21 of file NeonSliceWorkload.cpp.

Referenced by NeonLayerSupport::IsSliceSupported().

24 {
25  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
26  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
27 
30 
31  std::tie(starts, ends) = SetNeonSliceData(descriptor.m_Begin, descriptor.m_Size);
32 
33  return arm_compute::NESlice::validate(&aclInputInfo, &aclOutputInfo, starts, ends);
34 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
auto SetNeonSliceData(const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)

◆ NeonSoftmaxWorkloadValidate()

arm_compute::Status NeonSoftmaxWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SoftmaxDescriptor descriptor 
)

Definition at line 19 of file NeonSoftmaxWorkload.cpp.

Referenced by NeonLayerSupport::IsSoftmaxSupported().

22 {
23  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
26  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
27  return arm_compute::NESoftmaxLayer::validate(&aclInputInfo,
28  &aclOutputInfo,
29  descriptor.m_Beta,
30  aclAxis);
31 }
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank...

◆ NeonSpaceToBatchNdWorkloadValidate()

arm_compute::Status NeonSpaceToBatchNdWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SpaceToBatchNdDescriptor descriptor 
)

Definition at line 20 of file NeonSpaceToBatchNdWorkload.cpp.

Referenced by NeonLayerSupport::IsSpaceToBatchNdSupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
25  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
26 
27  // ArmNN blockShape is [H, W] Cl asks for W, H
28  int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
29  int32_t blockWidth = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[1]);
30 
31  arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(
32  descriptor.m_PadList[1].first, descriptor.m_PadList[0].first);
33  arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(
34  descriptor.m_PadList[1].second, descriptor.m_PadList[0].second);
35 
36  return arm_compute::NESpaceToBatchLayer::validate(&aclInputInfo,
37  blockWidth,
38  blockHeight,
39  paddingLeftTop,
40  paddingRightBottom,
41  &aclOutputInfo);
42 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonSpaceToDepthWorkloadValidate()

arm_compute::Status NeonSpaceToDepthWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SpaceToDepthDescriptor descriptor 
)

Definition at line 19 of file NeonSpaceToDepthWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by NeonLayerSupport::IsSpaceToDepthSupported().

22 {
23  DataLayout dataLayout = descriptor.m_DataLayout;
24  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout);
25  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout);
26 
27  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize);
28 
29  return arm_compute::NESpaceToDepthLayer::validate(&aclInput, &aclOutput, blockSize);
30 }
DataLayout
Definition: Types.hpp:50
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonSplitterWorkloadValidate()

arm_compute::Status NeonSplitterWorkloadValidate ( const TensorInfo input,
const std::vector< std::reference_wrapper< TensorInfo >> &  outputs,
unsigned int  splitAxis 
)

Definition at line 32 of file NeonSplitterWorkload.cpp.

Referenced by NeonLayerSupport::IsSplitterSupported().

35 {
36  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
37 
38  size_t numOutputs = outputs.size();
39 
40  std::vector<arm_compute::TensorInfo> aclOutputs;
41  aclOutputs.reserve(numOutputs);
42 
43  std::vector<arm_compute::ITensorInfo*> aclOutputPtr;
44  aclOutputPtr.reserve(numOutputs);
45 
46  for (size_t i = 0u; i < outputs.size(); ++i)
47  {
48  aclOutputs.emplace_back(BuildArmComputeTensorInfo(outputs[i]));
49  aclOutputPtr.emplace_back(&aclOutputs.back());
50  }
51 
52  unsigned int aclAxis = CalcAclAxis(input.GetNumDimensions(), splitAxis);
53  return arm_compute::NESplit::validate(&aclInputInfo, aclOutputPtr, aclAxis);
54 }

◆ NeonStackWorkloadValidate()

arm_compute::Status NeonStackWorkloadValidate ( const std::vector< const TensorInfo *> &  inputs,
const TensorInfo output,
const StackDescriptor descriptor 
)

Definition at line 27 of file NeonStackWorkload.cpp.

Referenced by NeonLayerSupport::IsStackSupported().

30 {
31  std::vector<arm_compute::TensorInfo> aclInputs;
32  for (const TensorInfo* input : inputs)
33  {
34  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(*input, armnn::DataLayout::NCHW);
35  aclInputs.emplace_back(aclInputInfo);
36  }
37 
38  std::vector<arm_compute::ITensorInfo*> aclInputPtrs;
39  for (arm_compute::ITensorInfo& input : aclInputs)
40  {
41  aclInputPtrs.emplace_back(&input);
42  }
43 
44  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
45  int aclAxis = CalcAxis(descriptor.m_Axis, descriptor.m_InputShape.GetNumDimensions());
46  return arm_compute::NEStackLayer::validate(aclInputPtrs, aclAxis, &aclOutputInfo);
47 }

◆ NeonStridedSliceWorkloadValidate()

arm_compute::Status NeonStridedSliceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const StridedSliceDescriptor descriptor 
)

Definition at line 19 of file NeonStridedSliceWorkload.cpp.

Referenced by NeonLayerSupport::IsStridedSliceSupported().

22 {
23  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
29 
30  std::tie(starts, ends, strides) = SetNeonStridedSliceData(descriptor.m_Begin,
31  descriptor.m_End,
32  descriptor.m_Stride);
33 
34  auto numDimensions = armnn::numeric_cast<int>(input.GetNumDimensions());
35  int32_t begin_mask = ConvertMaskToACLFormat(descriptor.m_BeginMask, numDimensions);
36  int32_t end_mask = ConvertMaskToACLFormat(descriptor.m_EndMask, numDimensions);
37  int32_t shrink_axis_mask = ConvertMaskToACLFormat(descriptor.m_ShrinkAxisMask, numDimensions);
38 
39  return arm_compute::NEStridedSlice::validate(&aclInput,
40  &aclOutput,
41  starts,
42  ends,
43  strides,
44  begin_mask,
45  end_mask,
46  shrink_axis_mask);
47 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
auto SetNeonStridedSliceData(const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)
int32_t ConvertMaskToACLFormat(int32_t mask, int32_t numDim)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonSubtractionWorkloadValidate()

arm_compute::Status NeonSubtractionWorkloadValidate ( const TensorInfo input0,
const TensorInfo input1,
const TensorInfo output,
const ActivationDescriptor activationDescriptor 
)

Definition at line 22 of file NeonSubtractionWorkload.cpp.

Referenced by NeonLayerSupport::IsSubtractionSupported(), and NeonBackend::OptimizeSubgraphView().

26 {
27  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
28  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
29  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
30 
31  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
32  activationDescriptor);
33 
34  return arm_compute::NEArithmeticSubtraction::validate(&aclInput0,
35  &aclInput1,
36  &aclOutput,
37  arm_compute::ConvertPolicy::SATURATE,
38  activationInfo);
39 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonTensorHandleFactoryId()

constexpr const char* armnn::NeonTensorHandleFactoryId ( )

Definition at line 14 of file NeonTensorHandleFactory.hpp.

Referenced by NeonTensorHandleFactory::GetIdStatic().

14 { return "Arm/Neon/TensorHandleFactory"; }

◆ NeonTransposeConvolution2dWorkloadValidate()

arm_compute::Status NeonTransposeConvolution2dWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TransposeConvolution2dDescriptor descriptor,
const TensorInfo weights,
const Optional< TensorInfo > &  biases 
)

Definition at line 25 of file NeonTransposeConvolution2dWorkload.cpp.

Referenced by NeonLayerSupport::IsTransposeConvolution2dSupported().

30 {
31  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
32  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
33  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
34 
35  arm_compute::TensorInfo aclBiasesInfo;
36  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
37 
38  if (descriptor.m_BiasEnabled)
39  {
40  ARMNN_ASSERT(biases.has_value());
41 
42  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
43  optionalAclBiasesInfo = &aclBiasesInfo;
44  }
45 
46  arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor);
47 
48  return arm_compute::NEDeconvolutionLayer::validate(&aclInputInfo,
49  &aclWeightsInfo,
50  optionalAclBiasesInfo,
51  &aclOutputInfo,
52  layerInfo);
53 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ NeonTransposeWorkloadValidate()

arm_compute::Status NeonTransposeWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TransposeDescriptor descriptor 
)

Definition at line 15 of file NeonTransposeWorkload.cpp.

Referenced by NeonLayerSupport::IsTransposeSupported().

18 {
19  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
20  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21  const armnn::PermutationVector& mappings = descriptor.m_DimMappings;
22 
23  return arm_compute::NEPermute::validate(&aclInputInfo, &aclOutputInfo,
24  armcomputetensorutils::BuildArmComputeTransposeVector(mappings));
25 }

◆ NextIndex()

bool armnn::NextIndex ( const unsigned int  numDims,
const armnn::TensorShape dims,
std::vector< unsigned int > &  current 
)

Definition at line 18 of file Mean.cpp.

Referenced by Mean().

19 {
20  unsigned int carry = 1;
21 
22  for (unsigned int idx = numDims; idx-- > 0; )
23  {
24  unsigned int current_val = current[idx] + carry;
25  if (dims[idx] == current_val)
26  {
27  current[idx] = 0;
28  }
29  else
30  {
31  current[idx] = current_val;
32  carry = 0;
33  break;
34  }
35  }
36  return (carry == 0);
37 }

◆ NonMaxSuppression()

std::vector< unsigned int > NonMaxSuppression ( unsigned int  numBoxes,
const std::vector< float > &  boxCorners,
const std::vector< float > &  scores,
float  nmsScoreThreshold,
unsigned int  maxDetection,
float  nmsIouThreshold 
)

Definition at line 49 of file DetectionPostProcess.cpp.

References GenerateRangeK(), IntersectionOverUnion(), numeric_cast(), and TopKSort().

Referenced by BOOST_AUTO_TEST_CASE(), and DetectionPostProcess().

55 {
56  // Select boxes that have scores above a given threshold.
57  std::vector<float> scoresAboveThreshold;
58  std::vector<unsigned int> indicesAboveThreshold;
59  for (unsigned int i = 0; i < numBoxes; ++i)
60  {
61  if (scores[i] >= nmsScoreThreshold)
62  {
63  scoresAboveThreshold.push_back(scores[i]);
64  indicesAboveThreshold.push_back(i);
65  }
66  }
67 
68  // Sort the indices based on scores.
69  unsigned int numAboveThreshold = armnn::numeric_cast<unsigned int>(scoresAboveThreshold.size());
70  std::vector<unsigned int> sortedIndices = GenerateRangeK(numAboveThreshold);
71  TopKSort(numAboveThreshold, sortedIndices.data(), scoresAboveThreshold.data(), numAboveThreshold);
72 
73  // Number of output cannot be more than max detections specified in the option.
74  unsigned int numOutput = std::min(maxDetection, numAboveThreshold);
75  std::vector<unsigned int> outputIndices;
76  std::vector<bool> visited(numAboveThreshold, false);
77 
78  // Prune out the boxes with high intersection over union by keeping the box with higher score.
79  for (unsigned int i = 0; i < numAboveThreshold; ++i)
80  {
81  if (outputIndices.size() >= numOutput)
82  {
83  break;
84  }
85  if (!visited[sortedIndices[i]])
86  {
87  outputIndices.push_back(indicesAboveThreshold[sortedIndices[i]]);
88  for (unsigned int j = i + 1; j < numAboveThreshold; ++j)
89  {
90  unsigned int iIndex = indicesAboveThreshold[sortedIndices[i]] * 4;
91  unsigned int jIndex = indicesAboveThreshold[sortedIndices[j]] * 4;
92  if (IntersectionOverUnion(&boxCorners[iIndex], &boxCorners[jIndex]) > nmsIouThreshold)
93  {
94  visited[sortedIndices[j]] = true;
95  }
96  }
97  }
98  }
99  return outputIndices;
100 }
float IntersectionOverUnion(const float *boxI, const float *boxJ)
std::vector< unsigned int > GenerateRangeK(unsigned int k)
void TopKSort(unsigned int k, unsigned int *indices, const float *values, unsigned int numElement)
std::vector< float > scores({ 0.0f, 0.9f, 0.8f, 0.0f, 0.75f, 0.72f, 0.0f, 0.6f, 0.5f, 0.0f, 0.93f, 0.95f, 0.0f, 0.5f, 0.4f, 0.0f, 0.3f, 0.2f })
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ numeric_cast() [1/9]

std::enable_if_t< std::is_unsigned<Source>::value && std::is_unsigned<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 35 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

Referenced by CaffeParserBase::AddConvLayerWithDepthwiseConv(), CaffeParserBase::AddConvLayerWithSplits(), AllocateOutputData(), ArgMinMax(), BOOST_AUTO_TEST_CASE(), ClArgMinMaxWorkload::ClArgMinMaxWorkload(), ClSpaceToBatchNdWorkload::ClSpaceToBatchNdWorkload(), ClStridedSliceWorkload::ClStridedSliceWorkload(), CompareActivationTestImpl(), armnnTfLiteParser::ComputeWrappedIndex(), OutputSlot::Connect(), CreateNetworkImpl< IParser >::Create(), SendCounterPacket::CreateCategoryRecord(), SendCounterPacket::CreateEventRecord(), TfLiteParser::CreateNetworkFromBinary(), RecordByRecordCaffeParser::CreateNetworkFromBinaryFile(), DepthwiseConvolution2dAsymmetricTestImpl(), DepthwiseConvolution2dTestImpl(), DetectionPostProcess(), RefL2NormalizationWorkload::Execute(), armnnUtils::ExpandDims(), FakeQuantization(), Gather(), CounterDirectory::GetCategoryCount(), MockCounterDirectory::GetCategoryCount(), CounterDirectory::GetCounterCount(), MockCounterDirectory::GetCounterCount(), CounterDirectory::GetCounterSetCount(), MockCounterDirectory::GetCounterSetCount(), CounterDirectory::GetDeviceCount(), MockCounterDirectory::GetDeviceCount(), Deserializer::GetNetworkOutputBindingInfo(), OutputSlot::GetNumConnections(), SubgraphView::GetNumInputSlots(), SubgraphView::GetNumOutputSlots(), StridedSliceDescriptor::GetStartForAxis(), StridedSliceDescriptor::GetStopForAxis(), GetStreamMetaDataPacketSize(), Cifar10Database::GetTestCaseData(), CaffePreprocessor::GetTestCaseData(), YoloDatabase::GetTestCaseData(), armnnUtils::GetUnsignedAxis(), RequestCountersPacketHandler::HandlePacket(), InferenceTestImage::InferenceTestImage(), PreluLayer::InferOutputShapes(), RefLayerSupport::IsMeanSupported(), CaffeParserBase::LoadNetParam(), LogSoftmax(), Mean(), NeonArgMinMaxWorkload::NeonArgMinMaxWorkload(), NeonSpaceToBatchNdWorkload::NeonSpaceToBatchNdWorkload(), NeonStridedSliceWorkload::NeonStridedSliceWorkload(), NonMaxSuppression(), ClassifierTestCaseProvider< TDatabase, InferenceModel >::OnInferenceTestFinished(), armnnTfParser::OutputShapeOfExpandDims(), Deserializer::OutputShapeOfReshape(), TfLiteParser::OutputShapeOfReshape(), armnnTfParser::OutputShapeOfSqueeze(), ParseArray(), ParseDataArray< armnn::DataType::QAsymmU8 >(), CaffeParserBase::ParseInputLayer(), CaffeParserBase::ParseLRNLayer(), Pooling2d(), ClassifierTestCase< TTestCaseDatabase, TModel >::ProcessResult(), QuantizerVisitor::QuantizerVisitor(), InferenceModel< IParser, TDataType >::Run(), Serializer::SaveSerializedToStream(), SendCounterPacket::SendPeriodicCounterCapturePacket(), SendCounterPacket::SendPeriodicCounterSelectionPacket(), SendCounterPacket::SendStreamMetaDataPacket(), SimpleConvolution2dNhwcTestImpl(), SimpleConvolution2dTestImpl(), InferenceTestImage::StbResize(), StridedSlice(), Graph::SubstituteSubgraph(), MeanQueueDescriptor::Validate(), MeanLayer::ValidateTensorShapesFromInputs(), VerifyTimelineLabelBinaryPacketData(), armnn::profiling::WriteTimelineLabelBinaryPacket(), and armnn::profiling::WriteTimelineMessageDirectoryPackage().

36 {
37 #if ENABLE_NUMERIC_CAST_CHECKS
38  if (source > std::numeric_limits<Dest>::max())
39  {
40  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to "
41  "narrower unsigned type. Overflow detected.");
42  }
43 #endif // ENABLE_NUMERIC_CAST_CHECKS
44 
45  return static_cast<Dest>(source);
46 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [2/9]

std::enable_if_t< std::is_signed<Source>::value && std::is_integral<Source>::value && std::is_signed<Dest>::value && std::is_integral<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 58 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

59 {
60 #if ENABLE_NUMERIC_CAST_CHECKS
61  if (source > std::numeric_limits<Dest>::max())
62  {
63  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed integral type to narrower signed type. "
64  "Overflow detected.");
65  }
66 
67  if (source < std::numeric_limits<Dest>::lowest())
68  {
69  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed integral type to narrower signed type. "
70  "Underflow detected.");
71  }
72 #endif // ENABLE_NUMERIC_CAST_CHECKS
73 
74  return static_cast<Dest>(source);
75 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [3/9]

std::enable_if_t< std::is_floating_point<Source>::value && std::is_floating_point<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 83 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

84 {
85 #if ENABLE_NUMERIC_CAST_CHECKS
86  if (source > std::numeric_limits<Dest>::max())
87  {
88  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
89  "Overflow detected.");
90  }
91 
92  if (source < std::numeric_limits<Dest>::lowest())
93  {
94  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
95  "Underflow detected.");
96  }
97 #endif // ENABLE_NUMERIC_CAST_CHECKS
98 
99  return static_cast<Dest>(source);
100 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [4/9]

std::enable_if_t< std::is_floating_point<Source>::value && std::is_signed<Dest>::value && std::is_integral<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 109 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

110 {
111 #if ENABLE_NUMERIC_CAST_CHECKS
112  if (source > static_cast<Source>(std::numeric_limits<Dest>::max()))
113  {
114  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
115  "Overflow detected.");
116  }
117 
118  if (source < static_cast<Source>(std::numeric_limits<Dest>::lowest()))
119  {
120  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
121  "Underflow detected.");
122  }
123 #endif // ENABLE_NUMERIC_CAST_CHECKS
124 
125  return static_cast<Dest>(source);
126 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [5/9]

std::enable_if_t< std::is_signed<Source>::value && std::is_integral<Source>::value && std::is_floating_point<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 135 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

136 {
137 #if ENABLE_NUMERIC_CAST_CHECKS
138  Dest sourceConverted = static_cast<Dest>(source);
139 
140  if (sourceConverted > std::numeric_limits<Dest>::max())
141  {
142  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to narrower floating point type. "
143  "Overflow detected.");
144  }
145 
146  if (sourceConverted < std::numeric_limits<Dest>::lowest())
147  {
148  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to narrower floating point type. "
149  "Underflow detected.");
150  }
151 #endif // ENABLE_NUMERIC_CAST_CHECKS
152 
153  return static_cast<Dest>(source);
154 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [6/9]

std::enable_if_t< std::is_signed<Dest>::value && std::is_integral<Dest>::value && std::is_unsigned<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 165 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

166 {
167 #if ENABLE_NUMERIC_CAST_CHECKS
168  if (sValue > static_cast< typename std::make_unsigned<Dest>::type >(std::numeric_limits<Dest>::max()))
169  {
170  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to signed type. "
171  "Overflow detected.");
172  }
173 #endif // ENABLE_NUMERIC_CAST_CHECKS
174 
175  return static_cast<Dest>(sValue);
176 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [7/9]

std::enable_if_t< std::is_floating_point<Dest>::value && std::is_unsigned<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 184 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

185 {
186 #if ENABLE_NUMERIC_CAST_CHECKS
187  if (static_cast<Dest>(sValue) > std::numeric_limits<Dest>::max())
188  {
189  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to floating point type. "
190  "Overflow detected.");
191  }
192 #endif // ENABLE_NUMERIC_CAST_CHECKS
193 
194  return static_cast<Dest>(sValue);
195 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [8/9]

std::enable_if_t< std::is_unsigned<Dest>::value && std::is_signed<Source>::value && std::is_integral<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 206 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

207 {
208 #if ENABLE_NUMERIC_CAST_CHECKS
209  if (sValue < 0)
210  {
211  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting negative value to unsigned type. "
212  "Underflow detected.");
213  }
214 
215  if (static_cast< typename std::make_unsigned<Source>::type >(sValue) > std::numeric_limits<Dest>::max())
216  {
217  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to unsigned type. "
218  "Overflow detected.");
219  }
220 #endif // ENABLE_NUMERIC_CAST_CHECKS
221  return static_cast<Dest>(sValue);
222 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [9/9]

std::enable_if_t< std::is_unsigned<Dest>::value && std::is_floating_point<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 230 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

231 {
232 #if ENABLE_NUMERIC_CAST_CHECKS
233  if (sValue < 0)
234  {
235  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting negative value to unsigned type. "
236  "Underflow detected.");
237  }
238 
239  if (sValue > static_cast<Source>(std::numeric_limits<Dest>::max()))
240  {
241  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to unsigned type. "
242  "Overflow detected.");
243  }
244 #endif // ENABLE_NUMERIC_CAST_CHECKS
245  return static_cast<Dest>(sValue);
246 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ Offset()

unsigned int armnn::Offset ( const TensorShape shape,
unsigned int  batch,
unsigned int  height,
unsigned int  width,
unsigned int  channels,
const DataLayoutIndexed dataLayout 
)
inline

Definition at line 19 of file BatchToSpaceNd.cpp.

References DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetDataLayout(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetWidthIndex(), and NHWC.

Referenced by BatchToSpaceNd().

21 {
22  if (dataLayout.GetDataLayout() == DataLayout::NHWC)
23  {
24  return ((batch * shape[dataLayout.GetHeightIndex()] + height) * shape[dataLayout.GetWidthIndex()] + width) *
25  shape[dataLayout.GetChannelsIndex()] + channels;
26  }
27  else
28  {
29  return ((batch * shape[dataLayout.GetChannelsIndex()] + channels) *
30  shape[dataLayout.GetHeightIndex()] + height) *
31  shape[dataLayout.GetWidthIndex()] + width;
32  }
33 }
unsigned int GetWidthIndex() const
unsigned int GetHeightIndex() const
armnn::DataLayout GetDataLayout() const
unsigned int GetChannelsIndex() const

◆ operator<<() [1/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const std::vector< Compute > &  compute 
)
inline

Deprecated function that will be removed together with the Compute enum.

Definition at line 47 of file BackendId.hpp.

References GetComputeDeviceAsCString().

48 {
49  for (const Compute& comp : compute)
50  {
51  os << GetComputeDeviceAsCString(comp) << " ";
52  }
53  return os;
54 }
Compute
The Compute enum is now deprecated and it is now being replaced by BackendId.
Definition: BackendId.hpp:21
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34

◆ operator<<() [2/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const std::set< Compute > &  compute 
)
inline

Deprecated function that will be removed together with the Compute enum.

Definition at line 58 of file BackendId.hpp.

References GetComputeDeviceAsCString().

59 {
60  for (const Compute& comp : compute)
61  {
62  os << GetComputeDeviceAsCString(comp) << " ";
63  }
64  return os;
65 }
Compute
The Compute enum is now deprecated and it is now being replaced by BackendId.
Definition: BackendId.hpp:21
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34

◆ operator<<() [3/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const BackendVersion backendVersion 
)
inline

Definition at line 61 of file IBackendInternal.hpp.

References BackendVersion::m_Major, and BackendVersion::m_Minor.

62 {
63  os << "[" << backendVersion.m_Major << "." << backendVersion.m_Minor << "]";
64 
65  return os;
66 }

◆ operator<<() [4/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const Compute compute 
)
inline

Deprecated function that will be removed together with the Compute enum.

Definition at line 69 of file BackendId.hpp.

References GetComputeDeviceAsCString().

70 {
71  os << GetComputeDeviceAsCString(compute);
72  return os;
73 }
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34

◆ operator<<() [5/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const BFloat16 b 
)
inline

Definition at line 119 of file BFloat16.hpp.

References BFloat16::ToFloat32(), and BFloat16::Val().

120 {
121  os << b.ToFloat32() << "(0x" << std::hex << b.Val() << ")";
122  return os;
123 }

◆ operator<<() [6/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const BackendId id 
)
inline

Definition at line 174 of file BackendId.hpp.

175 {
176  os << id.Get();
177  return os;
178 }

◆ operator<<() [7/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const TContainer< BackendId, TContainerTemplateArgs... > &  ids 
)

Definition at line 181 of file BackendId.hpp.

183 {
184  os << '[';
185  for (const auto& id : ids) { os << id << " "; }
186  os << ']';
187  return os;
188 }

◆ operator<<() [8/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
Status  stat 
)
inline

Definition at line 269 of file TypesUtils.hpp.

References GetStatusAsCString().

270 {
271  os << GetStatusAsCString(stat);
272  return os;
273 }
constexpr char const * GetStatusAsCString(Status status)
Definition: TypesUtils.hpp:17

◆ operator<<() [9/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const armnn::TensorShape shape 
)
inline

Definition at line 276 of file TypesUtils.hpp.

References Dequantize, TensorShape::GetNumDimensions(), and Quantize.

277 {
278  os << "[";
279  for (uint32_t i=0; i<shape.GetNumDimensions(); ++i)
280  {
281  if (i!=0)
282  {
283  os << ",";
284  }
285  os << shape[i];
286  }
287  os << "]";
288  return os;
289 }
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174

◆ operator>>() [1/2]

std::istream& armnn::operator>> ( std::istream &  in,
armnn::Compute compute 
)
inline

Definition at line 21 of file InferenceTest.hpp.

References ParseComputeDevice(), and Undefined.

22 {
23  std::string token;
24  in >> token;
25  compute = armnn::ParseComputeDevice(token.c_str());
26  if (compute == armnn::Compute::Undefined)
27  {
28  in.setstate(std::ios_base::failbit);
29  throw cxxopts::OptionException(fmt::format("Unrecognised compute device: {}", token));
30  }
31  return in;
32 }
constexpr armnn::Compute ParseComputeDevice(const char *str)
Deprecated function that will be removed together with the Compute enum.
Definition: TypesUtils.hpp:160

◆ operator>>() [2/2]

std::istream& armnn::operator>> ( std::istream &  in,
armnn::BackendId backend 
)
inline

Definition at line 34 of file InferenceTest.hpp.

References ParseComputeDevice(), and Undefined.

35 {
36  std::string token;
37  in >> token;
38  armnn::Compute compute = armnn::ParseComputeDevice(token.c_str());
39  if (compute == armnn::Compute::Undefined)
40  {
41  in.setstate(std::ios_base::failbit);
42  throw cxxopts::OptionException(fmt::format("Unrecognised compute device: {}", token));
43  }
44  backend = compute;
45  return in;
46 }
Compute
The Compute enum is now deprecated and it is now being replaced by BackendId.
Definition: BackendId.hpp:21
constexpr armnn::Compute ParseComputeDevice(const char *str)
Deprecated function that will be removed together with the Compute enum.
Definition: TypesUtils.hpp:160

◆ Optimize()

IOptimizedNetworkPtr Optimize ( const INetwork network,
const std::vector< BackendId > &  backendPreferences,
const IDeviceSpec deviceSpec,
const OptimizerOptions options = OptimizerOptions(),
Optional< std::vector< std::string > &>  messages = EmptyOptional() 
)

Create an optimized version of the network.

Parameters
networkINetwork description of the network to be optimized.
backendPreferencesThe choice of the backend ordered by user preferences.
deviceSpecDeviceSpec object as queried from the runtime. See IRuntime::GetDeviceSpec()
messagesIf there are failures or warnings a string describing same will be added to the vector
optionsOptimizerOptions object with optimizer configuration options
Returns
An IOptimizedNetworkPtr interface to the optimized network, throws an exception derived from armnn::Exception if process fails.

Definition at line 1011 of file Network.cpp.

References ApplyBackendOptimizations(), ARMNN_ASSERT, ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, AssignBackends(), BackendRegistryInstance(), CreateSupportedBackends(), IOptimizedNetwork::Destroy(), BackendSettings::GetAvailablePreferredBackends(), BackendRegistry::GetFactory(), Network::GetGraph(), OptimizedNetwork::GetGraph(), OptimizerOptions::m_Debug, OptimizationResult::m_Error, OptimizerOptions::m_ImportEnabled, OptimizerOptions::m_ModelOptions, OptimizerOptions::m_ReduceFp32ToBf16, OptimizerOptions::m_ReduceFp32ToFp16, BackendSettings::m_SelectedBackends, BackendSettings::m_SupportedBackends, MakeOptimizations(), Optimizer::Pass(), ReportError(), and SelectTensorHandleStrategy().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), GetSoftmaxProfilerJson(), InferenceModel< IParser, TDataType >::InferenceModel(), main(), QLstmEndToEnd(), QuantizedLstmEndToEnd(), NetworkQuantizer::Refine(), ParserPrototxtFixture< armnnOnnxParser::IOnnxParser >::Setup(), ParserFlatbuffersSerializeFixture::Setup(), ParserFlatbuffersFixture::Setup(), ParserPrototxtFixture< armnnOnnxParser::IOnnxParser >::SetupOptimizedNetwork(), and VerifyPostOptimisationStructureTestImpl().

1016 {
1017  if (backendPreferences.empty())
1018  {
1019  throw InvalidArgumentException("Invoked Optimize with no backends specified");
1020  }
1021 
1022  if (options.m_ReduceFp32ToFp16 && options.m_ReduceFp32ToBf16)
1023  {
1024  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
1025  }
1026 
1027  const Network& network = *PolymorphicDowncast<const Network*>(&inNetwork);
1028  std::unique_ptr<Graph> graph = std::make_unique<Graph>(network.GetGraph());
1029 
1030  auto optNet = IOptimizedNetworkPtr(new OptimizedNetwork(std::move(graph), options.m_ModelOptions),
1031  &IOptimizedNetwork::Destroy);
1032 
1033  OptimizedNetwork* optNetObjPtr = PolymorphicDowncast<OptimizedNetwork*>(optNet.get());
1034 
1035  // Get the optimized graph
1036  Graph& optGraph = optNetObjPtr->GetGraph();
1037 
1038  // Perform AddBroadcastReshapeLayer optimisation
1039  using namespace optimizations;
1040  Optimizer::Pass(optGraph, MakeOptimizations(AddBroadcastReshapeLayer()));
1041 
1042  // Infer the tensor infos for all output slots. Throws an exception on failure
1043  optGraph.InferTensorInfos();
1044 
1045  // Perform optimisation passes
1046  Optimizer::Pass(optGraph, MakeOptimizations(SquashEqualPermuteSiblings(),
1051  MovePermuteUp(),
1052  MoveTransposeUp(),
1053  PermuteAsReshape(),
1063 
1064  // If Fp32 to Fp16 optimization is set convert Fp32 network to Fp16
1065  if (options.m_ReduceFp32ToFp16)
1066  {
1067  Optimizer::Pass(optGraph, MakeOptimizations(Fp32NetworkToFp16Converter()));
1068  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
1069  }
1070 
1071  // If Fp32 to Bf16 optimization is set convert Fp32 network to Bf16
1072  // Convert input of Convolution2d and FullyConnected from Fp32 to Bf16
1073  // Only Constant weight of Convolution2d and FullyConnected are converted from Fp32 to Bf16
1074  if (options.m_ReduceFp32ToBf16)
1075  {
1076  Optimizer::Pass(optGraph, MakeOptimizations(Fp32NetworkToBf16Converter()));
1077  }
1078 
1079  // Initialize backend settings
1080  BackendSettings backendSettings(backendPreferences, deviceSpec);
1081  if (backendSettings.GetAvailablePreferredBackends().empty())
1082  {
1083  std::stringstream failureMsg;
1084  failureMsg << "None of the preferred backends " << backendPreferences
1085  << " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
1086  ReportError(failureMsg.str(), messages);
1087  throw InvalidArgumentException(failureMsg.str());
1088  }
1089 
1090  // Create a map to temporarily hold initialized backend objects
1091  TensorHandleFactoryRegistry tensorHandleFactoryRegistry;
1092  BackendsMap backends = CreateSupportedBackends(tensorHandleFactoryRegistry, backendSettings);
1093 
1094  // Assign an available backend to each layer
1095  Graph::Iterator firstLayer = optGraph.begin();
1096  Graph::Iterator lastLayer = optGraph.end();
1097  OptimizationResult assignBackendsResult = AssignBackends(optNetObjPtr,
1098  backendSettings,
1099  firstLayer,
1100  lastLayer,
1101  messages);
1102  if (assignBackendsResult.m_Error)
1103  {
1104  // Failed to assign a backend to each layer
1105  throw InvalidArgumentException("Failed to assign a backend to each layer");
1106  }
1107 
1108  Optimizer::Pass(optGraph, MakeOptimizations(OptimizeInverseConversionsFp16(),
1110 
1111  // Apply the backend-specific optimizations
1112  OptimizationResult backendOptimizationResult = ApplyBackendOptimizations(optNetObjPtr,
1113  backendSettings,
1114  backends,
1115  options.m_ModelOptions,
1116  messages);
1117  if (backendOptimizationResult.m_Error)
1118  {
1119  // Failed to apply the backend-specific optimizations
1120  throw InvalidArgumentException("Failed to apply the backend-specific optimizations");
1121  }
1122 
1123  // If the debug flag is set, then insert a DebugLayer after each layer
1124  // Doing this after applying the backend optimizations as they might have changed some layers
1125  if (options.m_Debug)
1126  {
1127  Optimizer::Pass(optGraph, MakeOptimizations(InsertDebugLayer()));
1128  }
1129 
1130  // Calculate the compatibility strategies for tensor handles
1131  OptimizationResult strategyResult = SelectTensorHandleStrategy(optGraph,
1132  backends,
1133  tensorHandleFactoryRegistry,
1134  options.m_ImportEnabled,
1135  messages);
1136  if (strategyResult.m_Error)
1137  {
1138  // Failed to apply the backend-specific optimizations
1139  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
1140  }
1141 
1142  // Based on the tensor handle strategy determined above, insert copy layers where required.
1143  optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
1144 
1145  // Convert constants
1146  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
1147  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsHalfToFloat()));
1148 
1149  // Run backend specific optimizations (deprecated)
1150  for (auto&& chosenBackend : backendSettings.m_SelectedBackends)
1151  {
1152  auto factoryFun = BackendRegistryInstance().GetFactory(chosenBackend);
1153  auto backendPtr = factoryFun();
1154  ARMNN_ASSERT(backendPtr.get() != nullptr);
1155 
1157  auto backendSpecificOptimizations = backendPtr->GetOptimizations();
1159 
1160  if (!backendSpecificOptimizations.empty())
1161  {
1162  Optimizer::Pass(optNetObjPtr->GetGraph(), backendSpecificOptimizations);
1163  }
1164  }
1165 
1166  return optNet;
1167 }
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:72
FactoryFunction GetFactory(const BackendId &id) const
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl< PermuteLayer > > OptimizeInversePermutes
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
OptimizeForConnection< TransposeLayer, TransposeLayer, OptimizeInversePermutesImpl< TransposeLayer > > OptimizeInverseTransposes
OptimizeForConnection< TransposeLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< TransposeLayer > > TransposeAndBatchToSpaceAsDepthToSpace
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoDepthwiseConvolution2DFloat32
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoDepthwiseConvolution2DFloat16
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoConvolution2DFloat16
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoConvolution2DFloat32
BackendRegistry & BackendRegistryInstance()
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
OptimizeForConnection< Layer, TransposeLayer, MoveTransposeUpImpl > MoveTransposeUp
OptimizeForConnection< PadLayer, Convolution2dLayer, FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
Definition: AddDebug.hpp:34
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteLayer > > PermuteAndBatchToSpaceAsDepthToSpace
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
OptimizeForType< TransposeLayer, TransposeAsReshapeImpl > TransposeAsReshape
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:600
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
OptimizeForConnection< Layer, TransposeLayer, SquashEqualSiblingsImpl< TransposeLayer > > SquashEqualTransposeSiblings
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
Definition: Network.cpp:518
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, bool importEnabled, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:943
OptimizationResult ApplyBackendOptimizations(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:537
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:504
OptimizeForType< Layer, ConvertFp32NetworkToBf16Impl > Fp32NetworkToBf16Converter
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:325

◆ Pad()

void Pad ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const PadQueueDescriptor data 
)

Definition at line 39 of file Pad.cpp.

References Decoder< IType >::Get(), TensorShape::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, PadDescriptor::m_PadList, PadDescriptor::m_PadValue, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

42 {
43  auto padList = data.m_Parameters.m_PadList;
44  auto padValue = data.m_Parameters.m_PadValue;
45 
46  unsigned int numOutputElements = outputInfo.GetNumElements();
47 
48  TensorShape outputShape = outputInfo.GetShape();
49  TensorShape inputShape = inputInfo.GetShape();
50 
51  unsigned int numInputDimensions = inputShape.GetNumDimensions();
52 
53 #ifndef NDEBUG
54 
55  unsigned int numOutputDimensions = outputShape.GetNumDimensions();
56  assert(numInputDimensions == numOutputDimensions);
57 
58 #endif
59 
60  unsigned int inputBatches = 0;
61  unsigned int inputChannels = 0;
62  unsigned int inputHeight = 0;
63  unsigned int inputWidth = 0;
64 
65  unsigned int outputChannels = 0;
66  unsigned int outputHeight = 0;
67  unsigned int outputWidth = 0;
68 
69  auto inputData = MakeDecoder<float>(inputInfo, data.m_Inputs[0]->Map());
70  auto outData = MakeEncoder<float>(outputInfo, data.m_Outputs[0]->Map());
71 
72  // Fill the output tensor with Pad value first
73  if (outputInfo.IsQuantized())
74  {
75  // For Quantized types Pad Value should not be quantized with scale and offset of the tensor info
76  auto temporaryInfo = TensorInfo(outputInfo.GetShape(), outputInfo.GetDataType(), 1.0f, 0);
77  auto outputData = MakeEncoder<float>(temporaryInfo, data.m_Outputs[0]->Map());
78  FillOutputWithPadValue(*outputData, padValue, numOutputElements);
79  }
80  else
81  {
82  FillOutputWithPadValue(*outData, padValue, numOutputElements);
83  }
84 
85  Decoder<float>& input = *inputData;
86  Encoder<float>& output = *outData;
87 
88  switch(numInputDimensions) {
89 
90  case 1:
91  inputWidth = inputShape[0];
92  for (unsigned int w = 0; w < inputWidth ; w++)
93  {
94  input[w];
95  auto inputValue = input.Get();
96  auto outputIndex = w + std::get<0>(padList[0]);
97  output[outputIndex];
98  output.Set(inputValue);
99  }
100 
101  break;
102  case 2 :
103  inputHeight = inputShape[0];
104  inputWidth = inputShape[1];
105  outputWidth = outputShape[1];
106 
107  for (unsigned int h = 0; h < inputHeight; h++)
108  {
109  for (unsigned int w = 0; w < inputWidth ; w++)
110  {
111  input[h * inputWidth + w];
112  auto inputValue = input.Get();
113  auto outputIndex = (h + std::get<0>(padList[0])) * outputWidth + (w + std::get<0>(padList[1]));
114  output[outputIndex];
115  output.Set(inputValue);
116  }
117  }
118 
119  break;
120  case 3 :
121  inputChannels = inputShape[0];
122  inputHeight = inputShape[1];
123  inputWidth = inputShape[2];
124  outputHeight = outputShape[1];
125  outputWidth = outputShape[2];
126 
127  for (unsigned int c = 0; c < inputChannels; c++)
128  {
129  for (unsigned int h = 0; h < inputHeight; h++)
130  {
131  for (unsigned int w = 0; w < inputWidth ; w++)
132  {
133  input[c * inputHeight * inputWidth + h * inputWidth + w];
134  auto inputValue = input.Get();
135  auto outputIndex = (c + std::get<0>(padList[0])) * outputHeight * outputWidth
136  + (h + std::get<0>(padList[1])) * outputWidth
137  + (w + std::get<0>(padList[2]));
138  output[outputIndex];
139  output.Set(inputValue);
140  }
141  }
142  }
143 
144  break;
145  case 4 :
146  inputBatches = inputShape[0];
147  inputChannels = inputShape[1];
148  inputHeight = inputShape[2];
149  inputWidth = inputShape[3];
150  outputChannels = outputShape[1];
151  outputHeight = outputShape[2];
152  outputWidth = outputShape[3];
153 
154  for (unsigned int b = 0; b < inputBatches; b++)
155  {
156  for (unsigned int c = 0; c < inputChannels; c++)
157  {
158  for (unsigned int h = 0; h < inputHeight; h++)
159  {
160  for (unsigned int w = 0; w < inputWidth ; w++)
161  {
162  input[b * inputChannels * inputHeight * inputWidth
163  + c * inputHeight * inputWidth
164  + h * inputWidth
165  + w];
166  auto inputValue = input.Get();
167  auto outputIndex = (b + std::get<0>(padList[0]))
168  * outputChannels * outputHeight * outputWidth
169  + (c + std::get<0>(padList[1])) * outputHeight * outputWidth
170  + (h + std::get<0>(padList[2])) * outputWidth
171  + (w + std::get<0>(padList[3]));
172  output[outputIndex];
173  output.Set(inputValue);
174  }
175  }
176  }
177  }
178 
179  break;
180  default :
181  break;
182  }
183 }

◆ ParseBoolean()

bool armnn::ParseBoolean ( const BackendOptions::Var value,
bool  defaultValue 
)

Definition at line 96 of file ClBackendContext.cpp.

References BackendOptions::Var::AsBool(), and BackendOptions::Var::IsBool().

97 {
98  if (value.IsBool())
99  {
100  return value.AsBool();
101  }
102  return defaultValue;
103 }

◆ ParseComputeDevice()

constexpr armnn::Compute armnn::ParseComputeDevice ( const char *  str)

Deprecated function that will be removed together with the Compute enum.

Definition at line 160 of file TypesUtils.hpp.

References CpuAcc, CpuRef, GpuAcc, StrEqual(), and Undefined.

Referenced by operator>>().

161 {
162  if (armnn::StrEqual(str, "CpuAcc"))
163  {
164  return armnn::Compute::CpuAcc;
165  }
166  else if (armnn::StrEqual(str, "CpuRef"))
167  {
168  return armnn::Compute::CpuRef;
169  }
170  else if (armnn::StrEqual(str, "GpuAcc"))
171  {
172  return armnn::Compute::GpuAcc;
173  }
174  else
175  {
177  }
178 }
CPU Execution: Reference C++ kernels.
constexpr bool StrEqual(const char *strA, const char(&strB)[N])
Definition: TypesUtils.hpp:148
GPU Execution: OpenCL: ArmCompute.
CPU Execution: NEON: ArmCompute.

◆ ParseFile()

std::string armnn::ParseFile ( const BackendOptions::Var value,
std::string  defaultValue 
)

Definition at line 105 of file ClBackendContext.cpp.

References BackendOptions::Var::AsString(), and BackendOptions::Var::IsString().

Referenced by ClBackendContext::ClBackendContext().

106 {
107  if (value.IsString())
108  {
109  return value.AsString();
110  }
111  return defaultValue;
112 }

◆ ParseOptions()

void armnn::ParseOptions ( const std::vector< BackendOptions > &  options,
BackendId  backend,
f 
)

Definition at line 269 of file BackendOptions.hpp.

References BackendOptions::BackendOption::GetName(), and BackendOptions::BackendOption::GetValue().

Referenced by ClBackendContext::ClBackendContext(), ClBackendModelContext::ClBackendModelContext(), and NeonBackendModelContext::NeonBackendModelContext().

270 {
271  for (auto optionsGroup : options)
272  {
273  if (optionsGroup.GetBackendId() == backend)
274  {
275  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
276  {
277  const BackendOptions::BackendOption option = optionsGroup.GetOption(i);
278  f(option.GetName(), option.GetValue());
279  }
280  }
281  }
282 }

◆ ParseTuningLevel()

TuningLevel armnn::ParseTuningLevel ( const BackendOptions::Var value,
TuningLevel  defaultValue 
)

Definition at line 78 of file ClBackendContext.cpp.

References ARMNN_LOG, BackendOptions::Var::AsInt(), Exhaustive, BackendOptions::Var::IsInt(), None, and warning.

Referenced by ClBackendContext::ClBackendContext().

79 {
80  if (value.IsInt())
81  {
82  int v = value.AsInt();
83  if (v > static_cast<int>(TuningLevel::Exhaustive) ||
84  v < static_cast<int>(TuningLevel::None))
85  {
86  ARMNN_LOG(warning) << "Invalid GpuAcc tuning level ("<< v << ") selected. "
87  "Using default(" << static_cast<int>(defaultValue) << ")";
88  } else
89  {
90  return static_cast<TuningLevel>(v);
91  }
92  }
93  return defaultValue;
94 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163

◆ PermuteTensor()

armnn::ConstTensor PermuteTensor ( const ConstCpuTensorHandle tensor,
const PermutationVector permutationVector,
void *  permuteBuffer 
)

Definition at line 14 of file WorkloadUtils.cpp.

References ARMNN_ASSERT_MSG, ConstCpuTensorHandle::GetConstTensor(), TensorInfo::GetDataType(), GetDataTypeSize(), TensorInfo::GetNumBytes(), TensorInfo::GetShape(), PermutationVector::GetSize(), ConstCpuTensorHandle::GetTensorInfo(), Permute, and armnnUtils::Permuted().

Referenced by ConvertWeightTensorFromArmnnToAcl(), and GatherTensorHandlePairs().

16 {
17  ARMNN_ASSERT_MSG(tensor, "Invalid input tensor");
18  ARMNN_ASSERT_MSG(permuteBuffer, "Invalid permute buffer");
19 
20  TensorInfo tensorInfo = tensor->GetTensorInfo();
21 
22  if (permutationVector.GetSize() > 0)
23  {
24  tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector);
25  armnnUtils::Permute(tensorInfo.GetShape(), permutationVector,
26  tensor->GetConstTensor<void>(), permuteBuffer,
27  GetDataTypeSize(tensorInfo.GetDataType()));
28  }
29  else
30  {
31  ::memcpy(permuteBuffer, tensor->GetConstTensor<void>(), tensorInfo.GetNumBytes());
32  }
33 
34  return ConstTensor(tensorInfo, permuteBuffer);
35 }
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:126

◆ PolymorphicDowncast()

DestType armnn::PolymorphicDowncast ( SourceType  value)

Polymorphic downcast for build in pointers only.

Usage: Child* pChild = PolymorphicDowncast<Child*>(pBase);

Template Parameters
DestTypePointer type to the target object (Child pointer type)
SourceTypePointer type to the source object (Base pointer type)
Parameters
valuePointer to the source object
Returns
Pointer of type DestType (Pointer of type child)

Definition at line 74 of file PolymorphicDowncast.hpp.

References ARMNN_POLYMORPHIC_CAST_CHECK.

75 {
76  static_assert(std::is_pointer<SourceType>::value &&
77  std::is_pointer<DestType>::value,
78  "PolymorphicDowncast only works with pointer types.");
79 
80  ARMNN_POLYMORPHIC_CAST_CHECK(dynamic_cast<DestType>(value) == static_cast<DestType>(value));
81  return static_cast<DestType>(value);
82 }
#define ARMNN_POLYMORPHIC_CAST_CHECK(cond)

◆ PolymorphicPointerDowncast()

auto armnn::PolymorphicPointerDowncast ( const SourceType &  value)

Polymorphic downcast for shared pointers and build in pointers.

Usage: auto pChild = PolymorphicPointerDowncast<Child>(pBase)

Template Parameters
DestTypeType of the target object (Child type)
SourceTypePointer type to the source object (Base (shared) pointer type)
Parameters
valuePointer to the source object
Returns
Pointer of type DestType ((Shared) pointer of type child)

Definition at line 94 of file PolymorphicDowncast.hpp.

References ARMNN_POLYMORPHIC_CAST_CHECK.

95 {
96  ARMNN_POLYMORPHIC_CAST_CHECK(utility::DynamicPointerCast<DestType>(value)
97  == utility::StaticPointerCast<DestType>(value));
98  return utility::StaticPointerCast<DestType>(value);
99 }
#define ARMNN_POLYMORPHIC_CAST_CHECK(cond)

◆ Pooling2d()

void Pooling2d ( Decoder< float > &  rInputDecoder,
Encoder< float > &  rOutputEncoder,
const TensorInfo inputInfo,
const TensorInfo outputInfo,
const Pooling2dDescriptor params 
)

Computes the Pooling2d operation.

Definition at line 142 of file Pooling2d.cpp.

References Decoder< IType >::DecodeTensor(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetDataLayout(), DataLayoutIndexed::GetHeightIndex(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), Pooling2dDescriptor::m_DataLayout, Pooling2dDescriptor::m_PadBottom, Pooling2dDescriptor::m_PaddingMethod, Pooling2dDescriptor::m_PadLeft, Pooling2dDescriptor::m_PadRight, Pooling2dDescriptor::m_PadTop, Pooling2dDescriptor::m_PoolHeight, Pooling2dDescriptor::m_PoolType, Pooling2dDescriptor::m_PoolWidth, Pooling2dDescriptor::m_StrideX, Pooling2dDescriptor::m_StrideY, NHWC, numeric_cast(), Pooling2d(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE(), Pooling2d(), and Pooling2dLayer::Pooling2dLayer().

147 {
148  const DataLayoutIndexed dataLayout(params.m_DataLayout);
149  auto channelsIndex = dataLayout.GetChannelsIndex();
150  auto heightIndex = dataLayout.GetHeightIndex();
151  auto widthIndex = dataLayout.GetWidthIndex();
152 
153  const int batchSize = armnn::numeric_cast<int>(outputInfo.GetShape()[0]);
154  const int channels = armnn::numeric_cast<int>(outputInfo.GetShape()[channelsIndex]);
155  const int heightOutput = armnn::numeric_cast<int>(outputInfo.GetShape()[heightIndex]);
156  const int widthOutput = armnn::numeric_cast<int>(outputInfo.GetShape()[widthIndex]);
157  const int heightInput = armnn::numeric_cast<int>(inputInfo.GetShape()[heightIndex]);
158  const int widthInput = armnn::numeric_cast<int>(inputInfo.GetShape()[widthIndex]);
159  const int padLeft = armnn::numeric_cast<int>(params.m_PadLeft);
160  const int padRight = armnn::numeric_cast<int>(params.m_PadRight);
161  const int padTop = armnn::numeric_cast<int>(params.m_PadTop);
162  const int padBottom = armnn::numeric_cast<int>(params.m_PadBottom);
163  const int strideX = armnn::numeric_cast<int>(params.m_StrideX);
164  const int strideY = armnn::numeric_cast<int>(params.m_StrideY);
165  const int poolHeight = armnn::numeric_cast<int>(params.m_PoolHeight);
166  const int poolWidth = armnn::numeric_cast<int>(params.m_PoolWidth);
167 
168  float defaultInitializer = DefaultInitializer(params.m_PoolType);
169 
170  Accumulator accumulate = GetAccumulator(params.m_PoolType);
171  Executor execute = GetExecutor(params.m_PoolType);
172 
173  // Check supported padding methods outside the loop to simplify
174  // the inner loop.
175  if (params.m_PaddingMethod != PaddingMethod::Exclude &&
176  params.m_PaddingMethod != PaddingMethod::IgnoreValue)
177  {
178  throw armnn::InvalidArgumentException("Unsupported padding type");
179  }
180 
181  const std::vector<float> decodedInputVec = rInputDecoder.DecodeTensor(inputInfo.GetShape());
182 
183  for (int n = 0; n < batchSize; n++)
184  {
185  for (int c = 0; c < channels; c++)
186  {
187  for (int yOutput = 0; yOutput < heightOutput; yOutput++)
188  {
189  // Calculate values independent of the x axis
190  int hstart = (yOutput * strideY) - padTop;
191  int hend = hstart + poolHeight;
192  // Clamp the pooling region inside the valid input area (which includes the padding).
193  // This is necessary because the final pooling in a row may overlap beyond the padding.
194  hend = std::min(hend, heightInput + padBottom);
195 
196  int height = hend - hstart;
197  bool hclamped = ClampRange(hstart, hend, heightInput);
198 
199  for (int xOutput = 0; xOutput < widthOutput; xOutput++)
200  {
201  int wstart = (xOutput * strideX) - padLeft;
202  int wend = wstart + poolWidth;
203 
204  // Clamp the pooling region inside the valid input area (which includes the padding).
205  // This is necessary because the final pooling in a row may overlap beyond the padding.
206  wend = std::min(wend, widthInput + padRight);
207 
208  float result = defaultInitializer;
209  float poolAreaSize = armnn::numeric_cast<float>(height * (wend - wstart));
210 
211  // Special case: when the pooling kernel is over a padding region and the padding
212  // size is larger or equal to the kernel and the kernel only covers
213  // padding and no real values, then we initialize the result as zero
214  // by convention. This is because we need to choose a value here and
215  // all values we have are padding, which we ignore.
216  if (OnPaddingOnly(hstart, hend, heightInput) ||
217  OnPaddingOnly(wstart, wend, widthInput))
218  {
219  result = 0.0f;
220 
221  int outputIndex;
222 
223  if(dataLayout.GetDataLayout() == DataLayout::NHWC)
224  {
225  outputIndex = n * heightOutput * widthOutput * channels +
226  yOutput * widthOutput * channels +
227  xOutput * channels +
228  c;
229  }
230  else
231  {
232  outputIndex = n * heightOutput * widthOutput * channels +
233  c * heightOutput * widthOutput +
234  yOutput * widthOutput +
235  xOutput;
236  }
237 
238  rOutputEncoder[static_cast<unsigned int>(outputIndex)];
239  rOutputEncoder.Set(result);
240  continue;
241  }
242 
243  bool clamped = hclamped |= ClampRange(wstart, wend, widthInput);
244 
245  if (clamped && params.m_PaddingMethod == PaddingMethod::Exclude)
246  {
247  // When we exclude the padding, it means we calculate with a smaller
248  // kernel size, so I changed the divisor here.
249  poolAreaSize = armnn::numeric_cast<float>((hend - hstart) * (wend - wstart));
250  }
251 
252  for (auto yInput = hstart; yInput < hend; yInput++)
253  {
254  for (auto xInput = wstart; xInput < wend; xInput++)
255  {
256 
257  int inputIndex;
258  if(dataLayout.GetDataLayout() == DataLayout::NHWC)
259  {
260  inputIndex = n * heightInput * widthInput * channels +
261  yInput * widthInput * channels +
262  xInput * channels +
263  c;
264 
265  }
266  else
267  {
268  inputIndex = n * heightInput * widthInput * channels +
269  c * heightInput * widthInput +
270  yInput * widthInput +
271  xInput;
272  }
273 
274  accumulate(result, decodedInputVec[static_cast<unsigned int>(inputIndex)]);
275  }
276  }
277 
278  execute(result, poolAreaSize);
279 
280  int outputIndex;
281 
282  if(dataLayout.GetDataLayout() == DataLayout::NHWC)
283  {
284  outputIndex = n * heightOutput * widthOutput * channels +
285  yOutput * widthOutput * channels +
286  xOutput * channels +
287  c;
288  }
289  else
290  {
291  outputIndex = n * heightOutput * widthOutput * channels +
292  c * heightOutput * widthOutput +
293  yOutput * widthOutput +
294  xOutput;
295  }
296 
297  rOutputEncoder[static_cast<unsigned int>(outputIndex)];
298  rOutputEncoder.Set(result);
299  }
300  }
301  }
302  }
303 }
uint32_t m_PadBottom
Padding bottom value in the height dimension.
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_PoolWidth
Pooling width value.
virtual void Set(IType right)=0
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, const unsigned int channelMultiplier=1, bool isDepthwise=false)=0
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadRight
Padding right value in the width dimension.
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.

◆ PreluImpl()

void PreluImpl ( const PreluQueueDescriptor data,
Decoder< float > &  inputData,
Decoder< float > &  alphaData,
Encoder< float > &  outputData 
)

Definition at line 13 of file PreluImpl.cpp.

References TensorInfo::GetShape(), GetTensorInfo(), QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, and BroadcastLoop::Unroll().

Referenced by RefPreluWorkload::Execute().

17 {
18  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]);
19  const TensorInfo& alphaInfo = GetTensorInfo(data.m_Inputs[1]);
20  const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[0]);
21 
22  const TensorShape& inputShape = inputInfo.GetShape();
23  const TensorShape& alphaShape = alphaInfo.GetShape();
24  const TensorShape& outputShape = outputInfo.GetShape();
25 
26  // PReLU activation: f(x) = alpha * x for x < 0, f(x) = x for x >= 0
27  auto prelu = [](float x, float alpha)
28  {
29  return x < 0 ? alpha * x : x;
30  };
31 
32  BroadcastLoop(inputShape, alphaShape, outputShape).Unroll(prelu, 0, inputData, alphaData, outputData);
33 }
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38

◆ PreserveTypeTestImpl()

void armnn::PreserveTypeTestImpl ( const DataType dataType)

Definition at line 2998 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float16, Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, QAsymmU8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

2999 {
3000  INetworkPtr network = INetwork::Create();
3001 
3002  // Add the layers
3003  IConnectableLayer* input0 = network->AddInputLayer(0);
3004  IConnectableLayer* input1 = network->AddInputLayer(1);
3005  IConnectableLayer* addition = network->AddAdditionLayer();
3006  IConnectableLayer* output = network->AddOutputLayer(2);
3007 
3008  input0->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
3009  input1->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
3010  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
3011 
3012  const TensorShape shape{1U, 2U, 3U};
3013  const TensorInfo info(shape, dataType);
3014  input0->GetOutputSlot(0).SetTensorInfo(info);
3015  input1->GetOutputSlot(0).SetTensorInfo(info);
3016  addition->GetOutputSlot(0).SetTensorInfo(info);
3017 
3018  QuantizerOptions options = dataType == DataType::Float32 ?
3019  QuantizerOptions(DataType::QAsymmU8, true) : QuantizerOptions(dataType, true);
3020 
3021  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get(), options)->ExportNetwork();
3022  TestPreserveType validatorQAsymmU8(options, dataType, shape, shape);
3023  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
3024  validatorQAsymmU8.CheckQuantizeDequantizeLayerVisited(
3025  dataType == DataType::Float32 || dataType == DataType::Float16);
3026 }
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
DataLayout::NCHW DataLayout::NCHW DataLayout::NHWC DataLayout::NHWC true

◆ Quantize() [1/2]

void armnn::Quantize ( uint8_t *  quant,
const float *  dequant,
const TensorInfo info 
)
inline

Definition at line 108 of file RefWorkloadUtils.hpp.

References TensorInfo::GetNumElements(), TensorInfo::GetQuantizationOffset(), and TensorInfo::GetQuantizationScale().

109 {
110  for (size_t i = 0; i < info.GetNumElements(); i++)
111  {
112  quant[i] = armnn::Quantize<uint8_t>(dequant[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
113  }
114 }

◆ Quantize() [2/2]

template int32_t Quantize< int32_t > ( float  value,
float  scale,
int32_t  offset 
)

Quantize a floating point data type into an 8-bit data type.

Explicit specialization of Quantize for int32_t.

Explicit specialization of Quantize for int16_t.

Explicit specialization of Quantize for uint8_t.

Explicit specialization of Quantize for int8_t.

Parameters
value- The value to quantize.
scale- The scale (must be non-zero).
offset- The offset.
Returns
- The quantized value calculated as round(value/scale)+offset.

Definition at line 30 of file TypesUtils.cpp.

References ARMNN_ASSERT.

Referenced by BOOST_AUTO_TEST_CASE().

31 {
32  static_assert(IsQuantizedType<QuantizedType>(), "Not an integer type.");
33  constexpr QuantizedType max = std::numeric_limits<QuantizedType>::max();
34  constexpr QuantizedType min = std::numeric_limits<QuantizedType>::lowest();
35  ARMNN_ASSERT(scale != 0.f);
36  ARMNN_ASSERT(!std::isnan(value));
37 
38  float clampedValue = std::min(std::max(static_cast<float>(round(value/scale) + offset), static_cast<float>(min)),
39  static_cast<float>(max));
40  auto quantizedBits = static_cast<QuantizedType>(clampedValue);
41 
42  return quantizedBits;
43 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ QuantizeConstant()

void armnn::QuantizeConstant ( const srcType *  src,
uint8_t *  dst,
size_t  numElements,
float &  scale,
int &  offset 
)

Definition at line 22 of file NetworkQuantizerUtils.hpp.

References ARMNN_ASSERT, QAsymmU8QuantizationScheme::ComputeScheme(), and CreateQuantizedConst().

Referenced by CreateQuantizedConst().

23 {
24  ARMNN_ASSERT(src);
25  ARMNN_ASSERT(dst);
26 
27  float min = std::numeric_limits<srcType>::max();
28  float max = std::numeric_limits<srcType>::lowest();
29  for (size_t i = 0; i < numElements; ++i)
30  {
31  min = std::min(min, src[i]);
32  max = std::max(max, src[i]);
33  }
34 
35  QAsymmU8QuantizationScheme quantizationScheme;
36  OffsetScalePair qParams = quantizationScheme.ComputeScheme(min, max);
37  scale = qParams.first;
38  offset = qParams.second;
39 
40  for (size_t i = 0; i < numElements; ++i)
41  {
42  dst[i] = armnn::Quantize<uint8_t>(src[i], scale, offset);
43  }
44 }
std::pair< float, int > OffsetScalePair
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ReducedOutputOffset()

unsigned int armnn::ReducedOutputOffset ( const unsigned int  numDims,
const armnn::TensorShape dims,
std::vector< unsigned int > &  index,
const unsigned int  numAxis,
const std::vector< unsigned int > &  axis 
)

Definition at line 39 of file Mean.cpp.

Referenced by Mean().

44 {
45  unsigned int offset = 0;
46  for (unsigned int idx = 0; idx < numDims; ++idx)
47  {
48  bool isAxis = false;
49  if (!axis.empty())
50  {
51  for (unsigned int axisIdx = 0; axisIdx < numAxis; ++axisIdx)
52  {
53  if (idx == axis[axisIdx])
54  {
55  isAxis = true;
56  break;
57  }
58  }
59  }
60  if (!isAxis)
61  {
62  offset = offset * dims[idx] + index[idx];
63  }
64  }
65  return offset;
66 }

◆ RefBackendId()

constexpr const char* armnn::RefBackendId ( )

Definition at line 10 of file RefBackendId.hpp.

Referenced by RefBackend::GetIdStatic().

10 { return "CpuRef"; }

◆ RefTensorHandleFactoryId()

constexpr const char* armnn::RefTensorHandleFactoryId ( )

Definition at line 15 of file RefTensorHandleFactory.hpp.

Referenced by RefTensorHandleFactory::GetIdStatic().

15 { return "Arm/Ref/TensorHandleFactory"; }

◆ ReorderWeightChannelsForAcl()

ConstTensor armnn::ReorderWeightChannelsForAcl ( const ConstTensor weightHandle,
DataLayout  dataLayout,
void *  permuteBuffer 
)

Definition at line 63 of file WorkloadUtils.cpp.

References BaseTensor< MemoryType >::GetInfo(), TensorInfo::GetNumBytes(), BaseTensor< MemoryType >::GetShape(), NCHW, and NHWC.

64 {
65  DataType* weight = static_cast<DataType*>(permuteBuffer);
66  const TensorShape& weightShape = weightHandle.GetShape();
67  unsigned int multiplier;
68  unsigned int height;
69  unsigned int width;
70  unsigned int inputChannels;
71  switch (dataLayout)
72  {
73  case DataLayout::NHWC: //It actually is [ H, W, I, M ]
74  height = weightShape[0];
75  width = weightShape[1];
76  inputChannels = weightShape[2];
77  multiplier = weightShape[3];
78  break;
79  case DataLayout::NCHW: //It actually is [ M, I, H, W ]
80  default:
81  height = weightShape[2];
82  width = weightShape[3];
83  inputChannels = weightShape[1];
84  multiplier = weightShape[0];
85  break;
86  }
87 
88  std::vector<DataType> weightAclOrder(height*width*inputChannels*multiplier);
89  unsigned int destinationWeightsChannel;
90  unsigned int totalChannels = inputChannels * multiplier;
91  unsigned int channelSize = height * width;
92  unsigned int inputChannel = 0;
93 
94  for (unsigned int originWeightsChannel = 0; originWeightsChannel < totalChannels; originWeightsChannel++)
95  {
96  inputChannel = originWeightsChannel % inputChannels;
97  destinationWeightsChannel = (originWeightsChannel - inputChannel) / inputChannels + multiplier * inputChannel;
98 
99  for (unsigned int i = 0; i < channelSize; i++)
100  {
101  weightAclOrder[i + destinationWeightsChannel * channelSize] =
102  weight[i + originWeightsChannel * channelSize];
103  }
104  }
105 
106  ::memcpy(permuteBuffer, weightAclOrder.data(), weightHandle.GetInfo().GetNumBytes());
107  return ConstTensor(weightHandle.GetInfo(), permuteBuffer);
108 }
DataType
Definition: Types.hpp:32

◆ ReportError()

void armnn::ReportError ( const std::string &  errorMessage,
Optional< std::vector< std::string > &>  errorMessages 
)

Definition at line 72 of file Network.cpp.

References ARMNN_LOG, and warning.

Referenced by AssignBackends(), CheckScaleSetOnQuantizedType(), Optimize(), and ReturnWithError().

74 {
75  std::stringstream fullErrorMessage;
76  fullErrorMessage << "ERROR: " << errorMessage;
77  ARMNN_LOG(warning) << fullErrorMessage.str();
78  if (errorMessages)
79  {
80  errorMessages.value().push_back(fullErrorMessage.str());
81  }
82 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163

◆ ReportUntouchedLayers()

void armnn::ReportUntouchedLayers ( OptimizationViews optimizationViews,
std::map< LayerGuid, Layer *>  untouched 
)
inline

Definition at line 50 of file ArmComputeSubgraphUtils.hpp.

References OptimizationViews::AddUntouchedSubgraph(), CreateInputsFrom(), and CreateOutputsFrom().

Referenced by NeonBackend::OptimizeSubgraphView(), and ClBackend::OptimizeSubgraphView().

51 {
52  std::vector<Layer*> untouchedVector;
53  for (const auto& pair : untouched)
54  {
55  Layer* layer = pair.second;
56  SubgraphView subgraphView(CreateInputsFrom({layer}),
57  CreateOutputsFrom({layer}),
58  {layer});
59  optimizationViews.AddUntouchedSubgraph(std::move(subgraphView));
60  }
61 }
SubgraphView::InputSlots CreateInputsFrom(const std::vector< Layer *> &layers)
SubgraphView::OutputSlots CreateOutputsFrom(const std::vector< Layer *> &layers)

◆ ReportWarning()

void armnn::ReportWarning ( const std::string &  warningMessage,
Optional< std::vector< std::string > &>  warningMessages 
)

Definition at line 84 of file Network.cpp.

References ARMNN_LOG, and warning.

Referenced by ApplyBackendOptimizations(), and AttemptBackendAssignment().

86 {
87  std::stringstream fullWarningMessage;
88  fullWarningMessage << "WARNING: " << warningMessage;
89  ARMNN_LOG(warning) << fullWarningMessage.str();
90  if (warningMessages)
91  {
92  warningMessages.value().push_back(fullWarningMessage.str());
93  }
94 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163

◆ RequiresCopy()

bool armnn::RequiresCopy ( ITensorHandleFactory::FactoryId  src,
ITensorHandleFactory::FactoryId  dst,
TensorHandleFactoryRegistry registry 
)

Definition at line 636 of file Network.cpp.

References ITensorHandleFactory::GetExportFlags(), TensorHandleFactoryRegistry::GetFactory(), and ITensorHandleFactory::GetImportFlags().

Referenced by CalculateSlotOption().

639 {
640  if (src != dst)
641  {
642  ITensorHandleFactory* srcFactory = registry.GetFactory(src);
643  ITensorHandleFactory* dstFactory = registry.GetFactory(dst);
644 
645  if (srcFactory && dstFactory &&
646  (srcFactory->GetExportFlags() & dstFactory->GetImportFlags()) != 0)
647  {
648  return false;
649  }
650  return true;
651  }
652  return false;
653 }

◆ ReshapeWeightsForAcl()

void ReshapeWeightsForAcl ( TensorInfo weightInfo,
DataLayout  dataLayout 
)

Definition at line 37 of file WorkloadUtils.cpp.

References TensorInfo::GetShape(), NCHW, NHWC, and TensorInfo::SetShape().

Referenced by ConvertWeightTensorFromArmnnToAcl(), ConvertWeightTensorInfoFromArmnnToAcl(), and GatherTensorHandlePairs().

38 {
39  // Reshape the weights in-place
40  const TensorShape& weightShape = weightInfo.GetShape();
41  switch (dataLayout)
42  {
43  case DataLayout::NHWC:
44  // The data layout is NHWC, reshape from [ H, W, I, M ] to [ 1, H, W, I * M ]
45  weightInfo.SetShape({ 1,
46  weightShape[0],
47  weightShape[1],
48  weightShape[2] * weightShape[3] });
49  weightInfo.SetShape({ 1,
50  weightShape[0] * weightShape[1],
51  weightShape[2],
52  weightShape[3] });
53  break;
54  case DataLayout::NCHW:
55  default:
56  // The data layout is NCHW, reshape from [ M, I, H, W ] to [ 1, I * M, H, W, ]
57  weightInfo.SetShape({ 1, weightShape[0] * weightShape[1], weightShape[2], weightShape[3] });
58  break;
59  }
60 }

◆ Resize()

void Resize ( Decoder< float > &  in,
const TensorInfo inputInfo,
Encoder< float > &  out,
const TensorInfo outputInfo,
DataLayoutIndexed  dataLayout,
armnn::ResizeMethod  resizeMethod,
bool  alignCorners,
bool  halfPixelCenters 
)

Definition at line 65 of file Resize.cpp.

References ARMNN_ASSERT, Bilinear, Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), NearestNeighbor, Resize(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE(), InferenceTestImage::GetSizeInBytes(), Resize(), and ResizeLayer::ResizeLayer().

73 {
74  // alignCorners and halfPixelCenters cannot both be true
75  ARMNN_ASSERT(!(alignCorners && halfPixelCenters));
76 
77  // We follow the definition of TensorFlow and AndroidNN: the top-left corner of a texel in the output
78  // image is projected into the input image to figure out the interpolants and weights. Note that this
79  // will yield different results than if projecting the centre of output texels.
80 
81  const unsigned int batchSize = inputInfo.GetShape()[0];
82  const unsigned int channelCount = inputInfo.GetShape()[dataLayout.GetChannelsIndex()];
83 
84  const unsigned int inputHeight = inputInfo.GetShape()[dataLayout.GetHeightIndex()];
85  const unsigned int inputWidth = inputInfo.GetShape()[dataLayout.GetWidthIndex()];
86  const unsigned int outputHeight = outputInfo.GetShape()[dataLayout.GetHeightIndex()];
87  const unsigned int outputWidth = outputInfo.GetShape()[dataLayout.GetWidthIndex()];
88 
89  // How much to scale pixel coordinates in the output image, to get the corresponding pixel coordinates
90  // in the input image.
91  const float scaleY = CalculateResizeScale(inputHeight, outputHeight, alignCorners);
92  const float scaleX = CalculateResizeScale(inputWidth, outputWidth, alignCorners);
93 
94  TensorShape inputShape = inputInfo.GetShape();
95  TensorShape outputShape = outputInfo.GetShape();
96 
97  for (unsigned int n = 0; n < batchSize; ++n)
98  {
99  for (unsigned int c = 0; c < channelCount; ++c)
100  {
101  for (unsigned int y = 0; y < outputHeight; ++y)
102  {
103  // Corresponding real-valued height coordinate in input image.
104  float iy = PixelScaler(y, scaleY, halfPixelCenters, resizeMethod);
105 
106  // Discrete height coordinate of top-left texel (in the 2x2 texel area used for interpolation).
107  const float fiy = (resizeMethod == armnn::ResizeMethod::NearestNeighbor && alignCorners) ?
108  roundf(iy) : floorf(iy);
109  // Pixel scaling a value with Half Pixel Centers can be negative, if so set to 0
110  const unsigned int y0 = static_cast<unsigned int>(std::max(fiy, 0.0f));
111 
112  // Interpolation weight (range [0,1]).
113  const float yw = iy - fiy;
114 
115  for (unsigned int x = 0; x < outputWidth; ++x)
116  {
117  // Real-valued and discrete width coordinates in input image.
118  float ix = PixelScaler(x, scaleX, halfPixelCenters, resizeMethod);
119 
120  // Nearest Neighbour uses rounding to align to corners
121  const float fix = resizeMethod == armnn::ResizeMethod::NearestNeighbor && alignCorners ?
122  roundf(ix) : floorf(ix);
123  // Pixel scaling a value with Half Pixel Centers can be negative, if so set to 0
124  const unsigned int x0 = static_cast<unsigned int>(std::max(fix, 0.0f));
125 
126  // Interpolation weight (range [0,1]).
127  const float xw = ix - fix;
128 
129  unsigned int x1;
130  unsigned int y1;
131  // Half Pixel Centers uses the scaling to compute a weighted parameter for nearby pixels
132  if (halfPixelCenters)
133  {
134  x1 = std::min(static_cast<unsigned int>(std::ceil(ix)), inputWidth - 1u);
135  y1 = std::min(static_cast<unsigned int>(std::ceil(iy)), inputHeight - 1u);
136  }
137  // Discrete width/height coordinates of texels below and to the right of (x0, y0).
138  else
139  {
140  x1 = std::min(x0 + 1, inputWidth - 1u);
141  y1 = std::min(y0 + 1, inputHeight - 1u);
142  }
143 
144  float interpolatedValue;
145  switch (resizeMethod)
146  {
148  {
149  in[dataLayout.GetIndex(inputShape, n, c, y0, x0)];
150  float input1 = in.Get();
151  in[dataLayout.GetIndex(inputShape, n, c, y0, x1)];
152  float input2 = in.Get();
153  in[dataLayout.GetIndex(inputShape, n, c, y1, x0)];
154  float input3 = in.Get();
155  in[dataLayout.GetIndex(inputShape, n, c, y1, x1)];
156  float input4 = in.Get();
157 
158  const float ly0 = Lerp(input1, input2, xw); // lerp along row y0.
159  const float ly1 = Lerp(input3, input4, xw); // lerp along row y1.
160  interpolatedValue = Lerp(ly0, ly1, yw);
161  break;
162  }
164  {
165  // calculate euclidean distance to the 4 neighbours
166  auto distance00 = EuclideanDistance(fix, fiy, x0, y0);
167  auto distance01 = EuclideanDistance(fix, fiy, x0, y1);
168  auto distance10 = EuclideanDistance(fix, fiy, x1, y0);
169  auto distance11 = EuclideanDistance(fix, fiy, x1, y1);
170 
171  auto minimum = std::min( { distance00, distance01, distance10, distance11 } );
172 
173  unsigned int xNearest = 0;
174  unsigned int yNearest = 0;
175 
176  if (minimum == distance00)
177  {
178  xNearest = x0;
179  yNearest = y0;
180  }
181  else if (minimum == distance01)
182  {
183  xNearest = x0;
184  yNearest = y1;
185  }
186  else if (minimum == distance10)
187  {
188  xNearest = x1;
189  yNearest = y0;
190  }
191  else if (minimum == distance11)
192  {
193  xNearest = x1;
194  yNearest = y1;
195  }
196  else
197  {
198  throw armnn::InvalidArgumentException("Resize Nearest Neighbor failure");
199  }
200 
201  in[dataLayout.GetIndex(inputShape, n, c, yNearest, xNearest)];
202  interpolatedValue = in.Get();
203  break;
204  }
205  default:
206  throw armnn::InvalidArgumentException("Unknown resize method: " +
207  std::to_string(static_cast<int>(resizeMethod)));
208  }
209  out[dataLayout.GetIndex(outputShape, n, c, y, x)];
210  out.Set(interpolatedValue);
211  }
212  }
213  }
214  }
215 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
virtual void Set(IType right)=0
unsigned int GetHeightIndex() const
virtual IType Get() const =0
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetChannelsIndex() const

◆ ReturnWithError()

OptimizationResult armnn::ReturnWithError ( OptimizationResult  res,
const Layer layer,
const BackendSettings backendSettings,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 96 of file Network.cpp.

References GetLayerTypeAsCString(), Layer::GetType(), OptimizationResult::m_Error, BackendSettings::m_PreferredBackends, and ReportError().

Referenced by AssignBackends(), and AttemptBackendAssignment().

100 {
101  std::stringstream failureMsg;
102  failureMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
103  << " is not supported on any preferred backend " << backendSettings.m_PreferredBackends;
104  ReportError(failureMsg.str(), errMessages);
105 
106  res.m_Error = true;
107  return res;
108 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:72
char const * GetLayerTypeAsCString(LayerType type)

◆ RunClFunction()

void armnn::RunClFunction ( arm_compute::IFunction &  function,
const CheckLocation location 
)
inline

Definition at line 134 of file ClWorkloadUtils.hpp.

References Error, error, and WrapClError().

Referenced by ClFillWorkload::Execute(), ClPadWorkload::Execute(), ClConvertFp16ToFp32Workload::Execute(), ClConvertFp32ToFp16Workload::Execute(), ClSubtractionWorkload::Execute(), ClAdditionWorkload::Execute(), ClQuantizeWorkload::Execute(), ClActivationWorkload::Execute(), ClRsqrtWorkload::Execute(), ClLstmFloatWorkload::Execute(), ClNegWorkload::Execute(), ClAbsWorkload::Execute(), ClExpWorkload::Execute(), ClPreluWorkload::Execute(), ClFloorFloatWorkload::Execute(), ClReshapeWorkload::Execute(), ClResizeWorkload::Execute(), ClGatherWorkload::Execute(), ClInstanceNormalizationWorkload::Execute(), ClSpaceToDepthWorkload::Execute(), ClMaximumWorkload::Execute(), ClMinimumWorkload::Execute(), ClBatchToSpaceNdWorkload::Execute(), ClNormalizationFloatWorkload::Execute(), ClArgMinMaxWorkload::Execute(), ClSliceWorkload::Execute(), ClL2NormalizationFloatWorkload::Execute(), ClComparisonWorkload::Execute(), ClDepthToSpaceWorkload::Execute(), ClStridedSliceWorkload::Execute(), ClSpaceToBatchNdWorkload::Execute(), ClQuantizedLstmWorkload::Execute(), ClMultiplicationWorkload::Execute(), ClDivisionFloatWorkload::Execute(), ClPooling2dWorkload::Execute(), ClSoftmaxWorkload::Execute(), ClLogSoftmaxWorkload::Execute(), ClBatchNormalizationFloatWorkload::Execute(), ClDepthwiseConvolutionWorkload::Execute(), ClTransposeWorkload::Execute(), ClPermuteWorkload::Execute(), ClFullyConnectedWorkload::Execute(), ClTransposeConvolution2dWorkload::Execute(), and ClConvolution2dWorkload::Execute().

135 {
136  try
137  {
138  function.run();
139  }
140  catch (cl::Error& error)
141  {
142  throw WrapClError(error, location);
143  }
144 }
RuntimeException WrapClError(const cl::Error &clError, const CheckLocation &location)

◆ RuntimeLoadedNetworksReserve()

void RuntimeLoadedNetworksReserve ( armnn::Runtime runtime)

Definition at line 30 of file RuntimeTests.cpp.

References BOOST_AUTO_TEST_SUITE().

Referenced by BOOST_AUTO_TEST_CASE().

31 {
32  runtime->m_LoadedNetworks.reserve(1);
33 }

◆ SelectTensorHandleStrategy()

OptimizationResult SelectTensorHandleStrategy ( Graph optGraph,
BackendsMap backends,
TensorHandleFactoryRegistry registry,
bool  importEnabled,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 943 of file Network.cpp.

References ARMNN_ASSERT, CalculateEdgeStrategy(), CalculateSlotOption(), CalculateSlotOptionForInput(), CalculateSlotOptionForOutput(), Graph::ForEachLayer(), Layer::GetBackendId(), OutputSlot::GetConnections(), Layer::GetNumOutputSlots(), Layer::GetOutputSlot(), Layer::GetType(), Input, ITensorHandleFactory::LegacyFactoryId, OptimizationResult::m_Error, Output, OutputSlot::SetEdgeStrategy(), OutputSlot::SetTensorHandleFactory(), and Undefined.

Referenced by BOOST_AUTO_TEST_CASE(), and Optimize().

948 {
949  OptimizationResult result;
950 
951  optGraph.ForEachLayer([&backends, &registry, &result, &errMessages, importEnabled](Layer* layer)
952  {
953  ARMNN_ASSERT(layer);
954 
955  // Lets make sure the backend is in our list of supported backends. Something went wrong during backend
956  // assignment if this check fails
957  ARMNN_ASSERT(backends.find(layer->GetBackendId()) != backends.end());
958 
959  // Check each output separately
960  for (unsigned int slotIdx = 0; slotIdx < layer->GetNumOutputSlots(); slotIdx++)
961  {
962  OutputSlot& outputSlot = layer->GetOutputSlot(slotIdx);
963 
964  ITensorHandleFactory::FactoryId slotOption = ITensorHandleFactory::LegacyFactoryId;
965 
966  // Calculate the factory to use which results in the fewest copies being made.
967  switch(layer->GetType())
968  {
969  case LayerType::Input:
970  slotOption = CalculateSlotOptionForInput(backends, outputSlot, registry);
971  break;
972  case LayerType::Output:
973  slotOption = CalculateSlotOptionForOutput(backends, outputSlot, registry);
974  break;
975  default:
976  slotOption = CalculateSlotOption(backends, outputSlot, registry);
977  break;
978  }
979  outputSlot.SetTensorHandleFactory(slotOption);
980 
981  // Now determine the "best" edge strategy for each connection given the slotOption.
982  unsigned int connectionIdx = 0;
983  for (auto&& connection : outputSlot.GetConnections())
984  {
985  const Layer& connectedLayer = connection->GetOwningLayer();
986 
987  EdgeStrategy strategy = CalculateEdgeStrategy(backends, slotOption, *layer, connectedLayer,
988  registry, importEnabled);
989 
990  if (strategy == EdgeStrategy::Undefined)
991  {
992  result.m_Error = true;
993  if (errMessages)
994  {
995  errMessages.value().emplace_back("Could not find valid strategy required for compatibility"
996  " between backends.");
997  }
998  return;
999  }
1000 
1001  outputSlot.SetEdgeStrategy(connectionIdx, strategy);
1002 
1003  connectionIdx++;
1004  }
1005  }
1006  });
1007 
1008  return result;
1009 }
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:748
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:738
ITensorHandleFactory::FactoryId FactoryId
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:656
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry &registry, bool importEnabled)
Definition: Network.cpp:857

◆ SetAllLoggingSinks()

void SetAllLoggingSinks ( bool  standardOut,
bool  debugOut,
bool  coloured 
)

Definition at line 142 of file Logging.cpp.

Referenced by SimpleLogger< Level >::AddSink(), BOOST_AUTO_TEST_CASE(), ConfigureLogging(), and main().

143 {
144  SetLoggingSinks<LogSeverity::Trace>(standardOut, debugOut, coloured);
145  SetLoggingSinks<LogSeverity::Debug>(standardOut, debugOut, coloured);
146  SetLoggingSinks<LogSeverity::Info>(standardOut, debugOut, coloured);
147  SetLoggingSinks<LogSeverity::Warning>(standardOut, debugOut, coloured);
148  SetLoggingSinks<LogSeverity::Error>(standardOut, debugOut, coloured);
149  SetLoggingSinks<LogSeverity::Fatal>(standardOut, debugOut, coloured);
150 }

◆ SetClSliceData()

auto armnn::SetClSliceData ( const std::vector< unsigned int > &  m_begin,
const std::vector< unsigned int > &  m_size 
)
inline

Definition at line 66 of file ClWorkloadUtils.hpp.

Referenced by ClSliceWorkload::ClSliceWorkload().

68 {
69  // This function must translate the size vector given to an end vector
70  // expected by the ACL NESlice workload
73 
74  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
75 
76  // For strided slices, we have the relationship size = (end - begin) / stride
77  // For slice, we assume stride to be a vector of all ones, yielding the formula
78  // size = (end - begin) therefore we know end = size + begin
79  for (unsigned int i = 0; i < num_dims; i++)
80  {
81  unsigned int revertedIndex = num_dims - i - 1;
82 
83  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
84  ends.set(i, static_cast<int>(m_begin[revertedIndex] + m_size[revertedIndex]));
85  }
86 
87  return std::make_tuple(starts, ends);
88 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetClStridedSliceData()

auto armnn::SetClStridedSliceData ( const std::vector< int > &  m_begin,
const std::vector< int > &  m_end,
const std::vector< int > &  m_stride 
)
inline

Definition at line 45 of file ClWorkloadUtils.hpp.

Referenced by ClStridedSliceWorkload::ClStridedSliceWorkload().

48 {
52 
53  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
54 
55  for (unsigned int i = 0; i < num_dims; i++) {
56  unsigned int revertedIndex = num_dims - i - 1;
57 
58  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
59  ends.set(i, static_cast<int>(m_end[revertedIndex]));
60  strides.set(i, static_cast<int>(m_stride[revertedIndex]));
61  }
62 
63  return std::make_tuple(starts, ends, strides);
64 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetLogFilter()

void SetLogFilter ( LogSeverity  level)

Definition at line 24 of file Logging.cpp.

References ARMNN_ASSERT, ARMNN_FALLTHROUGH, Debug, SimpleLogger< Level >::Enable(), Error, Fatal, SimpleLogger< Level >::Get(), IgnoreUnused(), Info, Trace, and Warning.

Referenced by SimpleLogger< Level >::AddSink(), BOOST_AUTO_TEST_CASE(), ConfigureLogging(), and main().

25 {
26  SimpleLogger<LogSeverity::Trace>::Get().Enable(false);
27  SimpleLogger<LogSeverity::Debug>::Get().Enable(false);
28  SimpleLogger<LogSeverity::Info>::Get().Enable(false);
29  SimpleLogger<LogSeverity::Warning>::Get().Enable(false);
30  SimpleLogger<LogSeverity::Error>::Get().Enable(false);
31  SimpleLogger<LogSeverity::Fatal>::Get().Enable(false);
32  switch (level)
33  {
34  case LogSeverity::Trace:
35  SimpleLogger<LogSeverity::Trace>::Get().Enable(true);
37  case LogSeverity::Debug:
38  SimpleLogger<LogSeverity::Debug>::Get().Enable(true);
40  case LogSeverity::Info:
41  SimpleLogger<LogSeverity::Info>::Get().Enable(true);
43  case LogSeverity::Warning:
44  SimpleLogger<LogSeverity::Warning>::Get().Enable(true);
46  case LogSeverity::Error:
47  SimpleLogger<LogSeverity::Error>::Get().Enable(true);
49  case LogSeverity::Fatal:
50  SimpleLogger<LogSeverity::Fatal>::Get().Enable(true);
51  break;
52  default:
53  ARMNN_ASSERT(false);
54  }
55 }
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:18
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ SetLoggingSinks()

void armnn::SetLoggingSinks ( bool  standardOut,
bool  debugOut,
bool  coloured 
)
inline

Definition at line 118 of file Logging.cpp.

References SimpleLogger< Level >::AddSink(), SimpleLogger< Level >::Get(), and SimpleLogger< Level >::RemoveAllSinks().

119 {
120  SimpleLogger<Level>::Get().RemoveAllSinks();
121 
122  if (standardOut)
123  {
124  if (coloured)
125  {
126  SimpleLogger<Level>::Get().AddSink(
127  std::make_shared<StandardOutputColourSink>(Level));
128  } else
129  {
130  SimpleLogger<Level>::Get().AddSink(
131  std::make_shared<StandardOutputSink>());
132  }
133  }
134 
135  if (debugOut)
136  {
137  SimpleLogger<Level>::Get().AddSink(
138  std::make_shared<DebugOutputSink>());
139  }
140 }

◆ SetNeonSliceData()

auto armnn::SetNeonSliceData ( const std::vector< unsigned int > &  m_begin,
const std::vector< unsigned int > &  m_size 
)
inline

Definition at line 92 of file NeonWorkloadUtils.hpp.

Referenced by NeonSliceWorkload::NeonSliceWorkload().

94 {
95  // This function must translate the size vector given to an end vector
96  // expected by the ACL NESlice workload
99 
100  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
101 
102  // For strided slices, we have the relationship size = (end - begin) / stride
103  // For slice, we assume stride to be a vector of all ones, yielding the formula
104  // size = (end - begin) therefore we know end = size + begin
105  for (unsigned int i = 0; i < num_dims; i++)
106  {
107  unsigned int revertedIndex = num_dims - i - 1;
108 
109  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
110  ends.set(i, static_cast<int>(m_begin[revertedIndex] + m_size[revertedIndex]));
111  }
112 
113  return std::make_tuple(starts, ends);
114 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetNeonStridedSliceData()

auto armnn::SetNeonStridedSliceData ( const std::vector< int > &  m_begin,
const std::vector< int > &  m_end,
const std::vector< int > &  m_stride 
)
inline

Definition at line 70 of file NeonWorkloadUtils.hpp.

Referenced by NeonStridedSliceWorkload::NeonStridedSliceWorkload().

73 {
77 
78  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
79 
80  for (unsigned int i = 0; i < num_dims; i++)
81  {
82  unsigned int revertedIndex = num_dims - i - 1;
83 
84  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
85  ends.set(i, static_cast<int>(m_end[revertedIndex]));
86  strides.set(i, static_cast<int>(m_stride[revertedIndex]));
87  }
88 
89  return std::make_tuple(starts, ends, strides);
90 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetupQuantize()

std::vector<uint8_t> armnn::SetupQuantize ( float  value)

Definition at line 2908 of file QuantizerTest.cpp.

References Float32, and TensorInfo::SetQuantizationScale().

Referenced by BOOST_AUTO_TEST_CASE().

2909 {
2910  armnn::TensorInfo inputInfo({ 1, 2, 2 }, armnn::DataType::Float32);
2911  inputInfo.SetQuantizationScale(1.0f);
2912  inputInfo.SetQuantizationOffset(1);
2913  std::vector<float> input({ value, 0.0f, 0.0f, 1.0f });
2914  const std::vector<float> &inputRef = input;
2915 
2916  auto output = armnnUtils::QuantizedVector<uint8_t>(inputRef,
2917  inputInfo.GetQuantizationScale(),
2918  inputInfo.GetQuantizationOffset());
2919 
2920  return output;
2921 }
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:464

◆ SetValueChecked()

◆ Slice()

void Slice ( const TensorInfo inputInfo,
const SliceDescriptor descriptor,
const void *  inputData,
void *  outputData,
unsigned int  dataTypeSize 
)

Definition at line 14 of file Slice.cpp.

References ARMNN_ASSERT, TensorShape::GetNumDimensions(), TensorInfo::GetShape(), IgnoreUnused(), SliceDescriptor::m_Begin, and SliceDescriptor::m_Size.

Referenced by BOOST_AUTO_TEST_CASE().

19 {
20  const TensorShape& inputShape = inputInfo.GetShape();
21  const unsigned int numDims = inputShape.GetNumDimensions();
22 
23  ARMNN_ASSERT(descriptor.m_Begin.size() == numDims);
24  ARMNN_ASSERT(descriptor.m_Size.size() == numDims);
25 
26  constexpr unsigned int maxNumDims = 4;
27  ARMNN_ASSERT(numDims <= maxNumDims);
28 
29  std::vector<unsigned int> paddedInput(4);
30  std::vector<unsigned int> paddedBegin(4);
31  std::vector<unsigned int> paddedSize (4);
32 
33  const unsigned int numPaddingDims = maxNumDims - numDims;
34  for (unsigned int i = 0u; i < maxNumDims; ++i)
35  {
36  if (i < numPaddingDims)
37  {
38  paddedInput[i] = 1u;
39  paddedBegin[i] = 0u;
40  paddedSize[i] = 1u;
41  }
42  else
43  {
44  const unsigned int j = i - numPaddingDims;
45  paddedInput[i] = inputShape[j];
46  paddedBegin[i] = descriptor.m_Begin[j];
47  paddedSize[i] = descriptor.m_Size[j];
48  }
49  }
50 
51  unsigned int dim0 = paddedInput[0];
52  unsigned int dim1 = paddedInput[1];
53  unsigned int dim2 = paddedInput[2];
54  unsigned int dim3 = paddedInput[3];
55 
56  unsigned int begin0 = paddedBegin[0];
57  unsigned int begin1 = paddedBegin[1];
58  unsigned int begin2 = paddedBegin[2];
59  unsigned int begin3 = paddedBegin[3];
60 
61  unsigned int size0 = paddedSize[0];
62  unsigned int size1 = paddedSize[1];
63  unsigned int size2 = paddedSize[2];
64  unsigned int size3 = paddedSize[3];
65 
66  ARMNN_ASSERT(begin0 + size0 <= dim0);
67  ARMNN_ASSERT(begin1 + size1 <= dim1);
68  ARMNN_ASSERT(begin2 + size2 <= dim2);
69  ARMNN_ASSERT(begin3 + size3 <= dim3);
70 
71  const unsigned char* input = reinterpret_cast<const unsigned char*>(inputData);
72  unsigned char* output = reinterpret_cast<unsigned char*>(outputData);
73 
74  IgnoreUnused(dim0);
75  for (unsigned int idx0 = begin0; idx0 < begin0 + size0; ++idx0)
76  {
77  for (unsigned int idx1 = begin1; idx1 < begin1 + size1; ++idx1)
78  {
79  for (unsigned int idx2 = begin2; idx2 < begin2 + size2; ++idx2)
80  {
81  for (unsigned int idx3 = begin3; idx3 < begin3 + size3; ++idx3)
82  {
83  const unsigned int inputOffset =
84  (((idx0 * dim1 + idx1) * dim2 + idx2) * dim3 + idx3) * dataTypeSize;
85 
86  ::memcpy(output, input + inputOffset, dataTypeSize);
87  output += dataTypeSize;
88  }
89  }
90  }
91  }
92 }
void IgnoreUnused(Ts &&...)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ Softmax()

void Softmax ( Decoder< float > &  in,
Encoder< float > &  out,
const TensorInfo inputTensorInfo,
float  beta,
int  axis 
)

Computes the softmax function on some inputs, into outputs, with a shape given by tensorInfo.

Definition at line 17 of file Softmax.cpp.

References ARMNN_ASSERT_MSG, Decoder< IType >::Get(), TensorShape::GetNumDimensions(), TensorInfo::GetNumDimensions(), armnnUtils::GetNumElementsBetween(), TensorInfo::GetShape(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

18 {
19  ARMNN_ASSERT_MSG(axis < static_cast<int>(inputTensorInfo.GetNumDimensions()),
20  "Required axis index greater than number of dimensions.");
21  ARMNN_ASSERT_MSG(axis >= -static_cast<int>(inputTensorInfo.GetNumDimensions()),
22  "Required axis index lower than negative of the number of dimensions");
23 
24  unsigned int uAxis = axis < 0 ?
25  inputTensorInfo.GetNumDimensions() - static_cast<unsigned int>(abs(axis))
26  : static_cast<unsigned int>(axis);
27 
28  const TensorShape& inputShape = inputTensorInfo.GetShape();
29  const unsigned int outerSize = armnnUtils::GetNumElementsBetween(inputShape, 0, uAxis);
30  const unsigned int axisSize = inputShape[uAxis];
31  const unsigned int innerSize = armnnUtils::GetNumElementsBetween(inputShape,
32  uAxis + 1,
33  inputShape.GetNumDimensions());
34 
35  for (unsigned int outer = 0; outer < outerSize; ++outer)
36  {
37  unsigned int inputBeginIdx = outer * axisSize * innerSize;
38  unsigned int inputEndIdx = inputBeginIdx + axisSize * innerSize;
39  unsigned int outputBeginIdx = outer * axisSize * innerSize;
40 
41  for (unsigned int inner = 0; inner < innerSize; ++inner, ++inputBeginIdx, ++inputEndIdx, ++outputBeginIdx)
42  {
43  // Find max
44  float maxValue = std::numeric_limits<float>::lowest();
45  for (unsigned int iter = inputBeginIdx; iter < inputEndIdx; iter += innerSize)
46  {
47  in[iter];
48  maxValue = std::max(maxValue, in.Get());
49  }
50 
51  // Compute sum
52  float sum = 0.0f;
53  for (unsigned int iter = inputBeginIdx; iter < inputEndIdx; iter += innerSize)
54  {
55  in[iter];
56  sum += std::exp((in.Get() - maxValue) * beta);
57  }
58 
59  // Compute result
60  unsigned int outputIter = outputBeginIdx;
61  out[outputIter];
62  for (unsigned int iter = inputBeginIdx; iter < inputEndIdx; iter += innerSize, outputIter += innerSize)
63  {
64  out[outputIter];
65  in[iter];
66  out.Set(std::exp((in.Get() - maxValue) * beta) / sum);
67  }
68  }
69  }
70 }
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
virtual void Set(IType right)=0
virtual IType Get() const =0
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ SpaceToBatchNd()

void SpaceToBatchNd ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const SpaceToBatchNdDescriptor params,
Decoder< float > &  inputData,
Encoder< float > &  outputData 
)

Definition at line 34 of file SpaceToBatchNd.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), GetOffset(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), SpaceToBatchNdDescriptor::m_BlockShape, SpaceToBatchNdDescriptor::m_DataLayout, SpaceToBatchNdDescriptor::m_PadList, Encoder< IType >::Set(), and SpaceToBatchNd().

Referenced by BOOST_AUTO_TEST_CASE(), SpaceToBatchNd(), and SpaceToBatchNdLayer::SpaceToBatchNdLayer().

39 {
40  DataLayoutIndexed dataLayout = params.m_DataLayout;
41 
42  const TensorShape& inputShape = inputInfo.GetShape();
43  const TensorShape& outputShape = outputInfo.GetShape();
44 
45  const unsigned int channels = inputShape[dataLayout.GetChannelsIndex()];
46 
47  const unsigned int inputBatchSize = inputShape[0];
48  const unsigned int inputHeight = inputShape[dataLayout.GetHeightIndex()];
49  const unsigned int inputWidth = inputShape[dataLayout.GetWidthIndex()];
50 
51  const unsigned int outputBatchSize = outputShape[0];
52  const unsigned int outputHeight = outputShape[dataLayout.GetHeightIndex()];
53  const unsigned int outputWidth = outputShape[dataLayout.GetWidthIndex()];
54 
55  const unsigned int blockHeight = params.m_BlockShape[0];
56  const unsigned int blockWidth = params.m_BlockShape[1];
57 
58  const unsigned int paddingTop = params.m_PadList[0].first;
59  const unsigned int paddingLeft = params.m_PadList[1].first;
60 
61  for (unsigned int outB = 0; outB < outputBatchSize; outB++)
62  {
63  unsigned int inB = outB % inputBatchSize;
64 
65  unsigned int shiftW = (outB / inputBatchSize) % blockWidth;
66  unsigned int shiftH = (outB / inputBatchSize) / blockWidth;
67 
68  for (unsigned int outH = 0; outH < outputHeight; outH++)
69  {
70  for (unsigned int outW = 0; outW < outputWidth; outW++)
71  {
72  if (outH * blockHeight + shiftH < paddingTop ||
73  outH * blockHeight + shiftH >= paddingTop + inputHeight ||
74  outW * blockWidth + shiftW < paddingLeft ||
75  outW * blockWidth + shiftW >= paddingLeft + inputWidth)
76  {
77  for (unsigned int c = 0; c < channels; c++)
78  {
79  unsigned int outOffset = GetOffset(outputShape,
80  outB,
81  outH,
82  outW,
83  c,
84  dataLayout);
85  outputData += outOffset;
86  outputData.Set(0);
87  outputData -= outOffset;
88  }
89  }
90  else
91  {
92  for (unsigned int c = 0; c < channels; c++)
93  {
94  unsigned int inOffset = GetOffset(inputShape,
95  inB,
96  (outH * blockHeight + shiftH) - paddingTop,
97  (outW * blockWidth + shiftW) - paddingLeft,
98  c,
99  dataLayout);
100 
101  unsigned int outOffset = GetOffset(outputShape,
102  outB,
103  outH,
104  outW,
105  c,
106  dataLayout);
107 
108  outputData += outOffset;
109  inputData += inOffset;
110  outputData.Set(inputData.Get());
111  inputData -= inOffset;
112  outputData -= outOffset;
113  }
114  }
115  }
116  }
117  }
118 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
virtual void Set(IType right)=0
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
unsigned int GetHeightIndex() const
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
virtual IType Get() const =0
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
std::vector< unsigned int > m_BlockShape
Block shape value.
unsigned int GetChannelsIndex() const

◆ SpaceToDepth()

void SpaceToDepth ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const SpaceToDepthDescriptor params,
Decoder< float > &  inputData,
Encoder< float > &  outputData 
)

Definition at line 36 of file SpaceToDepth.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), GetOffset(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, Encoder< IType >::Set(), and SpaceToDepth().

Referenced by BOOST_AUTO_TEST_CASE(), SpaceToDepth(), and SpaceToDepthLayer::SpaceToDepthLayer().

41 {
42  DataLayoutIndexed dataLayout = params.m_DataLayout;
43 
44  const TensorShape& inputShape = inputInfo.GetShape();
45  const TensorShape& outputShape = outputInfo.GetShape();
46 
47  const unsigned int inputBatchSize = inputShape[0];
48  const unsigned int inputChannels = inputShape[dataLayout.GetChannelsIndex()];
49 
50  const unsigned int outputHeight = outputShape[dataLayout.GetHeightIndex()];
51  const unsigned int outputWidth = outputShape[dataLayout.GetWidthIndex()];
52  const unsigned int outputChannels = outputShape[dataLayout.GetChannelsIndex()];
53 
54  const unsigned int blockSize = params.m_BlockSize;
55 
56  if (blockSize == 0)
57  {
59  "Input shape must be divisible by block size in all spatial dimensions: Block size is"
60  " equal to zero");
61  }
62 
63  for (unsigned int outChannelIndex = 0; outChannelIndex < outputChannels; outChannelIndex++)
64  {
65  unsigned int inChannelIndex = outChannelIndex % inputChannels;
66 
67  unsigned int shiftW = (outChannelIndex / inputChannels) % blockSize;
68  unsigned int shiftH = (outChannelIndex / inputChannels) / blockSize;
69 
70  for (unsigned int outH = 0; outH < outputHeight; outH++)
71  {
72  for (unsigned int outW = 0; outW < outputWidth; outW++)
73  {
74  for (unsigned int inBatchIndex = 0; inBatchIndex < inputBatchSize; inBatchIndex++)
75  {
76  unsigned int inOffset = GetOffset(inputShape,
77  inChannelIndex,
78  (outH * blockSize + shiftH),
79  (outW * blockSize + shiftW),
80  inBatchIndex,
81  dataLayout);
82 
83  unsigned int outOffset = GetOffset(outputShape,
84  outChannelIndex,
85  outH,
86  outW,
87  inBatchIndex,
88  dataLayout);
89 
90  outputData += outOffset;
91  inputData += inOffset;
92  outputData.Set(inputData.Get());
93  inputData -= inOffset;
94  outputData -= outOffset;
95  }
96  }
97  }
98  }
99 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
virtual void Set(IType right)=0
unsigned int GetHeightIndex() const
virtual IType Get() const =0
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int GetChannelsIndex() const

◆ Split()

void Split ( const SplitterQueueDescriptor data)

Definition at line 21 of file Splitter.cpp.

References ARMNN_ASSERT, Encoder< IType >::Get(), TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), GetTensorInfo(), QueueDescriptor::m_Inputs, SplitterQueueDescriptor::ViewOrigin::m_Origin, QueueDescriptor::m_Outputs, SplitterQueueDescriptor::m_ViewOrigins, and MaxNumOfTensorDimensions.

Referenced by RefSplitterWorkload::Execute(), and Splitter().

22 {
23  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]);
24 
25  std::unique_ptr<Decoder<float>> decoderPtr =
26  MakeDecoder<float>(inputInfo, data.m_Inputs[0]->Map());
27  Decoder<float>& decoder = *decoderPtr;
28 
29  for (unsigned int index = 0; index < inputInfo.GetNumElements(); ++index)
30  {
31  unsigned int indices[MaxNumOfTensorDimensions] = { 0 };
32 
33  unsigned int indexRemainder = index;
34  unsigned int dimensionStride = inputInfo.GetNumElements();
35 
36  for (unsigned int i = 0; i<inputInfo.GetNumDimensions(); i++)
37  {
38  dimensionStride /= inputInfo.GetShape()[i];
39  indices[i] = indexRemainder / dimensionStride; // Use integer division to round down.
40  indexRemainder -= indices[i] * dimensionStride;
41  }
42 
43  for (unsigned int viewIdx = 0; viewIdx < data.m_ViewOrigins.size(); ++viewIdx)
44  {
45  SplitterQueueDescriptor::ViewOrigin const& view = data.m_ViewOrigins[viewIdx];
46 
47  //Split view extents are defined by the size of (the corresponding) input tensor.
48  const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[viewIdx]);
49  ARMNN_ASSERT(outputInfo.GetNumDimensions() == inputInfo.GetNumDimensions());
50 
51  // Check all dimensions to see if this element is inside the given input view.
52  bool insideView = true;
53  for (unsigned int i = 0; i<outputInfo.GetNumDimensions(); i++)
54  {
55  if (indices[i] < view.m_Origin[i])
56  {
57  insideView = false;
58  }
59  if (indices[i] >= view.m_Origin[i] + outputInfo.GetShape()[i])
60  {
61  insideView = false;
62  }
63  }
64 
65  if (insideView)
66  {
67  std::unique_ptr<Encoder<float>> encoderPtr =
68  MakeEncoder<float>(outputInfo, data.m_Outputs[viewIdx]->Map());
69  Encoder<float>& encoder = *encoderPtr;
70 
71  unsigned int outIndex = 0;
72  unsigned int dimensionStride = 1;
73  float inputValue = 0.f;
74 
75  for (unsigned int i = outputInfo.GetNumDimensions(); i-- > 0;)
76  {
77  outIndex += dimensionStride * (indices[i] - view.m_Origin[i]);
78  dimensionStride *= outputInfo.GetShape()[i];
79  }
80 
81  decoder += index;
82  inputValue = decoder.Get();
83  decoder -= index;
84 
85  encoder += outIndex;
86  encoder.Set(inputValue);
87  break;
88  }
89  }
90  }
91 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ Splitter()

void armnn::Splitter ( const SplitterQueueDescriptor data)

Definition at line 17 of file Splitter.hpp.

References ARMNN_ASSERT, TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), GetTensorInfo(), QueueDescriptor::m_Inputs, SplitterQueueDescriptor::ViewOrigin::m_Origin, QueueDescriptor::m_Outputs, SplitterQueueDescriptor::m_ViewOrigins, MaxNumOfTensorDimensions, and Split().

Referenced by BOOST_AUTO_TEST_CASE().

18 {
19  const TensorInfo& inputInfo0 = GetTensorInfo(data.m_Inputs[0]);
20 
21  for (unsigned int index = 0; index < inputInfo0.GetNumElements(); ++index)
22  {
23  unsigned int indices[MaxNumOfTensorDimensions] = { 0 };
24 
25  unsigned int indexRemainder = index;
26  unsigned int dimensionStride = inputInfo0.GetNumElements();
27 
28  for (unsigned int i = 0; i<inputInfo0.GetNumDimensions(); i++)
29  {
30  dimensionStride /= inputInfo0.GetShape()[i];
31  indices[i] = indexRemainder / dimensionStride; // Use integer division to round down.
32  indexRemainder -= indices[i] * dimensionStride;
33  }
34 
35  for (unsigned int viewIdx = 0; viewIdx < data.m_ViewOrigins.size(); ++viewIdx)
36  {
37  SplitterQueueDescriptor::ViewOrigin const& view = data.m_ViewOrigins[viewIdx];
38 
39  //Split view extents are defined by the size of (the corresponding) input tensor.
40  const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[viewIdx]);
41  ARMNN_ASSERT(outputInfo.GetNumDimensions() == inputInfo0.GetNumDimensions());
42 
43  // Check all dimensions to see if this element is inside the given input view.
44  bool insideView = true;
45  for (unsigned int i = 0; i<outputInfo.GetNumDimensions(); i++)
46  {
47  if (indices[i] < view.m_Origin[i])
48  {
49  insideView = false;
50  }
51  if (indices[i] >= view.m_Origin[i] + outputInfo.GetShape()[i])
52  {
53  insideView = false;
54  }
55  }
56 
57  if (insideView)
58  {
59  unsigned int outIndex = 0;
60  unsigned int dimensionStride = 1;
61 
62  for (unsigned int i = outputInfo.GetNumDimensions(); i-- > 0;)
63  {
64  outIndex += dimensionStride * (indices[i] - view.m_Origin[i]);
65  dimensionStride *= outputInfo.GetShape()[i];
66  }
67 
68  //We are within the view, to copy input data to the output corresponding to this view.
69  DataType* outputData = GetOutputTensorData<DataType>(viewIdx, data);
70  ARMNN_ASSERT(outputData);
71 
72  const DataType* inputData = GetInputTensorData<DataType>(0, data);
73  ARMNN_ASSERT(inputData);
74 
75  outputData[outIndex] = inputData[index];
76  }
77  }
78  }
79 }
DataType
Definition: Types.hpp:32
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ Stack()

void Stack ( const StackQueueDescriptor data,
std::vector< std::unique_ptr< Decoder< float >>> &  inputs,
Encoder< float > &  output 
)

Definition at line 12 of file Stack.cpp.

References TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), GetTensorInfo(), StackDescriptor::m_Axis, QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

15 {
16  const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[0]);
17  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]);
18 
19  unsigned int outputNumDims = outputInfo.GetNumDimensions();
20  unsigned int inputNumDims = inputInfo.GetNumDimensions();
21 
22  const armnn::TensorShape& outputDims = outputInfo.GetShape();
23  const armnn::TensorShape& inputDims = inputInfo.GetShape();
24 
25  unsigned int axis = data.m_Parameters.m_Axis;
26 
27  // Initialise output data
28  unsigned int numOutputElements = 1;
29  for (unsigned int i=0; i<outputNumDims; ++i)
30  {
31  numOutputElements *= outputDims[i];
32  }
33 
34  const unsigned int iNumTensors = static_cast<unsigned int>(data.m_Inputs.size());
35  const unsigned int iBatchSize = inputDims[0];
36  const unsigned int iChannels = (inputNumDims > 1) ? inputDims[1] : 1;
37  const unsigned int iHeight = (inputNumDims > 2) ? inputDims[2] : 1;
38  const unsigned int iWidth = (inputNumDims > 3) ? inputDims[3] : 1;
39 
40  const unsigned int oBatchSize = outputDims[1];
41  const unsigned int oChannels = (outputNumDims > 2) ? outputDims[2] : 1;
42  const unsigned int oHeight = (outputNumDims > 3) ? outputDims[3] : 1;
43  const unsigned int oWidth = (outputNumDims > 4) ? outputDims[4] : 1;
44 
45  // Array to store the input coordinates
46  // iCoordinates[0] = i, iCoordinates[1] = bi, iCoordinates[2] = ci
47  // iCoordinates[3] = hi, iCoordinates[4] = wi, iCoordinates[5] = 0
48  // iCoordinates[5] will be always zero and used for not incrementing
49  // the output when the input has less than 4 dimensions
50  std::array<unsigned int, 6> iCoordinates{ 0 };
51 
52  // Array of pointers used to map the output coordinates to the input ones, in accordance with the axis
53  // This array is initialized with &iCoordinates[5] since this will be always zero
54  std::array<unsigned int *, 5> oCoordinates = { &iCoordinates[5],
55  &iCoordinates[5],
56  &iCoordinates[5],
57  &iCoordinates[5],
58  &iCoordinates[5] };
59 
60  // Set the axis coordinate
61  oCoordinates[axis] = &iCoordinates[0];
62 
63  // Map the output coordinates, accounting for the axis
64  unsigned int dim_shift = 0;
65  for(unsigned int dim = 0; dim < inputNumDims; ++dim)
66  {
67  if(dim == axis)
68  {
69  dim_shift++;
70  }
71  oCoordinates[dim + dim_shift] = &iCoordinates[dim + 1];
72  }
73 
74  // Alias for the input coordinates
75  unsigned int &i = iCoordinates[0];
76  unsigned int &bi = iCoordinates[1];
77  unsigned int &ci = iCoordinates[2];
78  unsigned int &hi = iCoordinates[3];
79  unsigned int &wi = iCoordinates[4];
80 
81  // Alias for the output coordinates
82  unsigned int &o = *(oCoordinates[0]);
83  unsigned int &bo = *(oCoordinates[1]);
84  unsigned int &co = *(oCoordinates[2]);
85  unsigned int &ho = *(oCoordinates[3]);
86  unsigned int &wo = *(oCoordinates[4]);
87 
88  // Stack tensors
89  for(; i < iNumTensors; ++(i))
90  {
91  for(bi = 0; bi < iBatchSize; ++(bi))
92  {
93  for(ci = 0; ci < iChannels; ++(ci))
94  {
95  for(hi = 0; hi < iHeight; ++(hi))
96  {
97  for(wi = 0; wi < iWidth; ++(wi))
98  {
99  output[o * oWidth * oHeight * oChannels * oBatchSize +
100  bo * oWidth * oHeight * oChannels +
101  co * oWidth * oHeight +
102  ho * oWidth +
103  wo];
104 
105  output.Set(inputs[i]->Get());
106 
107  ++(*(inputs[i]));
108  }
109  }
110  }
111  }
112  }
113 }
virtual void Set(IType right)=0
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38

◆ StrEqual()

constexpr bool armnn::StrEqual ( const char *  strA,
const char(&)  strB[N] 
)

Definition at line 148 of file TypesUtils.hpp.

Referenced by ParseComputeDevice().

149 {
150  bool isEqual = true;
151  for (unsigned i = 0; isEqual && (i < N); ++i)
152  {
153  isEqual = (strA[i] == strB[i]);
154  }
155  return isEqual;
156 }

◆ StridedSlice()

void StridedSlice ( const TensorInfo inputInfo,
const StridedSliceDescriptor params,
const void *  inputData,
void *  outputData,
unsigned int  dataTypeSize 
)

Definition at line 90 of file StridedSlice.cpp.

References TensorInfo::GetShape(), and numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

95 {
96  const unsigned char* input = reinterpret_cast<const unsigned char*>(inputData);
97  unsigned char* output = reinterpret_cast<unsigned char*>(outputData);
98 
99  const TensorShape inputShape = ExtendShape(inputInfo.GetShape(), 4);
100 
101  StridedSliceDescriptor paddedParams = params;
102 
103  // Pad parameters to 4 dimensions
104  PadParams(paddedParams, 4);
105 
106  const int start0 = paddedParams.GetStartForAxis(inputShape, 0);
107  const int stop0 = paddedParams.GetStopForAxis (inputShape, 0, start0);
108 
109  const int start1 = paddedParams.GetStartForAxis(inputShape, 1);
110  const int stop1 = paddedParams.GetStopForAxis (inputShape, 1, start1);
111 
112  const int start2 = paddedParams.GetStartForAxis(inputShape, 2);
113  const int stop2 = paddedParams.GetStopForAxis (inputShape, 2, start2);
114 
115  const int start3 = paddedParams.GetStartForAxis(inputShape, 3);
116  const int stop3 = paddedParams.GetStopForAxis (inputShape, 3, start3);
117 
118  const int step = armnn::numeric_cast<int>(dataTypeSize);
119 
120  for (int in0 = start0;
121  !LoopCondition(in0, stop0, paddedParams.m_Stride[0]);
122  in0 += paddedParams.m_Stride[0])
123  {
124  for (int in1 = start1;
125  !LoopCondition(in1, stop1, paddedParams.m_Stride[1]);
126  in1 += paddedParams.m_Stride[1])
127  {
128  for (int in2 = start2;
129  !LoopCondition(in2, stop2, paddedParams.m_Stride[2]);
130  in2 += paddedParams.m_Stride[2])
131  {
132  for (int in3 = start3;
133  !LoopCondition(in3, stop3, paddedParams.m_Stride[3]);
134  in3 += paddedParams.m_Stride[3])
135  {
136  int dim1 = armnn::numeric_cast<int>(inputShape[1]);
137  int dim2 = armnn::numeric_cast<int>(inputShape[2]);
138  int dim3 = armnn::numeric_cast<int>(inputShape[3]);
139 
140  int inputOffset = (((in0 * dim1 + in1) * dim2 + in2) * dim3 + in3) * step;
141  ::memcpy(output, input + inputOffset, dataTypeSize);
142  output += step;
143  }
144  }
145  }
146  }
147 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ swap() [1/2]

void armnn::swap ( OriginsDescriptor first,
OriginsDescriptor second 
)

Definition at line 350 of file Descriptors.cpp.

References ViewsDescriptor::swap, and swap().

Referenced by FullyConnectedFloat32Test(), FullyConnectedLargeTestCommon(), BackendId::operator=(), BufferManager::Reset(), SquashEqualSiblingsImpl< Comparable >::Run(), and BackendRegistry::Swap().

351 {
352  using std::swap;
353  swap(first.m_NumViews, second.m_NumViews);
354  swap(first.m_NumDimensions, second.m_NumDimensions);
355  swap(first.m_ViewOrigins, second.m_ViewOrigins);
356  swap(first.m_ConcatAxis, second.m_ConcatAxis);
357 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

◆ swap() [2/2]

void armnn::swap ( ViewsDescriptor first,
ViewsDescriptor second 
)

Definition at line 359 of file Descriptors.cpp.

References ViewsDescriptor::swap.

Referenced by swap().

360 {
361  using std::swap;
362  swap(first.m_Origins, second.m_Origins);
363  swap(first.m_ViewSizes, second.m_ViewSizes);
364 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

◆ TestQuantizeConvolution2d()

void armnn::TestQuantizeConvolution2d ( bool  useBiases)

Definition at line 1227 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IgnoreUnused(), info, Convolution2dDescriptor::m_BiasEnabled, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

1228 {
1229  class TestConv2dQuantization : public TestQuantization
1230  {
1231  public:
1232  TestConv2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1233  : TestQuantization(inputShape, outputShape) {}
1234 
1235  TestConv2dQuantization(const QuantizerOptions& options,
1236  const TensorShape& inputShape,
1237  const TensorShape& outputShape)
1238  : TestQuantization(options, inputShape, outputShape) {}
1239 
1240  void VisitConvolution2dLayer(const IConnectableLayer *layer,
1241  const Convolution2dDescriptor& convolution2dDescriptor,
1242  const ConstTensor& weights,
1243  const Optional<ConstTensor>& biases,
1244  const char *name = nullptr) override
1245  {
1246  IgnoreUnused(convolution2dDescriptor, name);
1247  TestQuantizationOnLayersWithBiases(layer, weights, biases);
1248  }
1249  };
1250 
1251  INetworkPtr network = INetwork::Create();
1252 
1253  TensorShape shape{3U};
1254  TensorInfo info(shape, DataType::Float32);
1255 
1256  std::vector<float> weightsData{-1.0f, 1.5f, 2.0f};
1257  ConstTensor weights(info, weightsData);
1258 
1259  Convolution2dDescriptor descriptor;
1260  descriptor.m_BiasEnabled = useBiases;
1261 
1262  // Add the layers
1263  IConnectableLayer* input0 = network->AddInputLayer(0);
1264  IConnectableLayer* conv2d;
1265  Optional<ConstTensor> optionalBiases;
1266  std::vector<float> biasesData{-1.0f, 1.5f, 2.0f};
1267  if (useBiases)
1268  {
1269  ConstTensor biases(info, biasesData);
1270  optionalBiases = Optional<ConstTensor>(biases);
1271  }
1272  conv2d = network->AddConvolution2dLayer(descriptor, weights, optionalBiases);
1273  IConnectableLayer* output = network->AddOutputLayer(1);
1274 
1275  // Establish connections
1276  input0->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
1277  conv2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1278 
1279  // Set TensorInfo
1280  input0->GetOutputSlot(0).SetTensorInfo(info);
1281  conv2d->GetOutputSlot(0).SetTensorInfo(info);
1282 
1283  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1284  TestConv2dQuantization validatorQAsymmU8(shape, shape);
1285  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1286 
1287  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1288  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1289  TestConv2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1290  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1291 
1292  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1293  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1294  TestConv2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1295  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1296 
1297  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
1298  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
1299  TestConv2dQuantization validatorQSymmS16(Qsymm16Options, shape, shape);
1300  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1301 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ TestQuantizeDepthwiseConvolution2d()

void armnn::TestQuantizeDepthwiseConvolution2d ( bool  useBiases)

Definition at line 1313 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IgnoreUnused(), info, DepthwiseConvolution2dDescriptor::m_BiasEnabled, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

1314 {
1315  class TestDepthwiseConv2dQuantization : public TestQuantization
1316  {
1317  public:
1318  TestDepthwiseConv2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1319  : TestQuantization(inputShape, outputShape) {}
1320 
1321  TestDepthwiseConv2dQuantization(const QuantizerOptions& options,
1322  const TensorShape& inputShape,
1323  const TensorShape& outputShape)
1324  : TestQuantization(options, inputShape, outputShape) {}
1325 
1326  void VisitDepthwiseConvolution2dLayer(const IConnectableLayer *layer,
1327  const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
1328  const ConstTensor& weights,
1329  const Optional<ConstTensor>& biases,
1330  const char *name = nullptr) override
1331  {
1332  IgnoreUnused(convolution2dDescriptor, name);
1333  TestQuantizationOnLayersWithBiases(layer, weights, biases);
1334  }
1335  };
1336 
1337  INetworkPtr network = INetwork::Create();
1338 
1339  TensorShape shape{3U};
1340  TensorInfo info(shape, DataType::Float32);
1341 
1342  std::vector<float> weightsData{-1.0f, 1.5f, 2.0f};
1343  ConstTensor weights(info, weightsData);
1344 
1345  DepthwiseConvolution2dDescriptor descriptor;
1346  descriptor.m_BiasEnabled = useBiases;
1347 
1348  // Add the layers
1349  IConnectableLayer* input0 = network->AddInputLayer(0);
1350  IConnectableLayer* depthwiseConv2d;
1351  Optional<ConstTensor> optionalBiases;
1352  std::vector<float> biasesData{-1.0f, 1.5f, 2.0f};
1353  if (useBiases)
1354  {
1355  ConstTensor biases(info, biasesData);
1356  optionalBiases = Optional<ConstTensor>(biases);
1357  }
1358  depthwiseConv2d = network->AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases);
1359  IConnectableLayer* output = network->AddOutputLayer(1);
1360 
1361  // Establish connections
1362  input0->GetOutputSlot(0).Connect(depthwiseConv2d->GetInputSlot(0));
1363  depthwiseConv2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1364 
1365  //Set TensorInfo
1366  input0->GetOutputSlot(0).SetTensorInfo(info);
1367  depthwiseConv2d->GetOutputSlot(0).SetTensorInfo(info);
1368 
1369  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1370  TestDepthwiseConv2dQuantization validatorQAsymmU8(shape, shape);
1371  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1372 
1373  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1374  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1375  TestDepthwiseConv2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1376  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1377 
1378  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1379  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1380  TestDepthwiseConv2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1381  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1382 
1383  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
1384  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
1385  TestDepthwiseConv2dQuantization validatorQSymmS16(Qsymm16Options, shape, shape);
1386  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1387 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ TestQuantizeTransposeConvolution2d()

void armnn::TestQuantizeTransposeConvolution2d ( bool  useBiases)

Definition at line 2669 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IgnoreUnused(), info, TransposeConvolution2dDescriptor::m_BiasEnabled, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

2670 {
2671  class TestTransposeConvolution2dQuantization : public TestQuantization
2672  {
2673  public:
2674  TestTransposeConvolution2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape) :
2675  TestQuantization(inputShape, outputShape)
2676  {}
2677 
2678  TestTransposeConvolution2dQuantization(const QuantizerOptions& options,
2679  const TensorShape& inputShape,
2680  const TensorShape& outputShape) :
2681  TestQuantization(options, inputShape, outputShape)
2682  {}
2683 
2684  void VisitTransposeConvolution2dLayer(const IConnectableLayer *layer,
2685  const TransposeConvolution2dDescriptor& descriptor,
2686  const ConstTensor& weights,
2687  const Optional<ConstTensor>& biases,
2688  const char *name = nullptr) override
2689  {
2690  IgnoreUnused(descriptor, name);
2691  TestQuantizationOnLayersWithBiases(layer, weights, biases);
2692  }
2693  };
2694 
2695  INetworkPtr network = INetwork::Create();
2696 
2697  TensorShape shape{ 3 };
2698  TensorInfo info(shape, DataType::Float32);
2699 
2700  std::initializer_list<float> floatData{ -1.0f, 1.5f, 2.0f };
2701  std::vector<float> weightsData(floatData);
2702  ConstTensor weights(info, weightsData);
2703 
2704  TransposeConvolution2dDescriptor descriptor;
2705  descriptor.m_BiasEnabled = useBiases;
2706 
2707  // construct network
2708  IConnectableLayer* input = network->AddInputLayer(0);
2709  Optional<ConstTensor> optionalBiases;
2710  std::vector<float> biasesData(floatData);
2711  if (useBiases)
2712  {
2713  ConstTensor biases(info, biasesData);
2714  optionalBiases = Optional<ConstTensor>(biases);
2715  }
2716  IConnectableLayer* transposeConv2d = network->AddTransposeConvolution2dLayer(descriptor, weights, optionalBiases);
2717  IConnectableLayer* output = network->AddOutputLayer(1);
2718 
2719  input->GetOutputSlot(0).Connect(transposeConv2d->GetInputSlot(0));
2720  transposeConv2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2721 
2722  input->GetOutputSlot(0).SetTensorInfo(info);
2723  transposeConv2d->GetOutputSlot(0).SetTensorInfo(info);
2724 
2725  // test QAsymmU8 quantization
2726  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2727  TestTransposeConvolution2dQuantization validatorQAsymmU8(shape, shape);
2728  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2729 
2730  //test QAsymmS8 quantization
2731  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2732  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2733  TestTransposeConvolution2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2734  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2735 
2736  // test QSymmS8 quantization
2737  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2738  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2739  TestTransposeConvolution2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2740  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2741 
2742  // test QSymmS16 quantization
2743  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2744  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2745  TestTransposeConvolution2dQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2746  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2747 }
void IgnoreUnused(Ts &&...)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ TopKSort()

void TopKSort ( unsigned int  k,
unsigned int *  indices,
const float *  values,
unsigned int  numElement 
)

Definition at line 24 of file DetectionPostProcess.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), DetectionPostProcess(), and NonMaxSuppression().

25 {
26  std::partial_sort(indices, indices + k, indices + numElement,
27  [&values](unsigned int i, unsigned int j) { return values[i] > values[j]; });
28 }

◆ TransposeConvolution2dImpl()

void TransposeConvolution2dImpl ( const TransposeConvolution2dDescriptor descriptor,
const TensorShape inputShape,
Decoder< float > &  inputDecoder,
const TensorShape outputShape,
Encoder< float > &  outputEncoder,
const TensorShape weightsShape,
Decoder< float > &  weightsDecoder,
Decoder< float > *  biasesDecoder 
)

Definition at line 15 of file TransposeConvolution2d.cpp.

References Decoder< IType >::DecodeTensor(), Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), TensorShape::GetNumElements(), DataLayoutIndexed::GetWidthIndex(), TransposeConvolution2dDescriptor::m_BiasEnabled, TransposeConvolution2dDescriptor::m_DataLayout, TransposeConvolution2dDescriptor::m_PadLeft, TransposeConvolution2dDescriptor::m_PadTop, TransposeConvolution2dDescriptor::m_StrideX, TransposeConvolution2dDescriptor::m_StrideY, NHWC, Encoder< IType >::Set(), and BaseIterator::SetIndex().

Referenced by RefTransposeConvolution2dWorkload::Execute().

23 {
24  if (descriptor.m_BiasEnabled && !biasesDecoder)
25  {
26  throw InvalidArgumentException("Biases enabled but no bias data provided");
27  }
28  const DataLayoutIndexed dataLayoutIndexed(descriptor.m_DataLayout);
29  const unsigned int channelsIndex = dataLayoutIndexed.GetChannelsIndex();
30  const unsigned int heightIndex = dataLayoutIndexed.GetHeightIndex();
31  const unsigned int widthIndex = dataLayoutIndexed.GetWidthIndex();
32 
33  const unsigned int numBatches = inputShape[0];
34 
35  const unsigned int inputWidth = inputShape[widthIndex];
36  const unsigned int inputHeight = inputShape[heightIndex];
37  const unsigned int inputDepth = inputShape[channelsIndex];
38 
39  const unsigned int weightsHeight = weightsShape[heightIndex];
40  const unsigned int weightsWidth = weightsShape[widthIndex];
41  const unsigned int weightsDepth = weightsShape[channelsIndex];
42 
43  const unsigned int outputHeight = outputShape[heightIndex];
44  const unsigned int outputWidth = outputShape[widthIndex];
45  const unsigned int outputDepth = outputShape[channelsIndex];
46 
47  const unsigned int paddingLeft = descriptor.m_PadLeft;
48  const unsigned int paddingTop = descriptor.m_PadTop;
49 
50  const unsigned int strideX = descriptor.m_StrideX;
51  const unsigned int strideY = descriptor.m_StrideY;
52 
53  std::vector<float> outputBuffer(outputShape.GetNumElements(), 0);
54 
55  const std::vector<float> inputVec = inputDecoder.DecodeTensor(inputShape);
56  const std::vector<float> filterVec = weightsDecoder.DecodeTensor(weightsShape);
57 
58  for (unsigned int batch = 0u; batch < numBatches; ++batch)
59  {
60  for (unsigned int yInput = 0u; yInput < inputHeight; ++yInput)
61  {
62  for (unsigned int xInput = 0u; xInput < inputWidth; ++xInput)
63  {
64  unsigned int xOutputOrigin = xInput * strideX - paddingLeft;
65  unsigned int yOutputOrigin = yInput * strideY - paddingTop;
66 
67  for (unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
68  {
69  for (unsigned int yWeights = 0u; yWeights < weightsHeight; ++yWeights)
70  {
71  for (unsigned int xWeights = 0u; xWeights < weightsWidth; ++xWeights)
72  {
73  unsigned int yOutput = yOutputOrigin + yWeights;
74  unsigned int xOutput = xOutputOrigin + xWeights;
75 
76  if (yOutput < outputHeight && xOutput< outputWidth)
77  {
78  for (unsigned int dInput = 0u; dInput < inputDepth; dInput++)
79  {
80  unsigned int inputIndex;
81  unsigned int outputIndex;
82  unsigned int weightsIndex;
83 
84  if(descriptor.m_DataLayout == armnn::DataLayout::NHWC)
85  {
86  inputIndex = batch * inputHeight * inputWidth * inputDepth +
87  yInput * inputWidth * inputDepth +
88  xInput * inputDepth +
89  dInput;
90 
91  weightsIndex = dOutput * weightsHeight * weightsWidth * weightsDepth +
92  yWeights * weightsWidth * weightsDepth +
93  xWeights * weightsDepth +
94  dInput;
95 
96  outputIndex = batch * outputHeight * outputWidth * outputDepth +
97  yOutput * outputWidth * outputDepth +
98  xOutput * outputDepth +
99  dOutput;
100  }
101  else
102  {
103  inputIndex = batch * inputDepth * inputHeight * inputWidth +
104  dInput * inputHeight * inputWidth +
105  yInput * inputWidth +
106  xInput;
107 
108  weightsIndex = dOutput * weightsDepth * weightsHeight * weightsWidth +
109  dInput * weightsHeight * weightsWidth +
110  yWeights * weightsWidth +
111  xWeights;
112 
113  outputIndex = batch * outputDepth * outputHeight * outputWidth +
114  dOutput * outputHeight * outputWidth +
115  yOutput * outputWidth +
116  xOutput;
117  }
118 
119  outputBuffer[outputIndex] += inputVec[inputIndex] * filterVec[weightsIndex];
120  }
121  }
122  }
123  }
124 
125  }
126  }
127  }
128  }
129 
130  // Apply bias (if enabled)
131  if (descriptor.m_BiasEnabled)
132  {
133  outputEncoder[0];
134  Decoder<float>& rBiasesDecoder = *biasesDecoder;
135 
136  for (unsigned int batch = 0u; batch < numBatches; ++batch)
137  {
138  for (unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
139  {
140  rBiasesDecoder.SetIndex(dOutput, dOutput);
141  for (unsigned int yOutput = 0u; yOutput < outputHeight; ++yOutput)
142  {
143  for (unsigned int xOutput = 0u; xOutput < outputWidth; ++xOutput)
144  {
145  const unsigned int outputIndex =
146  dataLayoutIndexed.GetIndex(outputShape, batch, dOutput, yOutput, xOutput);
147  outputBuffer[outputIndex] += rBiasesDecoder.Get();
148  }
149  }
150  }
151  }
152  }
153  outputEncoder[0];
154  for (float output : outputBuffer)
155  {
156  outputEncoder.Set(output);
157  ++outputEncoder;
158  }
159 }
virtual void Set(IType right)=0
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, const unsigned int channelMultiplier=1, bool isDepthwise=false)=0
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
virtual BaseIterator & SetIndex(unsigned int index, unsigned int axisIndex=0)=0

◆ TrueFunc()

bool armnn::TrueFunc ( Optional< std::string &>  reasonIfUnsupported,
Params &&...  params 
)

Definition at line 54 of file LayerSupportCommon.hpp.

References IgnoreUnused().

55 {
56  IgnoreUnused(reasonIfUnsupported);
57  IgnoreUnused(params...);
58  return true;
59 }
void IgnoreUnused(Ts &&...)

◆ ValidateFullyConnectedLayer()

void armnn::ValidateFullyConnectedLayer ( const bool  biasEnabled)

Definition at line 1099 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithFullyConnectedLayer(), IgnoreUnused(), QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

1100 {
1101  class TestFullyConnectedQuantization : public TestQuantization
1102  {
1103  public:
1104  TestFullyConnectedQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1105  : TestQuantization(inputShape, outputShape) {}
1106 
1107  TestFullyConnectedQuantization(const QuantizerOptions& options,
1108  const TensorShape& inputShape,
1109  const TensorShape& outputShape)
1110  : TestQuantization(options, inputShape, outputShape) {}
1111 
1112  void VisitFullyConnectedLayer(const IConnectableLayer* layer,
1113  const FullyConnectedDescriptor& desc,
1114  const ConstTensor& weights,
1115  const Optional<ConstTensor>& biases,
1116  const char* name = nullptr) override
1117  {
1118  IgnoreUnused(desc, name);
1119  TestQuantizationOnLayersWithBiases(layer, weights, biases);
1120  }
1121  };
1122 
1123  const TensorShape shape{3U};
1124  INetworkPtr network = CreateNetworkWithFullyConnectedLayer(biasEnabled, shape, shape);
1125 
1126  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1127  TestFullyConnectedQuantization validatorQAsymmU8(shape, shape);
1128  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1129 
1130  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1131  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1132  TestFullyConnectedQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1133  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1134 
1135  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1136  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1137  TestFullyConnectedQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1138  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1139 
1140  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
1141  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
1142  TestFullyConnectedQuantization validatorQSymmS16(Qsymm16Options, shape, shape);
1143  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1144 }
void IgnoreUnused(Ts &&...)
INetworkPtr CreateNetworkWithFullyConnectedLayer(const bool biasEnabled, const TensorShape &inputShape, const TensorShape &outputShape)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101

◆ VerifyTensorInfoDataType()

void armnn::VerifyTensorInfoDataType ( const armnn::TensorInfo info,
armnn::DataType  dataType 
)
inline

Definition at line 309 of file TypesUtils.hpp.

References TensorInfo::GetDataType(), GetDataTypeName(), and TensorInfo::GetShape().

Referenced by ParserFlatbuffersSerializeFixture::RunTest(), and ParserFlatbuffersFixture::RunTest().

310 {
311  if (info.GetDataType() != dataType)
312  {
313  std::stringstream ss;
314  ss << "Unexpected datatype:" << armnn::GetDataTypeName(info.GetDataType())
315  << " for tensor:" << info.GetShape()
316  << ". The type expected to be: " << armnn::GetDataTypeName(dataType);
317  throw armnn::Exception(ss.str());
318  }
319 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:180
DataType GetDataType() const
Definition: Tensor.hpp:194
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46

◆ VisitLayers()

void armnn::VisitLayers ( const LayerContainer &  layerContainer,
ILayerVisitor visitor 
)

Definition at line 49 of file NetworkQuantizerUtils.hpp.

References ILayerVisitor::FinishVisit(), and ILayerVisitor::StartVisit().

Referenced by BOOST_AUTO_TEST_CASE(), NetworkQuantizer::ExportNetwork(), NetworkQuantizer::OverrideInputRange(), NetworkQuantizer::Refine(), and VisitLayersTopologically().

50 {
51  visitor.StartVisit();
52  for (auto layer : layerContainer)
53  {
54  layer->Accept(visitor);
55  }
56  visitor.FinishVisit();
57 }

◆ VisitLayersTopologically()

void armnn::VisitLayersTopologically ( const INetwork inputNetwork,
ILayerVisitor visitor 
)

Definition at line 192 of file QuantizerTest.cpp.

References g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), IgnoreUnused(), info, and VisitLayers().

Referenced by BOOST_AUTO_TEST_CASE(), PreserveTypeTestImpl(), TestQuantizeConvolution2d(), TestQuantizeDepthwiseConvolution2d(), TestQuantizeTransposeConvolution2d(), and ValidateFullyConnectedLayer().

193 {
194  auto network = PolymorphicDowncast<const Network*>(inputNetwork);
195  auto graph = network->GetGraph().TopologicalSort();
196 
197  VisitLayers(graph, visitor);
198 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)

◆ WrapClError()

RuntimeException armnn::WrapClError ( const cl::Error clError,
const CheckLocation location 
)
inline

Definition at line 126 of file ClWorkloadUtils.hpp.

References Exception::what().

Referenced by ClWorkloadFactory::GetBackendId(), and RunClFunction().

127 {
128  std::stringstream message;
129  message << "CL error: " << clError.what() << ". Error code: " << clError.err();
130 
131  return RuntimeException(message.str(), location);
132 }

Variable Documentation

◆ g_AggregateProfilingEventsByInference

constexpr bool g_AggregateProfilingEventsByInference = true

Definition at line 38 of file Profiling.cpp.

◆ g_AsymmS8QuantizationBase

const float g_AsymmS8QuantizationBase = 255.0f

Definition at line 34 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_AsymmU8QuantizationBase

const float g_AsymmU8QuantizationBase = 255.0f

Definition at line 32 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_ProfilingEventCountHint

constexpr std::size_t g_ProfilingEventCountHint = 1024

Definition at line 30 of file Profiling.cpp.

◆ g_SymmS16QuantizationBase

const float g_SymmS16QuantizationBase = 32767.0f

Definition at line 36 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_SymmS8QuantizationBase

const float g_SymmS8QuantizationBase = 127.0f

Definition at line 35 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_TestTolerance

const float g_TestTolerance = 0.000001f

Definition at line 37 of file QuantizerTest.cpp.

◆ g_WriteProfilingEventSequence

constexpr bool g_WriteProfilingEventSequence = true

Definition at line 33 of file Profiling.cpp.

◆ g_WriteReportToStdOutOnProfilerDestruction

constexpr bool g_WriteReportToStdOutOnProfilerDestruction = false

Definition at line 42 of file Profiling.cpp.

◆ LOWEST_CAPTURE_PERIOD

constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u

The lowest performance data capture interval we support is 10 miliseconds.

Definition at line 21 of file Types.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), and PeriodicCounterSelectionCommandHandler::operator()().

◆ MaxNumOfTensorDimensions

◆ paddingRequiredLayers

const std::set<armnn::LayerType> paddingRequiredLayers
Initial value:
{
LayerType::Convolution2d,
LayerType::DepthwiseConvolution2d,
LayerType::Lstm,
LayerType::QuantizedLstm,
LayerType::TransposeConvolution2d
}
float Dequantize(QuantizedType value, float scale, int32_t offset)
Dequantize an 8-bit data type into a floating point data type.
Definition: TypesUtils.cpp:46
void DepthToSpace(const TensorInfo &inputInfo, const DepthToSpaceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
void ArgMinMax(Decoder< float > &in, OUT *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
Definition: ArgMinMax.cpp:16
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > &rBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.
void Stack(const StackQueueDescriptor &data, std::vector< std::unique_ptr< Decoder< float >>> &inputs, Encoder< float > &output)
Definition: Stack.cpp:12
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
void Gather(const TensorInfo &paramsInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo, Decoder< float > &params, const int32_t *indices, Encoder< float > &output, const int32_t axis)
Definition: Gather.cpp:17
QuantizedType Quantize(float value, float scale, int32_t offset)
Quantize a floating point data type into an 8-bit data type.
Definition: TypesUtils.cpp:30
void Mean(const armnn::TensorInfo &inputInfo, const armnn::TensorInfo &outputInfo, const std::vector< unsigned int > &axis, Decoder< float > &input, Encoder< float > &output)
Definition: Mean.cpp:71
void Pooling2d(Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
Computes the Pooling2d operation.
Definition: Pooling2d.cpp:142

Definition at line 16 of file NeonTensorHandleFactory.hpp.

Referenced by NeonTensorHandleFactory::GetCapabilities().

◆ tl_Profiler

thread_local Profiler* tl_Profiler = nullptr

Definition at line 484 of file Profiling.cpp.

Referenced by ProfilerManager::GetProfiler().