ArmNN  NotReleased
armnn Namespace Reference

Namespaces

 gatordmock
 
 optimizations
 
 profiling
 
 test
 

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  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
 
struct  BiasAndWeightsTypesCompatible
 
struct  BiasAndWeightsTypesMatch
 
class  BindableLayer
 
class  BooleanEncoder
 
struct  BroadcastLoop
 
struct  CheckLocation
 
class  ClAbsWorkload
 
class  ClActivationWorkload
 
class  ClAdditionWorkload
 
class  ClArgMinMaxWorkload
 
class  ClBackend
 
class  ClBackendContext
 
class  ClBatchNormalizationFloatWorkload
 
class  ClBatchToSpaceNdWorkload
 
class  ClConcatWorkload
 
class  ClConstantWorkload
 
class  ClContextControl
 
class  ClConvertFp16ToFp32Workload
 
class  ClConvertFp32ToFp16Workload
 
class  ClConvolution2dWorkload
 
class  ClDepthToSpaceWorkload
 
class  ClDepthwiseConvolutionWorkload
 
class  ClDequantizeWorkload
 
class  ClDivisionFloatWorkload
 
class  ClFloorFloatWorkload
 
class  ClFullyConnectedWorkload
 
class  ClGreaterWorkload
 
class  ClInstanceNormalizationWorkload
 
class  ClL2NormalizationFloatWorkload
 
class  ClLayerSupport
 
class  ClLstmFloatWorkload
 
class  ClMaximumWorkload
 
class  ClMeanWorkload
 
class  ClMemoryManager
 
class  ClMinimumWorkload
 
class  ClMultiplicationWorkload
 
class  ClNormalizationFloatWorkload
 
class  ClPadWorkload
 
class  ClPermuteWorkload
 
class  ClPooling2dWorkload
 
class  ClPreluWorkload
 
class  ClQuantizedLstmWorkload
 
class  ClQuantizeWorkload
 
class  ClReshapeWorkload
 
class  ClResizeWorkload
 
class  ClRsqrtWorkload
 
class  ClRuntimeUnavailableException
 
class  ClSliceWorkload
 
class  ClSoftmaxFloatWorkload
 
class  ClSoftmaxUint8Workload
 
class  ClSpaceToBatchNdWorkload
 
class  ClSpaceToDepthWorkload
 
class  ClSplitterWorkload
 
class  ClStackWorkload
 
class  ClStridedSliceWorkload
 
class  ClSubTensorHandle
 
class  ClSubtractionWorkload
 
class  ClTensorHandle
 
class  ClTensorHandleFactory
 
class  ClTransposeConvolution2dWorkload
 
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
 
class  ConstTensor
 A tensor defined by a TensorInfo (shape and data type) and an immutable backing store. More...
 
class  ConvertFp16ToFp32Layer
 This layer converts data type Float 16 to Float 32. More...
 
struct  ConvertFp16ToFp32QueueDescriptor
 
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
 
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
 
class  Encoder
 
struct  EqualQueueDescriptor
 
class  ErasedLayerNamesObservable
 
class  Event
 
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
 
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
 
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  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
 
class  IGraphObservable
 
class  IInputSlot
 An input connection slot for a layer. The input slot can be connected to an output slot of the preceding layer in the graph. Only one connection to the input slot is allowed. More...
 
class  ILayerSupport
 
class  ILayerVisitor
 
class  IMemoryManager
 
class  ImportMemGenericWorkload
 
class  INetwork
 
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  InvalidArgumentException
 
class  IOptimizedNetwork
 
class  IOutputSlot
 An output connection slot for a layer. The output slot may be connected to 1 or more input slots of subsequent layers in the graph. 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::ConvertFp16ToFp32 >
 
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::Floor >
 
struct  LayerTypeOfImpl< LayerType::FullyConnected >
 
struct  LayerTypeOfImpl< LayerType::Gather >
 
struct  LayerTypeOfImpl< LayerType::Input >
 
struct  LayerTypeOfImpl< LayerType::InstanceNormalization >
 
struct  LayerTypeOfImpl< LayerType::L2Normalization >
 
struct  LayerTypeOfImpl< LayerType::LogSoftmax >
 
struct  LayerTypeOfImpl< LayerType::Lstm >
 
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::Quantize >
 
struct  LayerTypeOfImpl< LayerType::QuantizedLstm >
 
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::TransposeConvolution2d >
 
class  LayerValidationException
 
class  LayerVisitorBase
 
class  LayerWithParameters
 
class  LoadedNetwork
 
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
 
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  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  NeonBatchNormalizationWorkload
 
class  NeonBatchToSpaceNdWorkload
 
class  NeonConcatWorkload
 
class  NeonConstantWorkload
 
class  NeonConvertFp16ToFp32Workload
 
class  NeonConvertFp32ToFp16Workload
 
class  NeonConvolution2dWorkload
 
class  NeonDepthToSpaceWorkload
 
class  NeonDepthwiseConvolutionWorkload
 
class  NeonDequantizeWorkload
 
class  NeonDetectionPostProcessWorkload
 
class  NeonDivisionWorkload
 
class  NeonFloorFloatWorkload
 
class  NeonFullyConnectedWorkload
 
class  NeonGreaterWorkload
 
class  NeonInstanceNormalizationWorkload
 
class  NeonInterceptorScheduler
 
class  NeonL2NormalizationFloatWorkload
 
class  NeonLayerSupport
 
class  NeonLstmFloatWorkload
 
class  NeonMaximumWorkload
 
class  NeonMeanWorkload
 
class  NeonMemoryManager
 
class  NeonMinimumWorkload
 
class  NeonMultiplicationWorkload
 
class  NeonNormalizationFloatWorkload
 
class  NeonPadWorkload
 
class  NeonPermuteWorkload
 
class  NeonPooling2dWorkload
 
class  NeonPreluWorkload
 
class  NeonQuantizedLstmWorkload
 
class  NeonQuantizeWorkload
 
class  NeonReshapeWorkload
 
class  NeonResizeWorkload
 
class  NeonRsqrtWorkload
 
class  NeonSliceWorkload
 
class  NeonSoftmaxFloatWorkload
 
class  NeonSoftmaxUint8Workload
 
class  NeonSpaceToBatchNdWorkload
 
class  NeonSpaceToDepthWorkload
 
class  NeonSplitterWorkload
 
class  NeonStackWorkload
 
class  NeonStridedSliceWorkload
 
class  NeonSubTensorHandle
 
class  NeonSubtractionWorkload
 
class  NeonTensorHandle
 
class  NeonTensorHandleFactory
 
class  NeonTimer
 
class  NeonTransposeConvolution2dWorkload
 
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  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
 
class  OptimizeForType
 
class  OptimizeForTypeImpl
 
class  OptimizeForTypeImpl< Layer, Wrapped >
 Specialization that calls Wrapped::Run() for any layer type. More...
 
class  Optimizer
 
struct  OptimizerOptions
 
class  Optional
 
class  OptionalBase
 
class  OptionalReferenceSwitch
 
class  OptionalReferenceSwitch< true, T >
 
struct  OriginsDescriptor
 An OriginsDescriptor for the ConcatLayer. Descriptor to configure the concatenation process. Number of views must be equal to the number of inputs, and their order must match - e.g. first view corresponds to the first input, second view to the second input, etc. 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
 
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
 
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
 
class  QuantizeLayer
 
struct  QuantizeQueueDescriptor
 
struct  QuantizerOptions
 
class  QuantizerVisitor
 Visitor object for quantizing layers in a network. More...
 
struct  QueueDescriptor
 
struct  QueueDescriptorWithParameters
 
class  RangeTracker
 
class  RefActivationWorkload
 
class  RefArgMinMaxWorkload
 
class  RefBackend
 
class  RefBatchNormalizationWorkload
 
class  RefBatchToSpaceNdWorkload
 
class  RefComparisonWorkload
 
class  RefConcatWorkload
 
class  RefConstantWorkload
 
class  RefConvertFp16ToFp32Workload
 
class  RefConvertFp32ToFp16Workload
 
class  RefConvolution2dWorkload
 
class  RefDebugWorkload
 
class  RefDepthToSpaceWorkload
 
class  RefDepthwiseConvolution2dWorkload
 
class  RefDequantizeWorkload
 
class  RefDetectionPostProcessWorkload
 
class  RefElementwiseUnaryWorkload
 
class  RefElementwiseWorkload
 
class  RefFakeQuantizationFloat32Workload
 
class  RefFloorWorkload
 
class  RefFullyConnectedWorkload
 
class  RefGatherWorkload
 
class  RefInstanceNormalizationWorkload
 
class  RefL2NormalizationWorkload
 
class  RefLayerSupport
 
class  RefLogSoftmaxWorkload
 
class  RefLstmWorkload
 
class  RefMeanWorkload
 
class  RefMemoryManager
 
class  RefNormalizationWorkload
 
class  RefPadWorkload
 
class  RefPermuteWorkload
 
class  RefPooling2dWorkload
 
class  RefPreluWorkload
 
class  RefQuantizeWorkload
 
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  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::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  SampleDynamicAdditionWorkload
 
class  SampleDynamicLayerSupport
 
class  SampleDynamicWorkloadFactory
 
class  SampleMemoryManager
 
class  SampleTensorHandle
 
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
 
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< ViewsDescriptor >
 
struct  StringMapping
 
class  SubgraphView
 
class  SubgraphViewSelector
 
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  TestQuantizedLstmLayerVisitor
 
class  TimeoutException
 
struct  TransposeConvolution2dDescriptor
 A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer. More...
 
class  TransposeConvolution2dLayer
 This layer represents a 2D transpose convolution operation. More...
 
struct  TransposeConvolution2dQueueDescriptor
 
struct  TypeAnyOf
 
class  TypedIterator
 
class  TypedWorkload
 
struct  TypeIs
 
struct  TypeNotPerAxisQuantized
 
struct  TypesAreEqual
 
class  UnimplementedException
 
struct  ViewsDescriptor
 A ViewsDescriptor for the SplitterLayer. Descriptor to configure the splitting process. Number of Views must be equal to the number of outputs, and their order must match - e.g. first view corresponds to the first output, second view to the second output, etc. More...
 
struct  VisitorNoThrowPolicy
 
struct  VisitorThrowingPolicy
 
class  WallClockTimer
 
class  WorkloadDataCollector
 
class  WorkloadFactoryBase
 
struct  WorkloadInfo
 

Typedefs

using BackendIdVector = std::vector< BackendId >
 
using BackendIdSet = std::unordered_set< BackendId >
 
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
 
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)>
 
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 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 = boost::variant< std::vector< float >, std::vector< int >, std::vector< unsigned char > >
 
template<DataType DT>
using ResolveType = typename ResolveTypeImpl< DT >::Type
 
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 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 ClGreaterFloat32Workload = ClGreaterWorkload< DataType::Float32 >
 
using ClGreaterUint8Workload = ClGreaterWorkload< DataType::QAsymmU8 >
 
using NeonGreaterFloat32Workload = NeonGreaterWorkload< DataType::Float32 >
 
using NeonGreaterUint8Workload = NeonGreaterWorkload< DataType::QAsymmU8 >
 
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 >
 
using RefAdditionWorkload = RefElementwiseWorkload< std::plus< float >, AdditionQueueDescriptor, StringMapping::RefAdditionWorkload_Execute >
 
using RefSubtractionWorkload = RefElementwiseWorkload< std::minus< float >, SubtractionQueueDescriptor, StringMapping::RefSubtractionWorkload_Execute >
 
using RefMultiplicationWorkload = RefElementwiseWorkload< std::multiplies< float >, MultiplicationQueueDescriptor, StringMapping::RefMultiplicationWorkload_Execute >
 
using RefDivisionWorkload = RefElementwiseWorkload< std::divides< float >, DivisionQueueDescriptor, StringMapping::RefDivisionWorkload_Execute >
 
using RefMaximumWorkload = RefElementwiseWorkload< armnn::maximum< float >, MaximumQueueDescriptor, StringMapping::RefMaximumWorkload_Execute >
 
using RefMinimumWorkload = RefElementwiseWorkload< armnn::minimum< float >, MinimumQueueDescriptor, StringMapping::RefMinimumWorkload_Execute >
 
using RefPadFloat32Workload = RefPadWorkload< DataType::Float32 >
 
using RefPadFloat16Workload = RefPadWorkload< DataType::Float16 >
 
using RefPadQAsymm8Workload = RefPadWorkload< DataType::QAsymmU8 >
 
using RefPadQSymm16Workload = RefPadWorkload< DataType::QSymmS16 >
 
using RefPermuteFloat16Workload = RefPermuteWorkload< DataType::Float16 >
 
using RefPermuteFloat32Workload = RefPermuteWorkload< DataType::Float32 >
 
using RefPermuteQAsymm8Workload = RefPermuteWorkload< DataType::QAsymmU8 >
 
using RefPermuteQSymm16Workload = RefPermuteWorkload< DataType::QSymmS16 >
 

Enumerations

enum  Compute { Undefined = 0, CpuRef = 1, CpuAcc = 2, GpuAcc = 3 }
 
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 }
 
enum  DataType {
  Float16 = 0, Float32 = 1, QAsymmU8 = 2, Signed32 = 3,
  Boolean = 4, QSymmS16 = 5, QuantizedSymm8PerAxis = 6, QSymmS8 = 7,
  QAsymmS8 = 8, 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
}
 
enum  ArgMinMaxFunction { Min = 0, Max = 1 }
 
enum  ComparisonOperation {
  Equal = 0, Greater = 1, GreaterOrEqual = 2, Less = 3,
  LessOrEqual = 4, NotEqual = 5
}
 
enum  UnaryOperation {
  Abs = 0, Exp = 1, Sqrt = 2, Rsqrt = 3,
  Neg = 4
}
 
enum  PoolingAlgorithm { Max = 0, Average = 1, L2 = 2 }
 
enum  ResizeMethod { Bilinear = 0, NearestNeighbor = 1 }
 
enum  PaddingMethod { IgnoreValue = 0, Exclude = 1 }
 
enum  NormalizationAlgorithmChannel { Across = 0, Within = 1 }
 
enum  NormalizationAlgorithmMethod { LocalBrightness = 0, LocalContrast = 1 }
 
enum  OutputShapeRounding { Floor = 0, Ceiling = 1 }
 
enum  LogSeverity {
  Trace, Debug, Info, Warning,
  Error, Fatal
}
 
enum  GraphEvent { LayerAdded, LayerErased }
 
enum  LayerType {
  FirstLayer, Activation = FirstLayer, Addition, ArgMinMax,
  BatchNormalization, BatchToSpaceNd, Comparison, Concat,
  Constant, ConvertFp16ToFp32, ConvertFp32ToFp16, Convolution2d,
  Debug, DepthToSpace, DepthwiseConvolution2d, Dequantize,
  DetectionPostProcess, Division, ElementwiseUnary, FakeQuantization,
  Floor, FullyConnected, Gather, Input,
  InstanceNormalization, L2Normalization, LogSoftmax, Lstm,
  Maximum, Mean, MemCopy, MemImport,
  Merge, Minimum, Multiplication, Normalization,
  Output, Pad, Permute, Pooling2d,
  PreCompiled, Prelu, Quantize, QuantizedLstm,
  Reshape, Resize, Slice, Softmax,
  SpaceToBatchNd, SpaceToDepth, Splitter, Stack,
  StandIn, StridedSlice, Subtraction, Switch,
  LastLayer, TransposeConvolution2d = LastLayer
}
 
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)
 
std::ostream & operator<< (std::ostream &os, const std::vector< Compute > &compute)
 
std::ostream & operator<< (std::ostream &os, const std::set< Compute > &compute)
 
std::ostream & operator<< (std::ostream &os, const Compute &compute)
 
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)
 
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 , typename ComparedType >
void ConditionalThrowIfNotEqual (const std::string &message, const ComparedType &leftHandSide, const ComparedType &rightHandSide)
 
IOptimizedNetworkPtr Optimize (const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
 
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)
 
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 * 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)
 
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)
 Explicit specialization of Quantize for int8_t. More...
 
template<typename QuantizedType >
float Dequantize (QuantizedType value, float scale, int32_t offset)
 
void VerifyTensorInfoDataType (const armnn::TensorInfo &info, armnn::DataType dataType)
 
void ConfigureLogging (bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
 
template<typename T >
bool CompatibleTypes (DataType)
 
template<>
bool CompatibleTypes< float > (DataType dataType)
 
template<>
bool CompatibleTypes< Half > (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 ConvertFp16ToFp32Layer *)
 
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 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 LogSoftmaxLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LstmLayer *)
 
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 QuantizedLstmLayer *)
 
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 TransposeConvolution2dLayer *)
 
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 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 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)
 
bool CheckScaleSetOnQuantizedType (Layer *layer, 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, 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)
 
OptimizationResult SelectTensorHandleStrategy (Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, 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< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
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 (CheckNamedLstmLayerPeephole)
 
 BOOST_AUTO_TEST_CASE (CheckLstmLayerProjection)
 
 BOOST_AUTO_TEST_CASE (CheckNamedLstmLayerProjection)
 
 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 (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 (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)
 
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::PoolingType ConvertPoolingAlgorithmToAclPoolingType (PoolingAlgorithm poolingAlgorithm)
 
arm_compute::DimensionRoundingType ConvertOutputShapeRoundingToAclDimensionRoundingType (OutputShapeRounding rounding)
 
arm_compute::NormType ConvertNormalizationAlgorithmChannelToAclNormType (NormalizationAlgorithmChannel channelType)
 
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo (const FullyConnectedDescriptor &fullyConnectedDesc)
 
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy (ResizeMethod resizeMethod)
 
unsigned int ComputeSoftmaxAclAxis (const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)
 
std::set< unsigned int > ComputeSplitAxis (const armnn::SplitterDescriptor &desc, const TensorShape &input)
 
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 * 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)
 
template<typename F >
void ParseOptions (const std::vector< BackendOptions > &options, BackendId backend, F f)
 
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)
 
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)
 
arm_compute::Status ClBatchToSpaceNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &desc)
 
arm_compute::Status ClConcatWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const OriginsDescriptor &descriptor)
 
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)
 
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)
 
arm_compute::Status ClDequantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClDivisionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, 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)
 
arm_compute::Status ClGreaterWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
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 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)
 
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 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)
 
arm_compute::Status ClTransposeConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
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)
 
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)
 
arm_compute::Status NeonBatchToSpaceNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &desc)
 
arm_compute::Status NeonConcatWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const OriginsDescriptor &descriptor)
 
arm_compute::Status NeonConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
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)
 
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)
 
arm_compute::Status NeonFullyConnectedWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor)
 
arm_compute::Status NeonGreaterWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
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 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)
 
arm_compute::Status NeonMultiplicationWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, 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 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)
 
arm_compute::Status NeonTransposeConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
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 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)
 
void ArgMinMax (Decoder< float > &in, int32_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< 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)
 
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)
 
void FullyConnected (const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, 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)
 
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)
 
template<typename T >
void Pad (const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_padList, const T *inputData, T *outData, const float padValue)
 
template void Pad< float > (const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_PadList, const float *inputData, float *outData, const float padValue)
 
template void Pad< Half > (const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_PadList, const Half *inputData, Half *outData, const float padValue)
 
template void Pad< uint8_t > (const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_PadList, const uint8_t *inputData, uint8_t *outData, const float padValue)
 
template void Pad< int16_t > (const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_PadList, const int16_t *inputData, int16_t *outData, const float padValue)
 
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 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)
 
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)
 
const float * GetInputTensorData (unsigned int idx, const AdditionQueueDescriptor &data)
 
float * GetOutputTensorData (unsigned int idx, const AdditionQueueDescriptor &data)
 
constexpr const char * SampleDynamicBackendId ()
 
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
 
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
 

Typedef Documentation

◆ 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 292 of file Network.hpp.

◆ BaseFloat32ComparisonWorkload

◆ BaseUint8ComparisonWorkload

◆ BindingPointInfo

Definition at line 146 of file Tensor.hpp.

◆ BooleanWorkload

◆ ClGreaterFloat32Workload

◆ ClGreaterUint8Workload

◆ 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 45 of file DescriptorsFwd.hpp.

◆ Coordinates

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

Definition at line 79 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 241 of file Types.hpp.

◆ DepthToSpaceDescriptor

A DepthToSpaceDescriptor for the DepthToSpaceLayer.

Definition at line 834 of file Descriptors.hpp.

◆ Dimensions

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

Definition at line 80 of file InternalTypes.hpp.

◆ DynamicBackendPtr

using DynamicBackendPtr = std::unique_ptr<DynamicBackend>

Definition at line 52 of file DynamicBackend.hpp.

◆ FactoryId

◆ Float16ToFloat32Workload

◆ 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 30 of file IBackendContext.hpp.

◆ IBackendInternalUniquePtr

typedef std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr

Definition at line 18 of file BackendRegistry.hpp.

◆ IBackendSharedPtr

using IBackendSharedPtr = std::shared_ptr<IBackend>

Definition at line 154 of file Types.hpp.

◆ IBackendUniquePtr

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

Definition at line 155 of file Types.hpp.

◆ IGpuAccTunedParametersPtr

The following API is replaced by the backend options API.

Definition at line 166 of file IRuntime.hpp.

◆ ILayerSupportSharedPtr

using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>

Definition at line 374 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 85 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 63 of file WorkloadData.hpp.

◆ InputTensors

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

Definition at line 225 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 544 of file INetwork.hpp.

◆ IRuntimePtr

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

Definition at line 24 of file IRuntime.hpp.

◆ LayerBindingId

using LayerBindingId = int

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

Definition at line 168 of file Types.hpp.

◆ LayerGuid

Define LayerGuid type.

Definition at line 233 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 73 of file LayersFwd.hpp.

◆ LogSoftmaxDescriptor

A LogSoftmaxDescriptor for the LogSoftmaxLayer.

Definition at line 142 of file Descriptors.hpp.

◆ MemorySourceFlags

using MemorySourceFlags = unsigned int

Definition at line 21 of file MemorySources.hpp.

◆ MergerDescriptor

Definition at line 49 of file DescriptorsFwd.hpp.

◆ MergerQueueDescriptor

Definition at line 121 of file WorkloadData.hpp.

◆ MinMaxRange

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

Definition at line 29 of file QuantizerTest.cpp.

◆ MinMaxRangeMap

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

Definition at line 31 of file QuantizerTest.cpp.

◆ MinMaxRanges

using MinMaxRanges = std::vector<MinMaxRange>

Definition at line 30 of file QuantizerTest.cpp.

◆ NeonGreaterFloat32Workload

◆ NeonGreaterUint8Workload

◆ NetworkId

using NetworkId = int

Definition at line 19 of file IRuntime.hpp.

◆ OffsetScalePair

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

Definition at line 16 of file NetworkQuantizationScheme.hpp.

◆ OutputQueueDescriptor

Definition at line 64 of file WorkloadData.hpp.

◆ OutputTensors

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

Definition at line 226 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

◆ RefDebugFloat16Workload

◆ RefDebugFloat32Workload

◆ RefDebugQAsymmS8Workload

◆ RefDebugQAsymmU8Workload

◆ RefDebugQSymmS16Workload

◆ RefDebugQSymmS8Workload

◆ RefDebugSigned32Workload

◆ RefDivisionWorkload

◆ RefMaximumWorkload

◆ RefMinimumWorkload

◆ RefMultiplicationWorkload

◆ RefPadFloat16Workload

◆ RefPadFloat32Workload

◆ RefPadQAsymm8Workload

◆ RefPadQSymm16Workload

◆ RefPermuteFloat16Workload

◆ RefPermuteFloat32Workload

◆ RefPermuteQAsymm8Workload

◆ RefPermuteQSymm16Workload

◆ RefSubtractionWorkload

◆ ResolveType

using ResolveType = typename ResolveTypeImpl<DT>::Type

Definition at line 66 of file ResolveType.hpp.

◆ SplitterDescriptor

Definition at line 50 of file DescriptorsFwd.hpp.

◆ supported

Definition at line 31 of file ISubgraphViewConverter.hpp.

◆ TContainer

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

Definition at line 33 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))

SoftReLu 
LeakyReLu 
Abs 
Sqrt 
Square 

Definition at line 54 of file Types.hpp.

◆ ArgMinMaxFunction

enum ArgMinMaxFunction
strong
Enumerator
Min 
Max 

Definition at line 68 of file Types.hpp.

◆ BoostLogSeverityMapping

◆ ComparisonOperation

enum ComparisonOperation
strong
Enumerator
Equal 
Greater 
GreaterOrEqual 
Less 
LessOrEqual 
NotEqual 

Definition at line 74 of file Types.hpp.

◆ Compute

enum Compute
strong
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,
25  CpuRef = 1,
27  CpuAcc = 2,
29  GpuAcc = 3
30 };
GPU Execution: OpenCL: ArmCompute.
CPU Execution: Reference C++ kernels.
CPU Execution: NEON: ArmCompute.

◆ DataLayout

enum DataLayout
strong
Enumerator
NCHW 
NHWC 

Definition at line 48 of file Types.hpp.

49 {
50  NCHW = 1,
51  NHWC = 2
52 };

◆ DataType

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

Definition at line 32 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 64 of file ITensorHandleFactory.hpp.

65 {
66  Undefined,
70 };
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
FirstLayer 
Activation 
Addition 
ArgMinMax 
BatchNormalization 
BatchToSpaceNd 
Comparison 
Concat 
Constant 
ConvertFp16ToFp32 
ConvertFp32ToFp16 
Convolution2d 
Debug 
DepthToSpace 
DepthwiseConvolution2d 
Dequantize 
DetectionPostProcess 
Division 
ElementwiseUnary 
FakeQuantization 
Floor 
FullyConnected 
Gather 
Input 
InstanceNormalization 
L2Normalization 
LogSoftmax 
Lstm 
Maximum 
Mean 
MemCopy 
MemImport 
Merge 
Minimum 
Multiplication 
Normalization 
Output 
Pad 
Permute 
Pooling2d 
PreCompiled 
Prelu 
Quantize 
QuantizedLstm 
Reshape 
Resize 
Slice 
Softmax 
SpaceToBatchNd 
SpaceToDepth 
Splitter 
Stack 
StandIn 
StridedSlice 
Subtraction 
Switch 
LastLayer 
TransposeConvolution2d 

Definition at line 14 of file InternalTypes.hpp.

15 {
16  FirstLayer,
18  Addition,
19  ArgMinMax,
22  Comparison,
23  Concat,
24  Constant,
28  Debug,
31  Dequantize,
33  Division,
36  Floor,
38  Gather,
39  Input,
42  LogSoftmax,
43  Lstm,
44  Maximum,
45  Mean,
46  MemCopy,
47  MemImport,
48  Merge,
49  Minimum,
52  Output,
53  Pad,
54  Permute,
55  Pooling2d,
57  Prelu,
58  Quantize,
60  Reshape,
61  Resize,
62  Slice,
63  Softmax,
66  Splitter,
67  Stack,
68  StandIn,
71  Switch,
72  // Last layer goes here.
73  LastLayer,
74  TransposeConvolution2d = LastLayer
75 };
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 Pooling2d(Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
Computes the Pooling2d operation.
Definition: Pooling2d.cpp:143
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:121
void FakeQuantization(const float *inputData, float *outputData, uint32_t numElements, float min, float max)
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:19
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)
QuantizedType Quantize(float value, float scale, int32_t offset)
Explicit specialization of Quantize for int8_t.
Definition: TypesUtils.cpp:31
void SpaceToBatchNd(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToBatchNdDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
void Gather(const TensorInfo &paramsInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo, Decoder< float > &params, const int32_t *indices, Encoder< float > &output)
Definition: Gather.cpp:18
float Dequantize(QuantizedType value, float scale, int32_t offset)
Definition: TypesUtils.cpp:47
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: Softmax.cpp:17
void Pad(const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_padList, const T *inputData, T *outData, const float padValue)
Definition: Pad.cpp:22
void ArgMinMax(Decoder< float > &in, int32_t *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
Definition: ArgMinMax.cpp:15
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 FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, 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 StridedSlice(const TensorInfo &inputInfo, const StridedSliceDescriptor &params, const void *inputData, void *outputData, unsigned int dataTypeSize)
void Slice(const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
Definition: Slice.cpp:15
void SpaceToDepth(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToDepthDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
void Splitter(const SplitterQueueDescriptor &data)
Definition: Splitter.hpp:17
void Resize(Decoder< float > &in, const TensorInfo &inputInfo, Encoder< float > &out, const TensorInfo &outputInfo, DataLayoutIndexed dataLayout, armnn::ResizeMethod resizeMethod, bool alignCorners)
Definition: Resize.cpp:35
float Activation(float in, ActivationFunction function, float a, float b)
Definition: Activation.cpp:12
void Stack(const StackQueueDescriptor &data, std::vector< std::unique_ptr< Decoder< float >>> &inputs, Encoder< float > &output)
Definition: Stack.cpp:12
void DepthToSpace(const TensorInfo &inputInfo, const DepthToSpaceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
void LogSoftmax(Decoder< float > &input, Encoder< float > &output, const TensorInfo &inputInfo, const LogSoftmaxDescriptor &descriptor)
Definition: LogSoftmax.cpp:30

◆ 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:19

◆ MemorySource

enum MemorySource
strong
Enumerator
Undefined 
Malloc 
DmaBuf 
DmaBufProtected 

Definition at line 13 of file MemorySources.hpp.

◆ NormalizationAlgorithmChannel

Enumerator
Across 
Within 

Definition at line 123 of file Types.hpp.

◆ NormalizationAlgorithmMethod

Enumerator
LocalBrightness 

Krichevsky 2012: Local Brightness Normalization.

LocalContrast 

Jarret 2009: Local Contrast Normalization.

Definition at line 129 of file Types.hpp.

130 {
132  LocalBrightness = 0,
134  LocalContrast = 1
135 };
Krichevsky 2012: Local Brightness Normalization.
Jarret 2009: Local Contrast Normalization.

◆ OutputShapeRounding

enum OutputShapeRounding
strong
Enumerator
Floor 
Ceiling 

Definition at line 137 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 115 of file Types.hpp.

116 {
118  IgnoreValue = 0,
120  Exclude = 1
121 };
The padding fields count, but are ignored.
The padding fields don&#39;t count and are ignored.

◆ PoolingAlgorithm

enum PoolingAlgorithm
strong
Enumerator
Max 
Average 
L2 

Definition at line 93 of file Types.hpp.

◆ ResizeMethod

enum ResizeMethod
strong
Enumerator
Bilinear 
NearestNeighbor 

Definition at line 100 of file Types.hpp.

◆ 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 

Definition at line 84 of file Types.hpp.

Function Documentation

◆ Activation() [1/2]

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

Definition at line 12 of file Activation.cpp.

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

Referenced by Activation().

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

◆ Activation() [2/2]

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

Definition at line 82 of file Activation.cpp.

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

88 {
89  unsigned int numElements = tensorInfo.GetNumElements();
90 
91  for (unsigned int i = 0; i < numElements; i++)
92  {
93  out.Set(Activation(in.Get(), function, a, b));
94  ++in;
95  ++out;
96  }
97  in -= numElements;
98  out -= numElements;
99 }
void Activation(Decoder< float > &in, Encoder< float > &out, const TensorInfo &tensorInfo, ActivationFunction function, float a, float b)
Definition: Activation.cpp:82
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ 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 103 of file DetectionPostProcess.cpp.

Referenced by DetectionPostProcess().

114 {
115  for (unsigned int i = 0; i < numOutput; ++i)
116  {
117  unsigned int boxIndex = i * 4;
118  if (i < numSelected)
119  {
120  unsigned int boxCornorIndex = selectedBoxes[outputIndices[i]] * 4;
121  detectionScores[i] = selectedScores[outputIndices[i]];
122  detectionClasses[i] = boost::numeric_cast<float>(selectedClasses[outputIndices[i]]);
123  detectionBoxes[boxIndex] = boxCorners[boxCornorIndex];
124  detectionBoxes[boxIndex + 1] = boxCorners[boxCornorIndex + 1];
125  detectionBoxes[boxIndex + 2] = boxCorners[boxCornorIndex + 2];
126  detectionBoxes[boxIndex + 3] = boxCorners[boxCornorIndex + 3];
127  }
128  else
129  {
130  detectionScores[i] = 0.0f;
131  detectionClasses[i] = 0.0f;
132  detectionBoxes[boxIndex] = 0.0f;
133  detectionBoxes[boxIndex + 1] = 0.0f;
134  detectionBoxes[boxIndex + 2] = 0.0f;
135  detectionBoxes[boxIndex + 3] = 0.0f;
136  }
137  }
138  numDetections[0] = boost::numeric_cast<float>(numSelected);
139 }

◆ AllTypesAreEqualImpl() [1/2]

bool armnn::AllTypesAreEqualImpl ( )

Definition at line 58 of file LayerSupportRules.hpp.

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

59 {
60  return true;
61 }

◆ AllTypesAreEqualImpl() [2/2]

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

Definition at line 64 of file LayerSupportRules.hpp.

References AllTypesAreEqualImpl().

65 {
66  static_assert(std::is_same<T, TensorInfo>::value, "Type T must be a TensorInfo");
67 
68  return (t1.GetDataType() == t2.GetDataType()) && AllTypesAreEqualImpl(t2, rest...);
69 }
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,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 345 of file Network.cpp.

References 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().

349 {
350  BOOST_ASSERT(optNetObjPtr);
351 
352  OptimizationResult result;
353 
354  // Get the optimized graph
355  Graph& optGraph = optNetObjPtr->GetGraph();
356 
357  // Run backend specific optimizations
358  for (auto&& selectedBackend : backendSettings.m_SelectedBackends)
359  {
360  auto backendObjPtr = backends.find(selectedBackend)->second.get();
361  BOOST_ASSERT(backendObjPtr);
362 
363  // Select sub-graphs based on backend
364  SubgraphViewSelector::Subgraphs subgraphs =
365  SubgraphViewSelector::SelectSubgraphs(optGraph,
366  // Select layers assigned to the requested backend
367  [&backendObjPtr](const Layer& layer)
368  {
369  return layer.GetType() != LayerType::Input &&
370  layer.GetType() != LayerType::Output &&
371  layer.GetBackendId() == backendObjPtr->GetId();
372  });
373  if (subgraphs.empty())
374  {
375  // No sub-graphs found, try with next selected backend
376  continue;
377  }
378 
379  // Try to optimize each sub-graph
380  for (auto& subgraph : subgraphs)
381  {
382  // Try to optimize the current sub-graph
383  OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph);
384  BOOST_ASSERT(optimizationViews.Validate(*subgraph));
385 
386  // Optimization attempted, check the resulting optimized sub-graph
387  for (auto& substitution : optimizationViews.GetSubstitutions())
388  {
389  // Sub-graph optimized, substitute the sub-graph with the new optimized one in the main optimized graph
390  SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
391  SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
392  optGraph.SubstituteSubgraph(substitutableSubgraph, replacementSubgraph);
393 
394  // Assign the current backend to the optimized sub-graph
395  std::for_each(replacementSubgraph.begin(), replacementSubgraph.end(), [&selectedBackend](Layer* l)
396  {
397  BOOST_ASSERT(l);
398  l->SetBackendId(selectedBackend);
399  });
400  }
401 
402  if (!optimizationViews.GetFailedSubgraphs().empty())
403  {
404  std::stringstream warningMsg;
405  warningMsg << "Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() << " backend.";
406  ReportWarning(warningMsg.str(), errMessages);
407 
408  // Failed to optimize the given sub-graph, re-assign the sub-graph layers to other available backends
409  BackendSettings settingsCopy(backendSettings);
410  if (!backendObjPtr->GetId().IsCpuRef())
411  {
412  // Add the current backend to the list of backends to ignore
413  settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
414  }
415 
416  int count=0;
417  for (auto& failedSubgraph : optimizationViews.GetFailedSubgraphs())
418  {
419  // An error occurred: the optimization was attempted but not performed, try different backends
420  std::stringstream subgraphMsg;
421  subgraphMsg << "Re-assigning backends to " << failedSubgraph.GetLayers().size()
422  << " layers inside sub-graph " << count++;
423  ReportWarning(subgraphMsg.str(), errMessages);
424 
425  OptimizationResult reassignmentResult = AssignBackends(optNetObjPtr,
426  settingsCopy,
427  *subgraph,
428  errMessages);
429  if (reassignmentResult.m_Error)
430  {
431  // Failed to re-assign one of the remaining backends to each layer of the sub-graph
432  result.m_Error = true;
433  return result;
434  }
435  }
436  }
437  }
438  }
439 
440  return result;
441 }
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
Definition: Network.cpp:86
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:312

◆ ArgMinMax()

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

Definition at line 15 of file ArgMinMax.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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

◆ AssignBackends() [1/2]

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

Definition at line 133 of file Network.cpp.

References CheckScaleSetOnQuantizedType(), Constant, ConvertFp16ToFp32, ConvertFp32ToFp16, CpuRef, Float16, Float32, BackendSettings::GetAvailablePreferredBackends(), GetDataTypeName(), OptimizedNetwork::GetGraph(), GetLayerTypeAsCString(), InsertConvertFp16ToFp32LayersBefore(), InsertConvertFp32ToFp16LayersAfter(), BackendSettings::IsCpuRefUsed(), IWorkloadFactory::IsLayerSupported(), OptimizationResult::m_Error, BackendSettings::m_PreferredBackends, BackendSettings::m_SelectedBackends, MemCopy, Permute, ReportError(), ReportWarning(), and Layer::SetBackendId().

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

138 {
139  OptimizationResult result;
140 
141  // Helper lambda to compose meaningful error message before returning with error
142  auto ReturnWithError = [&](const Layer* layer)
143  {
144  std::stringstream failureMsg;
145  failureMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
146  << " is not supported on any preferred backend " << backendSettings.m_PreferredBackends;
147  ReportError(failureMsg.str(), errMessages);
148 
149  result.m_Error = true;
150  return result;
151  };
152 
153  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
154  if (availablePreferredBackends.empty())
155  {
156  std::stringstream failureMsg;
157  failureMsg << "No preferred backends are available";
158  ReportError(failureMsg.str(), errMessages);
159 
160  result.m_Error = true;
161  return result;
162  }
163 
164  for (auto it = firstLayer; it != lastLayer; ++it)
165  {
166  auto layer = *it;
167 
168  DataType dataTypeIn = layer->GetNumInputSlots() == 0 ? DataType::Float32 :
169  layer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo().GetDataType();
170  DataType dataTypeOut = layer->GetNumOutputSlots() == 0 ? DataType::Float32 :
171  layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
172 
173  std::string reasonIfUnsupported;
174  bool found = false;
175  if (!CheckScaleSetOnQuantizedType(layer, errMessages))
176  {
177  // don't bomb immediately, find all the quantized outputs
178  // which haven't had a scale set and report them all back.
179  result.m_Error = true;
180  }
181 
182  for (const auto& backend : availablePreferredBackends)
183  {
184  // need to set the compute device on the layer
185  // before we can check if it is supported
186  layer->SetBackendId(backend);
187  if (!IWorkloadFactory::IsLayerSupported(*layer, EmptyOptional(), reasonIfUnsupported))
188  {
189  if (dataTypeIn == DataType::Float16 || dataTypeOut == DataType::Float16)
190  {
191  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
192  && layer->GetType() != LayerType::ConvertFp32ToFp16
193  && layer->GetType() != LayerType::ConvertFp16ToFp32)
194  {
195  // Insert FP16 -> FP32 conversion layer before current layer
196  std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
197  if (dataTypeIn == DataType::Float16)
198  {
199  convertFp16ToFp32Layers =
200  InsertConvertFp16ToFp32LayersBefore(optNetObjPtr->GetGraph(), *layer);
201  }
202 
203  // Insert FP32 -> FP16 conversion layer after current layer
204  std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
205  if (dataTypeOut == DataType::Float16)
206  {
207  convertFp32ToFp16Layers =
208  InsertConvertFp32ToFp16LayersAfter(optNetObjPtr->GetGraph(), *layer);
209  }
210 
211  // Assign a supported backend to the newly introduced conversion layers
212  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
213  {
214  bool supportedBackendFound = false;
215  std::string reasonIfUnsupported;
216 
217  // Try preferred backend first
218  layer->SetBackendId(preferredBackend);
219  if (IWorkloadFactory::IsLayerSupported(*layer,
220  EmptyOptional(),
221  reasonIfUnsupported))
222  {
223  supportedBackendFound = true;
224  }
225  else
226  {
227  for (const auto& backend : availablePreferredBackends)
228  {
229  // Skip preferred backend (we already determined that it is not supported)
230  if (backend == preferredBackend)
231  {
232  continue;
233  }
234 
235  layer->SetBackendId(backend);
236  if (IWorkloadFactory::IsLayerSupported(*layer,
237  EmptyOptional(),
238  reasonIfUnsupported))
239  {
240  supportedBackendFound = true;
241  break;
242  }
243  }
244  }
245 
246  return supportedBackendFound;
247  };
248 
249  for (ConvertFp16ToFp32Layer* convertLayer : convertFp16ToFp32Layers)
250  {
251  if (!AssignFirstSupportedBackend(convertLayer, backend))
252  {
253  return ReturnWithError(convertLayer);
254  }
255  }
256 
257  for (ConvertFp32ToFp16Layer* convertLayer : convertFp32ToFp16Layers)
258  {
259  if (!AssignFirstSupportedBackend(convertLayer, backend))
260  {
261  return ReturnWithError(convertLayer);
262  }
263  }
264 
265  found = true;
266  break;
267  }
268  }
269  std::stringstream warningMsg;
270  warningMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
271  << " is not supported on requested backend " << layer->GetBackendId().Get()
272  << " for input data type " << GetDataTypeName(dataTypeIn)
273  << " and output data type " << GetDataTypeName(dataTypeOut)
274  << " (reason: " << reasonIfUnsupported
275  << "), falling back to the next backend.";
276  ReportWarning(warningMsg.str(), errMessages);
277  }
278  else
279  {
280  found = true;
281  backendSettings.m_SelectedBackends.insert(backend);
282  break;
283  }
284  }
285 
286  // If the layer is unsupported by any devices, log and return a null network.
287  if (!found)
288  {
289  // NOTE: if the layer is not an operation queue type AND we have not got CpuRef as a
290  // fallback we should set the compute device on the layer to CpuRef (these are not
291  // available as accelerated operations, or are only available under certain
292  // conditions, currently they comprise MemCopy, Constant, Permute)
293  armnn::LayerType layerType = layer->GetType();
294  if (!backendSettings.IsCpuRefUsed() && (layerType == armnn::LayerType::MemCopy ||
295  layerType == armnn::LayerType::Constant ||
296  layerType == armnn::LayerType::Permute))
297  {
298  BackendId cpuBackendId(armnn::Compute::CpuRef);
299  layer->SetBackendId(cpuBackendId);
300  backendSettings.m_SelectedBackends.insert(cpuBackendId);
301  }
302  else
303  {
304  return ReturnWithError(layer);
305  }
306  }
307  }
308 
309  return result;
310 }
char const * GetLayerTypeAsCString(LayerType type)
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
Definition: Network.cpp:86
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:74
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:98
CPU Execution: Reference C++ kernels.
DataType
Definition: Types.hpp:32
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:165

◆ AssignBackends() [2/2]

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

Definition at line 312 of file Network.cpp.

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

316 {
317  Graph::Iterator firstLayer = subgraph.begin();
318  Graph::Iterator lastLayer = subgraph.end();
319  return AssignBackends(optNetObjPtr,
320  backendSettings,
321  firstLayer,
322  lastLayer,
323  errMessages);
324 }
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:312

◆ AssignSplitId()

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

Definition at line 301 of file SubgraphViewSelector.cpp.

References ForEachLayerInput().

Referenced by SubgraphViewSelector::SelectSubgraphs().

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

◆ 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 }
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
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ 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 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  BOOST_ASSERT_MSG(inputShape.GetNumDimensions() == 4, "Expected Input with 4 Dimensions");
46 
47  TensorShape outputShape = outputTensorInfo.GetShape();
48 
49  BOOST_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  BOOST_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  BOOST_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 Offset(const TensorShape &shape, unsigned int batch, unsigned int height, unsigned int width, unsigned int channels, const DataLayoutIndexed &dataLayout)
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:43
unsigned int GetHeightIndex() const
unsigned int GetWidthIndex() const
unsigned int GetChannelsIndex() const
virtual IType Get() const =0
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Set(IType right)=0

◆ BOOST_AUTO_TEST_CASE() [1/79]

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/79]

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/79]

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/79]

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/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckConvolution2dLayer  )

Definition at line 170 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().

171 {
172  Convolution2dDescriptor descriptor;
173  descriptor.m_PadLeft = 2;
174  descriptor.m_PadRight = 3;
175  descriptor.m_PadBottom = 1;
176  descriptor.m_PadTop = 5;
177  descriptor.m_StrideX = 2;
178  descriptor.m_StrideY = 3;
179  descriptor.m_DataLayout = DataLayout::NHWC;
180 
181  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
182  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
183  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
184 
185  TestConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional());
186 
187  Network net;
188 
189  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional());
190  layer->Accept(visitor);
191 }

◆ BOOST_AUTO_TEST_CASE() [6/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedConvolution2dLayer  )

Definition at line 193 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.

194 {
195  const char* layerName = "Convolution2dLayer";
196  Convolution2dDescriptor descriptor;
197  descriptor.m_PadLeft = 2;
198  descriptor.m_PadRight = 3;
199  descriptor.m_PadBottom = 1;
200  descriptor.m_PadTop = 5;
201  descriptor.m_StrideX = 2;
202  descriptor.m_StrideY = 3;
203  descriptor.m_DataLayout = DataLayout::NHWC;
204 
205  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
206  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
207  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
208 
209  TestConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional(), layerName);
210 
211  Network net;
212 
213  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional(), layerName);
214  layer->Accept(visitor);
215 }

◆ BOOST_AUTO_TEST_CASE() [7/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckConvolution2dLayerWithBiases  )

Definition at line 217 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.

218 {
219  Convolution2dDescriptor descriptor;
220  descriptor.m_PadLeft = 2;
221  descriptor.m_PadRight = 3;
222  descriptor.m_PadBottom = 1;
223  descriptor.m_PadTop = 5;
224  descriptor.m_StrideX = 2;
225  descriptor.m_StrideY = 3;
226  descriptor.m_DataLayout = DataLayout::NHWC;
227  descriptor.m_BiasEnabled = true;
228 
229  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
230  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
231  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
232 
233  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
234  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
235  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
236  Optional<ConstTensor> optionalBiases(biases);
237 
238  TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases);
239 
240  Network net;
241 
242  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases);
243  layer->Accept(visitor);
244 }

◆ BOOST_AUTO_TEST_CASE() [8/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeAddition  )

Definition at line 227 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(), info, options, QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

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

◆ BOOST_AUTO_TEST_CASE() [9/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedConvolution2dLayerWithBiases  )

Definition at line 246 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.

247 {
248  const char* layerName = "Convolution2dLayer";
249  Convolution2dDescriptor descriptor;
250  descriptor.m_PadLeft = 2;
251  descriptor.m_PadRight = 3;
252  descriptor.m_PadBottom = 1;
253  descriptor.m_PadTop = 5;
254  descriptor.m_StrideX = 2;
255  descriptor.m_StrideY = 3;
256  descriptor.m_DataLayout = DataLayout::NHWC;
257  descriptor.m_BiasEnabled = true;
258 
259  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
260  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
261  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
262 
263  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
264  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
265  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
266  Optional<ConstTensor> optionalBiases(biases);
267 
268  TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName);
269 
270  Network net;
271 
272  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases, layerName);
273  layer->Accept(visitor);
274 }

◆ BOOST_AUTO_TEST_CASE() [10/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckDepthwiseConvolution2dLayer  )

Definition at line 276 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.

277 {
278  DepthwiseConvolution2dDescriptor descriptor;
279  descriptor.m_PadLeft = 2;
280  descriptor.m_PadRight = 3;
281  descriptor.m_PadBottom = 1;
282  descriptor.m_PadTop = 5;
283  descriptor.m_StrideX = 2;
284  descriptor.m_StrideY = 3;
285  descriptor.m_DataLayout = DataLayout::NHWC;
286 
287  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
288  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
289  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
290 
291  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional());
292 
293  Network net;
294 
295  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, EmptyOptional());
296  layer->Accept(visitor);
297 }

◆ BOOST_AUTO_TEST_CASE() [11/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedDepthwiseConvolution2dLayer  )

Definition at line 299 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.

300 {
301  const char* layerName = "DepthwiseConvolution2dLayer";
302  DepthwiseConvolution2dDescriptor descriptor;
303  descriptor.m_PadLeft = 2;
304  descriptor.m_PadRight = 3;
305  descriptor.m_PadBottom = 1;
306  descriptor.m_PadTop = 5;
307  descriptor.m_StrideX = 2;
308  descriptor.m_StrideY = 3;
309  descriptor.m_DataLayout = DataLayout::NHWC;
310 
311  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
312  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
313  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
314 
315  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional(), layerName);
316 
317  Network net;
318 
319  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor,
320  weights,
321  EmptyOptional(),
322  layerName);
323  layer->Accept(visitor);
324 }

◆ BOOST_AUTO_TEST_CASE() [12/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckDepthwiseConvolution2dLayerWithBiases  )

Definition at line 326 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.

327 {
328  DepthwiseConvolution2dDescriptor descriptor;
329  descriptor.m_PadLeft = 2;
330  descriptor.m_PadRight = 3;
331  descriptor.m_PadBottom = 1;
332  descriptor.m_PadTop = 5;
333  descriptor.m_StrideX = 2;
334  descriptor.m_StrideY = 3;
335  descriptor.m_DataLayout = DataLayout::NHWC;
336  descriptor.m_BiasEnabled = true;
337 
338  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
339  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
340  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
341 
342  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
343  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
344  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
345  Optional<ConstTensor> optionalBiases(biases);
346 
347  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases);
348 
349  Network net;
350 
351  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases);
352  layer->Accept(visitor);
353 }

◆ BOOST_AUTO_TEST_CASE() [13/79]

armnn::BOOST_AUTO_TEST_CASE ( InputOutputLayerDynamicQuant  )

Definition at line 347 of file QuantizerTest.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [14/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedDepthwiseConvolution2dLayerWithBiases  )

Definition at line 355 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.

356 {
357  const char* layerName = "DepthwiseConvolution2dLayer";
358  DepthwiseConvolution2dDescriptor descriptor;
359  descriptor.m_PadLeft = 2;
360  descriptor.m_PadRight = 3;
361  descriptor.m_PadBottom = 1;
362  descriptor.m_PadTop = 5;
363  descriptor.m_StrideX = 2;
364  descriptor.m_StrideY = 3;
365  descriptor.m_DataLayout = DataLayout::NHWC;
366  descriptor.m_BiasEnabled = true;
367 
368  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
369  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
370  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
371 
372  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
373  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
374  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
375  Optional<ConstTensor> optionalBiases(biases);
376 
377  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName);
378 
379  Network net;
380 
381  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases, layerName);
382  layer->Accept(visitor);
383 }

◆ BOOST_AUTO_TEST_CASE() [15/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckFullyConnectedLayer  )

Definition at line 385 of file ConstTensorLayerVisitor.cpp.

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

386 {
387  FullyConnectedDescriptor descriptor;
388  descriptor.m_TransposeWeightMatrix = true;
389 
390  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
391  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
392  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
393 
394  TestFullyConnectedLayerVistor visitor(descriptor, weights, EmptyOptional());
395 
396  Network net;
397 
398  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, EmptyOptional());
399  layer->Accept(visitor);
400 }

◆ BOOST_AUTO_TEST_CASE() [16/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedFullyConnectedLayer  )

Definition at line 402 of file ConstTensorLayerVisitor.cpp.

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

403 {
404  const char* layerName = "FullyConnectedLayer";
405  FullyConnectedDescriptor descriptor;
406  descriptor.m_TransposeWeightMatrix = true;
407 
408  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
409  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
410  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
411 
412  TestFullyConnectedLayerVistor visitor(descriptor, weights, EmptyOptional(), layerName);
413 
414  Network net;
415 
416  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, EmptyOptional(), layerName);
417  layer->Accept(visitor);
418 }

◆ BOOST_AUTO_TEST_CASE() [17/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeAbsActivation  )

Definition at line 408 of file QuantizerTest.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [18/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckFullyConnectedLayerWithBiases  )

Definition at line 420 of file ConstTensorLayerVisitor.cpp.

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

421 {
422  FullyConnectedDescriptor descriptor;
423  descriptor.m_TransposeWeightMatrix = true;
424  descriptor.m_BiasEnabled = true;
425 
426  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
427  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
428  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
429 
430  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
431  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
432  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
433  Optional<ConstTensor> optionalBiases(biases);
434 
435  TestFullyConnectedLayerVistor visitor(descriptor, weights, optionalBiases);
436 
437  Network net;
438 
439  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, optionalBiases);
440  layer->Accept(visitor);
441 }

◆ BOOST_AUTO_TEST_CASE() [19/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeLinearActivation  )

Definition at line 439 of file QuantizerTest.cpp.

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

440 {
441  ActivationDescriptor descriptor;
442  descriptor.m_Function = ActivationFunction::Linear;
443  descriptor.m_A = 3.5f;
444  descriptor.m_B = -10.0f;
445 
446  const TensorShape shape{1U};
447  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
448 
449  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
450  TestActivationQuantization validatorQAsymmU8(shape, shape);
451  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
452 
453  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
454  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
455  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
456  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
457 
458  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
459  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
460  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
461  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
462 
463  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
464  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
465  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
466  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
467 }
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:85

◆ BOOST_AUTO_TEST_CASE() [20/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedFullyConnectedLayerWithBiases  )

Definition at line 443 of file ConstTensorLayerVisitor.cpp.

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

444 {
445  const char* layerName = "FullyConnectedLayer";
446  FullyConnectedDescriptor descriptor;
447  descriptor.m_TransposeWeightMatrix = true;
448  descriptor.m_BiasEnabled = true;
449 
450  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
451  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
452  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32), data);
453 
454  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
455  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
456  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData);
457  Optional<ConstTensor> optionalBiases(biases);
458 
459  TestFullyConnectedLayerVistor visitor(descriptor, weights, optionalBiases, layerName);
460 
461  Network net;
462 
463  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, optionalBiases, layerName);
464  layer->Accept(visitor);
465 }

◆ BOOST_AUTO_TEST_CASE() [21/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckBatchNormalizationLayer  )

Definition at line 467 of file ConstTensorLayerVisitor.cpp.

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

468 {
469  BatchNormalizationDescriptor descriptor;
470  descriptor.m_Eps = 0.0002f;
471  descriptor.m_DataLayout = DataLayout::NHWC;
472 
473  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
474  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
475  ConstTensor mean(TensorInfo(4, dimensions.data(), DataType::Float32), data);
476 
477  std::vector<float> varianceData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
478  std::vector<unsigned int> varianceDimensions = {1, 1, 3, 3};
479  ConstTensor variance(TensorInfo(4, varianceDimensions.data(), DataType::Float32), varianceData);
480 
481  std::vector<float> betaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
482  std::vector<unsigned int> betaDimensions = {1, 1, 3, 3};
483  ConstTensor beta(TensorInfo(4, betaDimensions.data(), DataType::Float32), betaData);
484 
485  std::vector<float> gammaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
486  std::vector<unsigned int> gammaDimensions = {1, 1, 3, 3};
487  ConstTensor gamma(TensorInfo(4, gammaDimensions.data(), DataType::Float32), gammaData);
488 
489  TestBatchNormalizationLayerVisitor visitor(descriptor, mean, variance, beta, gamma);
490 
491  Network net;
492 
493  IConnectableLayer* const layer = net.AddBatchNormalizationLayer(descriptor, mean, variance, beta, gamma);
494  layer->Accept(visitor);
495 }

◆ BOOST_AUTO_TEST_CASE() [22/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeReLuActivation  )

Definition at line 469 of file QuantizerTest.cpp.

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

470 {
471  ActivationDescriptor descriptor;
472  descriptor.m_Function = ActivationFunction::ReLu;
473  descriptor.m_A = 3.5f;
474  descriptor.m_B = -10.0f;
475 
476  const TensorShape shape{1U};
477  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
478 
479  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
480  TestActivationQuantization validatorQAsymmU8(shape, shape);
481  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
482 
483  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
484  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
485  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
486  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
487 
488  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
489  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
490  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
491  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
492 
493  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
494  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
495  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
496  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
497 }
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:85

◆ BOOST_AUTO_TEST_CASE() [23/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedBatchNormalizationLayer  )

Definition at line 497 of file ConstTensorLayerVisitor.cpp.

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

498 {
499  const char* layerName = "BatchNormalizationLayer";
500  BatchNormalizationDescriptor descriptor;
501  descriptor.m_Eps = 0.0002f;
502  descriptor.m_DataLayout = DataLayout::NHWC;
503 
504  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
505  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
506  ConstTensor mean(TensorInfo(4, dimensions.data(), DataType::Float32), data);
507 
508  std::vector<float> varianceData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
509  std::vector<unsigned int> varianceDimensions = {1, 1, 3, 3};
510  ConstTensor variance(TensorInfo(4, varianceDimensions.data(), DataType::Float32), varianceData);
511 
512  std::vector<float> betaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
513  std::vector<unsigned int> betaDimensions = {1, 1, 3, 3};
514  ConstTensor beta(TensorInfo(4, betaDimensions.data(), DataType::Float32), betaData);
515 
516  std::vector<float> gammaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
517  std::vector<unsigned int> gammaDimensions = {1, 1, 3, 3};
518  ConstTensor gamma(TensorInfo(4, gammaDimensions.data(), DataType::Float32), gammaData);
519 
520  TestBatchNormalizationLayerVisitor visitor(descriptor, mean, variance, beta, gamma, layerName);
521 
522  Network net;
523 
524  IConnectableLayer* const layer = net.AddBatchNormalizationLayer(
525  descriptor, mean, variance, beta, gamma, layerName);
526  layer->Accept(visitor);
527 }

◆ BOOST_AUTO_TEST_CASE() [24/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSoftReLuActivation  )

Definition at line 499 of file QuantizerTest.cpp.

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

500 {
501  ActivationDescriptor descriptor;
502  descriptor.m_Function = ActivationFunction::SoftReLu;
503  descriptor.m_A = 3.5f;
504  descriptor.m_B = -10.0f;
505 
506  const TensorShape shape{1U};
507  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
508 
509  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
510  TestActivationQuantization validatorQAsymmU8(shape, shape);
511  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
512 
513  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
514  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
515  TestActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
516  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
517 
518  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
519  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
520  TestActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
521  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
522 
523  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
524  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
525  TestActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
526  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
527 }
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:85

◆ BOOST_AUTO_TEST_CASE() [25/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeBoundedReluActivation  )

Definition at line 529 of file QuantizerTest.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [26/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckConstLayer  )

Definition at line 529 of file ConstTensorLayerVisitor.cpp.

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

530 {
531  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
532  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
533  ConstTensor input(TensorInfo(4, dimensions.data(), DataType::Float32), data);
534 
535  TestConstantLayerVisitor visitor(input);
536 
537  Network net;
538 
539  IConnectableLayer* const layer = net.AddConstantLayer(input);
540  layer->Accept(visitor);
541 }

◆ BOOST_AUTO_TEST_CASE() [27/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedConstLayer  )

Definition at line 543 of file ConstTensorLayerVisitor.cpp.

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

544 {
545  const char* layerName = "ConstantLayer";
546  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
547  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
548  ConstTensor input(TensorInfo(4, dimensions.data(), DataType::Float32), data);
549 
550  TestConstantLayerVisitor visitor(input, layerName);
551 
552  Network net;
553 
554  IConnectableLayer* const layer = net.AddConstantLayer(input, layerName);
555  layer->Accept(visitor);
556 }

◆ BOOST_AUTO_TEST_CASE() [28/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerBasic  )

Definition at line 558 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.

559 {
560  LstmDescriptor descriptor;
561  descriptor.m_ActivationFunc = 3;
562  descriptor.m_ClippingThresProj = 0.5f;
563  descriptor.m_ClippingThresCell = 0.3f;
564  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
565 
566  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
567  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
568  ConstTensor inputToForgetWeights(
569  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
570 
571  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
572  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
573  ConstTensor inputToCellWeights(
574  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
575 
576  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
577  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
578  ConstTensor inputToOutputWeights(
579  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
580 
581  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
582  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
583  ConstTensor recurrentToForgetWeights(TensorInfo(
584  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
585 
586  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
587  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
588  ConstTensor recurrentToCellWeights(TensorInfo(
589  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
590 
591  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
592  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
593  ConstTensor recurrentToOutputWeights(TensorInfo(
594  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
595 
596  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
597  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
598  ConstTensor forgetGateBias(TensorInfo(
599  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
600 
601  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
602  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
603  ConstTensor cellBias(TensorInfo(
604  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
605 
606  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
607  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
608  ConstTensor outputGateBias(TensorInfo(
609  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
610 
611  LstmInputParams params;
612  params.m_InputToForgetWeights = &inputToForgetWeights;
613  params.m_InputToCellWeights = &inputToCellWeights;
614  params.m_InputToOutputWeights = &inputToOutputWeights;
615  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
616  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
617  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
618  params.m_ForgetGateBias = &forgetGateBias;
619  params.m_CellBias = &cellBias;
620  params.m_OutputGateBias = &outputGateBias;
621 
622  TestLstmLayerVisitor visitor(descriptor, params);
623 
624  Network net;
625 
626  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
627  layer->Accept(visitor);
628 }

◆ BOOST_AUTO_TEST_CASE() [29/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeTanHActivation  )

Definition at line 585 of file QuantizerTest.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [30/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerBasic  )

Definition at line 630 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.

631 {
632  const char* layerName = "LstmLayer";
633  LstmDescriptor descriptor;
634  descriptor.m_ActivationFunc = 3;
635  descriptor.m_ClippingThresProj = 0.5f;
636  descriptor.m_ClippingThresCell = 0.3f;
637  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
638 
639  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
640  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
641  ConstTensor inputToForgetWeights(
642  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
643 
644  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
645  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
646  ConstTensor inputToCellWeights(
647  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
648 
649  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
650  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
651  ConstTensor inputToOutputWeights(
652  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
653 
654  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
655  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
656  ConstTensor recurrentToForgetWeights(TensorInfo(
657  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
658 
659  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
660  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
661  ConstTensor recurrentToCellWeights(TensorInfo(
662  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
663 
664  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
665  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
666  ConstTensor recurrentToOutputWeights(TensorInfo(
667  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
668 
669  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
670  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
671  ConstTensor forgetGateBias(TensorInfo(
672  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
673 
674  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
675  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
676  ConstTensor cellBias(TensorInfo(
677  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
678 
679  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
680  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
681  ConstTensor outputGateBias(TensorInfo(
682  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
683 
684  LstmInputParams params;
685  params.m_InputToForgetWeights = &inputToForgetWeights;
686  params.m_InputToCellWeights = &inputToCellWeights;
687  params.m_InputToOutputWeights = &inputToOutputWeights;
688  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
689  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
690  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
691  params.m_ForgetGateBias = &forgetGateBias;
692  params.m_CellBias = &cellBias;
693  params.m_OutputGateBias = &outputGateBias;
694 
695  TestLstmLayerVisitor visitor(descriptor, params, layerName);
696 
697  Network net;
698 
699  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
700  layer->Accept(visitor);
701 }

◆ BOOST_AUTO_TEST_CASE() [31/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeLeakyReLuActivation  )

Definition at line 680 of file QuantizerTest.cpp.

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

681 {
682  ActivationDescriptor descriptor;
683  descriptor.m_Function = ActivationFunction::LeakyReLu;
684  descriptor.m_A = 3.5f;
685  descriptor.m_B = -10.0f;
686 
687  const TensorShape shape{1U};
688  INetworkPtr network = CreateNetworkWithActivationLayer(descriptor, shape);
689 
690  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
691  TestLeakyReLuActivationQuantization validatorQAsymmU8(shape, shape);
692  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
693 
694  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
695  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
696  TestLeakyReLuActivationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
697  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
698 
699  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
700  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
701  TestLeakyReLuActivationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
702  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
703 
704  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
705  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
706  TestLeakyReLuActivationQuantization validatorQSymmS16(qSymmS16options, shape, shape);
707  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
708 }
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:85

◆ BOOST_AUTO_TEST_CASE() [32/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerCifgDisabled  )

Definition at line 703 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellToInputWeights, 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.

704 {
705  LstmDescriptor descriptor;
706  descriptor.m_ActivationFunc = 3;
707  descriptor.m_ClippingThresProj = 0.5f;
708  descriptor.m_ClippingThresCell = 0.3f;
709  descriptor.m_CifgEnabled = false; // if this is true then we DON'T need to set the OptCifgParams
710 
711  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
712  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
713  ConstTensor inputToForgetWeights(
714  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
715 
716  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
717  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
718  ConstTensor inputToCellWeights(
719  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
720 
721  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
722  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
723  ConstTensor inputToOutputWeights(
724  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
725 
726  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
727  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
728  ConstTensor recurrentToForgetWeights(TensorInfo(
729  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
730 
731  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
732  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
733  ConstTensor recurrentToCellWeights(TensorInfo(
734  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
735 
736  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
737  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
738  ConstTensor recurrentToOutputWeights(TensorInfo(
739  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
740 
741  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
742  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
743  ConstTensor forgetGateBias(TensorInfo(
744  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
745 
746  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
747  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
748  ConstTensor cellBias(TensorInfo(
749  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
750 
751  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
752  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
753  ConstTensor outputGateBias(TensorInfo(
754  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
755 
756  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
757  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
758  ConstTensor inputToInputWeights(
759  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32), inputToInputWeightsData);
760 
761  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
762  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
763  ConstTensor recurrentToInputWeights(TensorInfo(
764  4, recurrentToInputWeightsDimensions.data(), DataType::Float32), recurrentToInputWeightsData);
765 
766  std::vector<float> cellToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
767  std::vector<unsigned int> cellToInputWeightsDimensions = {1, 1, 3, 3};
768  ConstTensor cellToInputWeights(
769  TensorInfo(4, cellToInputWeightsDimensions.data(), DataType::Float32), cellToInputWeightsData);
770 
771  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
772  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
773  ConstTensor inputGateBias(
774  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32), inputGateBiasData);
775 
776  LstmInputParams params;
777  params.m_InputToForgetWeights = &inputToForgetWeights;
778  params.m_InputToCellWeights = &inputToCellWeights;
779  params.m_InputToOutputWeights = &inputToOutputWeights;
780  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
781  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
782  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
783  params.m_ForgetGateBias = &forgetGateBias;
784  params.m_CellBias = &cellBias;
785  params.m_OutputGateBias = &outputGateBias;
786 
787  params.m_InputToInputWeights = &inputToInputWeights;
788  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
789  params.m_CellToInputWeights = &cellToInputWeights;
790  params.m_InputGateBias = &inputGateBias;
791 
792  TestLstmLayerVisitor visitor(descriptor, params);
793 
794  Network net;
795 
796  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
797  layer->Accept(visitor);
798 }

◆ BOOST_AUTO_TEST_CASE() [33/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeBatchNorm  )

Definition at line 710 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(), info, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

711 {
712  class TestBatchNormalizationQuantization : public TestQuantization
713  {
714  public:
715  TestBatchNormalizationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
716  : TestQuantization(inputShape, outputShape) {}
717 
718  TestBatchNormalizationQuantization(const QuantizerOptions& options,
719  const TensorShape& inputShape,
720  const TensorShape& outputShape)
721  : TestQuantization(options, inputShape, outputShape) {}
722 
723  void VisitBatchNormalizationLayer(const IConnectableLayer* layer,
724  const BatchNormalizationDescriptor& desc,
725  const ConstTensor& mean,
726  const ConstTensor& variance,
727  const ConstTensor& beta,
728  const ConstTensor& gamma,
729  const char* name = nullptr) override
730  {
731  boost::ignore_unused(desc, name);
732  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
733 
734  // Based off default static range [-15.0f, 15.0f]
735  TestQuantizationParams(
736  info, {30.0f / g_AsymmU8QuantizationBase, 128},
737  {30.0f / g_AsymmS8QuantizationBase, 0},
738  {15.0f / g_SymmS8QuantizationBase, 0},
739  {15.0f / g_SymmS16QuantizationBase, 0});
740 
741  // Test constants
742  TestConstantQuantizationParams(mean.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
743  TestConstantQuantizationParams(variance.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
744  TestConstantQuantizationParams(beta.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
745  TestConstantQuantizationParams(gamma.GetInfo(), {3.0f / g_AsymmU8QuantizationBase, 85});
746  }
747  };
748 
749  INetworkPtr network = INetwork::Create();
750 
751  const TensorShape shape{3U};
752  TensorInfo info(shape, DataType::Float32);
753 
754  std::vector<float> meanData{-1.0f, 1.5f, 2.0f};
755  std::vector<float> varData{-1.0f, 1.5f, 2.0f};
756  std::vector<float> betaData{-1.0f, 1.5f, 2.0f};
757  std::vector<float> gammaData{-1.0f, 1.5f, 2.0f};
758 
759  ConstTensor mean(info, meanData);
760  ConstTensor var(info, varData);
761  ConstTensor beta(info, betaData);
762  ConstTensor gamma(info, gammaData);
763 
764  BatchNormalizationDescriptor desc;
765 
766  // Add the layers
767  IConnectableLayer* input0 = network->AddInputLayer(0);
768  IConnectableLayer* batchNorm = network->AddBatchNormalizationLayer(desc, mean, var, beta, gamma);
769  IConnectableLayer* output = network->AddOutputLayer(1);
770 
771  // Establish connections
772  input0->GetOutputSlot(0).Connect(batchNorm->GetInputSlot(0));
773  batchNorm->GetOutputSlot(0).Connect(output->GetInputSlot(0));
774 
775  // Set TensorInfo
776  input0->GetOutputSlot(0).SetTensorInfo(info);
777  batchNorm->GetOutputSlot(0).SetTensorInfo(info);
778 
779  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
780  TestBatchNormalizationQuantization validatorQAsymmU8(shape, shape);
781  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
782 
783  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
784  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
785  TestBatchNormalizationQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
786  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
787 
788  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
789  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
790  TestBatchNormalizationQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
791  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
792 
793  const QuantizerOptions QQsymm16Options(DataType::QSymmS16);
794  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), QQsymm16Options)->ExportNetwork();
795  TestBatchNormalizationQuantization validatorQSymmS16(QQsymm16Options, shape, shape);
796  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
797 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [34/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeDepthToSpace  )

Definition at line 799 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(), info, NHWC, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

800 {
801  class TestDepthToSpaceQuantization : public TestQuantization
802  {
803  public:
804  TestDepthToSpaceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
805  : TestQuantization(inputShape, outputShape) {}
806 
807  TestDepthToSpaceQuantization(const QuantizerOptions& options,
808  const TensorShape& inputShape,
809  const TensorShape& outputShape)
810  : TestQuantization(options, inputShape, outputShape) {}
811 
812  virtual void VisitDepthToSpaceLayer(const IConnectableLayer* layer,
813  const DepthToSpaceDescriptor& desc,
814  const char* name = nullptr)
815  {
816  boost::ignore_unused(desc, name);
817  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
818 
819  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
820  const OffsetScalePair qAsymmS8Params{ 30.0f / g_AsymmS8QuantizationBase, 0 };
821  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0 };
822  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
823 
824  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
825  }
826  };
827 
828  const TensorShape inputShape { 1, 2, 2, 4 };
829  const TensorShape outputShape{ 1, 4, 4, 1 };
830 
831  const TensorInfo inputInfo (inputShape, DataType::Float32);
832  const TensorInfo outputInfo(outputShape, DataType::Float32);
833 
834  INetworkPtr network = INetwork::Create();
835  const DepthToSpaceDescriptor descriptor(2, armnn::DataLayout::NHWC);
836 
837  IConnectableLayer* inputLayer = network->AddInputLayer(0);
838  IConnectableLayer* depthToSpaceLayer = network->AddDepthToSpaceLayer(descriptor);
839  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
840 
841  inputLayer->GetOutputSlot(0).Connect(depthToSpaceLayer->GetInputSlot(0));
842  depthToSpaceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
843 
844  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
845  depthToSpaceLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
846 
847  // test QAsymmU8 quantization
848  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
849  TestDepthToSpaceQuantization validatorQAsymmU8(inputShape, outputShape);
850  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
851 
852  // test QAsymmS8 quantization
853  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
854  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
855  TestDepthToSpaceQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, outputShape);
856  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
857 
858  // test QSymmS8 quantization
859  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
860  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
861  TestDepthToSpaceQuantization validatorQSymmS8(qSymmS8Options, inputShape, outputShape);
862  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
863 
864  // test QSymmS16 quantization
865  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
866  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
867  TestDepthToSpaceQuantization validatorQSymmS16(Qsymm16Options, inputShape, outputShape);
868  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
869 }
const float g_SymmS16QuantizationBase
SpaceToDepthDescriptor DepthToSpaceDescriptor
A DepthToSpaceDescriptor for the DepthToSpaceLayer.
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [35/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerCifgDisabled  )

Definition at line 800 of file ConstTensorLayerVisitor.cpp.

References IConnectableLayer::Accept(), Network::AddLstmLayer(), Float32, LstmDescriptor::m_ActivationFunc, LstmInputParams::m_CellBias, LstmInputParams::m_CellToInputWeights, 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.

801 {
802  const char* layerName = "LstmLayer";
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> cellToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
865  std::vector<unsigned int> cellToInputWeightsDimensions = {1, 1, 3, 3};
866  ConstTensor cellToInputWeights(
867  TensorInfo(4, cellToInputWeightsDimensions.data(), DataType::Float32), cellToInputWeightsData);
868 
869  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
870  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
871  ConstTensor inputGateBias(
872  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32), inputGateBiasData);
873 
874  LstmInputParams params;
875  params.m_InputToForgetWeights = &inputToForgetWeights;
876  params.m_InputToCellWeights = &inputToCellWeights;
877  params.m_InputToOutputWeights = &inputToOutputWeights;
878  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
879  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
880  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
881  params.m_ForgetGateBias = &forgetGateBias;
882  params.m_CellBias = &cellBias;
883  params.m_OutputGateBias = &outputGateBias;
884 
885  params.m_InputToInputWeights = &inputToInputWeights;
886  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
887  params.m_CellToInputWeights = &cellToInputWeights;
888  params.m_InputGateBias = &inputGateBias;
889 
890  TestLstmLayerVisitor visitor(descriptor, params, layerName);
891 
892  Network net;
893 
894  IConnectableLayer *const layer = net.AddLstmLayer(descriptor, params, layerName);
895  layer->Accept(visitor);
896 }

◆ BOOST_AUTO_TEST_CASE() [36/79]

armnn::BOOST_AUTO_TEST_CASE ( OverrideInputRangeEmptyNetwork  )

Definition at line 871 of file QuantizerTest.cpp.

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

872 {
873  RangeTracker ranges;
874  RangeTracker::MinMaxRange minMaxRange(-12.3f, 45.6f); // Range to use for the override
875 
876  Network network; // Empty network
877  auto inputLayers = network.GetGraph().GetInputLayers(); // Empty list of input layers
878 
879  OverrideInputRangeVisitor overrideInputRangeVisitor(ranges, 0, minMaxRange);
880  VisitLayers(inputLayers, overrideInputRangeVisitor);
881 
882  BOOST_CHECK(ranges.IsEmpty()); // Check that the map of ranges remained untouched
883 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
std::pair< float, float > MinMaxRange
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [37/79]

armnn::BOOST_AUTO_TEST_CASE ( OverrideInputRangeNoInputLayers  )

Definition at line 885 of file QuantizerTest.cpp.

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

886 {
887  RangeTracker ranges;
888  MinMaxRange minMaxRange(-12.3f, 45.6f); // Range to use for the override
889 
890  Network network;
891  network.AddAdditionLayer(); // Network with no input layers
892  auto inputLayers = network.GetGraph().GetInputLayers(); // Empty list of input layers
893 
894  OverrideInputRangeVisitor overrideInputRangeVisitor(ranges, 0, minMaxRange);
895  VisitLayers(inputLayers, overrideInputRangeVisitor);
896 
897  BOOST_CHECK(ranges.IsEmpty()); // Check that the map of ranges remained untouched
898 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
std::pair< float, float > MinMaxRange
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [38/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerPeephole  )

Definition at line 899 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.

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

◆ BOOST_AUTO_TEST_CASE() [39/79]

armnn::BOOST_AUTO_TEST_CASE ( OverrideInputRangeInputLayers  )

Definition at line 900 of file QuantizerTest.cpp.

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

901 {
902  RangeTracker ranges;
903  MinMaxRange minMaxRange(-12.3f, 45.6f); // Range to use for the override
904 
905  Network network;
906 
907  // Adding the layers
908  IConnectableLayer* input0 = network.AddInputLayer(0);
909  IConnectableLayer* input1 = network.AddInputLayer(1);
910  IConnectableLayer* addition = network.AddAdditionLayer();
911  IConnectableLayer* output = network.AddOutputLayer(2);
912 
913  // Connecting the layer
914  input0->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
915  input1->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
916  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
917 
918  // Setting the TensorInfos
919  TensorShape shape{1U};
920  TensorInfo info(shape, DataType::Float32);
921  input0->GetOutputSlot(0).SetTensorInfo(info);
922  input1->GetOutputSlot(0).SetTensorInfo(info);
923  addition->GetOutputSlot(0).SetTensorInfo(info);
924 
925  auto inputLayers = network.GetGraph().GetInputLayers(); // List of input layers
926 
927  // Trying to override the input range for the input layer with binding id 3 (does not exist in the network)
928  OverrideInputRangeVisitor overrideInputRangeVisitorLayer3(ranges, 3, minMaxRange);
929  VisitLayers(inputLayers, overrideInputRangeVisitorLayer3);
930 
931  // Check that the map of ranges remained untouched
932  BOOST_CHECK(ranges.IsEmpty());
933 
934  // Override the input range for the input layer with binding id 1
935  OverrideInputRangeVisitor overrideInputRangeVisitorLayer1(ranges, 1, minMaxRange);
936  VisitLayers(inputLayers, overrideInputRangeVisitorLayer1);
937 
938  // Check that the map of ranges has been populated
939  BOOST_CHECK(!ranges.IsEmpty());
940 
941  // Check that an entry for the input layer with binding id 0 does not exist
942  BOOST_CHECK(!ranges.HasRanges(input0->GetGuid()));
943 
944  // Check that an entry for the input layer with binding id 1 exists
945  BOOST_CHECK(ranges.HasRanges(input1->GetGuid()));
946 
947  // Check the the overridden values are what we intended to set
948  BOOST_CHECK(ranges.GetRange(input1->GetGuid(), 0) == minMaxRange);
949 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
std::pair< float, float > MinMaxRange
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [40/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerPeephole  )

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

◆ BOOST_AUTO_TEST_CASE() [41/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeFullyConnected  )

Definition at line 1036 of file QuantizerTest.cpp.

References ValidateFullyConnectedLayer().

1037 {
1039 }
void ValidateFullyConnectedLayer(const bool biasEnabled)

◆ BOOST_AUTO_TEST_CASE() [42/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeFullyConnectedBiasEnabled  )

Definition at line 1041 of file QuantizerTest.cpp.

References ValidateFullyConnectedLayer().

1042 {
1044 }
void ValidateFullyConnectedLayer(const bool biasEnabled)

◆ BOOST_AUTO_TEST_CASE() [43/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckLstmLayerProjection  )

Definition at line 1073 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.

1074 {
1075  LstmDescriptor descriptor;
1076  descriptor.m_ActivationFunc = 3;
1077  descriptor.m_ClippingThresProj = 0.5f;
1078  descriptor.m_ClippingThresCell = 0.3f;
1079  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1080  descriptor.m_ProjectionEnabled = true;
1081 
1082  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1083  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1084  ConstTensor inputToForgetWeights(
1085  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
1086 
1087  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1088  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1089  ConstTensor inputToCellWeights(
1090  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1091 
1092  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1093  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1094  ConstTensor inputToOutputWeights(
1095  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1096 
1097  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1098  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1099  ConstTensor recurrentToForgetWeights(TensorInfo(
1100  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1101 
1102  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1103  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1104  ConstTensor recurrentToCellWeights(TensorInfo(
1105  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1106 
1107  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1108  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1109  ConstTensor recurrentToOutputWeights(TensorInfo(
1110  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1111 
1112  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1113  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1114  ConstTensor forgetGateBias(TensorInfo(
1115  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1116 
1117  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1118  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1119  ConstTensor cellBias(TensorInfo(
1120  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1121 
1122  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1123  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1124  ConstTensor outputGateBias(TensorInfo(
1125  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1126 
1127  std::vector<float> projectionBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1128  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1129  ConstTensor projectionBias(
1130  TensorInfo(4, projectionBiasDimensions.data(), DataType::Float32), projectionBiasData);
1131 
1132  std::vector<float> projectionWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1133  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1134  ConstTensor projectionWeights(
1135  TensorInfo(4, projectionWeightsDimensions.data(), DataType::Float32), projectionWeightsData);
1136 
1137  LstmInputParams params;
1138  params.m_InputToForgetWeights = &inputToForgetWeights;
1139  params.m_InputToCellWeights = &inputToCellWeights;
1140  params.m_InputToOutputWeights = &inputToOutputWeights;
1141  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1142  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1143  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1144  params.m_ForgetGateBias = &forgetGateBias;
1145  params.m_CellBias = &cellBias;
1146  params.m_OutputGateBias = &outputGateBias;
1147 
1148  params.m_ProjectionWeights = &projectionWeights;
1149  params.m_ProjectionBias = &projectionBias;
1150 
1151  TestLstmLayerVisitor visitor(descriptor, params);
1152 
1153  Network net;
1154 
1155  IConnectableLayer *const layer = net.AddLstmLayer(descriptor, params);
1156  layer->Accept(visitor);
1157 }

◆ BOOST_AUTO_TEST_CASE() [44/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConvolution2d  )

Definition at line 1122 of file QuantizerTest.cpp.

References TestQuantizeConvolution2d().

1123 {
1125 }
void TestQuantizeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [45/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConvolution2dWithBiases  )

Definition at line 1127 of file QuantizerTest.cpp.

References TestQuantizeConvolution2d().

1128 {
1130 }
void TestQuantizeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [46/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedLstmLayerProjection  )

Definition at line 1159 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.

1160 {
1161  const char* layerName = "LstmLayer";
1162  LstmDescriptor descriptor;
1163  descriptor.m_ActivationFunc = 3;
1164  descriptor.m_ClippingThresProj = 0.5f;
1165  descriptor.m_ClippingThresCell = 0.3f;
1166  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1167  descriptor.m_ProjectionEnabled = true;
1168 
1169  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1170  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1171  ConstTensor inputToForgetWeights(
1172  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32), inputToForgetWeightsData);
1173 
1174  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1175  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1176  ConstTensor inputToCellWeights(
1177  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32), inputToCellWeightsData);
1178 
1179  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1180  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1181  ConstTensor inputToOutputWeights(
1182  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32), inputToOutputWeightsData);
1183 
1184  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1185  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1186  ConstTensor recurrentToForgetWeights(TensorInfo(
1187  4, recurrentToForgetWeightsDimensions.data(), DataType::Float32), recurrentToForgetWeightsData);
1188 
1189  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1190  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1191  ConstTensor recurrentToCellWeights(TensorInfo(
1192  4, recurrentToCellWeightsDimensions.data(), DataType::Float32), recurrentToCellWeightsData);
1193 
1194  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1195  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1196  ConstTensor recurrentToOutputWeights(TensorInfo(
1197  4, recurrentToOutputWeightsDimensions.data(), DataType::Float32), recurrentToOutputWeightsData);
1198 
1199  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1200  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1201  ConstTensor forgetGateBias(TensorInfo(
1202  4, forgetGateBiasDimensions.data(), DataType::Float32), forgetGateBiasData);
1203 
1204  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1205  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1206  ConstTensor cellBias(TensorInfo(
1207  4, cellBiasDimensions.data(), DataType::Float32), cellBiasData);
1208 
1209  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1210  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1211  ConstTensor outputGateBias(TensorInfo(
1212  4, outputGateBiasDimensions.data(), DataType::Float32), outputGateBiasData);
1213 
1214  std::vector<float> projectionBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1215  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1216  ConstTensor projectionBias(
1217  TensorInfo(4, projectionBiasDimensions.data(), DataType::Float32), projectionBiasData);
1218 
1219  std::vector<float> projectionWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1220  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1221  ConstTensor projectionWeights(
1222  TensorInfo(4, projectionWeightsDimensions.data(), DataType::Float32), projectionWeightsData);
1223 
1224  LstmInputParams params;
1225  params.m_InputToForgetWeights = &inputToForgetWeights;
1226  params.m_InputToCellWeights = &inputToCellWeights;
1227  params.m_InputToOutputWeights = &inputToOutputWeights;
1228  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1229  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1230  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1231  params.m_ForgetGateBias = &forgetGateBias;
1232  params.m_CellBias = &cellBias;
1233  params.m_OutputGateBias = &outputGateBias;
1234 
1235  params.m_ProjectionWeights = &projectionWeights;
1236  params.m_ProjectionBias = &projectionBias;
1237 
1238  TestLstmLayerVisitor visitor(descriptor, params, layerName);
1239 
1240  Network net;
1241 
1242  IConnectableLayer *const layer = net.AddLstmLayer(descriptor, params, layerName);
1243  layer->Accept(visitor);
1244 }

◆ BOOST_AUTO_TEST_CASE() [47/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeDepthwiseConvolution2d  )

Definition at line 1208 of file QuantizerTest.cpp.

References TestQuantizeDepthwiseConvolution2d().

1209 {
1211 }
void TestQuantizeDepthwiseConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [48/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeDepthwiseConvolution2dWithBiases  )

Definition at line 1213 of file QuantizerTest.cpp.

References TestQuantizeDepthwiseConvolution2d().

1214 {
1216 }
void TestQuantizeDepthwiseConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [49/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeInstanceNormalization  )

Definition at line 1218 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(), info, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1219 {
1220  class TestInstanceNormalizationQuantization : public TestQuantization
1221  {
1222  public:
1223  TestInstanceNormalizationQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1224  : TestQuantization(inputShape, outputShape) {}
1225 
1226  TestInstanceNormalizationQuantization(const QuantizerOptions& options,
1227  const TensorShape& inputShape,
1228  const TensorShape& outputShape)
1229  : TestQuantization(options, inputShape, outputShape) {}
1230 
1231  virtual void VisitInstanceNormalizationLayer(const IConnectableLayer* layer,
1232  const InstanceNormalizationDescriptor& descriptor,
1233  const char* name = nullptr)
1234  {
1235  boost::ignore_unused(descriptor, name);
1236  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
1237 
1238  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
1239  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
1240  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
1241  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
1242 
1243  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
1244  }
1245  };
1246 
1247  const TensorShape tensorShape{ 1, 4, 4, 1 };
1248  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1249 
1250  INetworkPtr network = INetwork::Create();
1251 
1252  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1253  IConnectableLayer* instanceNormLayer = network->AddInstanceNormalizationLayer(InstanceNormalizationDescriptor());
1254  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1255 
1256  inputLayer->GetOutputSlot(0).Connect(instanceNormLayer->GetInputSlot(0));
1257  instanceNormLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1258 
1259  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1260  instanceNormLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1261 
1262  // test QAsymmU8 quantization
1263  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1264  TestInstanceNormalizationQuantization validatorQAsymmU8(tensorShape, tensorShape);
1265  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1266 
1267  //test QAsymmS8 quantization
1268  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1269  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1270  TestInstanceNormalizationQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
1271  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1272 
1273  // test QSymmS8 quantization
1274  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1275  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1276  TestInstanceNormalizationQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
1277  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1278 
1279  // test QSymmS16 quantization
1280  const QuantizerOptions qSymmS16Options(DataType::QSymmS16);
1281  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16Options)->ExportNetwork();
1282  TestInstanceNormalizationQuantization validatorQSymmS16(qSymmS16Options, tensorShape, tensorShape);
1283  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1284 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [50/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckQuantizedLstmLayer  )

Definition at line 1246 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, QAsymmU8, and Signed32.

1247 {
1248  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1249  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1250  ConstTensor inputToInputWeights(
1251  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QAsymmU8), inputToInputWeightsData);
1252 
1253  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1254  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1255  ConstTensor inputToForgetWeights(
1256  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QAsymmU8), inputToForgetWeightsData);
1257 
1258  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1259  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1260  ConstTensor inputToCellWeights(
1261  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QAsymmU8), inputToCellWeightsData);
1262 
1263  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1264  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1265  ConstTensor inputToOutputWeights(
1266  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QAsymmU8), inputToOutputWeightsData);
1267 
1268 
1269  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1270  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1271  ConstTensor recurrentToInputWeights(TensorInfo(
1272  4, recurrentToInputWeightsDimensions.data(), DataType::QAsymmU8), recurrentToInputWeightsData);
1273 
1274  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1275  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1276  ConstTensor recurrentToForgetWeights(TensorInfo(
1277  4, recurrentToForgetWeightsDimensions.data(), DataType::QAsymmU8), recurrentToForgetWeightsData);
1278 
1279  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1280  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1281  ConstTensor recurrentToCellWeights(TensorInfo(
1282  4, recurrentToCellWeightsDimensions.data(), DataType::QAsymmU8), recurrentToCellWeightsData);
1283 
1284  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1285  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1286  ConstTensor recurrentToOutputWeights(TensorInfo(
1287  4, recurrentToOutputWeightsDimensions.data(), DataType::QAsymmU8), recurrentToOutputWeightsData);
1288 
1289 
1290  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1291  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1292  ConstTensor inputGateBias(
1293  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
1294 
1295  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1296  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1297  ConstTensor forgetGateBias(TensorInfo(
1298  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1299 
1300  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1301  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1302  ConstTensor cellBias(TensorInfo(
1303  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1304 
1305  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1306  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1307  ConstTensor outputGateBias(TensorInfo(
1308  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1309 
1310  QuantizedLstmInputParams params;
1311 
1312  params.m_InputToInputWeights = &inputToInputWeights;
1313  params.m_InputToForgetWeights = &inputToForgetWeights;
1314  params.m_InputToCellWeights = &inputToCellWeights;
1315  params.m_InputToOutputWeights = &inputToOutputWeights;
1316 
1317  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1318  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1319  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1320  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1321 
1322  params.m_InputGateBias = &inputGateBias;
1323  params.m_ForgetGateBias = &forgetGateBias;
1324  params.m_CellBias = &cellBias;
1325  params.m_OutputGateBias = &outputGateBias;
1326 
1327  TestQuantizedLstmLayerVisitor visitor(params);
1328 
1329  Network net;
1330 
1331  IConnectableLayer* const layer = net.AddQuantizedLstmLayer(params);
1332  layer->Accept(visitor);
1333 }

◆ BOOST_AUTO_TEST_CASE() [51/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeLogSoftmax  )

Definition at line 1286 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(), info, SoftmaxDescriptor::m_Beta, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1287 {
1288  class TestLogSoftmaxQuantization : public TestQuantization
1289  {
1290  public:
1291  TestLogSoftmaxQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1292  : TestQuantization(inputShape, outputShape) {}
1293 
1294  TestLogSoftmaxQuantization(const QuantizerOptions& options,
1295  const TensorShape& inputShape,
1296  const TensorShape& outputShape)
1297  : TestQuantization(options, inputShape, outputShape) {}
1298 
1299  void VisitLogSoftmaxLayer(const IConnectableLayer* layer,
1300  const SoftmaxDescriptor& descriptor,
1301  const char* name = nullptr) override
1302  {
1303  boost::ignore_unused(descriptor, name);
1304  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1305 
1306  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
1307  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
1308  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
1309  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
1310 
1311  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
1312  }
1313  };
1314 
1315  const TensorShape tensorShape{ 1U };
1316  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1317 
1318  INetworkPtr network = INetwork::Create();
1319 
1320  LogSoftmaxDescriptor descriptor;
1321  descriptor.m_Beta = 1.0f;
1322 
1323  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1324  IConnectableLayer* logSoftmaxLayer = network->AddLogSoftmaxLayer(descriptor);
1325  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1326 
1327  inputLayer->GetOutputSlot(0).Connect(logSoftmaxLayer->GetInputSlot(0));
1328  logSoftmaxLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1329 
1330  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1331  logSoftmaxLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1332 
1333  // test QAsymmU8 quantization
1334  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1335  TestLogSoftmaxQuantization validatorQAsymmU8(tensorShape, tensorShape);
1336  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1337 
1338  // test QAsymmS8 quantization
1339  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1340  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1341  TestLogSoftmaxQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
1342  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1343 
1344  // test QSymmS8 quantization
1345  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1346  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1347  TestLogSoftmaxQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
1348  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1349 
1350  // test QuantisedSymmS16 quantization
1351  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1352  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1353  TestLogSoftmaxQuantization validatorQSymmS16(qSymmS16options, tensorShape, tensorShape);
1354  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1355 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
float m_Beta
Exponentiation value.
SoftmaxDescriptor LogSoftmaxDescriptor
A LogSoftmaxDescriptor for the LogSoftmaxLayer.
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [52/79]

armnn::BOOST_AUTO_TEST_CASE ( CheckNamedQuantizedLstmLayer  )

Definition at line 1335 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.

1336 {
1337  const char* layerName = "LstmLayer";
1338  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1339  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1340  ConstTensor inputToInputWeights(
1341  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QAsymmU8), inputToInputWeightsData);
1342 
1343  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1344  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1345  ConstTensor inputToForgetWeights(
1346  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QAsymmU8), inputToForgetWeightsData);
1347 
1348  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1349  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1350  ConstTensor inputToCellWeights(
1351  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QAsymmU8), inputToCellWeightsData);
1352 
1353  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1354  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1355  ConstTensor inputToOutputWeights(
1356  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QAsymmU8), inputToOutputWeightsData);
1357 
1358 
1359  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1360  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1361  ConstTensor recurrentToInputWeights(TensorInfo(
1362  4, recurrentToInputWeightsDimensions.data(), DataType::QAsymmU8), recurrentToInputWeightsData);
1363 
1364  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1365  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1366  ConstTensor recurrentToForgetWeights(TensorInfo(
1367  4, recurrentToForgetWeightsDimensions.data(), DataType::QAsymmU8), recurrentToForgetWeightsData);
1368 
1369  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1370  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1371  ConstTensor recurrentToCellWeights(TensorInfo(
1372  4, recurrentToCellWeightsDimensions.data(), DataType::QAsymmU8), recurrentToCellWeightsData);
1373 
1374  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1375  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1376  ConstTensor recurrentToOutputWeights(TensorInfo(
1377  4, recurrentToOutputWeightsDimensions.data(), DataType::QAsymmU8), recurrentToOutputWeightsData);
1378 
1379 
1380  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1381  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1382  ConstTensor inputGateBias(
1383  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32), inputGateBiasData);
1384 
1385  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1386  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1387  ConstTensor forgetGateBias(TensorInfo(
1388  4, forgetGateBiasDimensions.data(), DataType::Signed32), forgetGateBiasData);
1389 
1390  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1391  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1392  ConstTensor cellBias(TensorInfo(
1393  4, cellBiasDimensions.data(), DataType::Signed32), cellBiasData);
1394 
1395  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1396  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1397  ConstTensor outputGateBias(TensorInfo(
1398  4, outputGateBiasDimensions.data(), DataType::Signed32), outputGateBiasData);
1399 
1400  QuantizedLstmInputParams params;
1401 
1402  params.m_InputToInputWeights = &inputToInputWeights;
1403  params.m_InputToForgetWeights = &inputToForgetWeights;
1404  params.m_InputToCellWeights = &inputToCellWeights;
1405  params.m_InputToOutputWeights = &inputToOutputWeights;
1406 
1407  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1408  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1409  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1410  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1411 
1412  params.m_InputGateBias = &inputGateBias;
1413  params.m_ForgetGateBias = &forgetGateBias;
1414  params.m_CellBias = &cellBias;
1415  params.m_OutputGateBias = &outputGateBias;
1416 
1417  TestQuantizedLstmLayerVisitor visitor(params, layerName);
1418 
1419  Network net;
1420 
1421  IConnectableLayer* const layer = net.AddQuantizedLstmLayer(params, layerName);
1422  layer->Accept(visitor);
1423 }

◆ BOOST_AUTO_TEST_CASE() [53/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSoftmax  )

Definition at line 1378 of file QuantizerTest.cpp.

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

1379 {
1380  class TestSoftmaxQuantization : public TestQuantization
1381  {
1382  public:
1383  TestSoftmaxQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1384  : TestQuantization(inputShape, outputShape) {}
1385 
1386  TestSoftmaxQuantization(const QuantizerOptions& options,
1387  const TensorShape& inputShape,
1388  const TensorShape& outputShape)
1389  : TestQuantization(options, inputShape, outputShape) {}
1390 
1391  void VisitSoftmaxLayer(const IConnectableLayer* layer,
1392  const SoftmaxDescriptor& descriptor,
1393  const char* name = nullptr) override
1394  {
1395  boost::ignore_unused(descriptor, name);
1396  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1397 
1398  // Based off default static range [0.0f, 1.0f]
1399  TestQuantizationParams(info, {1.0f / g_AsymmU8QuantizationBase, 0},
1400  {1.0f / g_AsymmS8QuantizationBase, -128},
1401  {1.0f / g_SymmS8QuantizationBase, 0},
1402  {1.0f / g_SymmS16QuantizationBase, 0});
1403  }
1404  };
1405 
1406  SoftmaxDescriptor descriptor;
1407  descriptor.m_Beta = 1.0f;
1408 
1409  const TensorShape shape{1U};
1410  INetworkPtr network = CreateNetworkWithSoftmaxLayer(descriptor, shape);
1411 
1412  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1413  TestSoftmaxQuantization validatorQAsymmU8(shape, shape);
1414  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1415 
1416  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1417  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1418  TestSoftmaxQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1419  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1420 
1421  // test QSymmS8 quantization
1422  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1423  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1424  TestSoftmaxQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1425  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1426 
1427  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1428  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1429  TestSoftmaxQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1430  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1431 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
INetworkPtr CreateNetworkWithSoftmaxLayer(const SoftmaxDescriptor &descriptor, const TensorShape &shape)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [54/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeStandIn  )

Definition at line 1433 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().

1434 {
1435  const TensorShape tensorShape{ 1U };
1436  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1437 
1438  INetworkPtr network = INetwork::Create();
1439 
1440  StandInDescriptor descriptor;
1441  descriptor.m_NumInputs = 1;
1442  descriptor.m_NumOutputs = 1;
1443 
1444  IConnectableLayer* inputLayer = network->AddInputLayer(0);
1445  IConnectableLayer* standInLayer = network->AddStandInLayer(descriptor);
1446  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1447 
1448  inputLayer->GetOutputSlot(0).Connect(standInLayer->GetInputSlot(0));
1449  standInLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1450 
1451  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1452  standInLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1453 
1454  // test QAsymmU8 quantization
1455  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get())->ExportNetwork(),
1457 
1458  // test QAsymmS8 quantization
1459  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1460  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork(),
1462 
1463  // test QuantisedSymmS16 quantization
1464  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1465  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork(),
1467 
1468  // test QuantisedSymmS16 quantization
1469  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1470  BOOST_CHECK_THROW(INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork(),
1472 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85

◆ BOOST_AUTO_TEST_CASE() [55/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizePermute  )

Definition at line 1511 of file QuantizerTest.cpp.

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

1512 {
1513  class TestPermuteQuantization : public TestLeakyReLuActivationQuantization
1514  {
1515  public:
1516  TestPermuteQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1517  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
1518 
1519  TestPermuteQuantization(const QuantizerOptions& options,
1520  const TensorShape& inputShape,
1521  const TensorShape& outputShape)
1522  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
1523 
1524  void VisitPermuteLayer(const IConnectableLayer* layer,
1525  const PermuteDescriptor& desc,
1526  const char* name = nullptr) override
1527  {
1528  boost::ignore_unused(desc, name);
1529  CheckForwardedQuantizationSettings(layer);
1530  }
1531  };
1532 
1533  INetworkPtr network = INetwork::Create();
1534 
1535  const TensorShape shape{1U};
1536  TensorInfo info(shape, DataType::Float32);
1537 
1538  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
1539 
1540  // Add the layer under test
1541  PermuteDescriptor desc;
1542  IConnectableLayer* permute = network->AddPermuteLayer(desc);
1543 
1544  CompleteLeakyReluNetwork(network.get(), activation, permute, info);
1545 
1546  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1547  TestPermuteQuantization validatorQAsymmU8(shape, shape);
1548  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1549 
1550  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1551  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1552  TestPermuteQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1553  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1554 
1555  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1556  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1557  TestPermuteQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1558  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1559 
1560  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1561  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1562  TestPermuteQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1563  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1564 }
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [56/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSpaceToBatch  )

Definition at line 1566 of file QuantizerTest.cpp.

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

1567 {
1568  class TestSpaceToBatchQuantization : public TestLeakyReLuActivationQuantization
1569  {
1570  public:
1571  TestSpaceToBatchQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1572  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
1573 
1574  TestSpaceToBatchQuantization(const QuantizerOptions& options,
1575  const TensorShape& inputShape,
1576  const TensorShape& outputShape)
1577  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
1578 
1579  void VisitSpaceToBatchNdLayer(const IConnectableLayer* layer,
1580  const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor,
1581  const char* name = nullptr) override
1582  {
1583  boost::ignore_unused(spaceToBatchNdDescriptor, name);
1584  CheckForwardedQuantizationSettings(layer);
1585  }
1586  };
1587 
1588  INetworkPtr network = INetwork::Create();
1589 
1590  const TensorShape shape{1U};
1591  TensorInfo info(shape, DataType::Float32);
1592 
1593  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
1594 
1595  // Add the layer under test
1596  SpaceToBatchNdDescriptor descriptor;
1597  IConnectableLayer* spaceToBatch = network->AddSpaceToBatchNdLayer(descriptor);
1598 
1599  CompleteLeakyReluNetwork(network.get(), activation, spaceToBatch, info);
1600 
1601  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1602  TestSpaceToBatchQuantization validatorQAsymmU8(shape, shape);
1603  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1604 
1605  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1606  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1607  TestSpaceToBatchQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1608  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1609 
1610  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1611  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1612  TestSpaceToBatchQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1613  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1614 
1615  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1616  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1617  TestSpaceToBatchQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1618  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1619 }
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [57/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSpaceToDepth  )

Definition at line 1621 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, options, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

1622 {
1623  class TestSpaceToDepthQuantization : public TestLeakyReLuActivationQuantization
1624  {
1625  public:
1626  TestSpaceToDepthQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1627  : TestLeakyReLuActivationQuantization(inputShape, outputShape)
1628  {}
1629 
1630  TestSpaceToDepthQuantization(const QuantizerOptions& options,
1631  const TensorShape& inputShape,
1632  const TensorShape& outputShape)
1633  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape)
1634  {}
1635 
1636  void VisitSpaceToDepthLayer(const IConnectableLayer* layer,
1637  const SpaceToDepthDescriptor&,
1638  const char* = nullptr) override
1639  {
1640  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1641  TestQuantizationParams(info,
1642  { 30.0f / g_AsymmU8QuantizationBase, 128 },
1643  { 30.0f / g_AsymmS8QuantizationBase, 0 },
1644  { 15.0f / g_SymmS8QuantizationBase, 0 },
1645  { 15.0f / g_SymmS16QuantizationBase, 0 });
1646  }
1647  };
1648 
1649  INetworkPtr network = INetwork::Create();
1650 
1651  const TensorShape shape{ 1u };
1652  TensorInfo info(shape, DataType::Float32);
1653 
1654  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
1655  IConnectableLayer* spaceToDepth = network->AddSpaceToDepthLayer(SpaceToDepthDescriptor());
1656 
1657  CompleteLeakyReluNetwork(network.get(), activation, spaceToDepth, info);
1658 
1659  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1660  TestSpaceToDepthQuantization validatorQAsymmU8(shape, shape);
1661  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1662 
1663  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1664  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1665  TestSpaceToDepthQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1666  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1667 
1668  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1669  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1670  TestSpaceToDepthQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1671  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1672 
1673  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1674  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1675  TestSpaceToDepthQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1676  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1677 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [58/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizePooling2d  )

Definition at line 1679 of file QuantizerTest.cpp.

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

1680 {
1681  class TestPooling2dQuantization : public TestLeakyReLuActivationQuantization
1682  {
1683  public:
1684  TestPooling2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1685  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
1686 
1687  TestPooling2dQuantization(const QuantizerOptions& options,
1688  const TensorShape& inputShape,
1689  const TensorShape& outputShape)
1690  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
1691 
1692  void VisitPooling2dLayer(const IConnectableLayer* layer,
1693  const Pooling2dDescriptor& desc,
1694  const char* name = nullptr) override
1695  {
1696  boost::ignore_unused(desc, name);
1697  CheckForwardedQuantizationSettings(layer);
1698  }
1699  };
1700 
1701  auto network = INetwork::Create();
1702 
1703  TensorShape shape{1U};
1704  TensorInfo info(shape, DataType::Float32);
1705 
1706  Pooling2dDescriptor desc;
1707  ActivationDescriptor activationDescriptor;
1708  activationDescriptor.m_Function = ActivationFunction::LeakyReLu;
1709  activationDescriptor.m_A = 3.5f;
1710  activationDescriptor.m_B = -10.0f;
1711 
1712  // Add the layers
1713  IConnectableLayer* input0 = network->AddInputLayer(0);
1714  IConnectableLayer* activation = network->AddActivationLayer(activationDescriptor);
1715  IConnectableLayer* pooling2d = network->AddPooling2dLayer(desc);
1716  IConnectableLayer* output = network->AddOutputLayer(3);
1717 
1718  // Establish connections
1719  input0->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
1720  activation->GetOutputSlot(0).Connect(pooling2d->GetInputSlot(0));
1721  pooling2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1722 
1723  // Set TensorInfo
1724  input0->GetOutputSlot(0).SetTensorInfo(info);
1725  activation->GetOutputSlot(0).SetTensorInfo(info);
1726  pooling2d->GetOutputSlot(0).SetTensorInfo(info);
1727 
1728  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1729  TestPooling2dQuantization validatorQAsymmU8(shape, shape);
1730  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1731 
1732  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1733  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1734  TestPooling2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1735  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1736 
1737  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1738  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1739  TestPooling2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1740  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1741 
1742  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1743  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1744  TestPooling2dQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1745  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1746 }
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [59/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConstant  )

Definition at line 1748 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(), info, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1749 {
1750  class TestConstantQuantization : public TestAdditionQuantization
1751  {
1752  public:
1753  TestConstantQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1754  : TestAdditionQuantization(inputShape, outputShape) {}
1755 
1756  TestConstantQuantization(const QuantizerOptions& options,
1757  const TensorShape& inputShape,
1758  const TensorShape& outputShape)
1759  : TestAdditionQuantization(options, inputShape, outputShape) {}
1760 
1761  void VisitConstantLayer(const IConnectableLayer* layer,
1762  const ConstTensor& input,
1763  const char* name = nullptr) override
1764  {
1765  boost::ignore_unused(input, name);
1766  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1767 
1768  // Based off the range of values in the const tensor used for the test: [-2.0f, 6.0f]
1769  TestQuantizationParams(info, {8.0f / g_AsymmU8QuantizationBase, 64},
1770  {8.0f / g_AsymmS8QuantizationBase, -64},
1771  {6.0f / g_SymmS8QuantizationBase, 0},
1772  {6.0f / g_SymmS16QuantizationBase, 0});
1773  }
1774  };
1775 
1776  INetworkPtr network = INetwork::Create();
1777 
1778  // Constant layer data
1779  std::vector<float> data = {-2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
1780  const TensorShape shape{1U, 1U, 3U, 3U};
1781  TensorInfo tensorInfo(shape, DataType::Float32);
1782  ConstTensor constantTensor(tensorInfo, data);
1783 
1784  // Add the layers
1785  IConnectableLayer* input = network->AddInputLayer(0);
1786  IConnectableLayer* constant = network->AddConstantLayer(constantTensor);
1787  IConnectableLayer* addition = network->AddAdditionLayer();
1788  IConnectableLayer* output = network->AddOutputLayer(1);
1789 
1790  // Establish connections
1791  input->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
1792  constant->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
1793  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1794 
1795  // Set TensorInfo in the remaining layers
1796  input->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1797  addition->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1798  constant->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1799 
1800  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1801  TestConstantQuantization validatorQAsymmU8(shape, shape);
1802  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1803 
1804  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1805  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1806  TestConstantQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1807  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1808 
1809  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1810  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1811  TestConstantQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1812  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1813 
1814  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1815  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1816  TestConstantQuantization validatorQSymmS16(qSymmS16options, shape, shape);
1817  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1818 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [60/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeArgMinMax  )

Definition at line 1820 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(), ArgMinMaxDescriptor::m_Function, Max, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1821 {
1822  class TestArgMinMaxQuantization : public TestQuantization
1823  {
1824  public:
1825  TestArgMinMaxQuantization(const TensorShape& inputShape, const TensorShape& outputShape) :
1826  TestQuantization(inputShape, outputShape) {}
1827 
1828  TestArgMinMaxQuantization(const QuantizerOptions& options,
1829  const TensorShape& inputShape,
1830  const TensorShape& outputShape) :
1831  TestQuantization(options, inputShape, outputShape)
1832  {}
1833 
1834  void VisitInputLayer(const IConnectableLayer* layer,
1835  LayerBindingId id,
1836  const char* name = nullptr) override
1837  {
1838  boost::ignore_unused(layer, id, name);
1839  }
1840 
1841  void VisitOutputLayer(const IConnectableLayer* layer,
1842  LayerBindingId id,
1843  const char* name = nullptr) override
1844  {
1845  boost::ignore_unused(layer, id, name);
1846  }
1847  void VisitArgMinMaxLayer(const IConnectableLayer* layer,
1848  const ArgMinMaxDescriptor& argMinMaxDescriptor,
1849  const char* name = nullptr) override
1850  {
1851  boost::ignore_unused(argMinMaxDescriptor, name);
1852  TensorInfo outputInfo = layer->GetOutputSlot(0).GetTensorInfo();
1853 
1854  TestQuantizationParams(outputInfo,
1855  { 30.0f / g_AsymmU8QuantizationBase, 128 },
1856  { 30.0f / g_AsymmS8QuantizationBase, 0},
1857  { 15.0f / g_SymmS8QuantizationBase, 0},
1858  { 15.0f / g_SymmS16QuantizationBase, 0 });
1859  }
1860  };
1861 
1862  INetworkPtr network = INetwork::Create();
1863 
1864  const TensorShape inputShape{ 1, 1, 1, 5 };
1865  const TensorShape outputShape{ 1, 1, 1 };
1866 
1867  TensorInfo inputInfo(inputShape, DataType::Float32);
1868  TensorInfo outputInfo(outputShape, DataType::Float32);
1869 
1870  // Add the input layers
1871  IConnectableLayer* input = network->AddInputLayer(0);
1872 
1873  // Add the layer under test
1874  ArgMinMaxDescriptor argMinMaxDescriptor;
1875  argMinMaxDescriptor.m_Function = ArgMinMaxFunction::Max;
1876  IConnectableLayer* argMinMaxLayer = network->AddArgMinMaxLayer(argMinMaxDescriptor);
1877 
1878  // Add the output layers
1879  IConnectableLayer* output = network->AddOutputLayer(1);
1880 
1881  // Establish connections
1882  input->GetOutputSlot(0).Connect(argMinMaxLayer->GetInputSlot(0));
1883  argMinMaxLayer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1884 
1885  // Set tensor info
1886  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
1887  argMinMaxLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1888 
1889  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1890  TestArgMinMaxQuantization validatorQAsymmU8(inputShape, outputShape);
1891  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1892 
1893  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1894  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1895  TestArgMinMaxQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, outputShape);
1896  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1897 
1898  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1899  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1900  TestArgMinMaxQuantization validatorQSymmS8(qSymmS8Options, inputShape, outputShape);
1901  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1902 
1903  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1904  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1905  TestArgMinMaxQuantization validatorQSymmS16(qSymmS16options, inputShape, outputShape);
1906  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1907 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:168

◆ BOOST_AUTO_TEST_CASE() [61/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeComparison  )

Definition at line 1909 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(), info, LessOrEqual, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1910 {
1911  class TestComparisonQuantization : public TestQuantization
1912  {
1913  public:
1914  TestComparisonQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1915  : TestQuantization(inputShape, outputShape) {}
1916 
1917  TestComparisonQuantization(const QuantizerOptions& options,
1918  const TensorShape& inputShape,
1919  const TensorShape& outputShape)
1920  : TestQuantization(options, inputShape, outputShape) {}
1921 
1922  void VisitComparisonLayer(const IConnectableLayer* layer,
1923  const ComparisonDescriptor& descriptor,
1924  const char* name = nullptr) override
1925  {
1926  boost::ignore_unused(descriptor, name);
1927  TensorInfo info = layer->GetOutputSlot(0).GetTensorInfo();
1928 
1929  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
1930  const OffsetScalePair qAsymmS8Params { 30.0f / g_AsymmS8QuantizationBase, 0};
1931  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0};
1932  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
1933 
1934  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
1935  }
1936  };
1937 
1938  const TensorShape tensorShape{ 1u };
1939  const TensorInfo tensorInfo(tensorShape, DataType::Float32);
1940 
1941  INetworkPtr network = INetwork::Create();
1942  ComparisonDescriptor descriptor(ComparisonOperation::LessOrEqual);
1943 
1944  IConnectableLayer* inputLayer0 = network->AddInputLayer(0);
1945  IConnectableLayer* inputLayer1 = network->AddInputLayer(1);
1946  IConnectableLayer* comparisonLayer = network->AddComparisonLayer(descriptor);
1947  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
1948 
1949  inputLayer0->GetOutputSlot(0).Connect(comparisonLayer->GetInputSlot(0));
1950  inputLayer1->GetOutputSlot(0).Connect(comparisonLayer->GetInputSlot(1));
1951  comparisonLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1952 
1953  inputLayer0->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1954  inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1955  comparisonLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
1956 
1957  // test QAsymmU8 quantization
1958  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1959  TestComparisonQuantization validatorQAsymmU8(tensorShape, tensorShape);
1960  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1961 
1962  // test QAsymmS8 quantization
1963  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1964  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1965  TestComparisonQuantization validatorQAsymmS8(qAsymmS8Options, tensorShape, tensorShape);
1966  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1967 
1968  // test QSymmS8 quantization
1969  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1970  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1971  TestComparisonQuantization validatorQSymmS8(qSymmS8Options, tensorShape, tensorShape);
1972  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1973 
1974  // test QuantisedSymmS16 quantization
1975  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
1976  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
1977  TestComparisonQuantization validatorQSymmS16(qSymmS16options, tensorShape, tensorShape);
1978  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1979 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [62/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeConcat  )

Definition at line 1981 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(), info, options, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

1982 {
1983  class TestConcatQuantization : public TestQuantization
1984  {
1985  public:
1986  TestConcatQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1987  : TestQuantization(inputShape, outputShape) {}
1988 
1989  TestConcatQuantization(const QuantizerOptions& options,
1990  const TensorShape& inputShape,
1991  const TensorShape& outputShape)
1992  : TestQuantization(options, inputShape, outputShape) {}
1993 
1994  void VisitInputLayer(const IConnectableLayer* layer,
1995  LayerBindingId id,
1996  const char* name = nullptr) override
1997  {
1998  boost::ignore_unused(layer, id, name);
1999  }
2000  void VisitOutputLayer(const IConnectableLayer* layer,
2001  LayerBindingId id,
2002  const char* name = nullptr) override
2003  {
2004  boost::ignore_unused(layer, id, name);
2005  }
2006  void VisitConcatLayer(const IConnectableLayer* layer,
2007  const OriginsDescriptor& originsDescriptor,
2008  const char* name = nullptr) override
2009  {
2010  boost::ignore_unused(originsDescriptor, name);
2011  TensorInfo outputInfo = layer->GetOutputSlot(0).GetTensorInfo();
2012  TestQuantizationParams(
2013  outputInfo, {60.8f / g_AsymmU8QuantizationBase, 65},
2014  {60.8f / g_SymmS8QuantizationBase, -63},
2015  {45.3f / g_SymmS8QuantizationBase, 0},
2016  {45.3f / g_SymmS16QuantizationBase, 0});
2017 
2018  TensorInfo inputInfo0 = layer->GetInputSlot(0).GetConnection()->GetTensorInfo();
2019  TensorInfo inputInfo1 = layer->GetInputSlot(1).GetConnection()->GetTensorInfo();
2020  TensorInfo inputInfo2 = layer->GetInputSlot(2).GetConnection()->GetTensorInfo();
2021 
2022  TestDifferentQuantizationScale(inputInfo0, inputInfo1);
2023  TestDifferentQuantizationScale(inputInfo0, inputInfo2);
2024  TestDifferentQuantizationScale(inputInfo1, inputInfo2);
2025  TestDifferentQuantizationScale(inputInfo0, outputInfo);
2026  }
2027  };
2028 
2029  INetworkPtr network = INetwork::Create();
2030 
2031  IConnectableLayer* input0 = network->AddInputLayer(0);
2032  IConnectableLayer* input1 = network->AddInputLayer(1);
2033  IConnectableLayer* input2 = network->AddInputLayer(2);
2034 
2035  OriginsDescriptor descriptor(3, 1);
2036  IConnectableLayer* concatLayer = network->AddConcatLayer(descriptor);
2037 
2038  IConnectableLayer* output0 = network->AddOutputLayer(3);
2039 
2040  // Establish connections
2041  input0->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(0));
2042  input1->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(1));
2043  input2->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(2));
2044  concatLayer->GetOutputSlot(0).Connect(output0->GetInputSlot(0));
2045 
2046  // Set TensorInfo
2047  const TensorShape shape{1U};
2048  TensorInfo info(shape, DataType::Float32);
2049 
2050  input0->GetOutputSlot(0).SetTensorInfo(info);
2051  input1->GetOutputSlot(0).SetTensorInfo(info);
2052  input2->GetOutputSlot(0).SetTensorInfo(info);
2053  concatLayer->GetOutputSlot(0).SetTensorInfo(info);
2054 
2055  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2056  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2057  INetworkQuantizerPtr quantizerPtrQAsymmU8 = INetworkQuantizer::Create(network.get());
2058  INetworkQuantizerPtr quantizerPtrQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options);
2059  INetworkQuantizerPtr quantizerPtrQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options);
2060  // Override the input ranges
2061  float min = -15.5f;
2062  float max = 45.3f;
2063 
2064  quantizerPtrQAsymmU8->OverrideInputRange(0, (min + 2.1f), (max - 3.2f));
2065  quantizerPtrQAsymmU8->OverrideInputRange(1, (min + 6.7f), max);
2066  quantizerPtrQAsymmU8->OverrideInputRange(2, min, (max - 7.8f));
2067 
2068  quantizerPtrQSymmS8->OverrideInputRange(0, (min + 2.1f), (max - 3.2f));
2069  quantizerPtrQSymmS8->OverrideInputRange(1, (min + 6.7f), max);
2070  quantizerPtrQSymmS8->OverrideInputRange(2, min, (max - 7.8f));
2071 
2072  quantizerPtrQSymmS16->OverrideInputRange(0, (min + 2.1f), (max - 3.2f));
2073  quantizerPtrQSymmS16->OverrideInputRange(1, (min + 6.7f), max);
2074  quantizerPtrQSymmS16->OverrideInputRange(2, min, (max - 7.8f));
2075 
2076  INetworkPtr quantizedNetworkQAsymmU8 = quantizerPtrQAsymmU8->ExportNetwork();
2077  TestConcatQuantization validatorQAsymmU8(shape, shape);
2078  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2079 
2080  INetworkPtr quantizedNetworkQSymmS8 = quantizerPtrQSymmS8->ExportNetwork();
2081  TestConcatQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2082  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2083 
2084  INetworkPtr quantizedNetworkQSymmS16 = quantizerPtrQSymmS16->ExportNetwork();
2085  TestConcatQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2086  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2087 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
std::unique_ptr< class INetworkQuantizer, void(*)(INetworkQuantizer *quantizer)> INetworkQuantizerPtr
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmU8QuantizationBase
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:168

◆ BOOST_AUTO_TEST_CASE() [63/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeReshape  )

Definition at line 2089 of file QuantizerTest.cpp.

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

2090 {
2091  class TestReshapeQuantization : public TestLeakyReLuActivationQuantization
2092  {
2093  public:
2094  TestReshapeQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2095  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2096 
2097  TestReshapeQuantization(const QuantizerOptions& options,
2098  const TensorShape& inputShape,
2099  const TensorShape& outputShape)
2100  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2101 
2102  virtual void VisitReshapeLayer(const IConnectableLayer* layer,
2103  const ReshapeDescriptor& reshapeDescriptor,
2104  const char* name = nullptr) override
2105  {
2106  boost::ignore_unused(reshapeDescriptor, name);
2107  CheckForwardedQuantizationSettings(layer);
2108  }
2109  };
2110 
2111  INetworkPtr network = INetwork::Create();
2112 
2113  const TensorShape shape{1U};
2114  TensorInfo info(shape, DataType::Float32);
2115 
2116  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2117 
2118  // Add the layer under test
2119  ReshapeDescriptor descriptor({1, 2, 3, 4});
2120  IConnectableLayer* reshape = network->AddReshapeLayer(descriptor);
2121 
2122  CompleteLeakyReluNetwork(network.get(), activation, reshape, info);
2123 
2124  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2125  TestReshapeQuantization validatorQAsymmU8(shape, shape);
2126  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2127 
2128  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2129  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2130  TestReshapeQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2131  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2132 
2133  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2134  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2135  TestReshapeQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2136  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2137 
2138  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2139  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2140  TestReshapeQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2141  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2142 }
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [64/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSplitter  )

Definition at line 2144 of file QuantizerTest.cpp.

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

2145 {
2146  class TestSplitterQuantization : public TestLeakyReLuActivationQuantization
2147  {
2148  public:
2149  TestSplitterQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2150  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2151 
2152  TestSplitterQuantization(const QuantizerOptions& options,
2153  const TensorShape& inputShape,
2154  const TensorShape& outputShape)
2155  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2156 
2157  virtual void VisitSplitterLayer(const IConnectableLayer* layer,
2158  const SplitterDescriptor& desc,
2159  const char* name = nullptr)
2160  {
2161  boost::ignore_unused(desc, name);
2162  CheckForwardedQuantizationSettings(layer);
2163  }
2164  };
2165 
2166  INetworkPtr network = INetwork::Create();
2167 
2168  const TensorShape shape{3U};
2169  TensorInfo info(shape, DataType::Float32);
2170 
2171  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2172 
2173  // Add the layer under test
2174  ViewsDescriptor splitterDesc(2,4);
2175  IConnectableLayer* splitter = network->AddSplitterLayer(splitterDesc);
2176  CompleteLeakyReluNetwork(network.get(), activation, splitter, info);
2177 
2178  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2179  TestSplitterQuantization validatorQAsymmU8(shape, shape);
2180  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2181 
2182  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2183  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2184  TestSplitterQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2185  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2186 
2187  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2188  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2189  TestSplitterQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2190  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2191 
2192  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2193  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2194  TestSplitterQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2195  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2196 }
ViewsDescriptor SplitterDescriptor
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [65/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeResize  )

Definition at line 2198 of file QuantizerTest.cpp.

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

2199 {
2200  class TestResizeQuantization : public TestLeakyReLuActivationQuantization
2201  {
2202  public:
2203  TestResizeQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2204  : TestLeakyReLuActivationQuantization(inputShape, outputShape)
2205  {}
2206 
2207  TestResizeQuantization(const QuantizerOptions& options,
2208  const TensorShape& inputShape,
2209  const TensorShape& outputShape)
2210  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape)
2211  {}
2212 
2213  void VisitResizeLayer(const IConnectableLayer* layer,
2214  const ResizeDescriptor& resizeDescriptor,
2215  const char* name = nullptr) override
2216  {
2217  boost::ignore_unused(resizeDescriptor, name);
2218  CheckForwardedQuantizationSettings(layer);
2219  }
2220  };
2221 
2222  INetworkPtr network = INetwork::Create();
2223 
2224  const TensorShape shape{1U};
2225  TensorInfo info(shape, DataType::Float32);
2226 
2227  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2228 
2229  // Add the layer under test
2230  ResizeDescriptor descriptor;
2231  descriptor.m_TargetHeight = 3;
2232  descriptor.m_TargetWidth = 3;
2233  IConnectableLayer* resizeLayer = network->AddResizeLayer(descriptor);
2234 
2235  CompleteLeakyReluNetwork(network.get(), activation, resizeLayer, info);
2236 
2237  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2238  TestResizeQuantization validatorQAsymmU8(shape, shape);
2239  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2240 
2241  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2242  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2243  TestResizeQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2244  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2245 
2246  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2247  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2248  TestResizeQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2249  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2250 
2251  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2252  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2253  TestResizeQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2254  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2255 }
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [66/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeStridedSlice  )

Definition at line 2257 of file QuantizerTest.cpp.

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

2258 {
2259  class TestStridedSliceQuantization : public TestLeakyReLuActivationQuantization
2260  {
2261  public:
2262  TestStridedSliceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2263  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2264 
2265  TestStridedSliceQuantization(const QuantizerOptions& options,
2266  const TensorShape& inputShape,
2267  const TensorShape& outputShape)
2268  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2269 
2270  virtual void VisitStridedSliceLayer(const IConnectableLayer* layer,
2271  const StridedSliceDescriptor& desc,
2272  const char* name = nullptr)
2273  {
2274  boost::ignore_unused(desc, name);
2275  CheckForwardedQuantizationSettings(layer);
2276  }
2277  };
2278 
2279  INetworkPtr network = INetwork::Create();
2280 
2281  const TensorShape shape{3U};
2282  TensorInfo info(shape, DataType::Float32);
2283 
2284  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2285 
2286  // Add the layer under test
2287  StridedSliceDescriptor stridedSliceDesc;
2288  IConnectableLayer* stridedSlice = network->AddStridedSliceLayer(stridedSliceDesc);
2289 
2290  CompleteLeakyReluNetwork(network.get(), activation, stridedSlice, info);
2291 
2292  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2293  TestStridedSliceQuantization validatorQAsymmU8(shape, shape);
2294  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2295 
2296  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2297  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2298  TestStridedSliceQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2299  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2300 
2301  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2302  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2303  TestStridedSliceQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2304  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2305 
2306  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2307  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2308  TestStridedSliceQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2309  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2310 }
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [67/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeBatchToSpace  )

Definition at line 2312 of file QuantizerTest.cpp.

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

2313 {
2314  class TestBatchToSpaceQuantization : public TestLeakyReLuActivationQuantization
2315  {
2316  public:
2317  TestBatchToSpaceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2318  : TestLeakyReLuActivationQuantization(inputShape, outputShape) {}
2319 
2320  TestBatchToSpaceQuantization(const QuantizerOptions& options,
2321  const TensorShape& inputShape,
2322  const TensorShape& outputShape)
2323  : TestLeakyReLuActivationQuantization(options, inputShape, outputShape) {}
2324 
2325  void VisitBatchToSpaceNdLayer(const IConnectableLayer* layer,
2326  const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor,
2327  const char* name = nullptr) override
2328  {
2329  boost::ignore_unused(batchToSpaceNdDescriptor, name);
2330  CheckForwardedQuantizationSettings(layer);
2331  }
2332  };
2333 
2334  INetworkPtr network = INetwork::Create();
2335 
2336  const TensorShape shape{1U};
2337  TensorInfo info(shape, DataType::Float32);
2338 
2339  IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info);
2340 
2341  // Add the layer under test
2342  BatchToSpaceNdDescriptor descriptor;
2343  IConnectableLayer* batchToSpace = network->AddBatchToSpaceNdLayer(descriptor);
2344 
2345  CompleteLeakyReluNetwork(network.get(), activation, batchToSpace, info);
2346 
2347  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2348  TestBatchToSpaceQuantization validatorQAsymmU8(shape, shape);
2349  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2350 
2351  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2352  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2353  TestBatchToSpaceQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2354  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2355 
2356  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2357  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2358  TestBatchToSpaceQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2359  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2360 
2361  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2362  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2363  TestBatchToSpaceQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2364  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2365 }
IConnectableLayer * CreateStartOfLeakyReluNetwork(INetwork *network, const TensorInfo &info)
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
void CompleteLeakyReluNetwork(INetwork *network, IConnectableLayer *activation, IConnectableLayer *layerUnderTest, const TensorInfo &info)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [68/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizePrelu  )

Definition at line 2367 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(), info, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2368 {
2369  class TestPreluQuantization : public TestQuantization
2370  {
2371  public:
2372  TestPreluQuantization(const TensorShape& inputShape,
2373  const TensorShape& alphaShape,
2374  const TensorShape& outputShape)
2375  : TestQuantization(inputShape, outputShape)
2376  , m_AlphaShape(alphaShape)
2377  {}
2378 
2379  TestPreluQuantization(const QuantizerOptions& options,
2380  const TensorShape& inputShape,
2381  const TensorShape& alphaShape,
2382  const TensorShape& outputShape)
2383  : TestQuantization(options, inputShape, outputShape)
2384  , m_AlphaShape(alphaShape)
2385  {}
2386 
2387  void VisitInputLayer(const IConnectableLayer* layer,
2388  LayerBindingId id,
2389  const char* name = nullptr) override
2390  {
2391  boost::ignore_unused(id, name);
2392  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
2393 
2394  switch (id)
2395  {
2396  case 0: // Input
2397  BOOST_TEST(m_InputShape == info.GetShape());
2398  break;
2399  case 1: // Alpha
2400  BOOST_TEST(m_AlphaShape == info.GetShape());
2401  break;
2402  default:
2403  throw InvalidArgumentException("Invalid layer binding id for PReLU layer");
2404  }
2405 
2406  // Based off current default [-15.0f, 15.0f]
2407  TestQuantizationParams(info,
2408  { 30.0f / g_AsymmU8QuantizationBase, 128 }, // QASymmU8
2409  { 30.0f / g_AsymmS8QuantizationBase, 0}, // QASymmS8
2410  { 15.0f / g_SymmS8QuantizationBase, 0}, // QSymmS8
2411  { 15.0f / g_SymmS16QuantizationBase, 0 }); // QSymmS16
2412  }
2413 
2414  void VisitOutputLayer(const IConnectableLayer* layer,
2415  LayerBindingId id,
2416  const char* name = nullptr) override
2417  {
2418  boost::ignore_unused(id, name);
2419  const TensorInfo& info = layer->GetInputSlot(0).GetConnection()->GetTensorInfo();
2420  BOOST_TEST(m_OutputShape == info.GetShape());
2421  }
2422 
2423  void VisitPreluLayer(const IConnectableLayer* layer,
2424  const char* name = nullptr) override
2425  {
2426  boost::ignore_unused(name);
2427  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
2428  TestQuantizationParams(info,
2429  { 30.0f / g_AsymmU8QuantizationBase, 128 }, // QASymmU8
2430  { 30.0f / g_AsymmS8QuantizationBase, 0}, // QAsymmS8
2431  { 15.0f / g_SymmS8QuantizationBase, 0}, // QSymmS8
2432  { 15.0f / g_SymmS16QuantizationBase, 0 }); // QSymmS16
2433  }
2434 
2435  private:
2436  TensorShape m_AlphaShape;
2437  };
2438 
2439  INetworkPtr network = INetwork::Create();
2440 
2441  const TensorShape inputShape{ 4, 1, 2 };
2442  const TensorShape alphaShape{ 5, 4, 3, 1 };
2443  const TensorShape outputShape{ 5, 4, 3, 2 };
2444  TensorInfo inputInfo(inputShape, DataType::Float32);
2445  TensorInfo alphaInfo(alphaShape, DataType::Float32);
2446  TensorInfo outputInfo(outputShape, DataType::Float32);
2447 
2448  // Add the input layers
2449  IConnectableLayer* input = network->AddInputLayer(0);
2450  IConnectableLayer* alpha = network->AddInputLayer(1);
2451 
2452  // Add the layer under test
2453  IConnectableLayer* prelu = network->AddPreluLayer("prelu");
2454 
2455  // Add the output layers
2456  IConnectableLayer* output = network->AddOutputLayer(0);
2457 
2458  // Establish connections
2459  input->GetOutputSlot(0).Connect(prelu->GetInputSlot(0));
2460  alpha->GetOutputSlot(0).Connect(prelu->GetInputSlot(1));
2461  prelu->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2462 
2463  // Set tensor info
2464  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
2465  alpha->GetOutputSlot(0).SetTensorInfo(alphaInfo);
2466  prelu->GetOutputSlot(0).SetTensorInfo(outputInfo);
2467 
2468  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2469  TestPreluQuantization validatorQAsymmU8(inputShape, alphaShape, outputShape);
2470  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2471 
2472  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2473  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2474  TestPreluQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, alphaShape, outputShape);
2475  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2476 
2477  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2478  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2479  TestPreluQuantization validatorQSymmS8(qSymmS8Options, inputShape, alphaShape, outputShape);
2480  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2481 
2482  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2483  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2484  TestPreluQuantization validatorQSymmS16(qSymmS16options, inputShape, alphaShape, outputShape);
2485  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2486 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:168

◆ BOOST_AUTO_TEST_CASE() [69/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeTransposeConvolution2d  )

Definition at line 2568 of file QuantizerTest.cpp.

References TestQuantizeTransposeConvolution2d().

2569 {
2571 }
void TestQuantizeTransposeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [70/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeTransposeConvolution2dWithBiases  )

Definition at line 2573 of file QuantizerTest.cpp.

References TestQuantizeTransposeConvolution2d().

2574 {
2576 }
void TestQuantizeTransposeConvolution2d(bool useBiases)

◆ BOOST_AUTO_TEST_CASE() [71/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeStack  )

Definition at line 2578 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(), options, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

2579 {
2580  class TestStackQuantization : public TestQuantization
2581  {
2582  public:
2583  TestStackQuantization(const TensorShape& inputShape,
2584  const TensorShape& outputShape)
2585  : TestQuantization(inputShape, outputShape) {}
2586 
2587  TestStackQuantization(const QuantizerOptions& options,
2588  const TensorShape& inputShape,
2589  const TensorShape& outputShape)
2590  : TestQuantization(options, inputShape, outputShape) {}
2591 
2592  void VisitInputLayer(const IConnectableLayer* layer,
2593  LayerBindingId id,
2594  const char* name = nullptr) override
2595  {
2596  boost::ignore_unused(layer, id, name);
2597  }
2598  void VisitOutputLayer(const IConnectableLayer* layer,
2599  LayerBindingId id,
2600  const char* name = nullptr) override
2601  {
2602  boost::ignore_unused(layer, id, name);
2603  }
2604 
2605  void VisitStackLayer(const IConnectableLayer* layer,
2606  const StackDescriptor& descriptor,
2607  const char* name = nullptr) override
2608  {
2609  boost::ignore_unused(descriptor, name);
2610  TensorInfo outputInfo = layer->GetOutputSlot(0).GetTensorInfo();
2611 
2612  TestQuantizationParams(outputInfo,
2613  { 30.0f / g_AsymmU8QuantizationBase, 128 },
2614  { 30.0f / g_AsymmS8QuantizationBase, 0},
2615  { 15.0f / g_SymmS8QuantizationBase, 0},
2616  { 15.0f / g_SymmS16QuantizationBase, 0 });
2617  }
2618  };
2619 
2620  INetworkPtr network = INetwork::Create();
2621 
2622  IConnectableLayer* input0 = network->AddInputLayer(0);
2623  IConnectableLayer* input1 = network->AddInputLayer(1);
2624 
2625  const TensorShape inputShape{ 3, 4, 5 };
2626  const TensorShape outputShape{ 3, 4, 2, 5 };
2627 
2628  StackDescriptor descriptor(2, 2, inputShape);
2629  IConnectableLayer* stackLayer = network->AddStackLayer(descriptor);
2630 
2631  IConnectableLayer* output = network->AddOutputLayer(0);
2632 
2633  input0->GetOutputSlot(0).Connect(stackLayer->GetInputSlot(0));
2634  input1->GetOutputSlot(0).Connect(stackLayer->GetInputSlot(1));
2635  stackLayer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2636 
2637  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2638  TestStackQuantization validatorQAsymmU8(inputShape, outputShape);
2639  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2640 
2641  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2642  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2643  TestStackQuantization validatorQAsymmS8(qAsymmS8Options, inputShape, inputShape);
2644  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2645 
2646  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2647  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2648  TestStackQuantization validatorQSymmS8(qSymmS8Options, inputShape, inputShape);
2649  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2650 
2651  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2652  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2653  TestStackQuantization validatorQSymmS16(qSymmS16options, inputShape, outputShape);
2654  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2655 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:168

◆ BOOST_AUTO_TEST_CASE() [72/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeSlice  )

Definition at line 2657 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(), info, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

2658 {
2659  class TestSliceQuantization : public TestQuantization
2660  {
2661  public:
2662  TestSliceQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
2663  : TestQuantization(inputShape, outputShape)
2664  {}
2665 
2666  TestSliceQuantization(const QuantizerOptions& options,
2667  const TensorShape& inputShape,
2668  const TensorShape& outputShape)
2669  : TestQuantization(options, inputShape, outputShape)
2670  {}
2671 
2672  virtual void VisitSliceLayer(const IConnectableLayer* layer,
2673  const SliceDescriptor& desc,
2674  const char* name = nullptr)
2675  {
2676  boost::ignore_unused(desc, name);
2677  const TensorInfo& info = layer->GetOutputSlot(0).GetTensorInfo();
2678 
2679  const OffsetScalePair qAsymmU8Params{ 30.0f / g_AsymmU8QuantizationBase, 128 };
2680  const OffsetScalePair qAsymmS8Params{ 30.0f / g_AsymmS8QuantizationBase, 0 };
2681  const OffsetScalePair qSymmS8Params { 15.0f / g_SymmS8QuantizationBase, 0 };
2682  const OffsetScalePair qSymmS16Params{ 15.0f / g_SymmS16QuantizationBase, 0 };
2683 
2684  TestQuantizationParams(info, qAsymmU8Params, qAsymmS8Params, qSymmS8Params, qSymmS16Params);
2685  }
2686  };
2687 
2688  TensorShape shape{ 3 };
2689  TensorInfo info(shape, DataType::Float32);
2690 
2691  INetworkPtr network = INetwork::Create();
2692 
2693  IConnectableLayer* inputLayer = network->AddInputLayer(0);
2694  IConnectableLayer* sliceLayer = network->AddSliceLayer(SliceDescriptor());
2695  IConnectableLayer* outputLayer = network->AddOutputLayer(0);
2696 
2697  inputLayer->GetOutputSlot(0).Connect(sliceLayer->GetInputSlot(0));
2698  sliceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2699 
2700  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
2701  sliceLayer->GetOutputSlot(0).SetTensorInfo(info);
2702 
2703  // test QAsymmU8 quantization
2704  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2705  TestSliceQuantization validatorQAsymmU8(shape, shape);
2706  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2707 
2708  // test QASymmS8 quantization
2709  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2710  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2711  TestSliceQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2712  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2713 
2714  // test QSymmS8 quantization
2715  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2716  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2717  TestSliceQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2718  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2719 
2720  // test QSymmS16 quantization
2721  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2722  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2723  TestSliceQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2724  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2725 }
const float g_SymmS16QuantizationBase
const float g_SymmS8QuantizationBase
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
const float g_AsymmS8QuantizationBase
const float g_AsymmU8QuantizationBase
std::pair< float, int > OffsetScalePair
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [73/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeInf  )

Definition at line 2742 of file QuantizerTest.cpp.

References SetupQuantize().

2743 {
2744  BOOST_CHECK_EQUAL(SetupQuantize(std::numeric_limits<float>::infinity())[0], 255);
2745 }
std::vector< uint8_t > SetupQuantize(float value)

◆ BOOST_AUTO_TEST_CASE() [74/79]

armnn::BOOST_AUTO_TEST_CASE ( QuantizeNegativeInf  )

Definition at line 2747 of file QuantizerTest.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [75/79]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeFloat32  )

Definition at line 2847 of file QuantizerTest.cpp.

References Float32, and PreserveTypeTestImpl().

2848 {
2849  PreserveTypeTestImpl(DataType::Float32);
2850 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [76/79]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeQAsymmU8  )

Definition at line 2852 of file QuantizerTest.cpp.

References PreserveTypeTestImpl(), and QAsymmU8.

2853 {
2854  PreserveTypeTestImpl(DataType::QAsymmU8);
2855 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [77/79]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeQsymm8  )

Definition at line 2857 of file QuantizerTest.cpp.

References PreserveTypeTestImpl(), and QSymmS8.

2858 {
2859  PreserveTypeTestImpl(DataType::QSymmS8);
2860 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [78/79]

armnn::BOOST_AUTO_TEST_CASE ( PreserveTypeQsymm16  )

Definition at line 2862 of file QuantizerTest.cpp.

References PreserveTypeTestImpl(), and QSymmS16.

2863 {
2864  PreserveTypeTestImpl(DataType::QSymmS16);
2865 }
void PreserveTypeTestImpl(const DataType &dataType)

◆ BOOST_AUTO_TEST_CASE() [79/79]

armnn::BOOST_AUTO_TEST_CASE ( TestConnectionPreservationAfterDynamicQuant  )

Definition at line 2867 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().

2868 {
2869  class TestConnectionPreservation : public LayerVisitorBase<VisitorNoThrowPolicy>
2870  {
2871  public:
2872  TestConnectionPreservation(const Graph& graph)
2873  : LayerVisitorBase<VisitorNoThrowPolicy>()
2874  , m_Graph(graph)
2875  {}
2876 
2877  void VisitAdditionLayer(const IConnectableLayer* layer, const char*) override
2878  {
2879  CheckLayerName(layer->GetInputSlot(0).GetConnection()->GetOwningLayerGuid(), "reLU1");
2880  CheckLayerName(layer->GetInputSlot(1).GetConnection()->GetOwningLayerGuid(), "reLU2");
2881  }
2882 
2883  void CheckLayerName(LayerGuid guid, std::string expectedName)
2884  {
2885  bool guidFound = false;
2886  for (Layer* layer : m_Graph)
2887  {
2888  if (layer->GetGuid() == guid)
2889  {
2890  BOOST_CHECK_EQUAL(layer->GetName(), expectedName.c_str());
2891  guidFound = true;
2892  break;
2893  }
2894  }
2895  if (!guidFound)
2896  {
2897  BOOST_FAIL("No layer matching the GUID was found");
2898  }
2899  }
2900 
2901  private:
2902  Graph m_Graph;
2903  };
2904 
2905  INetworkPtr network = INetwork::Create();
2906 
2907  IConnectableLayer* inputLayer = network->AddInputLayer(0,"inputLayer1");
2908  armnn::ActivationDescriptor ReLUDesc;
2909  ReLUDesc.m_Function = ActivationFunction::ReLu;
2910 
2911  IConnectableLayer* reLULayer1 = network->AddActivationLayer(ReLUDesc, "reLU1");
2912  IConnectableLayer* reLULayer2 = network->AddActivationLayer(ReLUDesc, "reLU2");
2913  IConnectableLayer* addLayer1 = network->AddAdditionLayer("addLayer1");
2914  IConnectableLayer* outputLayer = network->AddOutputLayer(0,"outPutLayer1");
2915 
2916  inputLayer->GetOutputSlot(0).Connect(reLULayer1->GetInputSlot(0));
2917  reLULayer1->GetOutputSlot(0).Connect(reLULayer2->GetInputSlot(0));
2918  reLULayer1->GetOutputSlot(0).Connect(addLayer1->GetInputSlot(0));
2919  reLULayer2->GetOutputSlot(0).Connect(addLayer1->GetInputSlot(1));
2920  addLayer1->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2921 
2922  inputLayer->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
2923  reLULayer1->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
2924  reLULayer2->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
2925  addLayer1->GetOutputSlot(0).SetTensorInfo(TensorInfo(TensorShape({1, 2, 2, 1}), DataType::Float32));
2926 
2927  TestConnectionPreservation visitor1(boost::polymorphic_downcast<const Network*>(network.get())->GetGraph());
2928  VisitLayersTopologically(network.get(), visitor1);
2929 
2931 
2932  armnn::TensorInfo tensorInfo = GetInputTensorInfo(boost::polymorphic_downcast<const Network*>(network.get()));
2933 
2934  std::vector<float> inputData({0, 2, 0, 4});
2935  armnn::ConstTensor inputTensor(tensorInfo, inputData.data());
2936 
2937  InputTensors inputTensors;
2938  inputTensors.push_back(std::make_pair(0, inputTensor));
2939  quantizer->Refine(inputTensors);
2940 
2941  INetworkPtr quantNetwork = quantizer->ExportNetwork();
2942 
2943  TestConnectionPreservation visitor2(boost::polymorphic_downcast<const Network*>(quantNetwork.get())->GetGraph());
2944  VisitLayersTopologically(quantNetwork.get(), visitor2);
2945 }
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:199
TensorInfo GetInputTensorInfo(const Network *network)
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
std::unique_ptr< class INetworkQuantizer, void(*)(INetworkQuantizer *quantizer)> INetworkQuantizerPtr
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:225
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square).
Definition: Descriptors.hpp:35
static INetworkQuantizerPtr Create(INetwork *inputNetwork, const QuantizerOptions &options=QuantizerOptions())
Create Quantizer object wrapped in unique_ptr.
profiling::ProfilingGuid LayerGuid
Define LayerGuid type.
Definition: Types.hpp:233

◆ boost_test_print_type() [1/2]

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

Definition at line 12 of file TensorTest.cpp.

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

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

◆ boost_test_print_type() [2/2]

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

Definition at line 24 of file TensorTest.cpp.

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

25 {
26  ostr << "TensorShape[ "
27  << shape.GetNumDimensions() << ","
28  << shape[0] << ","
29  << shape[1] << ","
30  << shape[2] << ","
31  << shape[3]
32  << " ]" << std::endl;
33  return ostr;
34 }
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:43

◆ 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 
)

Definition at line 664 of file Network.cpp.

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

Referenced by SelectTensorHandleStrategy().

669 {
670  auto toBackend = backends.find(connectedLayer.GetBackendId());
671  BOOST_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
672 
673  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
674 
675  // Legacy API check for backward compatibility
676  if (srcFactoryId == ITensorHandleFactory::LegacyFactoryId || dstPrefs.empty())
677  {
678  if (layer.GetBackendId() != connectedLayer.GetBackendId())
679  {
680  return EdgeStrategy::CopyToTarget;
681  }
682  else
683  {
684  return EdgeStrategy::DirectCompatibility;
685  }
686  }
687 
688  // TensorHandleFactory API present, so perform more sophisticated strategies.
689  // Dst Output layers don't require copy because they use import or map/unmap
690  if (connectedLayer.GetType() == LayerType::Output)
691  {
692  return EdgeStrategy::DirectCompatibility;
693  }
694 
695  // Search for direct match in prefs
696  for (auto&& pref : dstPrefs)
697  {
698  if (pref == srcFactoryId)
699  {
700  return EdgeStrategy::DirectCompatibility;
701  }
702  }
703 
704  // Search for export/import options
705  ITensorHandleFactory* srcFactory = registry.GetFactory(srcFactoryId);
706  if (srcFactory->GetExportFlags() != 0)
707  {
708  for (auto&& pref : dstPrefs)
709  {
710  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
711 
712  // Handles cases when a destPref is not listed in TensorHandleFactoryRegistry
713  if (!dstFactory) {
714  continue;
715  }
716 
717  if ((dstFactory->GetImportFlags() & srcFactory->GetExportFlags()) != 0)
718  {
719  return EdgeStrategy::ExportToTarget;
720  }
721  }
722  }
723 
724  // Search for copy options via map/unmap
725  if (srcFactory->SupportsMapUnmap())
726  {
727  for (auto&& pref : dstPrefs)
728  {
729  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
730  if (dstFactory && dstFactory->SupportsMapUnmap())
731  {
732  return EdgeStrategy::CopyToTarget;
733  }
734  }
735  }
736 
737  return EdgeStrategy::Undefined;
738 }

◆ CalculateSlotOption()

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

Definition at line 555 of file Network.cpp.

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

Referenced by SelectTensorHandleStrategy().

558 {
559  // First ensure the from backends can support the TensorHandeAPI
560  Layer& layer = outputSlot.GetOwningLayer();
561  auto frmBackend = backends.find(layer.GetBackendId());
562  if (frmBackend == backends.end() ||
563  !frmBackend->second->SupportsTensorAllocatorAPI())
564  {
565  return ITensorHandleFactory::LegacyFactoryId;
566  }
567 
568  // Connections to Output Layers requires support for map/unmap on the TensorHandle.
569  bool requiresMapUnmap = false;
570  for (auto&& connection : outputSlot.GetConnections())
571  {
572  const Layer& connectedLayer = connection->GetOwningLayer();
573  if (connectedLayer.GetType() == LayerType::Output)
574  {
575  requiresMapUnmap = true;
576  }
577  }
578 
579  IBackendInternal* srcBackend = frmBackend->second.get();
580  auto srcPrefs = srcBackend->GetHandleFactoryPreferences();
581 
582  // Initialize the scores
583  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
584  for (auto&& pref : srcPrefs)
585  {
586  if (requiresMapUnmap) // Only consider factories that support map/unmap if required
587  {
588  ITensorHandleFactory* factory = registry.GetFactory(pref);
589  if (!factory->SupportsMapUnmap())
590  {
591  // The current tensor handle factory does not support the map/unmap strategy, move to the next one
592  continue;
593  }
594  }
595 
596  auto it = factoryScores.find(pref);
597  if (it == factoryScores.end())
598  {
599  // Add new score to the table
600  factoryScores[pref] = 0;
601  }
602  }
603 
604  // Score each handle factory based on how many times it requires copies on the slot connections
605  for (auto&& connection : outputSlot.GetConnections())
606  {
607  const Layer& connectedLayer = connection->GetOwningLayer();
608 
609  auto toBackend = backends.find(connectedLayer.GetBackendId());
610  BOOST_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
611 
612  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
613  for (auto&& src : srcPrefs)
614  {
615  if (factoryScores.find(src) == factoryScores.end()) // Don't consider excluded factories
616  {
617  continue;
618  }
619 
620  for (auto&& dst : dstPrefs)
621  {
622  if (RequiresCopy(src, dst, registry))
623  {
624  // Copy avoided, increase the score
625  factoryScores[src]++;
626  break;
627  }
628  }
629  }
630  }
631 
632  // Find the lowest score
633  int minScore = std::numeric_limits<int>::max();
634  for (auto it : factoryScores)
635  {
636  minScore = std::min(minScore, it.second);
637  }
638 
639  // Collect factories matching the best(lowest) score
640  std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
641  for (auto it : factoryScores)
642  {
643  if (it.second == minScore)
644  {
645  optimalFactories.push_back(it.first);
646  }
647  }
648 
649  // For all compatible Factories matching the best score, find the preferred one for the current layer.
650  for (auto&& srcPref : srcPrefs)
651  {
652  for (auto&& comp : optimalFactories)
653  {
654  if (comp == srcPref)
655  {
656  return comp;
657  }
658  }
659  }
660 
661  return ITensorHandleFactory::LegacyFactoryId;
662 }
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:443

◆ CalculateSlotOptionForInput()

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

Definition at line 463 of file Network.cpp.

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

Referenced by SelectTensorHandleStrategy().

466 {
467  Layer& layer = slot.GetOwningLayer();
468  BOOST_ASSERT(layer.GetType() == LayerType::Input);
469 
470  // Explicitly select the tensorhandle factory for InputLayer because the rules for it are slightly different. It
471  // doesn't matter which backend it is assigned to because they all use the same implementation, which
472  // requires Map/Unmap support. This means that, so long as the handle type supports map/unmap semantics, we can
473  // select a factory with maximum compatibility with the layers connected to the InputLayer.
474 
475  // First ensure the from backends can support the TensorHandeAPI
476  auto frmBackend = backends.find(layer.GetBackendId());
477  if (frmBackend == backends.end() ||
478  !frmBackend->second->SupportsTensorAllocatorAPI())
479  {
480  return ITensorHandleFactory::LegacyFactoryId;
481  }
482 
483  // Go through all connections to the output slot and determine the TensorHandleFactory which results in the
484  // fewest copies.
485  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
486  int topScore = 0;
487  ITensorHandleFactory::FactoryId topChoice = ITensorHandleFactory::LegacyFactoryId;
488 
489  for (auto&& connection : slot.GetConnections())
490  {
491  const Layer& connectedLayer = connection->GetOwningLayer();
492 
493  auto toBackend = backends.find(connectedLayer.GetBackendId());
494  BOOST_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
495 
496  if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
497  {
498  // The destination backend does not support the tensor allocator API, move to the next one
499  continue;
500  }
501 
502  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
503  for (auto&& dst : dstPrefs)
504  {
505  // Input layers use the mem copy workload or import, so the selected factory must
506  // support either the map/unmap API or Import API
507  ITensorHandleFactory* factory = registry.GetFactory(dst);
508  if (!factory->SupportsMapUnmap() &&
509  !CheckFlag(factory->GetImportFlags(), MemorySource::Malloc)) // Just support cpu mem imports for now
510  {
511  // The current tensor handle factory does not support the map/unmap or import
512  // strategy, move to the next one
513  continue;
514  }
515 
516  auto it = factoryScores.find(dst);
517  if (it == factoryScores.end())
518  {
519  // Add new score to the table
520  factoryScores[dst] = 0;
521  if (topChoice == ITensorHandleFactory::LegacyFactoryId)
522  {
523  topChoice = dst;
524  }
525  }
526  else
527  {
528  // Increase the score
529  factoryScores[dst]++;
530 
531  // Track the best option
532  if (factoryScores[dst] > topScore)
533  {
534  topScore = factoryScores[dst];
535  topChoice = dst;
536  }
537  }
538  }
539  }
540 
541  return topChoice;
542 }
bool CheckFlag(MemorySourceFlags flags, MemorySource source)
ITensorHandleFactory::FactoryId FactoryId

◆ CalculateSlotOptionForOutput()

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

Definition at line 545 of file Network.cpp.

References ITensorHandleFactory::DeferredFactoryId.

Referenced by SelectTensorHandleStrategy().

548 {
549  boost::ignore_unused(backends, slot, registry);
550  return ITensorHandleFactory::DeferredFactoryId;
551 }

◆ 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 98 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().

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

◆ CheckSupportRule()

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

Definition at line 37 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::IsConvolution2dSupported(), RefLayerSupport::IsDebugSupported(), RefLayerSupport::IsDepthToSpaceSupported(), RefLayerSupport::IsDepthwiseConvolutionSupported(), RefLayerSupport::IsDequantizeSupported(), RefLayerSupport::IsDetectionPostProcessSupported(), RefLayerSupport::IsDivisionSupported(), RefLayerSupport::IsElementwiseUnarySupported(), RefLayerSupport::IsFakeQuantizationSupported(), RefLayerSupport::IsFloorSupported(), RefLayerSupport::IsFullyConnectedSupported(), RefLayerSupport::IsGatherSupported(), RefLayerSupport::IsInstanceNormalizationSupported(), RefLayerSupport::IsL2NormalizationSupported(), 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::IsReshapeSupported(), RefLayerSupport::IsResizeBilinearSupported(), RefLayerSupport::IsResizeSupported(), RefLayerSupport::IsSliceSupported(), RefLayerSupport::IsSoftmaxSupported(), RefLayerSupport::IsSpaceToBatchNdSupported(), RefLayerSupport::IsSpaceToDepthSupported(), RefLayerSupport::IsSplitterSupported(), RefLayerSupport::IsStackSupported(), RefLayerSupport::IsStridedSliceSupported(), RefLayerSupport::IsSubtractionSupported(), and RefLayerSupport::IsTransposeConvolution2dSupported().

38 {
39  bool supported = rule();
40  if (!supported && reason)
41  {
42  reasonIfUnsupported.value() += std::string(reason) + "\n"; // Append the reason on a new line
43  }
44  return supported;
45 }
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 
)

Definition at line 38 of file ClAdditionWorkload.cpp.

Referenced by ClLayerSupport::IsAdditionSupported().

41 {
42  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
43  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
44  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
45 
46  const arm_compute::Status aclStatus = arm_compute::CLArithmeticAddition::validate(&aclInput0Info,
47  &aclInput1Info,
48  &aclOutputInfo,
49  g_AclConvertPolicy);
50 
51  return aclStatus;
52 }
Status
Definition: Types.hpp:26

◆ ClArgMinMaxWorkloadValidate()

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

Definition at line 30 of file ClArgMinMaxWorkload.cpp.

Referenced by ClLayerSupport::IsArgMinMaxSupported().

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

◆ 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 
)

Definition at line 18 of file ClBatchNormalizationFloatWorkload.cpp.

Referenced by ClLayerSupport::IsBatchNormalizationSupported().

25 {
26  const arm_compute::TensorInfo aclInputInfo =
27  armcomputetensorutils::BuildArmComputeTensorInfo(input, desc.m_DataLayout);
28  const arm_compute::TensorInfo aclOutputInfo =
29  armcomputetensorutils::BuildArmComputeTensorInfo(output, desc.m_DataLayout);
30  const arm_compute::TensorInfo aclMeanInfo =
31  armcomputetensorutils::BuildArmComputeTensorInfo(mean, desc.m_DataLayout);
32  const arm_compute::TensorInfo aclVarInfo =
33  armcomputetensorutils::BuildArmComputeTensorInfo(var, desc.m_DataLayout);
34  const arm_compute::TensorInfo aclBetaInfo =
35  armcomputetensorutils::BuildArmComputeTensorInfo(beta, desc.m_DataLayout);
36  const arm_compute::TensorInfo aclGammaInfo =
37  armcomputetensorutils::BuildArmComputeTensorInfo(gamma, desc.m_DataLayout);
38 
39  return arm_compute::CLBatchNormalizationLayer::validate(&aclInputInfo,
40  &aclOutputInfo,
41  &aclMeanInfo,
42  &aclVarInfo,
43  &aclBetaInfo,
44  &aclGammaInfo,
45  desc.m_Eps);
46 }

◆ ClBatchToSpaceNdWorkloadValidate()

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

Definition at line 45 of file ClBatchToSpaceNdWorkload.cpp.

References BatchToSpaceNdDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsBatchToSpaceNdSupported().

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

◆ ClConcatWorkloadValidate()

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

Definition at line 29 of file ClConcatWorkload.cpp.

Referenced by ClLayerSupport::IsConcatSupported().

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

◆ 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
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
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 
)

Definition at line 23 of file ClConvolution2dWorkload.cpp.

Referenced by ClLayerSupport::IsConvolution2dSupported().

28 {
29  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
30  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
31  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
32 
33  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(descriptor.m_DilationX,
34  descriptor.m_DilationY);
35 
36  arm_compute::TensorInfo aclBiasesInfo;
37  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
38 
39  if (descriptor.m_BiasEnabled)
40  {
41  BOOST_ASSERT(biases.has_value());
42 
43  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
44  optionalAclBiasesInfo = &aclBiasesInfo;
45  }
46 
47  arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor);
48 
49  return arm_compute::CLConvolutionLayer::validate(&aclInputInfo,
50  &aclWeightsInfo,
51  optionalAclBiasesInfo,
52  &aclOutputInfo,
53  layerInfo,
54  arm_compute::WeightsInfo(),
55  aclDilationInfo);
56 }

◆ 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 = boost::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 }
Status
Definition: Types.hpp:26
DataLayout
Definition: Types.hpp:48

◆ ClDepthwiseConvolutionWorkloadValidate()

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

Definition at line 24 of file ClDepthwiseConvolutionWorkload.cpp.

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

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

◆ ClDequantizeWorkloadValidate()

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

Definition at line 23 of file ClDequantizeWorkload.cpp.

Referenced by ClLayerSupport::IsDequantizeSupported().

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

◆ ClDivisionWorkloadValidate()

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

Definition at line 15 of file ClDivisionFloatWorkload.cpp.

Referenced by ClLayerSupport::IsDivisionSupported().

18 {
19  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
20  const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  return arm_compute::CLArithmeticDivision::validate(&aclInput1, &aclInput2, &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 
)

Definition at line 19 of file ClFullyConnectedWorkload.cpp.

Referenced by ClLayerSupport::IsFullyConnectedSupported().

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

◆ ClGreaterWorkloadValidate()

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

Definition at line 24 of file ClGreaterWorkload.cpp.

Referenced by ClLayerSupport::IsComparisonSupported().

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::CLComparison::validate(
33  &aclInput0Info,
34  &aclInput1Info,
35  &aclOutputInfo,
36  arm_compute::ComparisonOperation::Greater);
37 
38  return aclStatus;
39 }
Status
Definition: Types.hpp:26

◆ 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 }

◆ 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 256 of file ClLstmFloatWorkload.cpp.

Referenced by ClLayerSupport::IsLstmSupported().

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

◆ ClMultiplicationWorkloadValidate()

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

Definition at line 14 of file ClMultiplicationWorkload.cpp.

Referenced by ClLayerSupport::IsMultiplicationSupported().

17 {
18  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
19  const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
20  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
21 
22  // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it,
23  // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be
24  // ignored for F32 tensors.
25  return arm_compute::CLPixelWiseMultiplication::validate(&aclInput1,
26  &aclInput2,
27  &aclOutput,
28  1.0f,
29  arm_compute::ConvertPolicy::SATURATE,
30  arm_compute::RoundingPolicy::TO_ZERO);
31 }

◆ 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
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 }

◆ 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  return arm_compute::CLScale::validate(&aclInputInfo,
37  &aclOutputInfo,
38  aclInterpolationPolicy,
39  arm_compute::BorderMode::REPLICATE,
40  arm_compute::PixelValue(0.f),
41  arm_compute::SamplingPolicy::TOP_LEFT,
42  true,
43  descriptor.m_BilinearAlignCorners);
44 }
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
DataLayout
Definition: Types.hpp:48

◆ ClRsqrtWorkloadValidate()

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

Definition at line 19 of file ClRsqrtWorkload.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::CLRsqrtLayer::validate(&aclInput, &aclOutput);
25 }

◆ ClSliceWorkloadValidate()

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

Definition at line 19 of file ClSliceWorkload.cpp.

Referenced by ClLayerSupport::IsSliceSupported().

22 {
23  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
28 
29  std::tie(starts, ends) = SetClSliceData(descriptor.m_Begin, descriptor.m_Size);
30 
31  return arm_compute::CLSlice::validate(&aclInput, &aclOutput, starts, ends);
32 }
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 16 of file ClSoftmaxBaseWorkload.cpp.

Referenced by ClLayerSupport::IsSoftmaxSupported().

19 {
20  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  unsigned int aclAxis = ComputeSoftmaxAclAxis(descriptor, input);
24  return arm_compute::CLSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis);
25 }
unsigned int ComputeSoftmaxAclAxis(const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)

◆ 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 = boost::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
32  int32_t blockWidth = boost::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 }

◆ ClSpaceToDepthWorkloadValidate()

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

Definition at line 44 of file ClSpaceToDepthWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsSpaceToDepthSupported().

47 {
48  DataLayout dataLayout = desc.m_DataLayout;
49  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
50 
51  int32_t blockSize = boost::numeric_cast<int32_t>(desc.m_BlockSize);
52 
53  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
54 
55  const arm_compute::Status aclStatus = arm_compute::CLSpaceToDepthLayer::validate(&aclInputInfo,
56  &aclOutputInfo,
57  blockSize);
58  return aclStatus;
59 }
Status
Definition: Types.hpp:26
DataLayout
Definition: Types.hpp:48

◆ ClSplitterWorkloadValidate()

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

Definition at line 31 of file ClSplitterWorkload.cpp.

Referenced by ClLayerSupport::IsSplitterSupported().

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

◆ ClStackWorkloadValidate()

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

Definition at line 30 of file ClStackWorkload.cpp.

Referenced by ClLayerSupport::IsStackSupported().

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

◆ ClStridedSliceWorkloadValidate()

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

Definition at line 26 of file ClStridedSliceWorkload.cpp.

Referenced by ClLayerSupport::IsStridedSliceSupported().

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

◆ ClSubtractionValidate()

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

Definition at line 38 of file ClSubtractionWorkload.cpp.

Referenced by ClLayerSupport::IsSubtractionSupported().

41 {
42  const arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0);
43  const arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1);
44  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
45 
46  const arm_compute::Status aclStatus = arm_compute::CLArithmeticSubtraction::validate(&aclInput0Info,
47  &aclInput1Info,
48  &aclOutputInfo,
49  g_AclConvertPolicy);
50 
51  return aclStatus;
52 }
Status
Definition: Types.hpp:26

◆ 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  BOOST_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 }

◆ 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 }
unsigned int MemorySourceFlags
MemorySourceFlags Combine(Arg source, Args... rest)

◆ CompatibleTypes()

bool armnn::CompatibleTypes ( DataType  )

Definition at line 15 of file CompatibleTypes.hpp.

16 {
17  return false;
18 }

◆ CompatibleTypes< float >()

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

Definition at line 21 of file CompatibleTypes.hpp.

References Float32.

22 {
23  return dataType == DataType::Float32;
24 }

◆ CompatibleTypes< Half >()

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

Definition at line 27 of file CompatibleTypes.hpp.

References Float16.

28 {
29  return dataType == DataType::Float16;
30 }

◆ CompatibleTypes< int16_t >()

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

Definition at line 49 of file CompatibleTypes.hpp.

References QSymmS16.

50 {
51  return dataType == DataType::QSymmS16;
52 }

◆ CompatibleTypes< int32_t >()

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

Definition at line 55 of file CompatibleTypes.hpp.

References Signed32.

56 {
57  return dataType == DataType::Signed32;
58 }

◆ CompatibleTypes< int8_t >()

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

Definition at line 39 of file CompatibleTypes.hpp.

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

40 {
42  return dataType == DataType::QSymmS8
43  || dataType == DataType::QuantizedSymm8PerAxis
44  || dataType == DataType::QAsymmS8;
46 }
#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 33 of file CompatibleTypes.hpp.

References Boolean, and QAsymmU8.

34 {
35  return dataType == DataType::Boolean || dataType == DataType::QAsymmU8;
36 }

◆ CompleteLeakyReluNetwork()

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

Definition at line 1495 of file QuantizerTest.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

1499 {
1500  // Add the output Layer
1501  IConnectableLayer* output = network->AddOutputLayer(3);
1502 
1503  // Establish connections
1504  activation->GetOutputSlot(0).Connect(layerUnderTest->GetInputSlot(0));
1505  layerUnderTest->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1506 
1507  //Set TensorInfo
1508  layerUnderTest->GetOutputSlot(0).SetTensorInfo(info);
1509 }

◆ ComputeSoftmaxAclAxis()

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

Definition at line 138 of file ArmComputeUtils.hpp.

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

Referenced by ClSoftmaxFloatWorkload::ClSoftmaxFloatWorkload(), ClSoftmaxUint8Workload::ClSoftmaxUint8Workload(), NeonSoftmaxFloatWorkload::NeonSoftmaxFloatWorkload(), and NeonSoftmaxUint8Workload::NeonSoftmaxUint8Workload().

139 {
140  // Detect the Android default value of -1 and return the ACL default value of 1.
141  if (softmaxDesc.m_Axis == -1)
142  {
143  return 1;
144  }
145 
146  unsigned int dim = tensor.GetNumDimensions();
147 
148  BOOST_ASSERT(dim != 0);
149 
150  // Currently ArmNN support axis 1.
151  return dim - 1;
152 }
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:92

◆ ComputeSplitAxis()

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

Definition at line 154 of file ArmComputeUtils.hpp.

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

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

155 {
156  unsigned int numSplit = desc.GetNumViews();
157  unsigned int numDimensions = desc.GetNumDimensions();
158  std::set<unsigned int> splitAxis;
159 
160  for (unsigned int i = 0; i < numSplit; ++i)
161  {
162  for (unsigned int dimIdx = 0; dimIdx < numDimensions; ++dimIdx)
163  {
164  if (desc.GetViewSizes(i)[dimIdx] != input[dimIdx])
165  {
166  splitAxis.insert(dimIdx);
167  }
168  }
169  }
170  return splitAxis;
171 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
uint32_t GetNumViews() const
Get the number of views.

◆ Concatenate()

void Concatenate ( const ConcatQueueDescriptor data)

Definition at line 14 of file Concatenate.cpp.

References 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  BOOST_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 }
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()

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

Definition at line 141 of file Exceptions.hpp.

142 {
143  if (!condition)
144  {
145  throw ExceptionType(message);
146  }
147 }

◆ 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 155 of file Exceptions.hpp.

158 {
159  if (!(leftHandSide == rightHandSide))
160  {
161  std::stringstream ss;
162  ss << message << " : " << leftHandSide << " != " << rightHandSide;
163  throw ExceptionType(ss.str());
164  }
165 }

◆ 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 SetLogFilter(LogSeverity level)
Definition: Logging.cpp:29
void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured)
Definition: Logging.cpp:147

◆ ConfigureTuner()

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

Definition at line 131 of file ClBackendContext.cpp.

References Exhaustive, None, Normal, and Rapid.

Referenced by ClBackendContext::ClBackendContext().

132 {
133  tuner.set_tune_new_kernels(true); // Turn on tuning initially.
134 
135  switch (level)
136  {
137  case TuningLevel::Rapid:
138  tuner.set_tuner_mode(arm_compute::CLTunerMode::RAPID);
139  break;
140  case TuningLevel::Normal:
141  tuner.set_tuner_mode(arm_compute::CLTunerMode::NORMAL);
142  break;
143  case TuningLevel::Exhaustive:
144  tuner.set_tuner_mode(arm_compute::CLTunerMode::EXHAUSTIVE);
145  break;
146  case TuningLevel::None:
147  default:
148  tuner.set_tune_new_kernels(false); // Turn off tuning. Set to "use" only mode.
149  break;
150  }
151 }

◆ ConvertActivationDescriptorToAclActivationLayerInfo()

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

Definition at line 73 of file ArmComputeUtils.hpp.

References ConvertActivationFunctionToAclActivationFunction(), ActivationDescriptor::m_A, ActivationDescriptor::m_B, and ActivationDescriptor::m_Function.

Referenced by ClActivationWorkload::ClActivationWorkload(), and NeonActivationWorkload::NeonActivationWorkload().

74 {
75  return arm_compute::ActivationLayerInfo(ConvertActivationFunctionToAclActivationFunction(actDesc.m_Function),
76  actDesc.m_A, actDesc.m_B);
77 }
arm_compute::ActivationLayerInfo::ActivationFunction ConvertActivationFunctionToAclActivationFunction(ActivationFunction armnnFunction)

◆ ConvertActivationFunctionToAclActivationFunction()

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

Definition at line 51 of file ArmComputeUtils.hpp.

References Abs, BoundedReLu, 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  default: throw InvalidArgumentException("Unsupported activation function");
69  }
70 }
ActivationFunction
Definition: Types.hpp:54

◆ ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo()

arm_compute::FullyConnectedLayerInfo armnn::ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo ( const FullyConnectedDescriptor fullyConnectedDesc)
inline

Definition at line 118 of file ArmComputeUtils.hpp.

References FullyConnectedDescriptor::m_TransposeWeightMatrix.

119 {
120  arm_compute::FullyConnectedLayerInfo fc_info;
121  fc_info.transpose_weights = fullyConnectedDesc.m_TransposeWeightMatrix;
122  return fc_info;
123 }

◆ 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 192 of file WorkloadUtils.cpp.

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

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

◆ ConvertNormalizationAlgorithmChannelToAclNormType()

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

Definition at line 106 of file ArmComputeUtils.hpp.

References Across, and Within.

107 {
108  using arm_compute::NormType;
109  switch (channelType)
110  {
111  case NormalizationAlgorithmChannel::Across: return NormType::CROSS_MAP;
112  case NormalizationAlgorithmChannel::Within: return NormType::IN_MAP_2D;
113  default: throw InvalidArgumentException("Unsupported normalization algorithm channel type");
114  }
115 }

◆ ConvertOutputShapeRoundingToAclDimensionRoundingType()

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

Definition at line 92 of file ArmComputeUtils.hpp.

References Ceiling, and Floor.

94 {
95  using arm_compute::DimensionRoundingType;
96 
97  switch (rounding)
98  {
99  case OutputShapeRounding::Ceiling: return DimensionRoundingType::CEIL;
100  case OutputShapeRounding::Floor: return DimensionRoundingType::FLOOR;
101  default: throw InvalidArgumentException("Unsupported Output Shape Rounding type");
102  }
103 }

◆ ConvertPoolingAlgorithmToAclPoolingType()

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

Definition at line 79 of file ArmComputeUtils.hpp.

References Average, L2, and Max.

80 {
81  using arm_compute::PoolingType;
82 
83  switch (poolingAlgorithm)
84  {
85  case PoolingAlgorithm::Max: return PoolingType::MAX;
86  case PoolingAlgorithm::Average: return PoolingType::AVG;
87  case PoolingAlgorithm::L2: return PoolingType::L2;
88  default: throw InvalidArgumentException("Unsupported pooling algorithm");
89  }
90 }

◆ ConvertResizeMethodToAclInterpolationPolicy()

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

Definition at line 125 of file ArmComputeUtils.hpp.

References Bilinear, and NearestNeighbor.

126 {
127  switch (resizeMethod)
128  {
129  case ResizeMethod::Bilinear:
130  return arm_compute::InterpolationPolicy::BILINEAR;
131  case ResizeMethod::NearestNeighbor:
132  return arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR;
133  default:
134  throw InvalidArgumentException("Unsupported resize method");
135  }
136 }

◆ ConvertWeightTensorFromArmnnToAcl()

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

Definition at line 132 of file WorkloadUtils.cpp.

References 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().

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

◆ ConvertWeightTensorInfoFromArmnnToAcl()

TensorInfo ConvertWeightTensorInfoFromArmnnToAcl ( const TensorInfo weightInfo,
DataLayout  dataLayout 
)

Definition at line 109 of file WorkloadUtils.cpp.

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

Referenced by GatherTensorHandlePairs().

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

◆ 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 >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), DataLayoutIndexed::GetWidthIndex(), NHWC, Encoder< IType >::Set(), and BaseIterator::SetIndex().

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  unsigned int depthMultiplier = depthwise ? rFilterShape[0] : 1;
99  unsigned int inputChannels = depthwise ? rFilterShape[1] : rFilterShape[channelsIndex];
100  unsigned int outputChannels = depthwise ? inputChannels * depthMultiplier : rFilterShape[0];
101 
102  unsigned int batchSize = rOutputShape[0];
103  unsigned int outputHeight = rOutputShape[heightIndex];
104  unsigned int outputWidth = rOutputShape[widthIndex];
105  unsigned int inputHeight = rInputShape[heightIndex];
106  unsigned int inputWidth = rInputShape[widthIndex];
107 
108  unsigned int filterHeight = depthwise ? rFilterShape[2] : rFilterShape[heightIndex];
109  unsigned int filterWidth = depthwise ? rFilterShape[3] : rFilterShape[widthIndex];
110 
111  for (unsigned int batchIdx = 0; batchIdx < batchSize; batchIdx++)
112  {
113  for (unsigned int cOutput = 0; cOutput < outputChannels; cOutput++)
114  {
115  for (unsigned int yOutput = 0; yOutput < outputHeight; yOutput++)
116  {
117  for (unsigned int xOutput = 0; xOutput < outputWidth; xOutput++)
118  {
119  // This loop goes over each output element.
120  float sum = 0.0f;
121 
122  // For depthwise, each output channel corresponds to exactly one input channel.
123  // For normal, must loop over each input channel.
124  for (unsigned int cInput = 0; cInput < (depthwise ? 1 : inputChannels); cInput++)
125  {
126  unsigned int depthwiseMultiplierIdx = 0;
127  if (depthwise)
128  {
129  cInput = cOutput / depthMultiplier;
130  depthwiseMultiplierIdx = cOutput % depthMultiplier;
131  }
132 
133  for (unsigned int yFilter = 0; yFilter < filterHeight; yFilter++)
134  {
135  for (unsigned int xFilter = 0; xFilter < filterWidth; xFilter++)
136  {
137  // This loop goes over each input element for each output element.
138  unsigned int filterIndex = 0;
139 
140  // Since dimensionality of kernel depends on depthwiseness, so does index.
141  if (depthwise)
142  {
143  filterIndex = depthwiseMultiplierIdx * filterWidth * filterHeight * inputChannels +
144  cInput * filterWidth * filterHeight +
145  yFilter * filterWidth +
146  xFilter;
147  }
148  else
149  {
150  // Keep this implementation, as using DataLayoutIndexed::GetIndex causes great
151  // performance regression.
152  if (dataLayout == DataLayout::NHWC)
153  {
154  filterIndex = cOutput * filterHeight * filterWidth * inputChannels +
155  yFilter * filterWidth * inputChannels +
156  xFilter * inputChannels +
157  cInput;
158  }
159  else
160  {
161  filterIndex = cOutput * filterWidth * filterHeight * inputChannels +
162  cInput * filterWidth * filterHeight +
163  yFilter * filterWidth +
164  xFilter;
165  }
166  }
167 
168  rFilterDecoder.SetIndex(filterIndex, cOutput);
169  float filterValue = rFilterDecoder.Get();
170 
171  unsigned int yInput = yOutput * yStride + yFilter * yDilation;
172  unsigned int xInput = xOutput * xStride + xFilter * xDilation;
173 
174  float inputValue;
175 
176  // Check if we're in the padding.
177  if (yInput < paddingTop || yInput >= inputHeight + paddingTop ||
178  xInput < paddingLeft || xInput >= inputWidth + paddingLeft )
179  {
180  inputValue = 0.0f;
181  }
182  else
183  {
184  unsigned int inputIndex = 0;
185 
186  // Keep this implementation, as using DataLayoutIndexed::GetIndex causes great
187  // performance regression.
188  if (dataLayout == DataLayout::NHWC)
189  {
190  inputIndex = batchIdx * inputHeight * inputWidth * inputChannels +
191  (yInput - paddingTop) * inputWidth * inputChannels +
192  (xInput - paddingLeft) * inputChannels +
193  cInput;
194  }
195  else
196  {
197  inputIndex = batchIdx * inputWidth * inputHeight * inputChannels +
198  inputWidth * inputHeight * cInput +
199  inputWidth * (yInput - paddingTop) +
200  xInput - paddingLeft;
201  }
202 
203  rInputDecoder[inputIndex];
204  inputValue = rInputDecoder.Get();
205  }
206 
207  sum += filterValue * inputValue;
208  }
209  }
210  }
211 
212  if (biasEnabled)
213  {
214  (*pBiasDecoder).SetIndex(cOutput, cOutput);
215  sum += pBiasDecoder->Get();
216  }
217 
218  unsigned int outIdx = dataLayoutIndexed.GetIndex(rOutputShape, batchIdx, cOutput, yOutput, xOutput);
219 
220  rOutputEncoder[outIdx];
221  rOutputEncoder.Set(sum);
222  }
223  }
224  }
225  }
226 }
virtual BaseIterator & SetIndex(unsigned int index, unsigned int axisIndex=0)=0
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ 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 49 of file WorkloadUtils.hpp.

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

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

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

◆ 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 242 of file Descriptors.hpp.

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

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

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

◆ CreateMergerDescriptorForConcatenation()

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

Definition at line 232 of file Descriptors.hpp.

References CreateDescriptorForConcatenation().

235 {
236  return CreateDescriptorForConcatenation(first, last, concatenationDimension);
237 }
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 297 of file QuantizerTest.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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

◆ CreateNetworkWithFullyConnectedLayer()

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

Definition at line 951 of file QuantizerTest.cpp.

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

Referenced by ValidateFullyConnectedLayer().

954 {
955  FullyConnectedDescriptor desc;
956  desc.m_BiasEnabled = biasEnabled;
957  INetworkPtr network = INetwork::Create();
958 
959  const TensorInfo info(inputShape, DataType::Float32);
960  const TensorInfo outputInfo(outputShape, DataType::Float32);
961 
962  std::vector<float> weightsData{-1.0f, 1.5f, 2.0f};
963  ConstTensor weights(info, weightsData);
964 
965  // Add the layers
966  IConnectableLayer* input0 = network->AddInputLayer(0);
967  IConnectableLayer* fullyConnected;
968  Optional<ConstTensor> optionalBias;
969  std::vector<float> biasData{10.0f, 20.0f, 30.0f};
970  if (desc.m_BiasEnabled)
971  {
972  ConstTensor bias(info, biasData);
973  optionalBias = Optional<ConstTensor>(bias);
974  }
975  fullyConnected = network->AddFullyConnectedLayer(desc, weights, optionalBias);
976  IConnectableLayer* output = network->AddOutputLayer(1);
977 
978  // Establish connections
979  input0->GetOutputSlot(0).Connect(fullyConnected->GetInputSlot(0));
980  fullyConnected->GetOutputSlot(0).Connect(output->GetInputSlot(0));
981 
982  // Set TensorInfo
983  input0->GetOutputSlot(0).SetTensorInfo(info);
984  fullyConnected->GetOutputSlot(0).SetTensorInfo(outputInfo);
985 
986  return network;
987 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85

◆ CreateNetworkWithInputOutputLayers()

INetworkPtr armnn::CreateNetworkWithInputOutputLayers ( )

Definition at line 318 of file QuantizerTest.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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

◆ CreateNetworkWithSoftmaxLayer()

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

Definition at line 1357 of file QuantizerTest.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

1358 {
1359  INetworkPtr network = INetwork::Create();
1360 
1361  // Add the layers
1362  IConnectableLayer* input0 = network->AddInputLayer(0);
1363  IConnectableLayer* softmax = network->AddSoftmaxLayer(descriptor);
1364  IConnectableLayer* output = network->AddOutputLayer(2);
1365 
1366  // Establish connections
1367  input0->GetOutputSlot(0).Connect(softmax->GetInputSlot(0));
1368  softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1369 
1370  // Set TensorInfo
1371  TensorInfo info(shape, DataType::Float32);
1372  input0->GetOutputSlot(0).SetTensorInfo(info);
1373  softmax->GetOutputSlot(0).SetTensorInfo(info);
1374 
1375  return network;
1376 }
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85

◆ CreateQuantizedConst()

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

Definition at line 15 of file NetworkQuantizerUtils.cpp.

References 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  BOOST_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 }
void QuantizeConstant(const srcType *src, uint8_t *dst, size_t numElements, float &scale, int &offset)
DataType
Definition: Types.hpp:32

◆ CreateStartOfLeakyReluNetwork()

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

Definition at line 1474 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().

1475 {
1476  ActivationDescriptor activationDescriptor;
1477  activationDescriptor.m_Function = ActivationFunction::LeakyReLu;
1478  activationDescriptor.m_A = 3.5f;
1479  activationDescriptor.m_B = -10.0f;
1480 
1481  // Add the layers
1482  IConnectableLayer* input0 = network->AddInputLayer(0);
1483  IConnectableLayer* activation = network->AddActivationLayer(activationDescriptor);
1484 
1485  // Establish connections
1486  input0->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
1487 
1488  // Set TensorInfo
1489  input0->GetOutputSlot(0).SetTensorInfo(info);
1490  activation->GetOutputSlot(0).SetTensorInfo(info);
1491 
1492  return activation;
1493 }

◆ CreateSupportedBackends()

BackendsMap CreateSupportedBackends ( TensorHandleFactoryRegistry handleFactoryRegistry,
BackendSettings backendSettings 
)

Definition at line 326 of file Network.cpp.

References BackendRegistryInstance(), and BackendSettings::m_SupportedBackends.

Referenced by Optimize().

328 {
329  BackendsMap backends;
330  auto const& backendRegistry = BackendRegistryInstance();
331  for (auto&& selectedBackend : backendSettings.m_SupportedBackends)
332  {
333  auto backendFactory = backendRegistry.GetFactory(selectedBackend);
334  auto backendObjPtr = backendFactory();
335  BOOST_ASSERT(backendObjPtr);
336 
337  backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
338 
339  backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
340  }
341 
342  return backends;
343 }
BackendRegistry & BackendRegistryInstance()
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:292

◆ Debug()

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

Definition at line 19 of file Debug.cpp.

References 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().

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

◆ 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 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  BOOST_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 }
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:121
unsigned int GetNumElements() const
Definition: Tensor.cpp:106
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
const TensorShape & GetShape() const
Definition: Tensor.hpp:88

◆ Dequantize() [1/4]

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

Definition at line 12 of file Dequantize.cpp.

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

16 {
17  boost::ignore_unused(outputInfo);
18  BOOST_ASSERT(inputInfo.GetNumElements() == outputInfo.GetNumElements());
19  for (unsigned int i = 0; i < inputInfo.GetNumElements(); i++)
20  {
21  // inputDecoder.Get() dequantizes the data element from whatever
22  // type is given by inputInfo to fp32 (If MakeDecoder supports that dequantization)
23  // outputEncoder.Set() transforms the data element to whatever type is
24  // given by outputInfo (if MakeEncoder supports that transformation)
25  outputEncoder.Set(inputDecoder.Get());
26  ++outputEncoder;
27  ++inputDecoder;
28  }
29 }
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ Dequantize() [2/4]

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

u8 helpers

Definition at line 76 of file RefWorkloadUtils.hpp.

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

77 {
78  std::vector<float> ret(info.GetNumElements());
79  for (size_t i = 0; i < info.GetNumElements(); i++)
80  {
81  ret[i] = armnn::Dequantize(quant[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
82  }
83  return ret;
84 }
float Dequantize(QuantizedType value, float scale, int32_t offset)
Definition: TypesUtils.cpp:47

◆ Dequantize() [3/4]

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

Definition at line 87 of file RefWorkloadUtils.hpp.

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

88 {
89  for (unsigned int i = 0; i < info.GetNumElements(); i++)
90  {
91  outputData[i] = Dequantize<T>(inputData[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
92  }
93 }

◆ 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 47 of file TypesUtils.cpp.

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

48 {
49  static_assert(IsQuantizedType<QuantizedType>(), "Not an integer type.");
50  BOOST_ASSERT(scale != 0.f);
51  BOOST_ASSERT(!IsNan(value));
52  float dequantized = boost::numeric_cast<float>(value - offset) * scale;
53  return dequantized;
54 }

◆ 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 141 of file DetectionPostProcess.cpp.

References AllocateOutputData(), anchors(), boxEncodings(), GenerateRangeK(), Decoder< IType >::Get(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), 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(), scores(), and TopKSort().

Referenced by DetectionPostProcessTestImpl().

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

◆ 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(), Event, JsonChildObject::GetChild(), Event::GetMeasurements(), Measurement, JsonChildObject::NumChildren(), JsonChildObject::SetType(), and JsonChildObject::SetUnit().

Referenced by Profiler::Print().

288 {
289  BOOST_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  BOOST_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

◆ FakeQuantization()

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

Definition at line 17 of file RefFakeQuantizationFloat32Workload.cpp.

18 {
19  float scale = (max - min) / 255.f;
20  int32_t offset = boost::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 }

◆ FalseFunc()

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

Definition at line 63 of file LayerSupportCommon.hpp.

64 {
65  boost::ignore_unused(reasonIfUnsupported);
66  boost::ignore_unused(params...);
67  return false;
68 }

◆ FalseFuncF16()

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

Definition at line 71 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseFuncF32()

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

Definition at line 79 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseFuncI32()

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

Definition at line 95 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseFuncU8()

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

Definition at line 87 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseInputFuncF16()

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

Definition at line 111 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseInputFuncF32()

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

Definition at line 103 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseOutputFuncF16()

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

Definition at line 127 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FalseOutputFuncF32()

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

Definition at line 119 of file LayerSupportCommon.hpp.

References SetValueChecked().

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

◆ FindKernelMeasurements()

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

Definition at line 63 of file Profiling.cpp.

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

64 {
65  BOOST_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 }

◆ FindMeasurement()

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

Definition at line 44 of file Profiling.cpp.

References Event::GetMeasurements().

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

45 {
46 
47  BOOST_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 }

◆ ForEachLayerInput()

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

Definition at line 259 of file SubgraphViewSelector.cpp.

References Layer::GetInputSlots().

Referenced by AssignSplitId(), and IsReadyForSplitAssignment().

262 {
263  Layer& layer = *layerInfo.m_Layer;
264 
265  for (auto inputSlot : layer.GetInputSlots())
266  {
267  auto connectedInput = boost::polymorphic_downcast<OutputSlot*>(inputSlot.GetConnection());
268  BOOST_ASSERT_MSG(connectedInput, "Dangling input slot detected.");
269  Layer& inputLayer = connectedInput->GetOwningLayer();
270 
271  auto parentInfo = layerInfos.find(&inputLayer);
272  if (parentInfo != layerInfos.end())
273  {
274  function(parentInfo->second);
275  }
276  }
277 }

◆ ForEachLayerOutput()

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

Definition at line 280 of file SubgraphViewSelector.cpp.

References Layer::GetOutputSlots().

Referenced by SubgraphViewSelector::SelectSubgraphs().

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

◆ FullyConnected()

void FullyConnected ( const TensorShape rInputShape,
Decoder< float > &  rInputDecoder,
const TensorShape rOutputShape,
Encoder< float > &  rOutputEncoder,
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 15 of file FullyConnected.cpp.

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

24 {
25  // Perform FullyConnected implementation
26  unsigned int outputSize = rOutputShape[1];
27 
28  for (unsigned int n = 0; n < rInputShape[0]; n++)
29  {
30  for (unsigned int channelOutput = 0; channelOutput < outputSize; channelOutput++)
31  {
32  float outval = 0.f;
33 
34  for (unsigned int channelInput = 0; channelInput < K; channelInput++)
35  {
36  float weight;
37  if (transposeWeights)
38  {
39  rWeightDecoder[channelOutput * K + channelInput];
40  weight = rWeightDecoder.Get();
41  }
42  else
43  {
44  rWeightDecoder[channelInput * outputSize + channelOutput];
45  weight = rWeightDecoder.Get();
46  }
47 
48  rInputDecoder[n * K + channelInput];
49  outval += weight * rInputDecoder.Get();
50  }
51 
52  if (biasEnabled)
53  {
54  rBiasDecoder[channelOutput];
55  outval += rBiasDecoder.Get();
56  }
57 
58  rOutputEncoder[n * outputSize + channelOutput];
59  rOutputEncoder.Set(outval);
60  }
61  }
62 }
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ Gather()

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

Definition at line 18 of file Gather.cpp.

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

24 {
25  boost::ignore_unused(outputInfo);
26  const TensorShape& paramsShape = paramsInfo.GetShape();
27 
28  unsigned int paramsProduct = 1;
29  for (unsigned int i = 1; i < paramsInfo.GetNumDimensions(); ++i)
30  {
31  paramsProduct = paramsProduct * paramsShape[i];
32  }
33 
34  unsigned int outIndex = 0;
35  for (unsigned int i = 0; i < indicesInfo.GetNumElements(); ++i)
36  {
37  unsigned int indx = boost::numeric_cast<unsigned int>(indices[i]);
38 
39  BOOST_ASSERT(indices[i] >= 0 && indx < paramsShape[0]);
40 
41  unsigned int startOffset = indx * paramsProduct;
42  unsigned int endOffset = startOffset + paramsProduct;
43 
44  for (unsigned int j = startOffset; j < endOffset; ++j)
45  {
46  params[j];
47  float outputValue = params.Get();
48  output[outIndex];
49  output.Set(outputValue);
50  ++outIndex;
51  }
52  }
53 
54  BOOST_ASSERT(outIndex == outputInfo.GetNumElements());
55 }
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ GatherTensorHandlePairs()

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

Definition at line 192 of file WorkloadUtils.hpp.

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

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

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

◆ GenerateRangeK()

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

Definition at line 18 of file DetectionPostProcess.cpp.

Referenced by DetectionPostProcess(), and NonMaxSuppression().

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

◆ GetActivationFunctionAsCString()

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

Definition at line 27 of file TypesUtils.hpp.

References Abs, BoundedReLu, 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  default: return "Unknown";
42  }
43 }

◆ GetArgMinMaxFunctionAsCString()

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

Definition at line 45 of file TypesUtils.hpp.

References Max, and Min.

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

◆ GetBiasDataType()

DataType GetBiasDataType ( DataType  inputDataType)

Definition at line 25 of file WorkloadData.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, 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::Float32:
32  return DataType::Float32;
33  case DataType::QAsymmS8:
34  return DataType::Signed32;
35  case DataType::QAsymmU8:
36  return DataType::Signed32;
37  case DataType::QSymmS8:
38  return DataType::Signed32;
39  case DataType::QSymmS16:
40  return DataType::Signed32;
41  default:
42  BOOST_ASSERT_MSG(false, "Invalid input data type");
43  return DataType::Float32;
44  }
45 }

◆ GetBiasTypeFromWeightsType()

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

◆ GetComparisonOperationAsCString()

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

Definition at line 55 of file TypesUtils.hpp.

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

Referenced by RefComparisonWorkload::Execute().

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

◆ 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(), 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 }
GPU Execution: OpenCL: ArmCompute.
CPU Execution: Reference C++ kernels.
CPU Execution: NEON: ArmCompute.

◆ GetDataLayoutName()

◆ GetDataTypeName()

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

Definition at line 165 of file TypesUtils.hpp.

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

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

166 {
167  switch (dataType)
168  {
169  case DataType::Float16: return "Float16";
170  case DataType::Float32: return "Float32";
171  case DataType::QAsymmU8: return "QAsymmU8";
172  case DataType::QAsymmS8: return "QAsymmS8";
173  case DataType::QSymmS8: return "QSymmS8";
175  case DataType::QuantizedSymm8PerAxis: return "QSymm8PerAxis";
177  case DataType::QSymmS16: return "QSymm16";
178  case DataType::Signed32: return "Signed32";
179  case DataType::Boolean: return "Boolean";
180 
181  default:
182  return "Unknown";
183  }
184 }
#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 113 of file TypesUtils.hpp.

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

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

114 {
115  switch (dataType)
116  {
117  case DataType::Float16: return 2U;
118  case DataType::Float32:
119  case DataType::Signed32: return 4U;
120  case DataType::QAsymmU8: return 1U;
121  case DataType::QAsymmS8: return 1U;
122  case DataType::QSymmS8: return 1U;
124  case DataType::QuantizedSymm8PerAxis: return 1U;
126  case DataType::QSymmS16: return 2U;
127  case DataType::Boolean: return 1U;
128  default: return 0U;
129  }
130 }
#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() [1/2]

const float* armnn::GetInputTensorData ( unsigned int  idx,
const AdditionQueueDescriptor data 
)

Definition at line 22 of file SampleDynamicAdditionWorkload.cpp.

References QueueDescriptor::m_Inputs, and ITensorHandle::Map().

23 {
24  const ITensorHandle* tensorHandle = data.m_Inputs[idx];
25  return reinterpret_cast<const float*>(tensorHandle->Map());
26 }

◆ GetInputTensorData() [2/2]

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

Definition at line 34 of file RefWorkloadUtils.hpp.

References ITensorHandle::Map().

Referenced by SampleDynamicAdditionWorkload::Execute().

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

◆ GetInputTensorDataFloat()

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

Definition at line 48 of file RefWorkloadUtils.hpp.

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

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

◆ GetInputTensorDataHalf()

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

Definition at line 60 of file RefWorkloadUtils.hpp.

Referenced by RefConvertFp16ToFp32Workload::Execute().

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

◆ GetInputTensorInfo()

TensorInfo armnn::GetInputTensorInfo ( const Network network)

Definition at line 337 of file QuantizerTest.cpp.

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

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

338 {
339  for (auto&& inputLayer : network->GetGraph().GetInputLayers())
340  {
341  BOOST_ASSERT_MSG(inputLayer->GetNumOutputSlots() == 1, "Input layer should have exactly 1 output slot");
342  return inputLayer->GetOutputSlot(0).GetTensorInfo();
343  }
344  throw InvalidArgumentException("Network has no input layers");
345 }

◆ GetLayerTypeAsCString()

const char * GetLayerTypeAsCString ( LayerType  type)

Definition at line 13 of file InternalTypes.cpp.

References Activation, Addition, ArgMinMax, BatchNormalization, BatchToSpaceNd, Comparison, Concat, Constant, ConvertFp16ToFp32, ConvertFp32ToFp16, Convolution2d, Debug, DepthToSpace, DepthwiseConvolution2d, Dequantize, DetectionPostProcess, Division, ElementwiseUnary, FakeQuantization, Floor, FullyConnected, Gather, Input, InstanceNormalization, L2Normalization, LogSoftmax, Lstm, Maximum, Mean, MemCopy, MemImport, Merge, Minimum, Multiplication, Normalization, Output, Pad, Permute, Pooling2d, PreCompiled, Prelu, Quantize, QuantizedLstm, Reshape, Resize, Slice, Softmax, SpaceToBatchNd, SpaceToDepth, Splitter, Stack, StandIn, StridedSlice, Subtraction, Switch, and TransposeConvolution2d.

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

14 {
15  switch (type)
16  {
17  case LayerType::Activation: return "Activation";
18  case LayerType::Addition: return "Addition";
19  case LayerType::ArgMinMax: return "ArgMinMax";
20  case LayerType::BatchNormalization: return "BatchNormalization";
21  case LayerType::BatchToSpaceNd: return "BatchToSpaceNd";
22  case LayerType::Comparison: return "Comparison";
23  case LayerType::Concat: return "Concat";
24  case LayerType::Constant: return "Constant";
25  case LayerType::ConvertFp16ToFp32: return "ConvertFp16ToFp32";
26  case LayerType::ConvertFp32ToFp16: return "ConvertFp32ToFp16";
27  case LayerType::Convolution2d: return "Convolution2d";
28  case LayerType::Debug: return "Debug";
29  case LayerType::DepthToSpace: return "DepthToSpace";
30  case LayerType::DepthwiseConvolution2d: return "DepthwiseConvolution2d";
31  case LayerType::Dequantize: return "Dequantize";
32  case LayerType::DetectionPostProcess: return "DetectionPostProcess";
33  case LayerType::Division: return "Division";
34  case LayerType::ElementwiseUnary: return "ElementwiseUnary";
35  case LayerType::FakeQuantization: return "FakeQuantization";
36  case LayerType::Floor: return "Floor";
37  case LayerType::FullyConnected: return "FullyConnected";
38  case LayerType::Gather: return "Gather";
39  case LayerType::Input: return "Input";
40  case LayerType::InstanceNormalization: return "InstanceNormalization";
41  case LayerType::L2Normalization: return "L2Normalization";
42  case LayerType::LogSoftmax: return "LogSoftmax";
43  case LayerType::Lstm: return "Lstm";
44  case LayerType::Maximum: return "Maximum";
45  case LayerType::Mean: return "Mean";
46  case LayerType::MemCopy: return "MemCopy";
47  case LayerType::MemImport: return "MemImport";
48  case LayerType::Merge: return "Merge";
49  case LayerType::Minimum: return "Minimum";
50  case LayerType::Multiplication: return "Multiplication";
51  case LayerType::Normalization: return "Normalization";
52  case LayerType::Output: return "Output";
53  case LayerType::Pad: return "Pad";
54  case LayerType::Permute: return "Permute";
55  case LayerType::Pooling2d: return "Pooling2d";
56  case LayerType::PreCompiled: return "PreCompiled";
57  case LayerType::Prelu: return "Prelu";
58  case LayerType::Quantize: return "Quantize";
59  case LayerType::QuantizedLstm: return "QuantizedLstm";
60  case LayerType::Reshape: return "Reshape";
61  case LayerType::Resize: return "Resize";
62  case LayerType::Slice: return "Slice";
63  case LayerType::Softmax: return "Softmax";
64  case LayerType::SpaceToBatchNd: return "SpaceToBatchNd";
65  case LayerType::SpaceToDepth: return "SpaceToDepth";
66  case LayerType::Splitter: return "Splitter";
67  case LayerType::Stack: return "Stack";
68  case LayerType::StandIn: return "StandIn";
69  case LayerType::StridedSlice: return "StridedSlice";
70  case LayerType::Subtraction: return "Subtraction";
71  case LayerType::Switch: return "Switch";
72  case LayerType::TransposeConvolution2d: return "TransposeConvolution2d";
73  default:
74  BOOST_ASSERT_MSG(false, "Unknown layer type");
75  return "Unknown";
76  }
77 }
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 Pooling2d(Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
Computes the Pooling2d operation.
Definition: Pooling2d.cpp:143
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:121
void FakeQuantization(const float *inputData, float *outputData, uint32_t numElements, float min, float max)
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:19
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)
QuantizedType Quantize(float value, float scale, int32_t offset)
Explicit specialization of Quantize for int8_t.
Definition: TypesUtils.cpp:31
void SpaceToBatchNd(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToBatchNdDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
void Gather(const TensorInfo &paramsInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo, Decoder< float > &params, const int32_t *indices, Encoder< float > &output)
Definition: Gather.cpp:18
float Dequantize(QuantizedType value, float scale, int32_t offset)
Definition: TypesUtils.cpp:47
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: Softmax.cpp:17
void Pad(const TensorInfo &inputInfo, const TensorInfo &outputInfo, std::vector< std::pair< unsigned int, unsigned int >> m_padList, const T *inputData, T *outData, const float padValue)
Definition: Pad.cpp:22
void ArgMinMax(Decoder< float > &in, int32_t *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
Definition: ArgMinMax.cpp:15
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 FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, 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 StridedSlice(const TensorInfo &inputInfo, const StridedSliceDescriptor &params, const void *inputData, void *outputData, unsigned int dataTypeSize)
void Slice(const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
Definition: Slice.cpp:15
void SpaceToDepth(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToDepthDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
void Splitter(const SplitterQueueDescriptor &data)
Definition: Splitter.hpp:17
void Resize(Decoder< float > &in, const TensorInfo &inputInfo, Encoder< float > &out, const TensorInfo &outputInfo, DataLayoutIndexed dataLayout, armnn::ResizeMethod resizeMethod, bool alignCorners)
Definition: Resize.cpp:35
float Activation(float in, ActivationFunction function, float a, float b)
Definition: Activation.cpp:12
void Stack(const StackQueueDescriptor &data, std::vector< std::unique_ptr< Decoder< float >>> &inputs, Encoder< float > &output)
Definition: Stack.cpp:12
void DepthToSpace(const TensorInfo &inputInfo, const DepthToSpaceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
void LogSoftmax(Decoder< float > &input, Encoder< float > &output, const TensorInfo &inputInfo, const LogSoftmaxDescriptor &descriptor)
Definition: LogSoftmax.cpp:30

◆ GetNormalizationAlgorithmChannelAsCString()

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

Definition at line 196 of file TypesUtils.hpp.

References Across, and Within.

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

197 {
198  switch (channel)
199  {
200  case NormalizationAlgorithmChannel::Across: return "Across";
201  case NormalizationAlgorithmChannel::Within: return "Within";
202  default: return "Unknown";
203  }
204 }

◆ GetNormalizationAlgorithmMethodAsCString()

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

Definition at line 206 of file TypesUtils.hpp.

References LocalBrightness, and LocalContrast.

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

207 {
208  switch (method)
209  {
210  case NormalizationAlgorithmMethod::LocalBrightness: return "LocalBrightness";
211  case NormalizationAlgorithmMethod::LocalContrast: return "LocalContrast";
212  default: return "Unknown";
213  }
214 }

◆ 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 }
armnn::DataLayout GetDataLayout() const
unsigned int GetHeightIndex() const
unsigned int GetWidthIndex() const
unsigned int GetChannelsIndex() const

◆ GetOutputShapeRoundingAsCString()

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

Definition at line 93 of file TypesUtils.hpp.

References Ceiling, and Floor.

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

94 {
95  switch (rounding)
96  {
97  case OutputShapeRounding::Ceiling: return "Ceiling";
98  case OutputShapeRounding::Floor: return "Floor";
99  default: return "Unknown";
100  }
101 }

◆ GetOutputTensorData() [1/2]

float* armnn::GetOutputTensorData ( unsigned int  idx,
const AdditionQueueDescriptor data 
)

Definition at line 28 of file SampleDynamicAdditionWorkload.cpp.

References QueueDescriptor::m_Outputs, and ITensorHandle::Map().

29 {
30  ITensorHandle* tensorHandle = data.m_Outputs[idx];
31  return reinterpret_cast<float*>(tensorHandle->Map());
32 }

◆ GetOutputTensorData() [2/2]

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

Definition at line 41 of file RefWorkloadUtils.hpp.

References ITensorHandle::Map().

Referenced by SampleDynamicAdditionWorkload::Execute().

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

◆ GetOutputTensorDataFloat()

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

Definition at line 54 of file RefWorkloadUtils.hpp.

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

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

◆ GetOutputTensorDataHalf()

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

Definition at line 66 of file RefWorkloadUtils.hpp.

Referenced by RefConvertFp32ToFp16Workload::Execute().

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

◆ GetPaddingMethodAsCString()

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

Definition at line 103 of file TypesUtils.hpp.

References Exclude, and IgnoreValue.

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

104 {
105  switch (method)
106  {
107  case PaddingMethod::Exclude: return "Exclude";
108  case PaddingMethod::IgnoreValue: return "IgnoreValue";
109  default: return "Unknown";
110  }
111 }

◆ GetPoolingAlgorithmAsCString()

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

Definition at line 82 of file TypesUtils.hpp.

References Average, L2, and Max.

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

83 {
84  switch (pooling)
85  {
86  case PoolingAlgorithm::Average: return "Average";
87  case PoolingAlgorithm::Max: return "Max";
88  case PoolingAlgorithm::L2: return "L2";
89  default: return "Unknown";
90  }
91 }

◆ 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 }

◆ GetResizeMethodAsCString()

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

Definition at line 216 of file TypesUtils.hpp.

References Bilinear, and NearestNeighbor.

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

217 {
218  switch (method)
219  {
220  case ResizeMethod::Bilinear: return "Bilinear";
221  case ResizeMethod::NearestNeighbor: return "NearestNeighbour";
222  default: return "Unknown";
223  }
224 }

◆ 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 & GetTensorInfo ( const ITensorHandle tensorHandle)
inline

float32 helpers

Definition at line 25 of file RefWorkloadUtils.hpp.

References RefTensorHandle::GetTensorInfo().

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

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

◆ GetUnaryOperationAsCString()

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

Definition at line 69 of file TypesUtils.hpp.

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

Referenced by RefElementwiseUnaryWorkload::Execute().

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

◆ GetUnpaddedTensorStrides()

TensorShape GetUnpaddedTensorStrides ( const TensorInfo tensorInfo)

Definition at line 14 of file CpuTensorHandle.cpp.

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

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

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

◆ InitializeArmComputeClTensorData()

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

Definition at line 90 of file ClWorkloadUtils.hpp.

92 {
93  BOOST_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::QAsymmS8:
105  case DataType::QAsymmU8:
106  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<uint8_t>());
107  break;
109  case DataType::QuantizedSymm8PerAxis:
111  case DataType::QSymmS8:
112  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int8_t>());
113  break;
115  case DataType::Signed32:
116  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int32_t>());
117  break;
118  default:
119  BOOST_ASSERT_MSG(false, "Unexpected tensor type.");
120  }
121 };
half_float::half Half
Definition: Half.hpp:16
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
void CopyArmComputeClTensorData(arm_compute::CLTensor &dstTensor, const T *srcData)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ InitializeArmComputeTensorData()

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

Definition at line 35 of file NeonWorkloadUtils.hpp.

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

37 {
38  BOOST_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  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int8_t>());
56  break;
58  case DataType::Signed32:
59  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int32_t>());
60  break;
61  default:
62  BOOST_ASSERT_MSG(false, "Unexpected tensor type.");
63  }
64 };
half_float::half Half
Definition: Half.hpp:16
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
void CopyArmComputeTensorData(arm_compute::Tensor &dstTensor, const T *srcData)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ InsertConvertFp16ToFp32LayersBefore()

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

Definition at line 40 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 AssignBackends(), BOOST_AUTO_TEST_CASE(), and ConvertFp32NetworkToFp16Impl::Run().

43 {
44  std::vector<ConvertFp16ToFp32Layer*> convertLayers;
45  convertLayers.reserve(layer.GetNumInputSlots());
46 
47  // Insert a ConvertFp16ToFp32Layer before each input slot
48  for (auto&& inputSlot = layer.BeginInputSlots(); inputSlot != layer.EndInputSlots(); ++inputSlot)
49  {
50  bool allowInsert = true;
51  if (expectCorrectInputType)
52  {
53  // Only insert ConvertFp16ToFp32Layer before FP16 input slots
54  OutputSlot* connectedOutputSlot = inputSlot->GetConnectedOutputSlot();
55  allowInsert =
56  connectedOutputSlot && connectedOutputSlot->GetTensorInfo().GetDataType() == DataType::Float16;
57  }
58 
59  if (allowInsert)
60  {
61  const std::string name =
62  std::string("convert_fp16_to_fp32-" + std::to_string(inputSlot->GetSlotIndex()) + "-") +
63  layer.GetName();
64  ConvertFp16ToFp32Layer* convertLayer =
65  graph.InsertNewLayer<ConvertFp16ToFp32Layer>(*inputSlot, name.c_str());
66 
67  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
68  convertInfo.SetDataType(DataType::Float32);
69 
70  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
71 
72  convertLayers.emplace_back(convertLayer);
73  }
74  }
75 
76  return convertLayers;
77 }

◆ InsertConvertFp32ToFp16LayersAfter()

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

Definition at line 79 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 AssignBackends(), BOOST_AUTO_TEST_CASE(), and ConvertFp32NetworkToFp16Impl::Run().

80 {
81  const unsigned int numOutputSlots = layer.GetNumOutputSlots();
82 
83  std::vector<ConvertFp32ToFp16Layer*> convertLayers;
84  convertLayers.reserve(numOutputSlots);
85 
86  // Update FP16 output slots to FP32 on current layer
87  ChangeOutputFp16ToFp32(layer);
88 
89  // Insert a ConvertFp32ToFp16Layer after each FP32 output slot
90  for (unsigned int slotIndex = 0u; slotIndex < numOutputSlots; ++slotIndex)
91  {
92  OutputSlot& outputSlot = layer.GetOutputSlot(slotIndex);
93  if(outputSlot.GetTensorInfo().GetDataType() == DataType::Float32)
94  {
95  const std::string name =
96  std::string("convert_fp32_to_fp16-" + std::to_string(slotIndex) + "-") + layer.GetName();
97  ConvertFp32ToFp16Layer* convertLayer =
98  graph.InsertNewLayer<ConvertFp32ToFp16Layer>(outputSlot, name.c_str());
99 
100  TensorInfo convertInfo = convertLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
101  convertInfo.SetDataType(DataType::Float16);
102 
103  convertLayer->GetOutputSlot().SetTensorInfo(convertInfo);
104 
105  convertLayers.emplace_back(convertLayer);
106  }
107  }
108 
109  return convertLayers;
110 }

◆ InsertDebugLayerAfter()

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

Definition at line 112 of file NetworkUtils.cpp.

References 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().

113 {
114  std::vector<DebugLayer*> debugLayers;
115  debugLayers.reserve(layer.GetNumOutputSlots());
116 
117  // Connect a DebugLayer to each output slot of the layer
118  for (auto outputSlot = layer.BeginOutputSlots(); outputSlot != layer.EndOutputSlots(); ++outputSlot)
119  {
120  const std::string debugName = std::string("DebugLayerAfter") + layer.GetNameStr();
121 
122  DebugLayer* debugLayer =
123  graph.InsertNewLayer<DebugLayer>(*outputSlot, debugName.c_str());
124 
125  // Sets output tensor info for the debug layer.
126  BOOST_ASSERT(debugLayer->GetInputSlot(0).GetConnectedOutputSlot() == &(*outputSlot));
127  TensorInfo debugInfo = debugLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
128 
129  debugLayer->GetOutputSlot().SetTensorInfo(debugInfo);
130 
131  // NOTE: It is OK to do this because DebugLayer is only supported on CpuRef
132  debugLayer->SetBackendId(Compute::CpuRef);
133 
134  debugLayers.emplace_back(debugLayer);
135  }
136 
137  return debugLayers;
138 }

◆ 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 }
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
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ IntersectionOverUnion()

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

Definition at line 31 of file DetectionPostProcess.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and NonMaxSuppression().

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

◆ 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.

75 {
76  FORWARD_LAYER_SUPPORT_FUNC(backend, IsActivationSupported, input, output, descriptor);
77 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 }
bool CheckTensorDataTypesEqual(const TensorInfo &input0, const TensorInfo &input1)
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsArgMinMaxSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ 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 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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,...)

◆ 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 
)

◆ 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 FORWARD_LAYER_SUPPORT_FUNC, and IsConcatSupported().

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

◆ 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 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 32 of file RefWorkloadFactory.cpp.

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

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

◆ 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.

Referenced by RefLayerSupport::IsDilatedDepthwiseConvolutionSupported().

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 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 53 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug(), and RefWorkloadFactory::CreatePad().

54 {
55  return IsDataType<DataType::Float16>(info);
56 }

◆ 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 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 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()

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

Definition at line 308 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

314 {
315  FORWARD_LAYER_SUPPORT_FUNC(backend, IsGatherSupported, input0, input1, output);
316 }
bool IsGatherSupported(const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 318 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and Greater.

324 {
326  IsComparisonSupported,
327  input0,
328  input1,
329  output,
330  ComparisonDescriptor(ComparisonOperation::Greater));
331 }
#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 333 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

337 {
339 }
#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 342 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

348 {
349  FORWARD_LAYER_SUPPORT_FUNC(backend, IsL2NormalizationSupported, input, output, descriptor);
350 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 352 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

359 {
360  FORWARD_LAYER_SUPPORT_FUNC(backend, IsLstmSupported, input, outputStateIn, cellStateIn,
361  scratchBuffer, outputStateOut, cellStateOut,
362  output, descriptor, paramsInfo);
363 }
#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 365 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

371 {
372  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMaximumSupported, input0, input1, output);
373 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 375 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

381 {
382  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMeanSupported, input, output, descriptor);
383 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 385 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

390 {
391  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMemCopySupported, input, output);
392 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsMemImportSupported()

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

Definition at line 394 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

399 {
400  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMemImportSupported, input, output);
401 }
#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 414 of file LayerSupport.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, FORWARD_LAYER_SUPPORT_FUNC, and IsMergerSupported().

420 {
421  BOOST_ASSERT(inputs.size() > 0);
422 
424  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMergerSupported, inputs, output, descriptor);
426 }
#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

◆ 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 403 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

409 {
410  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMergeSupported, input0, input1, output);
411 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 428 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

434 {
435  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMinimumSupported, input0, input1, output);
436 }
#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 438 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

444 {
445  FORWARD_LAYER_SUPPORT_FUNC(backend, IsMultiplicationSupported, input0, input1, output);
446 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 448 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

454 {
455  FORWARD_LAYER_SUPPORT_FUNC(backend, IsNormalizationSupported, input, output, descriptor);
456 }
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 19 of file RefWorkloadFactory.hpp.

19 { return true; }

◆ IsOperationQueueDescriptor() [2/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const MemCopyQueueDescriptor )

Definition at line 22 of file RefWorkloadFactory.hpp.

22 { return false; }

◆ IsOperationQueueDescriptor() [3/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const ConstantQueueDescriptor )

Definition at line 25 of file RefWorkloadFactory.hpp.

25 { return false; }

◆ IsOperationQueueDescriptor() [4/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const PermuteQueueDescriptor )

Definition at line 28 of file RefWorkloadFactory.hpp.

28 { 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 458 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

462 {
464 }
#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 466 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

472 {
473 
474  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPadSupported, input, output, descriptor);
475 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 501 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

507 {
508  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPermuteSupported, input, output, descriptor);
509 }
#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 511 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

517 {
518  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPooling2dSupported, input, output, descriptor);
519 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
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.

◆ 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 521 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

527 {
528  FORWARD_LAYER_SUPPORT_FUNC(backend, IsPreluSupported, input, alpha, output);
529 }
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 68 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

69 {
70  return IsDataType<DataType::QAsymmS8>(info);
71 }

◆ IsQAsymmU8()

bool armnn::IsQAsymmU8 ( const WorkloadInfo info)

Definition at line 73 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

74 {
75  return IsDataType<DataType::QAsymmU8>(info);
76 }

◆ IsQSymmS16()

bool armnn::IsQSymmS16 ( const WorkloadInfo info)

Definition at line 58 of file RefWorkloadFactory.cpp.

References info.

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

59 {
60  return IsDataType<DataType::QSymmS16>(info);
61 }

◆ IsQSymmS8()

bool armnn::IsQSymmS8 ( const WorkloadInfo info)

Definition at line 63 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

64 {
65  return IsDataType<DataType::QSymmS8>(info);
66 }

◆ IsQuantized8BitType()

constexpr bool armnn::IsQuantized8BitType ( DataType  dataType)

Definition at line 237 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(), and IsQuantizedType().

238 {
240  return dataType == DataType::QAsymmU8 ||
241  dataType == DataType::QAsymmS8 ||
242  dataType == DataType::QSymmS8 ||
243  dataType == DataType::QuantizedSymm8PerAxis;
245 }
#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 486 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

496 {
497  FORWARD_LAYER_SUPPORT_FUNC(backend, IsQuantizedLstmSupported, input, previousCellStateIn, previousOutputIn,
498  cellStateOut, output, paramsInfo);
499 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsQuantizedType() [1/2]

constexpr bool armnn::IsQuantizedType ( )

Definition at line 232 of file TypesUtils.hpp.

Referenced by TensorInfo::IsQuantized(), QuantizeQueueDescriptor::Validate(), and DequantizeQueueDescriptor::Validate().

233 {
234  return std::is_integral<T>::value;
235 }

◆ IsQuantizedType() [2/2]

constexpr bool armnn::IsQuantizedType ( DataType  dataType)

Definition at line 247 of file TypesUtils.hpp.

References IsQuantized8BitType(), and QSymmS16.

248 {
249  return dataType == DataType::QSymmS16 || IsQuantized8BitType(dataType);
250 }
constexpr bool IsQuantized8BitType(DataType dataType)
Definition: TypesUtils.hpp:237

◆ IsQuantizeSupported()

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

Definition at line 477 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

482 {
483  FORWARD_LAYER_SUPPORT_FUNC(backend, IsQuantizeSupported, input, output);
484 }
#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 366 of file SubgraphViewSelector.cpp.

References ForEachLayerInput().

Referenced by SubgraphViewSelector::SelectSubgraphs().

367 {
368  bool ready = true;
369  ForEachLayerInput(layerInfos, layerInfo,
370  [&ready](LayerSelectionInfo& parentInfo)
371  {
372  if (!parentInfo.m_IsProcessed)
373  {
374  ready = false;
375  }
376  });
377  return ready;
378 }
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 531 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and IsReshapeSupported().

537 {
538  FORWARD_LAYER_SUPPORT_FUNC(backend, IsReshapeSupported, input, output, descriptor);
539 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
bool IsReshapeSupported(const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ReshapeDescriptor &descriptor, char *reasonIfUnsupported, size_t reasonIfUnsupportedMaxLength)

◆ 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 552 of file LayerSupport.cpp.

References Bilinear, FORWARD_LAYER_SUPPORT_FUNC, IsResizeSupported(), ResizeDescriptor::m_Method, ResizeDescriptor::m_TargetHeight, and ResizeDescriptor::m_TargetWidth.

557 {
558  ResizeDescriptor descriptor;
559  descriptor.m_Method = ResizeMethod::Bilinear;
560 
561  const TensorShape& outputShape = output.GetShape();
562  descriptor.m_TargetWidth = outputShape[3];
563  descriptor.m_TargetHeight = outputShape[2];
564 
565  FORWARD_LAYER_SUPPORT_FUNC(backend, IsResizeSupported, input, output, descriptor);
566 }
#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 541 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

Referenced by ClLayerSupport::IsResizeBilinearSupported(), NeonLayerSupport::IsResizeBilinearSupported(), and IsResizeBilinearSupported().

547 {
548  FORWARD_LAYER_SUPPORT_FUNC(backend, IsResizeSupported, input, output, descriptor);
549 }
#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 568 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and Rsqrt.

573 {
575  IsElementwiseUnarySupported,
576  input,
577  output,
578  ElementwiseUnaryDescriptor(UnaryOperation::Rsqrt));
579 }
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsSigned32()

bool armnn::IsSigned32 ( const WorkloadInfo info)

Definition at line 48 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateDebug().

49 {
50  return IsDataType<DataType::Signed32>(info);
51 }

◆ 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 581 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

587 {
588  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSoftmaxSupported, input, output, descriptor);
589 }
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 591 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

597 {
598  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSpaceToBatchNdSupported, input, output, descriptor);
599 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 601 of file LayerSupport.cpp.

References ARMNN_DEPRECATED_MSG, and FORWARD_LAYER_SUPPORT_FUNC.

607 {
608  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSpaceToDepthSupported, input, output, descriptor);
609 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ IsSplitterSupported() [1/2]

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

Definition at line 612 of file LayerSupport.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, and FORWARD_LAYER_SUPPORT_FUNC.

Referenced by IsSplitterSupported().

617 {
619  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSplitterSupported, input, descriptor);
621 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
bool IsSplitterSupported(const BackendId &backend, const TensorInfo &input, const ViewsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ 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 623 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC, and IsSplitterSupported().

629 {
630  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSplitterSupported, input, outputs, descriptor);
631 }
bool IsSplitterSupported(const BackendId &backend, const TensorInfo &input, const ViewsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 633 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

639 {
640  FORWARD_LAYER_SUPPORT_FUNC(backend, IsStridedSliceSupported, input, output, descriptor);
641 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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 643 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

649 {
650  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSubtractionSupported, input0, input1, output);
651 }
#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 28 of file LayerSupportCommon.hpp.

References Boolean, Float16, Float32, QAsymmU8, and Signed32.

Referenced by RefLayerSupport::IsConvertFp16ToFp32Supported(), RefLayerSupport::IsConvertFp32ToFp16Supported(), and NeonLayerSupport::IsFloorSupported().

36 {
37  switch(dataType)
38  {
39  case DataType::Float16:
40  return float16FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
41  case DataType::Float32:
42  return float32FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
43  case DataType::QAsymmU8:
44  return uint8FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
45  case DataType::Signed32:
46  return int32FuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
47  case DataType::Boolean:
48  return booleanFuncPtr(reasonIfUnsupported, std::forward<Params>(params)...);
49  default:
50  return false;
51  }
52 }

◆ 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 653 of file LayerSupport.cpp.

References FORWARD_LAYER_SUPPORT_FUNC.

660 {
661  FORWARD_LAYER_SUPPORT_FUNC(backend, IsSwitchSupported, input0, input1, output0, output1);
662 }
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.
#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func,...)

◆ 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/57]

constexpr LayerType armnn::LayerEnumOf ( const T *  = nullptr)

◆ LayerEnumOf() [2/57]

constexpr LayerType armnn::LayerEnumOf ( const ActivationLayer )

Definition at line 93 of file LayersFwd.hpp.

◆ LayerEnumOf() [3/57]

constexpr LayerType armnn::LayerEnumOf ( const AdditionLayer )

Definition at line 94 of file LayersFwd.hpp.

◆ LayerEnumOf() [4/57]

constexpr LayerType armnn::LayerEnumOf ( const ArgMinMaxLayer )

Definition at line 95 of file LayersFwd.hpp.

◆ LayerEnumOf() [5/57]

constexpr LayerType armnn::LayerEnumOf ( const BatchNormalizationLayer )

Definition at line 96 of file LayersFwd.hpp.

◆ LayerEnumOf() [6/57]

constexpr LayerType armnn::LayerEnumOf ( const BatchToSpaceNdLayer )

Definition at line 97 of file LayersFwd.hpp.

◆ LayerEnumOf() [7/57]

constexpr LayerType armnn::LayerEnumOf ( const ComparisonLayer )

Definition at line 98 of file LayersFwd.hpp.

◆ LayerEnumOf() [8/57]

constexpr LayerType armnn::LayerEnumOf ( const ConcatLayer )

Definition at line 99 of file LayersFwd.hpp.

◆ LayerEnumOf() [9/57]

constexpr LayerType armnn::LayerEnumOf ( const ConstantLayer )

Definition at line 100 of file LayersFwd.hpp.

◆ LayerEnumOf() [10/57]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp16ToFp32Layer )

Definition at line 101 of file LayersFwd.hpp.

◆ LayerEnumOf() [11/57]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp32ToFp16Layer )

Definition at line 102 of file LayersFwd.hpp.

◆ LayerEnumOf() [12/57]

constexpr LayerType armnn::LayerEnumOf ( const Convolution2dLayer )

Definition at line 103 of file LayersFwd.hpp.

◆ LayerEnumOf() [13/57]

constexpr LayerType armnn::LayerEnumOf ( const DebugLayer )

Definition at line 104 of file LayersFwd.hpp.

◆ LayerEnumOf() [14/57]

constexpr LayerType armnn::LayerEnumOf ( const DepthToSpaceLayer )

Definition at line 105 of file LayersFwd.hpp.

◆ LayerEnumOf() [15/57]

constexpr LayerType armnn::LayerEnumOf ( const DepthwiseConvolution2dLayer )

Definition at line 106 of file LayersFwd.hpp.

◆ LayerEnumOf() [16/57]

constexpr LayerType armnn::LayerEnumOf ( const DequantizeLayer )

Definition at line 107 of file LayersFwd.hpp.

◆ LayerEnumOf() [17/57]

constexpr LayerType armnn::LayerEnumOf ( const DetectionPostProcessLayer )

Definition at line 108 of file LayersFwd.hpp.

◆ LayerEnumOf() [18/57]

constexpr LayerType armnn::LayerEnumOf ( const DivisionLayer )

Definition at line 109 of file LayersFwd.hpp.

◆ LayerEnumOf() [19/57]

constexpr LayerType armnn::LayerEnumOf ( const ElementwiseUnaryLayer )

Definition at line 110 of file LayersFwd.hpp.

◆ LayerEnumOf() [20/57]

constexpr LayerType armnn::LayerEnumOf ( const FakeQuantizationLayer )

Definition at line 111 of file LayersFwd.hpp.

◆ LayerEnumOf() [21/57]

constexpr LayerType armnn::LayerEnumOf ( const FloorLayer )

Definition at line 112 of file LayersFwd.hpp.

◆ LayerEnumOf() [22/57]

constexpr LayerType armnn::LayerEnumOf ( const FullyConnectedLayer )

Definition at line 113 of file LayersFwd.hpp.

◆ LayerEnumOf() [23/57]

constexpr LayerType armnn::LayerEnumOf ( const GatherLayer )

Definition at line 114 of file LayersFwd.hpp.

◆ LayerEnumOf() [24/57]

constexpr LayerType armnn::LayerEnumOf ( const InputLayer )

Definition at line 115 of file LayersFwd.hpp.

◆ LayerEnumOf() [25/57]

constexpr LayerType armnn::LayerEnumOf ( const InstanceNormalizationLayer )

Definition at line 116 of file LayersFwd.hpp.

◆ LayerEnumOf() [26/57]

constexpr LayerType armnn::LayerEnumOf ( const L2NormalizationLayer )

Definition at line 117 of file LayersFwd.hpp.

◆ LayerEnumOf() [27/57]

constexpr LayerType armnn::LayerEnumOf ( const LogSoftmaxLayer )

Definition at line 118 of file LayersFwd.hpp.

◆ LayerEnumOf() [28/57]

constexpr LayerType armnn::LayerEnumOf ( const LstmLayer )

Definition at line 119 of file LayersFwd.hpp.

◆ LayerEnumOf() [29/57]

constexpr LayerType armnn::LayerEnumOf ( const MaximumLayer )

Definition at line 120 of file LayersFwd.hpp.

◆ LayerEnumOf() [30/57]

constexpr LayerType armnn::LayerEnumOf ( const MeanLayer )

Definition at line 121 of file LayersFwd.hpp.

◆ LayerEnumOf() [31/57]

constexpr LayerType armnn::LayerEnumOf ( const MemCopyLayer )

Definition at line 122 of file LayersFwd.hpp.

◆ LayerEnumOf() [32/57]

constexpr LayerType armnn::LayerEnumOf ( const MemImportLayer )

Definition at line 123 of file LayersFwd.hpp.

◆ LayerEnumOf() [33/57]

constexpr LayerType armnn::LayerEnumOf ( const MergeLayer )

Definition at line 124 of file LayersFwd.hpp.

◆ LayerEnumOf() [34/57]

constexpr LayerType armnn::LayerEnumOf ( const MinimumLayer )

Definition at line 125 of file LayersFwd.hpp.

◆ LayerEnumOf() [35/57]

constexpr LayerType armnn::LayerEnumOf ( const MultiplicationLayer )

Definition at line 126 of file LayersFwd.hpp.

◆ LayerEnumOf() [36/57]

constexpr LayerType armnn::LayerEnumOf ( const NormalizationLayer )

Definition at line 127 of file LayersFwd.hpp.

◆ LayerEnumOf() [37/57]

constexpr LayerType armnn::LayerEnumOf ( const OutputLayer )

Definition at line 128 of file LayersFwd.hpp.

◆ LayerEnumOf() [38/57]

constexpr LayerType armnn::LayerEnumOf ( const PadLayer )

Definition at line 129 of file LayersFwd.hpp.

◆ LayerEnumOf() [39/57]

constexpr LayerType armnn::LayerEnumOf ( const PermuteLayer )

Definition at line 130 of file LayersFwd.hpp.

◆ LayerEnumOf() [40/57]

constexpr LayerType armnn::LayerEnumOf ( const Pooling2dLayer )

Definition at line 131 of file LayersFwd.hpp.

◆ LayerEnumOf() [41/57]

constexpr LayerType armnn::LayerEnumOf ( const PreCompiledLayer )

Definition at line 132 of file LayersFwd.hpp.

◆ LayerEnumOf() [42/57]

constexpr LayerType armnn::LayerEnumOf ( const PreluLayer )

Definition at line 133 of file LayersFwd.hpp.

◆ LayerEnumOf() [43/57]

constexpr LayerType armnn::LayerEnumOf ( const QuantizeLayer )

Definition at line 134 of file LayersFwd.hpp.

◆ LayerEnumOf() [44/57]

constexpr LayerType armnn::LayerEnumOf ( const QuantizedLstmLayer )

Definition at line 135 of file LayersFwd.hpp.

◆ LayerEnumOf() [45/57]

constexpr LayerType armnn::LayerEnumOf ( const ReshapeLayer )

Definition at line 136 of file LayersFwd.hpp.

◆ LayerEnumOf() [46/57]

constexpr LayerType armnn::LayerEnumOf ( const ResizeLayer )

Definition at line 137 of file LayersFwd.hpp.

◆ LayerEnumOf() [47/57]

constexpr LayerType armnn::LayerEnumOf ( const SliceLayer )

Definition at line 138 of file LayersFwd.hpp.

◆ LayerEnumOf() [48/57]

constexpr LayerType armnn::LayerEnumOf ( const SoftmaxLayer )

Definition at line 139 of file LayersFwd.hpp.

◆ LayerEnumOf() [49/57]

constexpr LayerType armnn::LayerEnumOf ( const SpaceToBatchNdLayer )

Definition at line 140 of file LayersFwd.hpp.

◆ LayerEnumOf() [50/57]

constexpr LayerType armnn::LayerEnumOf ( const SpaceToDepthLayer )

Definition at line 141 of file LayersFwd.hpp.

◆ LayerEnumOf() [51/57]

constexpr LayerType armnn::LayerEnumOf ( const SplitterLayer )

Definition at line 142 of file LayersFwd.hpp.

◆ LayerEnumOf() [52/57]

constexpr LayerType armnn::LayerEnumOf ( const StackLayer )

Definition at line 143 of file LayersFwd.hpp.

◆ LayerEnumOf() [53/57]

constexpr LayerType armnn::LayerEnumOf ( const StandInLayer )

Definition at line 144 of file LayersFwd.hpp.

◆ LayerEnumOf() [54/57]

constexpr LayerType armnn::LayerEnumOf ( const StridedSliceLayer )

Definition at line 145 of file LayersFwd.hpp.

◆ LayerEnumOf() [55/57]

constexpr LayerType armnn::LayerEnumOf ( const SubtractionLayer )

Definition at line 146 of file LayersFwd.hpp.

◆ LayerEnumOf() [56/57]

constexpr LayerType armnn::LayerEnumOf ( const SwitchLayer )

Definition at line 147 of file LayersFwd.hpp.

◆ LayerEnumOf() [57/57]

constexpr LayerType armnn::LayerEnumOf ( const TransposeConvolution2dLayer )

Definition at line 148 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:19

◆ LogSoftmax()

void LogSoftmax ( Decoder< float > &  input,
Encoder< float > &  output,
const TensorInfo inputInfo,
const LogSoftmaxDescriptor descriptor 
)

Definition at line 30 of file LogSoftmax.cpp.

References Decoder< IType >::Get(), TensorShape::GetNumDimensions(), TensorInfo::GetNumDimensions(), armnnUtils::GetNumElementsBetween(), TensorInfo::GetShape(), SoftmaxDescriptor::m_Axis, SoftmaxDescriptor::m_Beta, and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

34 {
35  const unsigned int numDimensions = inputInfo.GetNumDimensions();
36 
37  bool axisIsValid = ValidateAxis(descriptor.m_Axis, numDimensions);
38  BOOST_ASSERT_MSG(axisIsValid,
39  "Axis index is not in range [-numDimensions, numDimensions).");
40  boost::ignore_unused(axisIsValid);
41 
42  unsigned int uAxis = descriptor.m_Axis < 0 ?
43  numDimensions - boost::numeric_cast<unsigned int>(std::abs(descriptor.m_Axis)) :
44  boost::numeric_cast<unsigned int>(descriptor.m_Axis);
45 
46  const TensorShape& inputShape = inputInfo.GetShape();
47  const unsigned int outerSize = armnnUtils::GetNumElementsBetween(inputShape, 0, uAxis);
48  const unsigned int axisSize = inputShape[uAxis];
49  const unsigned int innerSize = armnnUtils::GetNumElementsBetween(inputShape,
50  uAxis + 1,
51  inputShape.GetNumDimensions());
52 
53  for (unsigned int outer = 0; outer < outerSize; ++outer)
54  {
55  for (unsigned int inner = 0; inner < innerSize; ++inner)
56  {
57  // Find max
58  input[outer * axisSize * innerSize + inner];
59  float maxValue = input.Get();
60  for (unsigned int i = 1u; i < axisSize; ++i)
61  {
62  input[(outer * axisSize + i) * innerSize + inner];
63  maxValue = std::max(maxValue, input.Get());
64  }
65 
66  // Compute sum
67  float sum = 0.0f;
68  for (unsigned int i = 0u; i < axisSize; ++i)
69  {
70  input[(outer * axisSize + i) * innerSize + inner];
71  sum += std::exp((input.Get() - maxValue) * descriptor.m_Beta);
72  }
73 
74  // Compute log sum
75  const float logSum = std::log(sum);
76 
77  // Compute result
78  for (unsigned int i = 0u; i < axisSize; ++i)
79  {
80  const unsigned int index = (outer * axisSize + i) * innerSize + inner;
81 
82  input [index];
83  output[index];
84 
85  output.Set((input.Get() - maxValue) * descriptor.m_Beta - logSum);
86  }
87  }
88  }
89 }
virtual IType Get() const =0
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
virtual void Set(IType right)=0

◆ 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/2]

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_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, 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::Float16:
106  {
107  return std::make_unique<Float16Decoder>(static_cast<const Half*>(data));
108  }
109  case DataType::Float32:
110  {
111  return std::make_unique<Float32Decoder>(static_cast<const float*>(data));
112  }
113  case DataType::Signed32:
114  {
115  return MakeSigned32Decoder(info, data);
116  }
117  case DataType::QSymmS8:
118  {
119  if (info.HasPerAxisQuantization())
120  {
121  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
122  return std::make_unique<QSymm8PerAxisDecoder>(
123  static_cast<const int8_t*>(data),
124  params.second,
125  params.first);
126  }
127  else
128  {
129  return std::make_unique<QSymmS8Decoder>(
130  static_cast<const int8_t*>(data),
131  info.GetQuantizationScale(),
132  info.GetQuantizationOffset());
133  }
134  }
135  default:
136  {
137  BOOST_ASSERT_MSG(false, "Unsupported Data Type!");
138  break;
139  }
140  }
141  return nullptr;
142 }
half_float::half Half
Definition: Half.hpp:16
#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

◆ MakeDecoder() [2/2]

std::unique_ptr<Decoder<float> > armnn::MakeDecoder ( const TensorInfo info,
const void *  data 
)
inline

Definition at line 70 of file Decoders.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, 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::Float16:
106  {
107  return std::make_unique<Float16Decoder>(static_cast<const Half*>(data));
108  }
109  case DataType::Float32:
110  {
111  return std::make_unique<Float32Decoder>(static_cast<const float*>(data));
112  }
113  case DataType::Signed32:
114  {
115  return MakeSigned32Decoder(info, data);
116  }
117  case DataType::QSymmS8:
118  {
119  if (info.HasPerAxisQuantization())
120  {
121  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
122  return std::make_unique<QSymm8PerAxisDecoder>(
123  static_cast<const int8_t*>(data),
124  params.second,
125  params.first);
126  }
127  else
128  {
129  return std::make_unique<QSymmS8Decoder>(
130  static_cast<const int8_t*>(data),
131  info.GetQuantizationScale(),
132  info.GetQuantizationOffset());
133  }
134  }
135  default:
136  {
137  BOOST_ASSERT_MSG(false, "Unsupported Data Type!");
138  break;
139  }
140  }
141  return nullptr;
142 }
half_float::half Half
Definition: Half.hpp:16
#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

◆ MakeEncoder() [1/3]

std::unique_ptr<Encoder<T> > armnn::MakeEncoder ( const TensorInfo info,
void *  data = nullptr 
)
inline

Definition at line 21 of file Encoders.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, 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<Float16Encoder>(static_cast<Half*>(data));
81  }
83  {
84  return std::make_unique<Float32Encoder>(static_cast<float*>(data));
85  }
86  default:
87  {
88  BOOST_ASSERT_MSG(false, "Unsupported target Data Type!");
89  break;
90  }
91  }
92  return nullptr;
93 }
half_float::half Half
Definition: Half.hpp:16
#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

◆ MakeEncoder() [2/3]

std::unique_ptr<Encoder<float> > armnn::MakeEncoder ( const TensorInfo info,
void *  data 
)
inline

Definition at line 21 of file Encoders.hpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, 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<Float16Encoder>(static_cast<Half*>(data));
81  }
83  {
84  return std::make_unique<Float32Encoder>(static_cast<float*>(data));
85  }
86  default:
87  {
88  BOOST_ASSERT_MSG(false, "Unsupported target Data Type!");
89  break;
90  }
91  }
92  return nullptr;
93 }
half_float::half Half
Definition: Half.hpp:16
#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

◆ MakeEncoder() [3/3]

std::unique_ptr<Encoder<bool> > armnn::MakeEncoder ( const TensorInfo info,
void *  data 
)
inline

Definition at line 96 of file Encoders.hpp.

References Boolean, and TensorInfo::GetDataType().

97 {
98  switch(info.GetDataType())
99  {
101  {
102  return std::make_unique<BooleanEncoder>(static_cast<uint8_t*>(data));
103  }
104  default:
105  {
106  BOOST_ASSERT_MSG(false, "Cannot encode from boolean. Not supported target Data Type!");
107  break;
108  }
109  }
110  return nullptr;
111 }

◆ MakeInfo()

arm_compute::DetectionPostProcessLayerInfo armnn::MakeInfo ( const DetectionPostProcessDescriptor desc)

Definition at line 18 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().

19 {
20  return arm_compute::DetectionPostProcessLayerInfo(desc.m_MaxDetections,
21  desc.m_MaxClassesPerDetection,
22  desc.m_NmsScoreThreshold,
23  desc.m_NmsIouThreshold,
24  desc.m_NumClasses,
25  { desc.m_ScaleX,
26  desc.m_ScaleY,
27  desc.m_ScaleW,
28  desc.m_ScaleH },
29  desc.m_UseRegularNms,
30  desc.m_DetectionsPerClass);
31 }

◆ MakeOptimizations()

Optimizer::Optimizations armnn::MakeOptimizations ( Args &&...  args)

Definition at line 43 of file Optimizer.hpp.

References Append().

Referenced by 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)

Definition at line 304 of file Optional.hpp.

References CONSTRUCT_IN_PLACE.

305 {
306  return Optional<T>(CONSTRUCT_IN_PLACE, std::forward<Args>(args)...);
307 }
#define CONSTRUCT_IN_PLACE
Definition: Optional.hpp:41

◆ 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 Decoder< IType >::Get(), TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), NextIndex(), 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 = boost::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  BOOST_ASSERT(boost::numeric_cast<float>(current) <
132  (std::numeric_limits<float>::max() / boost::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] / boost::numeric_cast<float>(numElementsInAxis));
140  }
141  }
142 }
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:92
bool NextIndex(const unsigned int numDims, const armnn::TensorShape &dims, std::vector< unsigned int > &current)
Definition: Mean.cpp:18
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 IType Get() const =0
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Set(IType right)=0

◆ 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"; }

◆ NeonAbsWorkloadValidate()

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

Definition at line 18 of file NeonAbsWorkload.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::NEAbsLayer::validate(&aclInput, &aclOutput);
24 }

◆ NeonActivationWorkloadValidate()

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

Definition at line 15 of file NeonActivationWorkload.cpp.

Referenced by NeonLayerSupport::IsActivationSupported().

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

◆ NeonAdditionWorkloadValidate()

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

Definition at line 17 of file NeonAdditionWorkload.cpp.

Referenced by NeonLayerSupport::IsAdditionSupported().

20 {
21  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
22  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
23  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
24 
25  return arm_compute::NEArithmeticAddition::validate(&aclInput0,
26  &aclInput1,
27  &aclOutput,
28  arm_compute::ConvertPolicy::SATURATE);
29 }

◆ NeonArgMinMaxWorkloadValidate()

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

Definition at line 29 of file NeonArgMinMaxWorkload.cpp.

Referenced by NeonLayerSupport::IsArgMinMaxSupported().

32 {
33  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
34  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
35 
36  auto numDims = input.GetNumDimensions();
37  auto unsignedAxis = armnnUtils::GetUnsignedAxis(numDims, descriptor.m_Axis);
38  int aclAxis = boost::numeric_cast<int>(CalcAclAxis(numDims, unsignedAxis));
39 
40  if (descriptor.m_Function == ArgMinMaxFunction::Max)
41  {
42  return arm_compute::NEArgMinMaxLayer::validate(&aclInput, aclAxis, &aclOutput,
43  arm_compute::ReductionOperation::ARG_IDX_MAX);
44  }
45  else
46  {
47  return arm_compute::NEArgMinMaxLayer::validate(&aclInput, aclAxis, &aclOutput,
48  arm_compute::ReductionOperation::ARG_IDX_MIN);
49  }
50 }
unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)

◆ 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 
)

Definition at line 20 of file NeonBatchNormalizationWorkload.cpp.

Referenced by NeonLayerSupport::IsBatchNormalizationSupported().

27 {
28  const arm_compute::TensorInfo aclInputInfo =
29  armcomputetensorutils::BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
30  const arm_compute::TensorInfo aclOutputInfo =
31  armcomputetensorutils::BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
32  const arm_compute::TensorInfo aclMeanInfo =
33  armcomputetensorutils::BuildArmComputeTensorInfo(mean, descriptor.m_DataLayout);
34  const arm_compute::TensorInfo aclVarInfo =
35  armcomputetensorutils::BuildArmComputeTensorInfo(var, descriptor.m_DataLayout);
36  const arm_compute::TensorInfo aclBetaInfo =
37  armcomputetensorutils::BuildArmComputeTensorInfo(beta, descriptor.m_DataLayout);
38  const arm_compute::TensorInfo aclGammaInfo =
39  armcomputetensorutils::BuildArmComputeTensorInfo(gamma, descriptor.m_DataLayout);
40 
41  return arm_compute::NEBatchNormalizationLayer::validate(&aclInputInfo,
42  &aclOutputInfo,
43  &aclMeanInfo,
44  &aclVarInfo,
45  &aclBetaInfo,
46  &aclGammaInfo,
47  descriptor.m_Eps);
48 }

◆ NeonBatchToSpaceNdWorkloadValidate()

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

Definition at line 16 of file NeonBatchToSpaceNdWorkload.cpp.

Referenced by NeonLayerSupport::IsBatchToSpaceNdSupported().

19 {
20  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, desc.m_DataLayout);
21  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, desc.m_DataLayout);
22 
23  // ArmNN blockShape is [H, W] Cl asks for W, H
24  int32_t blockHeight = boost::numeric_cast<int32_t>(desc.m_BlockShape[0]);
25  int32_t blockWidth = boost::numeric_cast<int32_t>(desc.m_BlockShape[1]);
26 
27  const arm_compute::Status aclStatus = arm_compute::NEBatchToSpaceLayer::validate(&aclInputInfo,
28  blockWidth,
29  blockHeight,
30  &aclOutputInfo);
31  return aclStatus;
32 }
Status
Definition: Types.hpp:26

◆ NeonConcatWorkloadValidate()

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

Definition at line 28 of file NeonConcatWorkload.cpp.

Referenced by NeonLayerSupport::IsConcatSupported().

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

◆ NeonConvolution2dWorkloadValidate()

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

Definition at line 22 of file NeonConvolution2dWorkload.cpp.

Referenced by NeonLayerSupport::IsConvolution2dSupported().

27 {
28  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
29  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
30  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
31 
32  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(descriptor.m_DilationX,
33  descriptor.m_DilationY);
34 
35  arm_compute::TensorInfo aclBiasesInfo;
36  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
37 
38  if (descriptor.m_BiasEnabled)
39  {
40  BOOST_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::NEConvolutionLayer::validate(&aclInputInfo,
49  &aclWeightsInfo,
50  optionalAclBiasesInfo,
51  &aclOutputInfo,
52  layerInfo,
53  arm_compute::WeightsInfo(),
54  aclDilationInfo);
55 }

◆ NeonDepthToSpaceWorkloadValidate()

arm_compute::Status NeonDepthToSpaceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const DepthToSpaceDescriptor descriptor 
)

Definition at line 20 of file NeonDepthToSpaceWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by NeonLayerSupport::IsDepthToSpaceSupported().

23 {
24  DataLayout dataLayout = descriptor.m_DataLayout;
25  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout);
26  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout);
27 
28  int32_t blockSize = boost::numeric_cast<int32_t>(descriptor.m_BlockSize);
29 
30  return arm_compute::NEDepthToSpaceLayer::validate(&aclInput, &aclOutput, blockSize);
31 }
DataLayout
Definition: Types.hpp:48

◆ NeonDepthwiseConvolutionWorkloadValidate()

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

Definition at line 28 of file NeonDepthwiseConvolutionWorkload.cpp.

Referenced by NeonLayerSupport::IsDepthwiseConvolutionSupported(), and NeonLayerSupport::IsDilatedDepthwiseConvolutionSupported().

33 {
34  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
35  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
36 
37  // ArmNN's weight format is [ M, I, H, W ]
38  const unsigned int aclDepthMultiplier = weights.GetShape()[0];
39 
40  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
41  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
42  TensorInfo weightsPermuted = ConvertWeightTensorInfoFromArmnnToAcl(weights, descriptor.m_DataLayout);
43 
44  // Convert the weights into the compute library format
45  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weightsPermuted, descriptor.m_DataLayout);
46 
47  arm_compute::TensorInfo aclBiasesInfo;
48  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
49 
50  if (descriptor.m_BiasEnabled)
51  {
52  BOOST_ASSERT(biases.has_value());
53 
54  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
55  optionalAclBiasesInfo = &aclBiasesInfo;
56  }
57 
58  arm_compute::PadStrideInfo aclPadStrideInfo = BuildArmComputePadStrideInfo(descriptor);
59  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
60  descriptor.m_DilationX,descriptor.m_DilationY);
61 
62  return arm_compute::NEDepthwiseConvolutionLayer::validate(&aclInputInfo,
63  &aclWeightsInfo,
64  optionalAclBiasesInfo,
65  &aclOutputInfo,
66  aclPadStrideInfo,
67  aclDepthMultiplier,
68  arm_compute::ActivationLayerInfo(),
69  aclDilationInfo);
70 }
uint32_t m_DilationX
Dilation factor value for width dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
bool m_BiasEnabled
Enable/disable bias.
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
bool has_value() const noexcept
Definition: Optional.hpp:53
TensorInfo ConvertWeightTensorInfoFromArmnnToAcl(const TensorInfo &weightInfo, DataLayout dataLayout)
uint32_t m_DilationY
Dilation factor value for height dimension.

◆ NeonDequantizeWorkloadValidate()

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

Definition at line 21 of file NeonDequantizeWorkload.cpp.

Referenced by NeonLayerSupport::IsDequantizeSupported().

23 {
24  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
25  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
26 
27  return arm_compute::NEDequantizationLayer::validate(&aclInput, &aclOutput);
28 }

◆ 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 33 of file NeonDetectionPostProcessWorkload.cpp.

References info, and MakeInfo().

41 {
42  arm_compute::DetectionPostProcessLayerInfo info = MakeInfo(desc);
43 
44  const arm_compute::TensorInfo aclBoxEncodings =
45  armcomputetensorutils::BuildArmComputeTensorInfo(boxEncodings);
46 
47  const arm_compute::TensorInfo aclScores =
48  armcomputetensorutils::BuildArmComputeTensorInfo(scores);
49 
50  const arm_compute::TensorInfo aclAnchors =
51  armcomputetensorutils::BuildArmComputeTensorInfo(anchors);
52 
53  arm_compute::TensorInfo aclDetectionBoxes =
54  armcomputetensorutils::BuildArmComputeTensorInfo(detectionBoxes);
55 
56  arm_compute::TensorInfo aclDetectionClasses =
57  armcomputetensorutils::BuildArmComputeTensorInfo(detectionClasses);
58 
59  arm_compute::TensorInfo aclDetectionScores =
60  armcomputetensorutils::BuildArmComputeTensorInfo(detectionScores);
61 
62  arm_compute::TensorInfo aclNumDetections =
63  armcomputetensorutils::BuildArmComputeTensorInfo(numDetections);
64 
65  return arm_compute::NEDetectionPostProcessLayer::validate(
66  &aclBoxEncodings,
67  &aclScores,
68  &aclAnchors,
69  &aclDetectionBoxes,
70  &aclDetectionClasses,
71  &aclDetectionScores,
72  &aclNumDetections,
73  info);
74 }
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::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 > 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 })
arm_compute::DetectionPostProcessLayerInfo MakeInfo(const DetectionPostProcessDescriptor &desc)

◆ NeonDivisionWorkloadValidate()

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

Definition at line 13 of file NeonDivisionWorkload.cpp.

Referenced by NeonLayerSupport::IsDivisionSupported().

16 {
17  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
18  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
19  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
20 
21  return arm_compute::NEElementwiseDivision::validate(&aclInput0,
22  &aclInput1,
23  &aclOutput);
24 }

◆ NeonFullyConnectedWorkloadValidate()

arm_compute::Status NeonFullyConnectedWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const TensorInfo weights,
const TensorInfo biases,
const FullyConnectedDescriptor descriptor 
)

Definition at line 19 of file NeonFullyConnectedWorkload.cpp.

Referenced by NeonLayerSupport::IsFullyConnectedSupported().

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

◆ NeonGreaterWorkloadValidate()

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

Definition at line 13 of file NeonGreaterWorkload.cpp.

Referenced by NeonLayerSupport::IsComparisonSupported().

16 {
17  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
18  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
19  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
20 
21  return arm_compute::NEGreater::validate(&aclInput0,
22  &aclInput1,
23  &aclOutput);
24 }

◆ 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 18 of file NeonL2NormalizationFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsL2NormalizationSupported().

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

◆ 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 271 of file NeonLstmFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsLstmSupported().

280 {
281  arm_compute::LSTMParams<arm_compute::ITensorInfo> lstm_params_info;
282 
283  // The inputs and outputs
284  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
285  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
286  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
287  const arm_compute::TensorInfo aclScratchBufferInfo = BuildArmComputeTensorInfo(scratchBuffer);
288  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
289  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
290  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
291 
292  // Basic parameters
293  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
294  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
295  const arm_compute::TensorInfo aclInputToCellWeightsInfo
296  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
297  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
298  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
299  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
300  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
301  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
302  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
303  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
304  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
305  const arm_compute::TensorInfo aclForgetGateBiasInfo
306  = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
307  const arm_compute::TensorInfo aclCellBiasInfo
308  = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
309  const arm_compute::TensorInfo aclOutputGateBiasInfo
310  = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
311 
312  arm_compute::TensorInfo aclInputToInputWeightsInfo;
313  arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
314  arm_compute::TensorInfo aclCellToInputWeightsInfo;
315  arm_compute::TensorInfo aclInputGateBiasInfo;
316  arm_compute::TensorInfo aclProjectionWeightsInfo;
317  arm_compute::TensorInfo aclProjectionBiasInfo;
318  arm_compute::TensorInfo aclCellToForgetWeightsInfo;
319  arm_compute::TensorInfo aclCellToOutputWeightsInfo;
320 
321  arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
322  arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
323  arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
324  arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
325 
326 
327  if (!descriptor.m_CifgEnabled)
328  {
329  if (descriptor.m_PeepholeEnabled)
330  {
331  aclCellToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToInputWeights());
332  }
333  aclInputToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
334  aclRecurrentToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
335  aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
336 
337  lstm_params_info.set_cifg_params(&aclInputToInputWeightsInfo, &aclRecurrentToInputWeightsInfo,
338  descriptor.m_PeepholeEnabled ? &aclCellToInputWeightsInfo : nullptr,
339  &aclInputGateBiasInfo);
340  }
341 
342  if (descriptor.m_ProjectionEnabled)
343  {
344  if (paramsInfo.m_ProjectionBias != nullptr)
345  {
346  aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionBias());
347  }
348  aclProjectionWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionWeights());
349 
350  lstm_params_info.set_projection_params(&aclProjectionWeightsInfo,
351  paramsInfo.m_ProjectionBias != nullptr ?
352  &aclProjectionBiasInfo : nullptr);
353  }
354 
355  if (descriptor.m_PeepholeEnabled)
356  {
357  aclCellToForgetWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToForgetWeights());
358  aclCellToOutputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToOutputWeights());
359 
360  lstm_params_info.set_peephole_params(&aclCellToForgetWeightsInfo, &aclCellToOutputWeightsInfo);
361  }
362 
363  if (descriptor.m_LayerNormEnabled)
364  {
365  if (!descriptor.m_CifgEnabled)
366  {
367  aclInputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputLayerNormWeights());
368  }
369  aclForgetLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetLayerNormWeights());
370  aclCellLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellLayerNormWeights());
371  aclOutputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputLayerNormWeights());
372 
373  lstm_params_info.set_layer_normalization_params(descriptor.m_CifgEnabled ?
374  nullptr : &aclInputLayerNormWeightsInfo,
375  &aclForgetLayerNormWeightsInfo,
376  &aclCellLayerNormWeightsInfo,
377  &aclOutputLayerNormWeightsInfo);
378  }
379 
380  float cell_threshold = descriptor.m_ClippingThresCell;
381  float projection_threshold = descriptor.m_ClippingThresProj;
382 
383  // for preparing the object for the class ActivationLayerInfo, we need to consider 5 situations
384  arm_compute::ActivationLayerInfo activationLayerInfo;
385  switch (descriptor.m_ActivationFunc)
386  {
387  case 0:
388  // no activation, do nothing
389  break;
390  case 1:
391  activationLayerInfo = arm_compute::ActivationLayerInfo(
392  arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
393  break;
394  case 3:
395  activationLayerInfo = arm_compute::ActivationLayerInfo(
396  arm_compute::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.0);
397  break;
398  case 4:
399  activationLayerInfo = arm_compute::ActivationLayerInfo(
400  arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0, 1.0);
401  break;
402  case 6:
403  activationLayerInfo = arm_compute::ActivationLayerInfo(
404  arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC);
405  break;
406  default:
407  throw armnn::Exception("Wrong Type of Activation Function!");
408  }
409 
410  return arm_compute::NELSTMLayer::validate(&aclInputInfo,
411  &aclInputToForgetWeightsInfo,
412  &aclInputToCellWeightsInfo,
413  &aclInputToOutputWeightsInfo,
414  &aclRecurrentToForgetWeightsInfo,
415  &aclRecurrentToCellWeightsInfo,
416  &aclRecurrentToOutputWeightsInfo,
417  &aclForgetGateBiasInfo,
418  &aclCellBiasInfo,
419  &aclOutputGateBiasInfo,
420  &aclOutputStateInInfo,
421  &aclCellStateInInfo,
422  &aclScratchBufferInfo,
423  &aclOutputStateOutInfo,
424  &aclCellStateOutInfo,
425  &aclOutputInfo,
426  lstm_params_info,
427  activationLayerInfo,
428  cell_threshold,
429  projection_threshold);
430 }
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 13 of file NeonMaximumWorkload.cpp.

Referenced by NeonLayerSupport::IsMaximumSupported().

16 {
17  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
18  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
19  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
20 
21  return arm_compute::NEElementwiseMax::validate(&aclInput0,
22  &aclInput1,
23  &aclOutput);
24 }

◆ 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 13 of file NeonMinimumWorkload.cpp.

Referenced by NeonLayerSupport::IsMinimumSupported().

16 {
17  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
18  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
19  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
20 
21  return arm_compute::NEElementwiseMin::validate(&aclInput0,
22  &aclInput1,
23  &aclOutput);
24 }

◆ NeonMultiplicationWorkloadValidate()

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

Definition at line 15 of file NeonMultiplicationWorkload.cpp.

Referenced by NeonLayerSupport::IsMultiplicationSupported().

18 {
19  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
20  const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
21  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it,
24  // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be
25  // ignored for F32 tensors.
26  return arm_compute::NEPixelWiseMultiplication::validate(&aclInput1,
27  &aclInput2,
28  &aclOutput,
29  1.0f,
30  arm_compute::ConvertPolicy::SATURATE,
31  arm_compute::RoundingPolicy::TO_ZERO);
32 }

◆ NeonNormalizationWorkloadValidate()

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

Definition at line 47 of file NeonNormalizationFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsNormalizationSupported().

50 {
51  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
52  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
53 
54  arm_compute::NormalizationLayerInfo normalizationInfo = BuildArmComputeNormalizationLayerInfo(descriptor);
55 
56  return arm_compute::NENormalizationLayer::validate(&aclInput, &aclOutput, normalizationInfo);
57 }

◆ 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 20 of file NeonPooling2dWorkload.cpp.

Referenced by NeonLayerSupport::IsPooling2dSupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo =
25  BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
26  const arm_compute::TensorInfo aclOutputInfo =
27  BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
28 
29  arm_compute::PoolingLayerInfo layerInfo = BuildArmComputePoolingLayerInfo(descriptor);
30 
31  return arm_compute::NEPoolingLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo);
32 }

◆ NeonPreluWorkloadValidate()

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

Definition at line 15 of file NeonPreluWorkload.cpp.

Referenced by NeonLayerSupport::IsPreluSupported().

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

◆ 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 19 of file NeonQuantizeWorkload.cpp.

Referenced by NeonLayerSupport::IsQuantizeSupported().

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

◆ 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 20 of file NeonResizeWorkload.cpp.

Referenced by NeonLayerSupport::IsResizeSupported().

23 {
24  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
25  arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
26 
27  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(descriptor.m_DataLayout);
28  aclInputInfo.set_data_layout(aclDataLayout);
29  aclOutputInfo.set_data_layout(aclDataLayout);
30 
31  arm_compute::InterpolationPolicy aclInterpolationPolicy =
33 
34  return arm_compute::NEScale::validate(&aclInputInfo,
35  &aclOutputInfo,
36  aclInterpolationPolicy,
37  arm_compute::BorderMode::REPLICATE,
38  arm_compute::PixelValue(0.f),
39  arm_compute::SamplingPolicy::TOP_LEFT);
40 }
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
DataLayout
Definition: Types.hpp:48

◆ 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 19 of file NeonSliceWorkload.cpp.

Referenced by NeonLayerSupport::IsSliceSupported().

22 {
23  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
28 
29  std::tie(starts, ends) = SetNeonSliceData(descriptor.m_Begin, descriptor.m_Size);
30 
31  return arm_compute::NESlice::validate(&aclInputInfo, &aclOutputInfo, starts, ends);
32 }
auto SetNeonSliceData(const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ NeonSoftmaxWorkloadValidate()

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

Definition at line 16 of file NeonSoftmaxBaseWorkload.cpp.

Referenced by NeonLayerSupport::IsSoftmaxSupported().

19 {
20  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
21  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
22 
23  unsigned int aclAxis = ComputeSoftmaxAclAxis(descriptor, input);
24  return arm_compute::NESoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis);
25 }
unsigned int ComputeSoftmaxAclAxis(const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)

◆ NeonSpaceToBatchNdWorkloadValidate()

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

Definition at line 16 of file NeonSpaceToBatchNdWorkload.cpp.

Referenced by NeonLayerSupport::IsSpaceToBatchNdSupported().

19 {
20  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
21  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
22 
23  // ArmNN blockShape is [H, W] Cl asks for W, H
24  int32_t blockHeight = boost::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
25  int32_t blockWidth = boost::numeric_cast<int32_t>(descriptor.m_BlockShape[1]);
26 
27  arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(
28  descriptor.m_PadList[1].first, descriptor.m_PadList[0].first);
29  arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(
30  descriptor.m_PadList[1].second, descriptor.m_PadList[0].second);
31 
32  return arm_compute::NESpaceToBatchLayer::validate(&aclInputInfo,
33  blockWidth,
34  blockHeight,
35  paddingLeftTop,
36  paddingRightBottom,
37  &aclOutputInfo);
38 }

◆ NeonSpaceToDepthWorkloadValidate()

arm_compute::Status NeonSpaceToDepthWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const SpaceToDepthDescriptor descriptor 
)

Definition at line 15 of file NeonSpaceToDepthWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by NeonLayerSupport::IsSpaceToDepthSupported().

18 {
19  DataLayout dataLayout = descriptor.m_DataLayout;
20  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout);
21  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout);
22 
23  int32_t blockSize = boost::numeric_cast<int32_t>(descriptor.m_BlockSize);
24 
25  return arm_compute::NESpaceToDepthLayer::validate(&aclInput, &aclOutput, blockSize);
26 }
DataLayout
Definition: Types.hpp:48

◆ NeonSplitterWorkloadValidate()

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

Definition at line 31 of file NeonSplitterWorkload.cpp.

Referenced by NeonLayerSupport::IsSplitterSupported().

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

◆ NeonStackWorkloadValidate()

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

Definition at line 28 of file NeonStackWorkload.cpp.

Referenced by NeonLayerSupport::IsStackSupported().

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 
39  std::vector<arm_compute::ITensorInfo*> aclInputPtrs;
40  for (arm_compute::ITensorInfo& input : aclInputs)
41  {
42  aclInputPtrs.emplace_back(&input);
43  }
44 
45  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
46  int aclAxis = CalcAxis(descriptor.m_Axis, descriptor.m_InputShape.GetNumDimensions());
47  return arm_compute::NEStackLayer::validate(aclInputPtrs, aclAxis, &aclOutputInfo);
48 }

◆ NeonStridedSliceWorkloadValidate()

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

Definition at line 17 of file NeonStridedSliceWorkload.cpp.

Referenced by NeonLayerSupport::IsStridedSliceSupported().

20 {
21  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
27 
28  std::tie(starts, ends, strides) = SetNeonStridedSliceData(descriptor.m_Begin,
29  descriptor.m_End,
30  descriptor.m_Stride);
31 
32  auto numDimensions = boost::numeric_cast<int>(input.GetNumDimensions());
33  int32_t begin_mask = ConvertMaskToACLFormat(descriptor.m_BeginMask, numDimensions);
34  int32_t end_mask = ConvertMaskToACLFormat(descriptor.m_EndMask, numDimensions);
35  int32_t shrink_axis_mask = ConvertMaskToACLFormat(descriptor.m_ShrinkAxisMask, numDimensions);
36 
37  return arm_compute::NEStridedSlice::validate(&aclInput,
38  &aclOutput,
39  starts,
40  ends,
41  strides,
42  begin_mask,
43  end_mask,
44  shrink_axis_mask);
45 }
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)

◆ NeonSubtractionWorkloadValidate()

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

Definition at line 17 of file NeonSubtractionWorkload.cpp.

Referenced by NeonLayerSupport::IsSubtractionSupported().

20 {
21  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
22  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
23  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
24 
25  return arm_compute::NEArithmeticSubtraction::validate(&aclInput0,
26  &aclInput1,
27  &aclOutput,
28  arm_compute::ConvertPolicy::SATURATE);
29 }

◆ 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 26 of file NeonTransposeConvolution2dWorkload.cpp.

Referenced by NeonLayerSupport::IsTransposeConvolution2dSupported().

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  arm_compute::TensorInfo aclBiasesInfo;
37  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
38 
39  if (descriptor.m_BiasEnabled)
40  {
41  BOOST_ASSERT(biases.has_value());
42 
43  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
44  optionalAclBiasesInfo = &aclBiasesInfo;
45  }
46 
47  arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor);
48 
49  return arm_compute::NEDeconvolutionLayer::validate(&aclInputInfo,
50  &aclWeightsInfo,
51  optionalAclBiasesInfo,
52  &aclOutputInfo,
53  layerInfo);
54 }

◆ 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 50 of file DetectionPostProcess.cpp.

References GenerateRangeK(), IntersectionOverUnion(), and TopKSort().

Referenced by BOOST_AUTO_TEST_CASE(), and DetectionPostProcess().

56 {
57  // Select boxes that have scores above a given threshold.
58  std::vector<float> scoresAboveThreshold;
59  std::vector<unsigned int> indicesAboveThreshold;
60  for (unsigned int i = 0; i < numBoxes; ++i)
61  {
62  if (scores[i] >= nmsScoreThreshold)
63  {
64  scoresAboveThreshold.push_back(scores[i]);
65  indicesAboveThreshold.push_back(i);
66  }
67  }
68 
69  // Sort the indices based on scores.
70  unsigned int numAboveThreshold = boost::numeric_cast<unsigned int>(scoresAboveThreshold.size());
71  std::vector<unsigned int> sortedIndices = GenerateRangeK(numAboveThreshold);
72  TopKSort(numAboveThreshold, sortedIndices.data(), scoresAboveThreshold.data(), numAboveThreshold);
73 
74  // Number of output cannot be more than max detections specified in the option.
75  unsigned int numOutput = std::min(maxDetection, numAboveThreshold);
76  std::vector<unsigned int> outputIndices;
77  std::vector<bool> visited(numAboveThreshold, false);
78 
79  // Prune out the boxes with high intersection over union by keeping the box with higher score.
80  for (unsigned int i = 0; i < numAboveThreshold; ++i)
81  {
82  if (outputIndices.size() >= numOutput)
83  {
84  break;
85  }
86  if (!visited[sortedIndices[i]])
87  {
88  outputIndices.push_back(indicesAboveThreshold[sortedIndices[i]]);
89  }
90  for (unsigned int j = i + 1; j < numAboveThreshold; ++j)
91  {
92  unsigned int iIndex = indicesAboveThreshold[sortedIndices[i]] * 4;
93  unsigned int jIndex = indicesAboveThreshold[sortedIndices[j]] * 4;
94  if (IntersectionOverUnion(&boxCorners[iIndex], &boxCorners[jIndex]) > nmsIouThreshold)
95  {
96  visited[sortedIndices[j]] = true;
97  }
98  }
99  }
100  return outputIndices;
101 }
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 })
void TopKSort(unsigned int k, unsigned int *indices, const float *values, unsigned int numElement)
std::vector< unsigned int > GenerateRangeK(unsigned int k)
float IntersectionOverUnion(const float *boxI, const float *boxJ)

◆ 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 }
armnn::DataLayout GetDataLayout() const
unsigned int GetHeightIndex() const
unsigned int GetWidthIndex() const
unsigned int GetChannelsIndex() const

◆ operator<<() [1/8]

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 }
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Definition: BackendId.hpp:34

◆ operator<<() [2/8]

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 }
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Definition: BackendId.hpp:34

◆ operator<<() [3/8]

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/8]

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)
Definition: BackendId.hpp:34

◆ operator<<() [5/8]

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<<() [6/8]

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<<() [7/8]

std::ostream& armnn::operator<< ( std::ostream &  os,
Status  stat 
)
inline

Definition at line 252 of file TypesUtils.hpp.

References GetStatusAsCString().

253 {
254  os << GetStatusAsCString(stat);
255  return os;
256 }
constexpr char const * GetStatusAsCString(Status status)
Definition: TypesUtils.hpp:17

◆ operator<<() [8/8]

std::ostream& armnn::operator<< ( std::ostream &  os,
const armnn::TensorShape shape 
)
inline

Definition at line 259 of file TypesUtils.hpp.

References Dequantize, TensorShape::GetNumDimensions(), and Quantize.

260 {
261  os << "[";
262  for (uint32_t i=0; i<shape.GetNumDimensions(); ++i)
263  {
264  if (i!=0)
265  {
266  os << ",";
267  }
268  os << shape[i];
269  }
270  os << "]";
271  return os;
272 }
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:43

◆ operator>>() [1/2]

std::istream& armnn::operator>> ( std::istream &  in,
armnn::Compute compute 
)
inline

Definition at line 19 of file InferenceTest.hpp.

References ParseComputeDevice(), and Undefined.

20 {
21  std::string token;
22  in >> token;
23  compute = armnn::ParseComputeDevice(token.c_str());
24  if (compute == armnn::Compute::Undefined)
25  {
26  in.setstate(std::ios_base::failbit);
27  throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
28  }
29  return in;
30 }
constexpr armnn::Compute ParseComputeDevice(const char *str)
Definition: TypesUtils.hpp:145

◆ operator>>() [2/2]

std::istream& armnn::operator>> ( std::istream &  in,
armnn::BackendId backend 
)
inline

Definition at line 32 of file InferenceTest.hpp.

References ParseComputeDevice(), and Undefined.

33 {
34  std::string token;
35  in >> token;
36  armnn::Compute compute = armnn::ParseComputeDevice(token.c_str());
37  if (compute == armnn::Compute::Undefined)
38  {
39  in.setstate(std::ios_base::failbit);
40  throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
41  }
42  backend = compute;
43  return in;
44 }
constexpr armnn::Compute ParseComputeDevice(const char *str)
Definition: TypesUtils.hpp:145

◆ 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 807 of file Network.cpp.

References ApplyBackendOptimizations(), 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_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(), QuantizedLstmEndToEnd(), NetworkQuantizer::Refine(), ParserPrototxtFixture< armnnOnnxParser::IOnnxParser >::Setup(), ParserFlatbuffersSerializeFixture::Setup(), ParserFlatbuffersFixture::Setup(), ParserPrototxtFixture< armnnOnnxParser::IOnnxParser >::SetupOptimizedNetwork(), and VerifyPostOptimisationStructureTestImpl().

812 {
813  if (backendPreferences.empty())
814  {
815  throw armnn::InvalidArgumentException("Invoked Optimize with no backends specified");
816  }
817 
818  const Network& network = *boost::polymorphic_downcast<const Network*>(&inNetwork);
819  std::unique_ptr<Graph> graph = std::make_unique<Graph>(network.GetGraph());
820 
821  auto optNet = IOptimizedNetworkPtr(new OptimizedNetwork(std::move(graph)), &IOptimizedNetwork::Destroy);
822 
823  OptimizedNetwork* optNetObjPtr = boost::polymorphic_downcast<OptimizedNetwork*>(optNet.get());
824 
825  // Get the optimized graph
826  Graph& optGraph = optNetObjPtr->GetGraph();
827 
828  // Perform optimisation passes
829  using namespace optimizations;
830  Optimizer::Pass(optGraph, MakeOptimizations(SquashEqualPermuteSiblings(),
833  MovePermuteUp(),
838 
839  // Infer the tensor infos for all output slots. Throws an exception on failure
840  optGraph.InferTensorInfos();
841 
842  // If Fp32 to Fp16 optimization is set convert Fp32 network to Fp16
843  if (options.m_ReduceFp32ToFp16)
844  {
845  Optimizer::Pass(optGraph, MakeOptimizations(Fp32NetworkToFp16Converter()));
846  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
847  }
848 
849  // Initialize backend settings
850  BackendSettings backendSettings(backendPreferences, deviceSpec);
851  if (backendSettings.GetAvailablePreferredBackends().empty())
852  {
853  std::stringstream failureMsg;
854  failureMsg << "None of the preferred backends " << backendPreferences
855  << " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
856  ReportError(failureMsg.str(), messages);
857  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
858  }
859 
860  // Create a map to temporarily hold initialized backend objects
861  TensorHandleFactoryRegistry tensorHandleFactoryRegistry;
862  BackendsMap backends = CreateSupportedBackends(tensorHandleFactoryRegistry, backendSettings);
863 
864  // Assign an available backend to each layer
865  Graph::Iterator firstLayer = optGraph.begin();
866  Graph::Iterator lastLayer = optGraph.end();
867  OptimizationResult assignBackendsResult = AssignBackends(optNetObjPtr,
868  backendSettings,
869  firstLayer,
870  lastLayer,
871  messages);
872  if (assignBackendsResult.m_Error)
873  {
874  // Failed to assign a backend to each layer
875  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
876  }
877 
878  Optimizer::Pass(optGraph, MakeOptimizations(OptimizeInverseConversionsFp16(),
880 
881  // Apply the backend-specific optimizations
882  OptimizationResult backendOptimizationResult = ApplyBackendOptimizations(optNetObjPtr,
883  backendSettings,
884  backends,
885  messages);
886  if (backendOptimizationResult.m_Error)
887  {
888  // Failed to apply the backend-specific optimizations
889  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
890  }
891 
892  // If the debug flag is set, then insert a DebugLayer after each layer
893  // Doing this after applying the backend optimizations as they might have changed some layers
894  if (options.m_Debug)
895  {
896  Optimizer::Pass(optGraph, MakeOptimizations(InsertDebugLayer()));
897  }
898 
899  // Calculate the compatibility strategies for tensor handles
900  OptimizationResult strategyResult = SelectTensorHandleStrategy(optGraph,
901  backends,
902  tensorHandleFactoryRegistry,
903  messages);
904  if (strategyResult.m_Error)
905  {
906  // Failed to apply the backend-specific optimizations
907  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
908  }
909 
910  // Based on the tensor handle strategy determined above, insert copy layers where required.
911  optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
912 
913  // Convert constants
914  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
915  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsHalfToFloat()));
916 
917  // Run backend specific optimizations (deprecated)
918  for (auto&& chosenBackend : backendSettings.m_SelectedBackends)
919  {
920  auto factoryFun = BackendRegistryInstance().GetFactory(chosenBackend);
921  auto backendPtr = factoryFun();
922  BOOST_ASSERT(backendPtr.get() != nullptr);
923 
925  auto backendSpecificOptimizations = backendPtr->GetOptimizations();
927 
928  if (!backendSpecificOptimizations.empty())
929  {
930  Optimizer::Pass(optNetObjPtr->GetGraph(), backendSpecificOptimizations);
931  }
932  }
933 
934  return optNet;
935 }
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
FactoryFunction GetFactory(const BackendId &id) const
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
Definition: Network.cpp:326
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl > PermuteAndBatchToSpaceAsDepthToSpace
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
OptimizeForConnection< PadLayer, Convolution2dLayer, FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:741
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
BackendRegistry & BackendRegistryInstance()
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:292
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:74
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
OptimizationResult ApplyBackendOptimizations(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:345
OptimizationResult AssignBackends(OptimizedNetwork *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:312
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:544
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
Definition: AddDebug.hpp:34
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl > OptimizeInversePermutes
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ Pad()

void Pad ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
std::vector< std::pair< unsigned int, unsigned int >>  m_padList,
const T *  inputData,
T *  outData,
const float  padValue 
)

Definition at line 22 of file Pad.cpp.

References TensorShape::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), Pad< float >(), Pad< Half >(), Pad< int16_t >(), and Pad< uint8_t >().

Referenced by BOOST_AUTO_TEST_CASE(), and RefPadWorkload< DataType >::Execute().

28 {
29  unsigned int numOutputElements = outputInfo.GetNumElements();
30 
31  TensorShape outputShape = outputInfo.GetShape();
32  TensorShape inputShape = inputInfo.GetShape();
33 
34  unsigned int numInputDimensions = inputShape.GetNumDimensions();
35 
36  #ifndef NDEBUG
37 
38  unsigned int numOutputDimensions = outputShape.GetNumDimensions();
39  assert(numInputDimensions == numOutputDimensions);
40 
41  #endif
42 
43  unsigned int inputBatches = 0;
44  unsigned int inputChannels = 0;
45  unsigned int inputHeight = 0;
46  unsigned int inputWidth = 0;
47 
48  unsigned int outputChannels = 0;
49  unsigned int outputHeight = 0;
50  unsigned int outputWidth = 0;
51 
52  T convertedPadValue = static_cast<T>(padValue);
53 
54  for (unsigned int i = 0; i < numOutputElements; ++i)
55  {
56  outData[i] = convertedPadValue;
57  }
58 
59  switch(numInputDimensions) {
60 
61  case 1:
62 
63  inputWidth = inputShape[0];
64 
65  for (unsigned int w = 0; w < inputWidth ; w++)
66  {
67  outData[w+std::get<0>(m_padList[0])] = inputData[w];
68  }
69 
70  break;
71 
72  case 2 :
73 
74  inputHeight = inputShape[0];
75  inputWidth = inputShape[1];
76  outputHeight = outputShape[0];
77  outputWidth = outputShape[1];
78 
79  for (unsigned int h = 0; h < inputHeight; h++)
80  {
81  for (unsigned int w = 0; w < inputWidth ; w++)
82  {
83  outData[(h+std::get<0>(m_padList[0]))*outputWidth
84  + (w+std::get<0>(m_padList[1]))] = inputData[h * inputWidth + w];
85  }
86  }
87 
88  break;
89 
90  case 3 :
91 
92  inputChannels = inputShape[0];
93  inputHeight = inputShape[1];
94  inputWidth = inputShape[2];
95  outputChannels = outputShape[0];
96  outputHeight = outputShape[1];
97  outputWidth = outputShape[2];
98 
99  for (unsigned int c = 0; c < inputChannels; c++)
100  {
101  for (unsigned int h = 0; h < inputHeight; h++)
102  {
103  for (unsigned int w = 0; w < inputWidth ; w++)
104  {
105  outData[(c+std::get<0>(m_padList[0]))*outputHeight*outputWidth
106  + (h+std::get<0>(m_padList[1]))*outputWidth
107  + (w+std::get<0>(m_padList[2]))] = inputData[c * inputHeight * inputWidth
108  + h * inputWidth
109  + w];
110  }
111  }
112  }
113 
114  break;
115 
116  case 4 :
117 
118  inputBatches = inputShape[0];
119  inputChannels = inputShape[1];
120  inputHeight = inputShape[2];
121  inputWidth = inputShape[3];
122  outputChannels = outputShape[1];
123  outputHeight = outputShape[2];
124  outputWidth = outputShape[3];
125 
126  for (unsigned int b = 0; b < inputBatches; b++)
127  {
128  for (unsigned int c = 0; c < inputChannels; c++)
129  {
130  for (unsigned int h = 0; h < inputHeight; h++)
131  {
132  for (unsigned int w = 0; w < inputWidth ; w++)
133  {
134  outData[(b+std::get<0>(m_padList[0])) * outputChannels * outputHeight * outputWidth
135  + (c+std::get<0>(m_padList[1])) * outputHeight * outputWidth
136  + (h+std::get<0>(m_padList[2])) * outputWidth
137  + (w+std::get<0>(m_padList[3]))] = inputData[b * inputChannels * inputHeight
138  * inputWidth
139  + c * inputHeight * inputWidth
140  + h * inputWidth
141  + w];
142  }
143  }
144  }
145  }
146 
147  break;
148 
149  default :
150 
151  break;
152  }
153 }

◆ Pad< float >()

template void armnn::Pad< float > ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
std::vector< std::pair< unsigned int, unsigned int >>  m_PadList,
const float *  inputData,
float *  outData,
const float  padValue 
)

Referenced by Pad().

◆ Pad< Half >()

template void armnn::Pad< Half > ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
std::vector< std::pair< unsigned int, unsigned int >>  m_PadList,
const Half inputData,
Half outData,
const float  padValue 
)

Referenced by Pad().

◆ Pad< int16_t >()

template void armnn::Pad< int16_t > ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
std::vector< std::pair< unsigned int, unsigned int >>  m_PadList,
const int16_t *  inputData,
int16_t *  outData,
const float  padValue 
)

Referenced by Pad().

◆ Pad< uint8_t >()

template void armnn::Pad< uint8_t > ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
std::vector< std::pair< unsigned int, unsigned int >>  m_PadList,
const uint8_t *  inputData,
uint8_t *  outData,
const float  padValue 
)

Referenced by Pad().

◆ 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 
103  return defaultValue;
104 }

◆ ParseComputeDevice()

constexpr armnn::Compute armnn::ParseComputeDevice ( const char *  str)

Deprecated function that will be removed together with the Compute enum

Definition at line 145 of file TypesUtils.hpp.

References CpuAcc, CpuRef, GpuAcc, StrEqual(), and Undefined.

Referenced by operator>>().

146 {
147  if (armnn::StrEqual(str, "CpuAcc"))
148  {
149  return armnn::Compute::CpuAcc;
150  }
151  else if (armnn::StrEqual(str, "CpuRef"))
152  {
153  return armnn::Compute::CpuRef;
154  }
155  else if (armnn::StrEqual(str, "GpuAcc"))
156  {
157  return armnn::Compute::GpuAcc;
158  }
159  else
160  {
162  }
163 }
constexpr bool StrEqual(const char *strA, const char(&strB)[N])
Definition: TypesUtils.hpp:133
GPU Execution: OpenCL: ArmCompute.
CPU Execution: Reference C++ kernels.
CPU Execution: NEON: ArmCompute.

◆ ParseFile()

std::string armnn::ParseFile ( const BackendOptions::Var value,
std::string  defaultValue 
)

Definition at line 106 of file ClBackendContext.cpp.

References BackendOptions::Var::AsString(), and BackendOptions::Var::IsString().

Referenced by ClBackendContext::ClBackendContext().

107 {
108  if (value.IsString())
109  {
110  return value.AsString();
111  }
112  return defaultValue;
113 }

◆ ParseOptions()

void armnn::ParseOptions ( const std::vector< BackendOptions > &  options,
BackendId  backend,
f 
)

Definition at line 116 of file ClBackendContext.cpp.

References BackendOptions::BackendOption::GetName(), and BackendOptions::BackendOption::GetValue().

Referenced by ClBackendContext::ClBackendContext().

117 {
118  for (auto optionsGroup : options)
119  {
120  if (optionsGroup.GetBackendId() == backend)
121  {
122  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
123  {
124  const BackendOptions::BackendOption option = optionsGroup.GetOption(i);
125  f(option.GetName(), option.GetValue());
126  }
127  }
128  }
129 }
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ ParseTuningLevel()

TuningLevel armnn::ParseTuningLevel ( const BackendOptions::Var value,
TuningLevel  defaultValue 
)

Definition at line 78 of file ClBackendContext.cpp.

References ARMNN_LOG, Exhaustive, BackendOptions::Var::IsInt(), None, and warning.

Referenced by ClBackendContext::ClBackendContext().

79 {
80  if (value.IsInt())
81  {
82  int v = value.IsInt();
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 13 of file WorkloadUtils.cpp.

References ConstCpuTensorHandle::GetConstTensor(), TensorInfo::GetDataType(), GetDataTypeSize(), TensorInfo::GetNumBytes(), TensorInfo::GetShape(), PermutationVector::GetSize(), ConstCpuTensorHandle::GetTensorInfo(), Permute, and armnnUtils::Permuted().

Referenced by ConvertWeightTensorFromArmnnToAcl(), and GatherTensorHandlePairs().

15 {
16  BOOST_ASSERT_MSG(tensor, "Invalid input tensor");
17  BOOST_ASSERT_MSG(permuteBuffer, "Invalid permute buffer");
18 
19  TensorInfo tensorInfo = tensor->GetTensorInfo();
20 
21  if (permutationVector.GetSize() > 0)
22  {
23  tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector);
24  armnnUtils::Permute(tensorInfo.GetShape(), permutationVector,
25  tensor->GetConstTensor<void>(), permuteBuffer,
26  GetDataTypeSize(tensorInfo.GetDataType()));
27  }
28  else
29  {
30  ::memcpy(permuteBuffer, tensor->GetConstTensor<void>(), tensorInfo.GetNumBytes());
31  }
32 
33  return ConstTensor(tensorInfo, permuteBuffer);
34 }
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:121
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:113

◆ 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 143 of file Pooling2d.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), 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, Pooling2d(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE(), Pooling2d(), and Pooling2dLayer::Pooling2dLayer().

148 {
149  const DataLayoutIndexed dataLayout(params.m_DataLayout);
150  auto channelsIndex = dataLayout.GetChannelsIndex();
151  auto heightIndex = dataLayout.GetHeightIndex();
152  auto widthIndex = dataLayout.GetWidthIndex();
153 
154  const int batchSize = boost::numeric_cast<int>(outputInfo.GetShape()[0]);
155  const int channels = boost::numeric_cast<int>(outputInfo.GetShape()[channelsIndex]);
156  const int heightOutput = boost::numeric_cast<int>(outputInfo.GetShape()[heightIndex]);
157  const int widthOutput = boost::numeric_cast<int>(outputInfo.GetShape()[widthIndex]);
158  const int heightInput = boost::numeric_cast<int>(inputInfo.GetShape()[heightIndex]);
159  const int widthInput = boost::numeric_cast<int>(inputInfo.GetShape()[widthIndex]);
160  const int padLeft = boost::numeric_cast<int>(params.m_PadLeft);
161  const int padRight = boost::numeric_cast<int>(params.m_PadRight);
162  const int padTop = boost::numeric_cast<int>(params.m_PadTop);
163  const int padBottom = boost::numeric_cast<int>(params.m_PadBottom);
164  const int strideX = boost::numeric_cast<int>(params.m_StrideX);
165  const int strideY = boost::numeric_cast<int>(params.m_StrideY);
166  const int poolHeight = boost::numeric_cast<int>(params.m_PoolHeight);
167  const int poolWidth = boost::numeric_cast<int>(params.m_PoolWidth);
168 
169  float defaultInitializer = DefaultInitializer(params.m_PoolType);
170 
171  Accumulator accumulate = GetAccumulator(params.m_PoolType);
172  Executor execute = GetExecutor(params.m_PoolType);
173 
174  TensorShape outputShape = outputInfo.GetShape();
175  TensorShape inputShape = inputInfo.GetShape();
176 
177  // Check supported padding methods outside the loop to simplify
178  // the inner loop.
179  if (params.m_PaddingMethod != PaddingMethod::Exclude &&
180  params.m_PaddingMethod != PaddingMethod::IgnoreValue)
181  {
182  throw armnn::InvalidArgumentException("Unsupported padding type");
183  }
184 
185  for (int n = 0; n < batchSize; n++)
186  {
187  for (int c = 0; c < channels; c++)
188  {
189  for (int yOutput = 0; yOutput < heightOutput; yOutput++)
190  {
191  // Calculate values independent of the x axis
192  int hstart = (yOutput * strideY) - padTop;
193  int hend = hstart + poolHeight;
194  // Clamp the pooling region inside the valid input area (which includes the padding).
195  // This is necessary because the final pooling in a row may overlap beyond the padding.
196  hend = std::min(hend, heightInput + padBottom);
197 
198  int height = hend - hstart;
199  bool hclamped = ClampRange(hstart, hend, heightInput);
200 
201  for (int xOutput = 0; xOutput < widthOutput; xOutput++)
202  {
203  int wstart = (xOutput * strideX) - padLeft;
204  int wend = wstart + poolWidth;
205 
206  // Clamp the pooling region inside the valid input area (which includes the padding).
207  // This is necessary because the final pooling in a row may overlap beyond the padding.
208  wend = std::min(wend, widthInput + padRight);
209 
210  float result = defaultInitializer;
211  float poolAreaSize = boost::numeric_cast<float>(height * (wend - wstart));
212 
213  // Special case: when the pooling kernel is over a padding region and the padding
214  // size is larger or equal to the kernel and the kernel only covers
215  // padding and no real values, then we initialize the result as zero
216  // by convention. This is because we need to choose a value here and
217  // all values we have are padding, which we ignore.
218  if (OnPaddingOnly(hstart, hend, heightInput) ||
219  OnPaddingOnly(wstart, wend, widthInput))
220  {
221  result = 0.0f;
222 
223  unsigned int outputIndex = dataLayout.GetIndex(outputShape,
224  boost::numeric_cast<unsigned int>(n),
225  boost::numeric_cast<unsigned int>(c),
226  boost::numeric_cast<unsigned int>(yOutput),
227  boost::numeric_cast<unsigned int>(xOutput));
228  rOutputEncoder[outputIndex];
229  rOutputEncoder.Set(result);
230  continue;
231  }
232 
233  bool clamped = hclamped |= ClampRange(wstart, wend, widthInput);
234 
235  if (clamped && params.m_PaddingMethod == PaddingMethod::Exclude)
236  {
237  // When we exclude the padding, it means we calculate with a smaller
238  // kernel size, so I changed the divisor here.
239  poolAreaSize = boost::numeric_cast<float>((hend - hstart) * (wend - wstart));
240  }
241 
242  for (auto yInput = hstart; yInput < hend; yInput++)
243  {
244  for (auto xInput = wstart; xInput < wend; xInput++)
245  {
246  unsigned int inputIndex = dataLayout.GetIndex(inputShape,
247  boost::numeric_cast<unsigned int>(n),
248  boost::numeric_cast<unsigned int>(c),
249  boost::numeric_cast<unsigned int>(yInput),
250  boost::numeric_cast<unsigned int>(xInput));
251 
252  rInputDecoder[inputIndex];
253  float inval = rInputDecoder.Get();
254 
255  accumulate(result, inval);
256  }
257  }
258 
259  execute(result, poolAreaSize);
260 
261  unsigned int outputIndex = dataLayout.GetIndex(outputShape,
262  boost::numeric_cast<unsigned int>(n),
263  boost::numeric_cast<unsigned int>(c),
264  boost::numeric_cast<unsigned int>(yOutput),
265  boost::numeric_cast<unsigned int>(xOutput));
266 
267  rOutputEncoder[outputIndex];
268  rOutputEncoder.Set(result);
269  }
270  }
271  }
272  }
273 }
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_PoolWidth
Pooling width value.
uint32_t m_PadLeft
Padding left value in the width dimension.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
virtual IType Get() const =0
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadBottom
Padding bottom value in the height dimension.
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Set(IType right)=0
uint32_t m_StrideX
Stride value when proceeding through input for the width 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 2817 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float16, Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, options, QAsymmU8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

2818 {
2819  INetworkPtr network = INetwork::Create();
2820 
2821  // Add the layers
2822  IConnectableLayer* input0 = network->AddInputLayer(0);
2823  IConnectableLayer* input1 = network->AddInputLayer(1);
2824  IConnectableLayer* addition = network->AddAdditionLayer();
2825  IConnectableLayer* output = network->AddOutputLayer(2);
2826 
2827  input0->GetOutputSlot(0).Connect(addition->GetInputSlot(0));
2828  input1->GetOutputSlot(0).Connect(addition->GetInputSlot(1));
2829  addition->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2830 
2831  const TensorShape shape{1U, 2U, 3U};
2832  const TensorInfo info(shape, dataType);
2833  input0->GetOutputSlot(0).SetTensorInfo(info);
2834  input1->GetOutputSlot(0).SetTensorInfo(info);
2835  addition->GetOutputSlot(0).SetTensorInfo(info);
2836 
2837  QuantizerOptions options = dataType == DataType::Float32 ?
2838  QuantizerOptions(DataType::QAsymmU8, true) : QuantizerOptions(dataType, true);
2839 
2840  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get(), options)->ExportNetwork();
2841  TestPreserveType validatorQAsymmU8(options, dataType, shape, shape);
2842  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2843  validatorQAsymmU8.CheckQuantizeDequantizeLayerVisited(
2844  dataType == DataType::Float32 || dataType == DataType::Float16);
2845 }
DataLayout::NCHW DataLayout::NCHW DataLayout::NHWC DataLayout::NHWC true
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ Quantize() [1/2]

void armnn::Quantize ( uint8_t *  quant,
const float *  dequant,
const TensorInfo info 
)
inline

Definition at line 95 of file RefWorkloadUtils.hpp.

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

96 {
97  for (size_t i = 0; i < info.GetNumElements(); i++)
98  {
99  quant[i] = armnn::Quantize<uint8_t>(dequant[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
100  }
101 }

◆ Quantize() [2/2]

template int32_t Quantize< int32_t > ( float  value,
float  scale,
int32_t  offset 
)

Explicit specialization of Quantize for int8_t.

Explicit specialization of Quantize for int32_t.

Explicit specialization of Quantize for int16_t.

Explicit specialization of Quantize for uint8_t.

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

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 31 of file TypesUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

32 {
33  static_assert(IsQuantizedType<QuantizedType>(), "Not an integer type.");
34  constexpr QuantizedType max = std::numeric_limits<QuantizedType>::max();
35  constexpr QuantizedType min = std::numeric_limits<QuantizedType>::lowest();
36  BOOST_ASSERT(scale != 0.f);
37  BOOST_ASSERT(!std::isnan(value));
38 
39  float clampedValue = std::min(std::max(static_cast<float>(round(value/scale) + offset), static_cast<float>(min)),
40  static_cast<float>(max));
41  auto quantizedBits = static_cast<QuantizedType>(clampedValue);
42 
43  return quantizedBits;
44 }

◆ QuantizeConstant()

void armnn::QuantizeConstant ( const srcType *  src,
uint8_t *  dst,
size_t  numElements,
float &  scale,
int &  offset 
)

Definition at line 23 of file NetworkQuantizerUtils.hpp.

References QAsymmU8QuantizationScheme::ComputeScheme(), and CreateQuantizedConst().

Referenced by CreateQuantizedConst().

24 {
25  BOOST_ASSERT(src);
26  BOOST_ASSERT(dst);
27 
28  float min = std::numeric_limits<srcType>::max();
29  float max = std::numeric_limits<srcType>::lowest();
30  for (size_t i = 0; i < numElements; ++i)
31  {
32  min = std::min(min, src[i]);
33  max = std::max(max, src[i]);
34  }
35 
36  QAsymmU8QuantizationScheme quantizationScheme;
37  OffsetScalePair qParams = quantizationScheme.ComputeScheme(min, max);
38  scale = qParams.first;
39  offset = qParams.second;
40 
41  for (size_t i = 0; i < numElements; ++i)
42  {
43  dst[i] = armnn::Quantize<uint8_t>(src[i], scale, offset);
44  }
45 }
std::pair< float, int > OffsetScalePair

◆ 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 62 of file WorkloadUtils.cpp.

References BaseTensor< MemoryType >::GetInfo(), TensorInfo::GetNumBytes(), BaseTensor< MemoryType >::GetShape(), NCHW, and NHWC.

63 {
64  DataType* weight = static_cast<DataType*>(permuteBuffer);
65  const TensorShape& weightShape = weightHandle.GetShape();
66  unsigned int multiplier;
67  unsigned int height;
68  unsigned int width;
69  unsigned int inputChannels;
70  switch (dataLayout)
71  {
72  case DataLayout::NHWC: //It actually is [ H, W, I, M ]
73  height = weightShape[0];
74  width = weightShape[1];
75  inputChannels = weightShape[2];
76  multiplier = weightShape[3];
77  break;
78  case DataLayout::NCHW: //It actually is [ M, I, H, W ]
79  default:
80  height = weightShape[2];
81  width = weightShape[3];
82  inputChannels = weightShape[1];
83  multiplier = weightShape[0];
84  break;
85  }
86 
87  std::vector<DataType> weightAclOrder(height*width*inputChannels*multiplier);
88  unsigned int destinationWeightsChannel;
89  unsigned int totalChannels = inputChannels * multiplier;
90  unsigned int channelSize = height * width;
91  unsigned int inputChannel = 0;
92 
93  for (unsigned int originWeightsChannel = 0; originWeightsChannel < totalChannels; originWeightsChannel++)
94  {
95  inputChannel = originWeightsChannel % inputChannels;
96  destinationWeightsChannel = (originWeightsChannel - inputChannel) / inputChannels + multiplier * inputChannel;
97 
98  for (unsigned int i = 0; i < channelSize; i++)
99  {
100  weightAclOrder[i + destinationWeightsChannel * channelSize] =
101  weight[i + originWeightsChannel * channelSize];
102  }
103  }
104 
105  ::memcpy(permuteBuffer, weightAclOrder.data(), weightHandle.GetInfo().GetNumBytes());
106  return ConstTensor(weightHandle.GetInfo(), permuteBuffer);
107 }
DataType
Definition: Types.hpp:32

◆ ReportError()

void armnn::ReportError ( const std::string &  errorMessage,
Optional< std::vector< std::string > &>  errorMessages 
)

Definition at line 74 of file Network.cpp.

References ARMNN_LOG, and warning.

Referenced by AssignBackends(), CheckScaleSetOnQuantizedType(), and Optimize().

76 {
77  std::stringstream fullErrorMessage;
78  fullErrorMessage << "ERROR: " << errorMessage;
79  ARMNN_LOG(warning) << fullErrorMessage.str();
80  if (errorMessages)
81  {
82  errorMessages.value().push_back(fullErrorMessage.str());
83  }
84 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163

◆ ReportWarning()

void armnn::ReportWarning ( const std::string &  warningMessage,
Optional< std::vector< std::string > &>  warningMessages 
)

Definition at line 86 of file Network.cpp.

References ARMNN_LOG, and warning.

Referenced by ApplyBackendOptimizations(), and AssignBackends().

88 {
89  std::stringstream fullWarningMessage;
90  fullWarningMessage << "WARNING: " << warningMessage;
91  ARMNN_LOG(warning) << fullWarningMessage.str();
92  if (warningMessages)
93  {
94  warningMessages.value().push_back(fullWarningMessage.str());
95  }
96 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163

◆ RequiresCopy()

bool armnn::RequiresCopy ( ITensorHandleFactory::FactoryId  src,
ITensorHandleFactory::FactoryId  dst,
TensorHandleFactoryRegistry registry 
)

Definition at line 443 of file Network.cpp.

References ITensorHandleFactory::GetExportFlags(), TensorHandleFactoryRegistry::GetFactory(), and ITensorHandleFactory::GetImportFlags().

Referenced by CalculateSlotOption().

446 {
447  if (src != dst)
448  {
449  ITensorHandleFactory* srcFactory = registry.GetFactory(src);
450  ITensorHandleFactory* dstFactory = registry.GetFactory(dst);
451 
452  if (srcFactory && dstFactory &&
453  (srcFactory->GetExportFlags() & dstFactory->GetImportFlags()) != 0)
454  {
455  return false;
456  }
457  return true;
458  }
459  return false;
460 }

◆ ReshapeWeightsForAcl()

void ReshapeWeightsForAcl ( TensorInfo weightInfo,
DataLayout  dataLayout 
)

Definition at line 36 of file WorkloadUtils.cpp.

References TensorInfo::GetShape(), NCHW, NHWC, and TensorInfo::SetShape().

Referenced by ConvertWeightTensorFromArmnnToAcl(), ConvertWeightTensorInfoFromArmnnToAcl(), and GatherTensorHandlePairs().

37 {
38  // Reshape the weights in-place
39  const TensorShape& weightShape = weightInfo.GetShape();
40  switch (dataLayout)
41  {
42  case DataLayout::NHWC:
43  // The data layout is NHWC, reshape from [ H, W, I, M ] to [ 1, H, W, I * M ]
44  weightInfo.SetShape({ 1,
45  weightShape[0],
46  weightShape[1],
47  weightShape[2] * weightShape[3] });
48  weightInfo.SetShape({ 1,
49  weightShape[0] * weightShape[1],
50  weightShape[2],
51  weightShape[3] });
52  break;
53  case DataLayout::NCHW:
54  default:
55  // The data layout is NCHW, reshape from [ M, I, H, W ] to [ 1, I * M, H, W, ]
56  weightInfo.SetShape({ 1, weightShape[0] * weightShape[1], weightShape[2], weightShape[3] });
57  break;
58  }
59 }

◆ Resize()

void Resize ( Decoder< float > &  in,
const TensorInfo inputInfo,
Encoder< float > &  out,
const TensorInfo outputInfo,
DataLayoutIndexed  dataLayout,
armnn::ResizeMethod  resizeMethod,
bool  alignCorners 
)

Definition at line 35 of file Resize.cpp.

References 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().

42 {
43  // We follow the definition of TensorFlow and AndroidNN: the top-left corner of a texel in the output
44  // image is projected into the input image to figure out the interpolants and weights. Note that this
45  // will yield different results than if projecting the centre of output texels.
46 
47  const unsigned int batchSize = inputInfo.GetShape()[0];
48  const unsigned int channelCount = inputInfo.GetShape()[dataLayout.GetChannelsIndex()];
49 
50  const unsigned int inputHeight = inputInfo.GetShape()[dataLayout.GetHeightIndex()];
51  const unsigned int inputWidth = inputInfo.GetShape()[dataLayout.GetWidthIndex()];
52  const unsigned int outputHeight = outputInfo.GetShape()[dataLayout.GetHeightIndex()];
53  const unsigned int outputWidth = outputInfo.GetShape()[dataLayout.GetWidthIndex()];
54 
55  const unsigned int sizeOffset = resizeMethod == armnn::ResizeMethod::Bilinear && alignCorners ? 1 : 0;
56 
57  // How much to scale pixel coordinates in the output image, to get the corresponding pixel coordinates
58  // in the input image.
59  const float scaleY = boost::numeric_cast<float>(inputHeight - sizeOffset)
60  / boost::numeric_cast<float>(outputHeight - sizeOffset);
61  const float scaleX = boost::numeric_cast<float>(inputWidth - sizeOffset)
62  / boost::numeric_cast<float>(outputWidth - sizeOffset);
63 
64  TensorShape inputShape = inputInfo.GetShape();
65  TensorShape outputShape = outputInfo.GetShape();
66 
67  for (unsigned int n = 0; n < batchSize; ++n)
68  {
69  for (unsigned int c = 0; c < channelCount; ++c)
70  {
71  for (unsigned int y = 0; y < outputHeight; ++y)
72  {
73  // Corresponding real-valued height coordinate in input image.
74  const float iy = boost::numeric_cast<float>(y) * scaleY;
75 
76  // Discrete height coordinate of top-left texel (in the 2x2 texel area used for interpolation).
77  const float fiy = floorf(iy);
78  const unsigned int y0 = boost::numeric_cast<unsigned int>(fiy);
79 
80  // Interpolation weight (range [0,1]).
81  const float yw = iy - fiy;
82 
83  for (unsigned int x = 0; x < outputWidth; ++x)
84  {
85  // Real-valued and discrete width coordinates in input image.
86  const float ix = boost::numeric_cast<float>(x) * scaleX;
87  const float fix = floorf(ix);
88  const unsigned int x0 = boost::numeric_cast<unsigned int>(fix);
89 
90  // Interpolation weight (range [0,1]).
91  const float xw = ix - fix;
92 
93  // Discrete width/height coordinates of texels below and to the right of (x0, y0).
94  const unsigned int x1 = std::min(x0 + 1, inputWidth - 1u);
95  const unsigned int y1 = std::min(y0 + 1, inputHeight - 1u);
96 
97  float interpolatedValue;
98  switch (resizeMethod)
99  {
101  {
102  in[dataLayout.GetIndex(inputShape, n, c, y0, x0)];
103  float input1 = in.Get();
104  in[dataLayout.GetIndex(inputShape, n, c, y0, x1)];
105  float input2 = in.Get();
106  in[dataLayout.GetIndex(inputShape, n, c, y1, x0)];
107  float input3 = in.Get();
108  in[dataLayout.GetIndex(inputShape, n, c, y1, x1)];
109  float input4 = in.Get();
110 
111  const float ly0 = Lerp(input1, input2, xw); // lerp along row y0.
112  const float ly1 = Lerp(input3, input4, xw); // lerp along row y1.
113  interpolatedValue = Lerp(ly0, ly1, yw);
114  break;
115  }
117  {
118  // calculate euclidean distance to the 4 neighbours
119  auto distance00 = EuclideanDistance(fix, fiy, x0, y0);
120  auto distance01 = EuclideanDistance(fix, fiy, x0, y1);
121  auto distance10 = EuclideanDistance(fix, fiy, x1, y0);
122  auto distance11 = EuclideanDistance(fix, fiy, x1, y1);
123 
124  auto minimum = std::min( { distance00, distance01, distance10, distance11 } );
125 
126  unsigned int xNearest = 0;
127  unsigned int yNearest = 0;
128 
129  if (minimum == distance00)
130  {
131  xNearest = x0;
132  yNearest = y0;
133  }
134  else if (minimum == distance01)
135  {
136  xNearest = x0;
137  yNearest = y1;
138  }
139  else if (minimum == distance10)
140  {
141  xNearest = x1;
142  yNearest = y0;
143  }
144  else if (minimum == distance11)
145  {
146  xNearest = x1;
147  yNearest = y1;
148  }
149  else
150  {
151  throw armnn::InvalidArgumentException("Resize Nearest Neighbor failure");
152  }
153 
154  in[dataLayout.GetIndex(inputShape, n, c, yNearest, xNearest)];
155  interpolatedValue = in.Get();
156  break;
157  }
158  default:
159  throw armnn::InvalidArgumentException("Unknown resize method: " +
160  std::to_string(static_cast<int>(resizeMethod)));
161  }
162  out[dataLayout.GetIndex(outputShape, n, c, y, x)];
163  out.Set(interpolatedValue);
164  }
165  }
166  }
167  }
168 }
unsigned int GetHeightIndex() const
unsigned int GetWidthIndex() const
unsigned int GetChannelsIndex() const
virtual IType Get() const =0
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Set(IType right)=0
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const

◆ RunClFunction()

void armnn::RunClFunction ( arm_compute::IFunction &  function,
const CheckLocation location 
)
inline

Definition at line 131 of file ClWorkloadUtils.hpp.

References Error, error, and WrapClError().

Referenced by ClPadWorkload::Execute(), ClAdditionWorkload::Execute(), ClSubtractionWorkload::Execute(), ClConvertFp32ToFp16Workload::Execute(), ClConvertFp16ToFp32Workload::Execute(), ClActivationWorkload::Execute(), ClLstmFloatWorkload::Execute(), ClPreluWorkload::Execute(), ClAbsWorkload::Execute(), ClQuantizeWorkload::Execute(), ClRsqrtWorkload::Execute(), ClInstanceNormalizationWorkload::Execute(), ClSoftmaxFloatWorkload::Execute(), ClSpaceToDepthWorkload::Execute(), ClMaximumWorkload::Execute(), ClMinimumWorkload::Execute(), ClNormalizationFloatWorkload::Execute(), ClBatchToSpaceNdWorkload::Execute(), ClFloorFloatWorkload::Execute(), ClReshapeWorkload::Execute(), ClResizeWorkload::Execute(), ClSoftmaxUint8Workload::Execute(), ClSliceWorkload::Execute(), ClL2NormalizationFloatWorkload::Execute(), ClGreaterWorkload< T >::Execute(), ClArgMinMaxWorkload::Execute(), ClDepthToSpaceWorkload::Execute(), ClMultiplicationWorkload::Execute(), ClSpaceToBatchNdWorkload::Execute(), ClQuantizedLstmWorkload::Execute(), ClStridedSliceWorkload::Execute(), ClDivisionFloatWorkload::Execute(), ClPooling2dWorkload::Execute(), ClBatchNormalizationFloatWorkload::Execute(), ClDepthwiseConvolutionWorkload::Execute(), ClFullyConnectedWorkload::Execute(), ClConvolution2dWorkload::Execute(), ClPermuteWorkload::Execute(), and ClTransposeConvolution2dWorkload::Execute().

132 {
133  try
134  {
135  function.run();
136  }
137  catch (cl::Error& error)
138  {
139  throw WrapClError(error, location);
140  }
141 }
RuntimeException WrapClError(const cl::Error &clError, const CheckLocation &location)

◆ RuntimeLoadedNetworksReserve()

void RuntimeLoadedNetworksReserve ( armnn::Runtime runtime)

Definition at line 28 of file RuntimeTests.cpp.

References BOOST_AUTO_TEST_SUITE().

Referenced by BOOST_AUTO_TEST_CASE().

29 {
30  runtime->m_LoadedNetworks.reserve(1);
31 }

◆ SampleDynamicBackendId()

constexpr const char* armnn::SampleDynamicBackendId ( )

Definition at line 17 of file SampleDynamicBackend.cpp.

References OptimizationViews::AddUntouchedSubgraph().

17 { return "SampleDynamic"; }

◆ SelectTensorHandleStrategy()

OptimizationResult SelectTensorHandleStrategy ( Graph optGraph,
BackendsMap backends,
TensorHandleFactoryRegistry registry,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 741 of file Network.cpp.

References 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().

745 {
746  OptimizationResult result;
747 
748  optGraph.ForEachLayer([&backends, &registry, &result, &errMessages](Layer* layer)
749  {
750  BOOST_ASSERT(layer);
751 
752  // Lets make sure the backend is in our list of supported backends. Something went wrong during backend
753  // assignment if this check fails
754  BOOST_ASSERT(backends.find(layer->GetBackendId()) != backends.end());
755 
756  // Check each output separately
757  for (unsigned int slotIdx = 0; slotIdx < layer->GetNumOutputSlots(); slotIdx++)
758  {
759  OutputSlot& outputSlot = layer->GetOutputSlot(slotIdx);
760 
761  ITensorHandleFactory::FactoryId slotOption = ITensorHandleFactory::LegacyFactoryId;
762 
763  // Calculate the factory to use which results in the fewest copies being made.
764  switch(layer->GetType())
765  {
766  case LayerType::Input:
767  slotOption = CalculateSlotOptionForInput(backends, outputSlot, registry);
768  break;
769  case LayerType::Output:
770  slotOption = CalculateSlotOptionForOutput(backends, outputSlot, registry);
771  break;
772  default:
773  slotOption = CalculateSlotOption(backends, outputSlot, registry);
774  break;
775  }
776  outputSlot.SetTensorHandleFactory(slotOption);
777 
778  // Now determine the "best" edge strategy for each connection given the slotOption.
779  unsigned int connectionIdx = 0;
780  for (auto&& connection : outputSlot.GetConnections())
781  {
782  const Layer& connectedLayer = connection->GetOwningLayer();
783 
784  EdgeStrategy strategy = CalculateEdgeStrategy(backends, slotOption, *layer, connectedLayer, registry);
785 
786  if (strategy == EdgeStrategy::Undefined)
787  {
788  result.m_Error = true;
789  if (errMessages)
790  {
791  errMessages.value().emplace_back("Could not find valid strategy required for compatibility"
792  " between backends.");
793  }
794  return;
795  }
796 
797  outputSlot.SetEdgeStrategy(connectionIdx, strategy);
798 
799  connectionIdx++;
800  }
801  }
802  });
803 
804  return result;
805 }
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:664
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:555
ITensorHandleFactory::FactoryId FactoryId
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:545
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:463

◆ SetAllLoggingSinks()

void SetAllLoggingSinks ( bool  standardOut,
bool  debugOut,
bool  coloured 
)

Definition at line 147 of file Logging.cpp.

Referenced by SimpleLogger< Level >::AddSink(), BOOST_AUTO_TEST_CASE(), and ConfigureLogging().

148 {
149  SetLoggingSinks<LogSeverity::Trace>(standardOut, debugOut, coloured);
150  SetLoggingSinks<LogSeverity::Debug>(standardOut, debugOut, coloured);
151  SetLoggingSinks<LogSeverity::Info>(standardOut, debugOut, coloured);
152  SetLoggingSinks<LogSeverity::Warning>(standardOut, debugOut, coloured);
153  SetLoggingSinks<LogSeverity::Error>(standardOut, debugOut, coloured);
154  SetLoggingSinks<LogSeverity::Fatal>(standardOut, debugOut, coloured);
155 }

◆ 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 29 of file Logging.cpp.

References ARMNN_FALLTHROUGH, Debug, SimpleLogger< Level >::Enable(), Error, Fatal, SimpleLogger< Level >::Get(), Info, Trace, and Warning.

Referenced by SimpleLogger< Level >::AddSink(), BOOST_AUTO_TEST_CASE(), and ConfigureLogging().

30 {
31  SimpleLogger<LogSeverity::Trace>::Get().Enable(false);
32  SimpleLogger<LogSeverity::Debug>::Get().Enable(false);
33  SimpleLogger<LogSeverity::Info>::Get().Enable(false);
34  SimpleLogger<LogSeverity::Warning>::Get().Enable(false);
35  SimpleLogger<LogSeverity::Error>::Get().Enable(false);
36  SimpleLogger<LogSeverity::Fatal>::Get().Enable(false);
37  switch (level)
38  {
39  case LogSeverity::Trace:
40  SimpleLogger<LogSeverity::Trace>::Get().Enable(true);
42  case LogSeverity::Debug:
43  SimpleLogger<LogSeverity::Debug>::Get().Enable(true);
45  case LogSeverity::Info:
46  SimpleLogger<LogSeverity::Info>::Get().Enable(true);
48  case LogSeverity::Warning:
49  SimpleLogger<LogSeverity::Warning>::Get().Enable(true);
51  case LogSeverity::Error:
52  SimpleLogger<LogSeverity::Error>::Get().Enable(true);
54  case LogSeverity::Fatal:
55  SimpleLogger<LogSeverity::Fatal>::Get().Enable(true);
56  break;
57  default:
58  BOOST_ASSERT(false);
59  }
60 }
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:19
#define ARMNN_FALLTHROUGH
Definition: Utils.hpp:35

◆ SetLoggingSinks()

void armnn::SetLoggingSinks ( bool  standardOut,
bool  debugOut,
bool  coloured 
)
inline

Definition at line 123 of file Logging.cpp.

References SimpleLogger< Level >::AddSink(), SimpleLogger< Level >::Get(), and SimpleLogger< Level >::RemoveAllSinks().

124 {
125  SimpleLogger<Level>::Get().RemoveAllSinks();
126 
127  if (standardOut)
128  {
129  if (coloured)
130  {
131  SimpleLogger<Level>::Get().AddSink(
132  std::make_shared<StandardOutputColourSink>(Level));
133  } else
134  {
135  SimpleLogger<Level>::Get().AddSink(
136  std::make_shared<StandardOutputSink>());
137  }
138  }
139 
140  if (debugOut)
141  {
142  SimpleLogger<Level>::Get().AddSink(
143  std::make_shared<DebugOutputSink>());
144  }
145 }

◆ SetNeonSliceData()

auto armnn::SetNeonSliceData ( const std::vector< unsigned int > &  m_begin,
const std::vector< unsigned int > &  m_size 
)
inline

Definition at line 88 of file NeonWorkloadUtils.hpp.

Referenced by NeonSliceWorkload::NeonSliceWorkload().

90 {
91  // This function must translate the size vector given to an end vector
92  // expected by the ACL NESlice workload
95 
96  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
97 
98  // For strided slices, we have the relationship size = (end - begin) / stride
99  // For slice, we assume stride to be a vector of all ones, yielding the formula
100  // size = (end - begin) therefore we know end = size + begin
101  for (unsigned int i = 0; i < num_dims; i++)
102  {
103  unsigned int revertedIndex = num_dims - i - 1;
104 
105  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
106  ends.set(i, static_cast<int>(m_begin[revertedIndex] + m_size[revertedIndex]));
107  }
108 
109  return std::make_tuple(starts, ends);
110 }
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 66 of file NeonWorkloadUtils.hpp.

Referenced by NeonStridedSliceWorkload::NeonStridedSliceWorkload().

69 {
73 
74  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
75 
76  for (unsigned int i = 0; i < num_dims; i++)
77  {
78  unsigned int revertedIndex = num_dims - i - 1;
79 
80  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
81  ends.set(i, static_cast<int>(m_end[revertedIndex]));
82  strides.set(i, static_cast<int>(m_stride[revertedIndex]));
83  }
84 
85  return std::make_tuple(starts, ends, strides);
86 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetupQuantize()

std::vector<uint8_t> armnn::SetupQuantize ( float  value)

Definition at line 2727 of file QuantizerTest.cpp.

References Float32, and TensorInfo::SetQuantizationScale().

Referenced by BOOST_AUTO_TEST_CASE().

2728 {
2729  armnn::TensorInfo inputInfo({ 1, 2, 2 }, armnn::DataType::Float32);
2730  inputInfo.SetQuantizationScale(1.0f);
2731  inputInfo.SetQuantizationOffset(1);
2732  std::vector<float> input({ value, 0.0f, 0.0f, 1.0f });
2733  const std::vector<float> &inputRef = input;
2734 
2735  auto output = armnnUtils::QuantizedVector<uint8_t>(inputRef,
2736  inputInfo.GetQuantizationScale(),
2737  inputInfo.GetQuantizationOffset());
2738 
2739  return output;
2740 }
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:259

◆ SetValueChecked()

◆ Slice()

void Slice ( const TensorInfo inputInfo,
const SliceDescriptor descriptor,
const void *  inputData,
void *  outputData,
unsigned int  dataTypeSize 
)

Definition at line 15 of file Slice.cpp.

References TensorShape::GetNumDimensions(), TensorInfo::GetShape(), SliceDescriptor::m_Begin, and SliceDescriptor::m_Size.

Referenced by BOOST_AUTO_TEST_CASE().

20 {
21  const TensorShape& inputShape = inputInfo.GetShape();
22  const unsigned int numDims = inputShape.GetNumDimensions();
23 
24  BOOST_ASSERT(descriptor.m_Begin.size() == numDims);
25  BOOST_ASSERT(descriptor.m_Size.size() == numDims);
26 
27  constexpr unsigned int maxNumDims = 4;
28  BOOST_ASSERT(numDims <= maxNumDims);
29 
30  std::vector<unsigned int> paddedInput(4);
31  std::vector<unsigned int> paddedBegin(4);
32  std::vector<unsigned int> paddedSize (4);
33 
34  const unsigned int numPaddingDims = maxNumDims - numDims;
35  for (unsigned int i = 0u; i < maxNumDims; ++i)
36  {
37  if (i < numPaddingDims)
38  {
39  paddedInput[i] = 1u;
40  paddedBegin[i] = 0u;
41  paddedSize[i] = 1u;
42  }
43  else
44  {
45  const unsigned int j = i - numPaddingDims;
46  paddedInput[i] = inputShape[j];
47  paddedBegin[i] = descriptor.m_Begin[j];
48  paddedSize[i] = descriptor.m_Size[j];
49  }
50  }
51 
52  unsigned int dim0 = paddedInput[0];
53  unsigned int dim1 = paddedInput[1];
54  unsigned int dim2 = paddedInput[2];
55  unsigned int dim3 = paddedInput[3];
56 
57  unsigned int begin0 = paddedBegin[0];
58  unsigned int begin1 = paddedBegin[1];
59  unsigned int begin2 = paddedBegin[2];
60  unsigned int begin3 = paddedBegin[3];
61 
62  unsigned int size0 = paddedSize[0];
63  unsigned int size1 = paddedSize[1];
64  unsigned int size2 = paddedSize[2];
65  unsigned int size3 = paddedSize[3];
66 
67  BOOST_ASSERT(begin0 + size0 <= dim0);
68  BOOST_ASSERT(begin1 + size1 <= dim1);
69  BOOST_ASSERT(begin2 + size2 <= dim2);
70  BOOST_ASSERT(begin3 + size3 <= dim3);
71 
72  const unsigned char* input = reinterpret_cast<const unsigned char*>(inputData);
73  unsigned char* output = reinterpret_cast<unsigned char*>(outputData);
74 
75  boost::ignore_unused(dim0);
76  for (unsigned int idx0 = begin0; idx0 < begin0 + size0; ++idx0)
77  {
78  for (unsigned int idx1 = begin1; idx1 < begin1 + size1; ++idx1)
79  {
80  for (unsigned int idx2 = begin2; idx2 < begin2 + size2; ++idx2)
81  {
82  for (unsigned int idx3 = begin3; idx3 < begin3 + size3; ++idx3)
83  {
84  const unsigned int inputOffset =
85  (((idx0 * dim1 + idx1) * dim2 + idx2) * dim3 + idx3) * dataTypeSize;
86 
87  ::memcpy(output, input + inputOffset, dataTypeSize);
88  output += dataTypeSize;
89  }
90  }
91  }
92  }
93 }

◆ 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 Decoder< IType >::Get(), TensorShape::GetNumDimensions(), TensorInfo::GetNumDimensions(), armnnUtils::GetNumElementsBetween(), TensorInfo::GetShape(), and Encoder< IType >::Set().

Referenced by BOOST_AUTO_TEST_CASE().

18 {
19  BOOST_ASSERT_MSG(axis < static_cast<int>(inputTensorInfo.GetNumDimensions()),
20  "Required axis index greater than number of dimensions.");
21  BOOST_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 }
virtual IType Get() const =0
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
virtual void Set(IType right)=0

◆ 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 }
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).
std::vector< unsigned int > m_BlockShape
Block shape value.
unsigned int GetWidthIndex() const
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
unsigned int GetChannelsIndex() const
virtual IType Get() const =0
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Set(IType right)=0

◆ 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 }
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int GetHeightIndex() const
unsigned int GetWidthIndex() const
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
unsigned int GetChannelsIndex() const
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
virtual IType Get() const =0
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
virtual void Set(IType right)=0

◆ Split()

void Split ( const SplitterQueueDescriptor data)

Definition at line 22 of file Splitter.cpp.

References 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().

23 {
24  const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]);
25 
26  std::unique_ptr<Decoder<float>> decoderPtr =
27  MakeDecoder<float>(inputInfo, data.m_Inputs[0]->Map());
28  Decoder<float>& decoder = *decoderPtr;
29 
30  for (unsigned int index = 0; index < inputInfo.GetNumElements(); ++index)
31  {
32  unsigned int indices[MaxNumOfTensorDimensions] = { 0 };
33 
34  unsigned int indexRemainder = index;
35  unsigned int dimensionStride = inputInfo.GetNumElements();
36 
37  for (unsigned int i = 0; i<inputInfo.GetNumDimensions(); i++)
38  {
39  dimensionStride /= inputInfo.GetShape()[i];
40  indices[i] = indexRemainder / dimensionStride; // Use integer division to round down.
41  indexRemainder -= indices[i] * dimensionStride;
42  }
43 
44  for (unsigned int viewIdx = 0; viewIdx < data.m_ViewOrigins.size(); ++viewIdx)
45  {
46  SplitterQueueDescriptor::ViewOrigin const& view = data.m_ViewOrigins[viewIdx];
47 
48  //Split view extents are defined by the size of (the corresponding) input tensor.
49  const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[viewIdx]);
50  BOOST_ASSERT(outputInfo.GetNumDimensions() == inputInfo.GetNumDimensions());
51 
52  // Check all dimensions to see if this element is inside the given input view.
53  bool insideView = true;
54  for (unsigned int i = 0; i<outputInfo.GetNumDimensions(); i++)
55  {
56  if (indices[i] < view.m_Origin[i])
57  {
58  insideView = false;
59  }
60  if (indices[i] >= view.m_Origin[i] + outputInfo.GetShape()[i])
61  {
62  insideView = false;
63  }
64  }
65 
66  if (insideView)
67  {
68  std::unique_ptr<Encoder<float>> encoderPtr =
69  MakeEncoder<float>(outputInfo, data.m_Outputs[viewIdx]->Map());
70  Encoder<float>& encoder = *encoderPtr;
71 
72  unsigned int outIndex = 0;
73  unsigned int dimensionStride = 1;
74  float inputValue = 0.f;
75 
76  for (unsigned int i = outputInfo.GetNumDimensions(); i-- > 0;)
77  {
78  outIndex += dimensionStride * (indices[i] - view.m_Origin[i]);
79  dimensionStride *= outputInfo.GetShape()[i];
80  }
81 
82  decoder += index;
83  inputValue = decoder.Get();
84  decoder -= index;
85 
86  encoder += outIndex;
87  encoder.Set(inputValue);
88  break;
89  }
90  }
91  }
92 }
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 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  BOOST_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  BOOST_ASSERT(outputData);
71 
72  const DataType* inputData = GetInputTensorData<DataType>(0, data);
73  BOOST_ASSERT(inputData);
74 
75  outputData[outIndex] = inputData[index];
76  }
77  }
78  }
79 }
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
DataType
Definition: Types.hpp:32

◆ 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 }
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
virtual void Set(IType right)=0

◆ StrEqual()

constexpr bool armnn::StrEqual ( const char *  strA,
const char(&)  strB[N] 
)

Definition at line 133 of file TypesUtils.hpp.

Referenced by ParseComputeDevice().

134 {
135  bool isEqual = true;
136  for (unsigned i = 0; isEqual && (i < N); ++i)
137  {
138  isEqual = (strA[i] == strB[i]);
139  }
140  return isEqual;
141 }

◆ 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().

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 = boost::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 = boost::numeric_cast<int>(inputShape[1]);
137  int dim2 = boost::numeric_cast<int>(inputShape[2]);
138  int dim3 = boost::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 }

◆ swap() [1/2]

void armnn::swap ( OriginsDescriptor first,
OriginsDescriptor second 
)

Definition at line 342 of file Descriptors.cpp.

References ViewsDescriptor::swap, and swap().

Referenced by FullyConnectedFloat32Test(), FullyConnectedLargeTestCommon(), BackendId::operator=(), SquashEqualSiblingsImpl< Comparable >::Run(), and BackendRegistry::Swap().

343 {
344  using std::swap;
345  swap(first.m_NumViews, second.m_NumViews);
346  swap(first.m_NumDimensions, second.m_NumDimensions);
347  swap(first.m_ViewOrigins, second.m_ViewOrigins);
348  swap(first.m_ConcatAxis, second.m_ConcatAxis);
349 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

◆ swap() [2/2]

void armnn::swap ( ViewsDescriptor first,
ViewsDescriptor second 
)

Definition at line 351 of file Descriptors.cpp.

References ViewsDescriptor::swap.

Referenced by swap().

352 {
353  using std::swap;
354  swap(first.m_Origins, second.m_Origins);
355  swap(first.m_ViewSizes, second.m_ViewSizes);
356 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

◆ TestQuantizeConvolution2d()

void armnn::TestQuantizeConvolution2d ( bool  useBiases)

Definition at line 1046 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, Convolution2dDescriptor::m_BiasEnabled, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

1047 {
1048  class TestConv2dQuantization : public TestQuantization
1049  {
1050  public:
1051  TestConv2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1052  : TestQuantization(inputShape, outputShape) {}
1053 
1054  TestConv2dQuantization(const QuantizerOptions& options,
1055  const TensorShape& inputShape,
1056  const TensorShape& outputShape)
1057  : TestQuantization(options, inputShape, outputShape) {}
1058 
1059  void VisitConvolution2dLayer(const IConnectableLayer *layer,
1060  const Convolution2dDescriptor& convolution2dDescriptor,
1061  const ConstTensor& weights,
1062  const Optional<ConstTensor>& biases,
1063  const char *name = nullptr) override
1064  {
1065  boost::ignore_unused(convolution2dDescriptor, name);
1066  TestQuantizationOnLayersWithBiases(layer, weights, biases);
1067  }
1068  };
1069 
1070  INetworkPtr network = INetwork::Create();
1071 
1072  TensorShape shape{3U};
1073  TensorInfo info(shape, DataType::Float32);
1074 
1075  std::vector<float> weightsData{-1.0f, 1.5f, 2.0f};
1076  ConstTensor weights(info, weightsData);
1077 
1078  Convolution2dDescriptor descriptor;
1079  descriptor.m_BiasEnabled = useBiases;
1080 
1081  // Add the layers
1082  IConnectableLayer* input0 = network->AddInputLayer(0);
1083  IConnectableLayer* conv2d;
1084  Optional<ConstTensor> optionalBiases;
1085  std::vector<float> biasesData{-1.0f, 1.5f, 2.0f};
1086  if (useBiases)
1087  {
1088  ConstTensor biases(info, biasesData);
1089  optionalBiases = Optional<ConstTensor>(biases);
1090  }
1091  conv2d = network->AddConvolution2dLayer(descriptor, weights, optionalBiases);
1092  IConnectableLayer* output = network->AddOutputLayer(1);
1093 
1094  // Establish connections
1095  input0->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
1096  conv2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1097 
1098  // Set TensorInfo
1099  input0->GetOutputSlot(0).SetTensorInfo(info);
1100  conv2d->GetOutputSlot(0).SetTensorInfo(info);
1101 
1102  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1103  TestConv2dQuantization validatorQAsymmU8(shape, shape);
1104  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1105 
1106  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1107  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1108  TestConv2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1109  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1110 
1111  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1112  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1113  TestConv2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1114  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1115 
1116  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
1117  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
1118  TestConv2dQuantization validatorQSymmS16(Qsymm16Options, shape, shape);
1119  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1120 }
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ TestQuantizeDepthwiseConvolution2d()

void armnn::TestQuantizeDepthwiseConvolution2d ( bool  useBiases)

Definition at line 1132 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, DepthwiseConvolution2dDescriptor::m_BiasEnabled, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

1133 {
1134  class TestDepthwiseConv2dQuantization : public TestQuantization
1135  {
1136  public:
1137  TestDepthwiseConv2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
1138  : TestQuantization(inputShape, outputShape) {}
1139 
1140  TestDepthwiseConv2dQuantization(const QuantizerOptions& options,
1141  const TensorShape& inputShape,
1142  const TensorShape& outputShape)
1143  : TestQuantization(options, inputShape, outputShape) {}
1144 
1145  void VisitDepthwiseConvolution2dLayer(const IConnectableLayer *layer,
1146  const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
1147  const ConstTensor& weights,
1148  const Optional<ConstTensor>& biases,
1149  const char *name = nullptr) override
1150  {
1151  boost::ignore_unused(convolution2dDescriptor, name);
1152  TestQuantizationOnLayersWithBiases(layer, weights, biases);
1153  }
1154  };
1155 
1156  INetworkPtr network = INetwork::Create();
1157 
1158  TensorShape shape{3U};
1159  TensorInfo info(shape, DataType::Float32);
1160 
1161  std::vector<float> weightsData{-1.0f, 1.5f, 2.0f};
1162  ConstTensor weights(info, weightsData);
1163 
1164  DepthwiseConvolution2dDescriptor descriptor;
1165  descriptor.m_BiasEnabled = useBiases;
1166 
1167  // Add the layers
1168  IConnectableLayer* input0 = network->AddInputLayer(0);
1169  IConnectableLayer* depthwiseConv2d;
1170  Optional<ConstTensor> optionalBiases;
1171  std::vector<float> biasesData{-1.0f, 1.5f, 2.0f};
1172  if (useBiases)
1173  {
1174  ConstTensor biases(info, biasesData);
1175  optionalBiases = Optional<ConstTensor>(biases);
1176  }
1177  depthwiseConv2d = network->AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases);
1178  IConnectableLayer* output = network->AddOutputLayer(1);
1179 
1180  // Establish connections
1181  input0->GetOutputSlot(0).Connect(depthwiseConv2d->GetInputSlot(0));
1182  depthwiseConv2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
1183 
1184  //Set TensorInfo
1185  input0->GetOutputSlot(0).SetTensorInfo(info);
1186  depthwiseConv2d->GetOutputSlot(0).SetTensorInfo(info);
1187 
1188  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1189  TestDepthwiseConv2dQuantization validatorQAsymmU8(shape, shape);
1190  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1191 
1192  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1193  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1194  TestDepthwiseConv2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1195  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1196 
1197  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1198  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1199  TestDepthwiseConv2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1200  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1201 
1202  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
1203  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
1204  TestDepthwiseConv2dQuantization validatorQSymmS16(Qsymm16Options, shape, shape);
1205  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1206 }
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ TestQuantizeTransposeConvolution2d()

void armnn::TestQuantizeTransposeConvolution2d ( bool  useBiases)

Definition at line 2488 of file QuantizerTest.cpp.

References IOutputSlot::Connect(), INetworkQuantizer::Create(), INetwork::Create(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), info, TransposeConvolution2dDescriptor::m_BiasEnabled, options, QAsymmS8, QSymmS16, QSymmS8, IOutputSlot::SetTensorInfo(), and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

2489 {
2490  class TestTransposeConvolution2dQuantization : public TestQuantization
2491  {
2492  public:
2493  TestTransposeConvolution2dQuantization(const TensorShape& inputShape, const TensorShape& outputShape) :
2494  TestQuantization(inputShape, outputShape)
2495  {}
2496 
2497  TestTransposeConvolution2dQuantization(const QuantizerOptions& options,
2498  const TensorShape& inputShape,
2499  const TensorShape& outputShape) :
2500  TestQuantization(options, inputShape, outputShape)
2501  {}
2502 
2503  void VisitTransposeConvolution2dLayer(const IConnectableLayer *layer,
2504  const TransposeConvolution2dDescriptor& descriptor,
2505  const ConstTensor& weights,
2506  const Optional<ConstTensor>& biases,
2507  const char *name = nullptr) override
2508  {
2509  boost::ignore_unused(descriptor, name);
2510  TestQuantizationOnLayersWithBiases(layer, weights, biases);
2511  }
2512  };
2513 
2514  INetworkPtr network = INetwork::Create();
2515 
2516  TensorShape shape{ 3 };
2517  TensorInfo info(shape, DataType::Float32);
2518 
2519  std::initializer_list<float> floatData{ -1.0f, 1.5f, 2.0f };
2520  std::vector<float> weightsData(floatData);
2521  ConstTensor weights(info, weightsData);
2522 
2523  TransposeConvolution2dDescriptor descriptor;
2524  descriptor.m_BiasEnabled = useBiases;
2525 
2526  // construct network
2527  IConnectableLayer* input = network->AddInputLayer(0);
2528  Optional<ConstTensor> optionalBiases;
2529  std::vector<float> biasesData(floatData);
2530  if (useBiases)
2531  {
2532  ConstTensor biases(info, biasesData);
2533  optionalBiases = Optional<ConstTensor>(biases);
2534  }
2535  IConnectableLayer* transposeConv2d = network->AddTransposeConvolution2dLayer(descriptor, weights, optionalBiases);
2536  IConnectableLayer* output = network->AddOutputLayer(1);
2537 
2538  input->GetOutputSlot(0).Connect(transposeConv2d->GetInputSlot(0));
2539  transposeConv2d->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2540 
2541  input->GetOutputSlot(0).SetTensorInfo(info);
2542  transposeConv2d->GetOutputSlot(0).SetTensorInfo(info);
2543 
2544  // test QAsymmU8 quantization
2545  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
2546  TestTransposeConvolution2dQuantization validatorQAsymmU8(shape, shape);
2547  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
2548 
2549  //test QAsymmS8 quantization
2550  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
2551  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
2552  TestTransposeConvolution2dQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
2553  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
2554 
2555  // test QSymmS8 quantization
2556  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
2557  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
2558  TestTransposeConvolution2dQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
2559  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
2560 
2561  // test QSymmS16 quantization
2562  const QuantizerOptions qSymmS16options(DataType::QSymmS16);
2563  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), qSymmS16options)->ExportNetwork();
2564  TestTransposeConvolution2dQuantization validatorQSymmS16(qSymmS16options, shape, shape);
2565  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
2566 }
void VisitLayersTopologically(const INetwork *inputNetwork, ILayerVisitor &visitor)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:85
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ TopKSort()

void TopKSort ( unsigned int  k,
unsigned int *  indices,
const float *  values,
unsigned int  numElement 
)

Definition at line 25 of file DetectionPostProcess.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), DetectionPostProcess(), and NonMaxSuppression().

26 {
27  std::partial_sort(indices, indices + k, indices + numElement,
28  [&values](unsigned int i, unsigned int j) { return values[i] > values[j]; });
29 }

◆ 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 >::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, 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  unsigned int numBatches = inputShape[0];
34 
35  unsigned int inputWidth = inputShape[widthIndex];
36  unsigned int inputHeight = inputShape[heightIndex];
37  unsigned int inputDepth = inputShape[channelsIndex];
38 
39  unsigned int weightsHeight = weightsShape[heightIndex];
40  unsigned int weightsWidth = weightsShape[widthIndex];
41 
42  unsigned int outputHeight = outputShape[heightIndex];
43  unsigned int outputWidth = outputShape[widthIndex];
44  unsigned int outputDepth = outputShape[channelsIndex];
45 
46  unsigned int paddingLeft = descriptor.m_PadLeft;
47  unsigned int paddingTop = descriptor.m_PadTop;
48 
49  unsigned int strideX = descriptor.m_StrideX;
50  unsigned int strideY = descriptor.m_StrideY;
51 
52  std::vector<float> outputBuffer(outputShape.GetNumElements(), 0);
53 
54  for (unsigned int batch = 0u; batch < numBatches; ++batch)
55  {
56  for (unsigned int yInput = 0u; yInput < inputHeight; ++yInput)
57  {
58  for (unsigned int xInput = 0u; xInput < inputWidth; ++xInput)
59  {
60  unsigned int xOutputOrigin = xInput * strideX - paddingLeft;
61  unsigned int yOutputOrigin = yInput * strideY - paddingTop;
62 
63  for (unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
64  {
65  for (unsigned int yWeights = 0u; yWeights < weightsHeight; ++yWeights)
66  {
67  for (unsigned int xWeights = 0u; xWeights < weightsWidth; ++xWeights)
68  {
69  unsigned int yOutput = yOutputOrigin + yWeights;
70  unsigned int xOutput = xOutputOrigin + xWeights;
71 
72  if (yOutput < outputHeight && xOutput< outputWidth)
73  {
74  for (unsigned int dInput = 0u; dInput < inputDepth; dInput++)
75  {
76  const unsigned int inputIndex =
77  dataLayoutIndexed.GetIndex(inputShape, batch, dInput, yInput, xInput);
78  inputDecoder[inputIndex];
79 
80  const unsigned int weightsIndex =
81  dataLayoutIndexed.GetIndex(weightsShape, dOutput, dInput, yWeights, xWeights);
82  weightsDecoder.SetIndex(weightsIndex, dOutput);
83 
84  const unsigned int outputIndex =
85  dataLayoutIndexed.GetIndex(outputShape, batch, dOutput, yOutput, xOutput);
86  outputEncoder[outputIndex];
87 
88  float output = outputBuffer[outputIndex];
89  output += inputDecoder.Get() * weightsDecoder.Get();
90  outputBuffer[outputIndex] = output;
91  }
92  }
93  }
94  }
95  }
96  }
97  }
98  }
99 
100  // Apply bias (if enabled)
101  if (descriptor.m_BiasEnabled)
102  {
103  outputEncoder[0];
104  Decoder<float>& rBiasesDecoder = *biasesDecoder;
105 
106  for (unsigned int batch = 0u; batch < numBatches; ++batch)
107  {
108  for (unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
109  {
110  rBiasesDecoder.SetIndex(dOutput, dOutput);
111  for (unsigned int yOutput = 0u; yOutput < outputHeight; ++yOutput)
112  {
113  for (unsigned int xOutput = 0u; xOutput < outputWidth; ++xOutput)
114  {
115  const unsigned int outputIndex =
116  dataLayoutIndexed.GetIndex(outputShape, batch, dOutput, yOutput, xOutput);
117  outputBuffer[outputIndex] += rBiasesDecoder.Get();
118  }
119  }
120  }
121  }
122  }
123  outputEncoder[0];
124  for (float output : outputBuffer)
125  {
126  outputEncoder.Set(output);
127  ++outputEncoder;
128  }
129 }
virtual BaseIterator & SetIndex(unsigned int index, unsigned int axisIndex=0)=0
virtual IType Get() const =0
virtual void Set(IType right)=0

◆ TrueFunc()

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

Definition at line 55 of file LayerSupportCommon.hpp.

56 {
57  boost::ignore_unused(reasonIfUnsupported);
58  boost::ignore_unused(params...);
59  return true;
60 }

◆ ValidateFullyConnectedLayer()

void armnn::ValidateFullyConnectedLayer ( const bool  biasEnabled)

Definition at line 989 of file QuantizerTest.cpp.

References INetworkQuantizer::Create(), CreateNetworkWithFullyConnectedLayer(), options, QAsymmS8, QSymmS16, QSymmS8, and VisitLayersTopologically().

Referenced by BOOST_AUTO_TEST_CASE().

990 {
991  class TestFullyConnectedQuantization : public TestQuantization
992  {
993  public:
994  TestFullyConnectedQuantization(const TensorShape& inputShape, const TensorShape& outputShape)
995  : TestQuantization(inputShape, outputShape) {}
996 
997  TestFullyConnectedQuantization(const QuantizerOptions& options,
998  const TensorShape& inputShape,
999  const TensorShape& outputShape)
1000  : TestQuantization(options, inputShape, outputShape) {}
1001 
1002  void VisitFullyConnectedLayer(const IConnectableLayer* layer,
1003  const FullyConnectedDescriptor& desc,
1004  const ConstTensor& weights,
1005  const Optional<ConstTensor>& biases,
1006  const char* name = nullptr) override
1007  {
1008  boost::ignore_unused(desc, name);
1009  TestQuantizationOnLayersWithBiases(layer, weights, biases);
1010  }
1011  };
1012 
1013  const TensorShape shape{3U};
1014  INetworkPtr network = CreateNetworkWithFullyConnectedLayer(biasEnabled, shape, shape);
1015 
1016  INetworkPtr quantizedNetworkQAsymmU8 = INetworkQuantizer::Create(network.get())->ExportNetwork();
1017  TestFullyConnectedQuantization validatorQAsymmU8(shape, shape);
1018  VisitLayersTopologically(quantizedNetworkQAsymmU8.get(), validatorQAsymmU8);
1019 
1020  const QuantizerOptions qAsymmS8Options(DataType::QAsymmS8);
1021  INetworkPtr quantizedNetworkQAsymmS8 = INetworkQuantizer::Create(network.get(), qAsymmS8Options)->ExportNetwork();
1022  TestFullyConnectedQuantization validatorQAsymmS8(qAsymmS8Options, shape, shape);
1023  VisitLayersTopologically(quantizedNetworkQAsymmS8.get(), validatorQAsymmS8);
1024 
1025  const QuantizerOptions qSymmS8Options(DataType::QSymmS8);
1026  INetworkPtr quantizedNetworkQSymmS8 = INetworkQuantizer::Create(network.get(), qSymmS8Options)->ExportNetwork();
1027  TestFullyConnectedQuantization validatorQSymmS8(qSymmS8Options, shape, shape);
1028  VisitLayersTopologically(quantizedNetworkQSymmS8.get(), validatorQSymmS8);
1029 
1030  const QuantizerOptions Qsymm16Options(DataType::QSymmS16);
1031  INetworkPtr quantizedNetworkQSymmS16 = INetworkQuantizer::Create(network.get(), Qsymm16Options)->ExportNetwork();
1032  TestFullyConnectedQuantization validatorQSymmS16(Qsymm16Options, shape, shape);
1033  VisitLayersTopologically(quantizedNetworkQSymmS16.get(), validatorQSymmS16);
1034 }
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:85
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ VerifyTensorInfoDataType()

void armnn::VerifyTensorInfoDataType ( const armnn::TensorInfo info,
armnn::DataType  dataType 
)
inline

Definition at line 292 of file TypesUtils.hpp.

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

Referenced by ParserFlatbuffersSerializeFixture::RunTest(), and ParserFlatbuffersFixture::RunTest().

293 {
294  if (info.GetDataType() != dataType)
295  {
296  std::stringstream ss;
297  ss << "Unexpected datatype:" << armnn::GetDataTypeName(info.GetDataType())
298  << " for tensor:" << info.GetShape()
299  << ". The type expected to be: " << armnn::GetDataTypeName(dataType);
300  throw armnn::Exception(ss.str());
301  }
302 }
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
DataType GetDataType() const
Definition: Tensor.hpp:95
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:165

◆ VisitLayers()

void armnn::VisitLayers ( const LayerContainer &  layerContainer,
ILayerVisitor visitor 
)

Definition at line 50 of file NetworkQuantizerUtils.hpp.

References ILayerVisitor::FinishVisit(), and ILayerVisitor::StartVisit().

Referenced by BOOST_AUTO_TEST_CASE(), NetworkQuantizer::ExportNetwork(), NetworkQuantizer::OverrideInputRange(), NetworkQuantizer::Refine(), and VisitLayersTopologically().

51 {
52  visitor.StartVisit();
53  for (auto layer : layerContainer)
54  {
55  layer->Accept(visitor);
56  }
57  visitor.FinishVisit();
58 }

◆ VisitLayersTopologically()

void armnn::VisitLayersTopologically ( const INetwork inputNetwork,
ILayerVisitor visitor 
)

Definition at line 193 of file QuantizerTest.cpp.

References g_AsymmS8QuantizationBase, g_AsymmU8QuantizationBase, g_SymmS16QuantizationBase, g_SymmS8QuantizationBase, IConnectableLayer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), info, options, and VisitLayers().

Referenced by BOOST_AUTO_TEST_CASE(), PreserveTypeTestImpl(), TestQuantizeConvolution2d(), TestQuantizeDepthwiseConvolution2d(), TestQuantizeTransposeConvolution2d(), and ValidateFullyConnectedLayer().

194 {
195  auto network = boost::polymorphic_downcast<const Network*>(inputNetwork);
196  auto graph = network->GetGraph().TopologicalSort();
197 
198  VisitLayers(graph, visitor);
199 }
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)

◆ WrapClError()

RuntimeException armnn::WrapClError ( const cl::Error clError,
const CheckLocation location 
)
inline

Definition at line 123 of file ClWorkloadUtils.hpp.

References Exception::what().

Referenced by ClWorkloadFactory::GetBackendId(), and RunClFunction().

124 {
125  std::stringstream message;
126  message << "CL error: " << clError.what() << ". Error code: " << clError.err();
127 
128  return RuntimeException(message.str(), location);
129 }

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 35 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_AsymmU8QuantizationBase

const float g_AsymmU8QuantizationBase = 255.0f

Definition at line 33 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 37 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_SymmS8QuantizationBase

const float g_SymmS8QuantizationBase = 127.0f

Definition at line 36 of file QuantizerTest.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and VisitLayersTopologically().

◆ g_TestTolerance

const float g_TestTolerance = 0.000001f

Definition at line 38 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

◆ MaxNumOfTensorDimensions

◆ tl_Profiler

thread_local Profiler* tl_Profiler = nullptr

Definition at line 484 of file Profiling.cpp.

Referenced by ProfilerManager::GetProfiler().