ArmNN
 22.02
armnn Namespace Reference

Copyright (c) 2021 ARM Limited and Contributors. More...

Namespaces

 experimental
 
 gatordmock
 
 optimizations
 
 profiling
 
 stringUtils
 
 test
 
 timelinedecoder
 
 utility
 

Classes

struct  abs
 
class  AbsLayer
 
struct  AbsQueueDescriptor
 
struct  ActivationDescriptor
 An ActivationDescriptor for the ActivationLayer. More...
 
class  ActivationLayer
 This layer represents an activation operation with the specified activation function. More...
 
struct  ActivationQueueDescriptor
 
class  AddedLayerObservable
 
class  AdditionLayer
 This layer represents an addition operation. More...
 
struct  AdditionQueueDescriptor
 
struct  Allocator
 
struct  ArgMinMaxDescriptor
 An ArgMinMaxDescriptor for ArgMinMaxLayer. More...
 
class  ArgMinMaxLayer
 This layer represents a ArgMinMax operation. More...
 
struct  ArgMinMaxQueueDescriptor
 
class  BackendCapabilityException
 
class  BackendId
 
struct  BackendOptions
 Struct for the users to pass backend specific options. More...
 
class  BackendProfilingException
 
class  BackendRegistry
 
struct  BackendSettings
 
class  BackendUnavailableException
 Class for non-fatal exceptions raised while initialising a backend. More...
 
struct  BackendVersion
 
class  BadOptionalAccessException
 
struct  BaseDescriptor
 Base class for all descriptors. More...
 
class  BaseIterator
 
class  BaseMemoryManager
 
class  BaseTensor
 
class  BaseWorkload
 
struct  BatchNormalizationDescriptor
 A BatchNormalizationDescriptor for the BatchNormalizationLayer. More...
 
class  BatchNormalizationLayer
 This layer represents a batch normalization operation. More...
 
struct  BatchNormalizationQueueDescriptor
 
struct  BatchToSpaceNdDescriptor
 A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer. More...
 
class  BatchToSpaceNdLayer
 This layer represents a BatchToSpaceNd operation. More...
 
struct  BatchToSpaceNdQueueDescriptor
 
class  BFloat16
 
class  BFloat16Decoder
 
class  BFloat16Encoder
 
struct  BiasAndWeightsTypesCompatible
 
struct  BiasAndWeightsTypesMatch
 
class  BindableLayer
 
class  BooleanDecoder
 
class  BooleanDecoderBool
 
class  BooleanEncoder
 
struct  BroadcastLoop
 
struct  BufferStorage
 
struct  Capability
 Capability of the TensorHandleFactory. More...
 
class  CastLayer
 This layer represents a cast operation. More...
 
struct  CastQueueDescriptor
 
struct  ChannelShuffleDescriptor
 A ChannelShuffleDescriptor for the ChannelShuffle operator. More...
 
class  ChannelShuffleLayer
 
struct  ChannelShuffleQueueDescriptor
 
struct  CheckLocation
 
class  ClAbsWorkload
 
class  ClActivationWorkload
 
class  ClAdditionWorkload
 
class  ClArgMinMaxWorkload
 
class  ClBackend
 
class  ClBackendContext
 
class  ClBackendDefaultAllocator
 Default Memory Allocator class returned from IBackendInternal::GetDefaultAllocator(MemorySource) More...
 
class  ClBackendModelContext
 The ClBackendModelContext is used to pass in CL specific backend ModelOptions. More...
 
class  ClBaseWorkload
 
class  ClBatchNormalizationFloatWorkload
 
class  ClBatchToSpaceNdWorkload
 
class  ClCastWorkload
 
class  ClChannelShuffleWorkload
 
class  ClComparisonWorkload
 
class  ClConcatWorkload
 
class  ClConstantWorkload
 
struct  ClContextBuilder
 
class  ClContextControl
 
class  ClContextDeserializer
 
class  ClContextSerializer
 
class  ClConvertFp16ToFp32Workload
 
class  ClConvertFp32ToFp16Workload
 
class  ClConvolution2dWorkload
 
class  ClConvolution3dWorkload
 
class  ClDepthToSpaceWorkload
 
class  ClDepthwiseConvolutionWorkload
 
class  ClDequantizeWorkload
 
class  ClDivisionWorkload
 
class  ClExpWorkload
 
class  ClFillWorkload
 
class  ClFloorFloatWorkload
 
class  ClFullyConnectedWorkload
 
class  ClGatherWorkload
 
class  ClImportSubTensorHandle
 
class  ClImportTensorHandle
 
class  ClImportTensorHandleFactory
 This factory creates ClImportTensorHandles that refer to imported memory tensors. More...
 
class  ClInstanceNormalizationWorkload
 
class  ClL2NormalizationFloatWorkload
 
class  ClLayerSupport
 
class  ClLogicalAndWorkload
 
class  ClLogicalNotWorkload
 
class  ClLogicalOrWorkload
 
class  ClLogSoftmaxWorkload
 
class  ClLogWorkload
 
class  ClLstmFloatWorkload
 
class  ClMaximumWorkload
 
class  ClMeanWorkload
 
class  ClMemoryManager
 
class  ClMinimumWorkload
 
class  ClMultiplicationWorkload
 
class  ClNegWorkload
 
class  ClNormalizationFloatWorkload
 
class  ClPadWorkload
 
class  ClPermuteWorkload
 
class  ClPooling2dWorkload
 
class  ClPreluWorkload
 
class  ClQLstmWorkload
 
class  ClQuantizedLstmWorkload
 
class  ClQuantizeWorkload
 
struct  ClRankWorkload
 
class  ClReduceWorkload
 
class  ClReshapeWorkload
 
class  ClResizeWorkload
 
class  ClRsqrtWorkload
 
class  ClRuntimeUnavailableException
 
class  ClSinWorkload
 
class  ClSliceWorkload
 
class  ClSoftmaxWorkload
 
class  ClSpaceToBatchNdWorkload
 
class  ClSpaceToDepthWorkload
 
class  ClSplitterWorkload
 
class  ClStackWorkload
 
class  ClStridedSliceWorkload
 
class  ClSubTensorHandle
 
class  ClSubtractionWorkload
 
class  ClTensorHandle
 
class  ClTensorHandleFactory
 
class  ClTransposeConvolution2dWorkload
 
class  ClTransposeWorkload
 
class  ClTunedParameters
 
class  ClWorkloadFactory
 
struct  ComparisonDescriptor
 A ComparisonDescriptor for the ComparisonLayer. More...
 
class  ComparisonLayer
 This layer represents a comparison operation. More...
 
struct  ComparisonQueueDescriptor
 
class  ConcatLayer
 This layer represents a merge operation. More...
 
struct  ConcatQueueDescriptor
 
class  ConstantLayer
 A layer that the constant data can be bound to. More...
 
class  ConstantMemoryStrategy
 
struct  ConstantQueueDescriptor
 
class  ConstPassthroughTensorHandle
 
struct  ConstructInPlace
 Disambiguation tag that can be passed to the constructor to indicate that the contained object should be constructed in-place. More...
 
class  ConstTensor
 A tensor defined by a TensorInfo (shape and data type) and an immutable backing store. More...
 
class  ConstTensorHandle
 
class  ConvertBf16ToFp32Layer
 This layer converts data type BFloat16 to Float32. More...
 
struct  ConvertBf16ToFp32QueueDescriptor
 
class  ConvertFp16ToFp32Layer
 This layer converts data type Float 16 to Float 32. More...
 
struct  ConvertFp16ToFp32QueueDescriptor
 
class  ConvertFp32ToBf16Layer
 This layer converts data type Float32 to BFloat16. More...
 
struct  ConvertFp32ToBf16QueueDescriptor
 
class  ConvertFp32ToFp16Layer
 This layer converts data type Float 32 to Float 16. More...
 
struct  ConvertFp32ToFp16QueueDescriptor
 
struct  Convolution2dDescriptor
 A Convolution2dDescriptor for the Convolution2dLayer. More...
 
class  Convolution2dLayer
 This layer represents a convolution 2d operation. More...
 
struct  Convolution2dQueueDescriptor
 
struct  Convolution3dDescriptor
 A Convolution3dDescriptor for the Convolution3dLayer. More...
 
class  Convolution3dLayer
 This layer represents a convolution 3d operation. More...
 
struct  Convolution3dQueueDescriptor
 
class  CopyMemGenericWorkload
 
class  DebugLayer
 This layer visualizes the data flowing through the network. More...
 
struct  DebugQueueDescriptor
 
class  Decoder
 
class  DefaultAllocator
 Default Memory Allocator class returned from IBackendInternal::GetDefaultAllocator(MemorySource) More...
 
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
 Depthwise Convolution 2D layer workload data. More...
 
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  ElementwiseBaseLayer
 NOTE: this is an abstract class to encapsulate the element wise operations, it does not implement: std::unique_ptr<IWorkload> Layer::CreateWorkload(const IWorkloadFactory& factory) const = 0; Layer* Clone(Graph& graph) const = 0;. More...
 
struct  ElementwiseBinaryFunction
 
struct  ElementwiseUnaryDescriptor
 A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer. More...
 
struct  ElementwiseUnaryFunction
 
class  ElementwiseUnaryLayer
 This layer represents a elementwiseUnary operation. More...
 
struct  ElementwiseUnaryQueueDescriptor
 
struct  EmptyOptional
 EmptyOptional is used to initialize the Optional class in case we want to have default value for an Optional in a function declaration. More...
 
class  Encoder
 
struct  EqualQueueDescriptor
 
class  ErasedLayerNamesObservable
 
class  Event
 Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Event::GetMeasurements() is called. More...
 
class  Exception
 Base class for all ArmNN exceptions so that users can filter to just those. More...
 
class  ExecutionFrame
 
struct  exp
 
struct  FakeQuantizationDescriptor
 A FakeQuantizationDescriptor for the FakeQuantizationLayer. More...
 
class  FakeQuantizationLayer
 This layer represents a fake quantization operation. More...
 
struct  FakeQuantizationQueueDescriptor
 
class  FileNotFoundException
 
struct  FillDescriptor
 A FillDescriptor for the FillLayer. More...
 
class  FillLayer
 This layer represents a fill operation. More...
 
struct  FillQueueDescriptor
 
class  FirstInputTypedWorkload
 
struct  FLATBUFFERS_FINAL_CLASS
 
class  Float16Decoder
 
class  Float16Encoder
 
class  Float32Decoder
 
class  Float32Encoder
 
class  FloorLayer
 This layer represents a floor operation. More...
 
struct  FloorQueueDescriptor
 
struct  FullyConnectedDescriptor
 A FullyConnectedDescriptor for the FullyConnectedLayer. More...
 
class  FullyConnectedLayer
 This layer represents a fully connected operation. More...
 
struct  FullyConnectedQueueDescriptor
 
struct  GatherDescriptor
 A GatherDescriptor for the GatherLayer. More...
 
class  GatherLayer
 This layer represents a Gather operator. More...
 
struct  GatherQueueDescriptor
 
class  Graph
 
class  GraphObservable
 
class  GraphValidationException
 
struct  GreaterQueueDescriptor
 
class  HtmlBold
 
class  HtmlFont
 
class  HtmlSection
 
class  HtmlSimpleTag
 
class  IAclTensorHandle
 
class  IBackend
 Each backend should implement an IBackend. More...
 
class  IBackendContext
 
class  IBackendInternal
 
class  IBackendModelContext
 
class  IClTensorHandle
 
class  ICLTensorProxy
 
class  IConnectableLayer
 Interface for a layer that is connectable to other layers via InputSlots and OutputSlots. More...
 
class  ICustomAllocator
 Custom Allocator interface. More...
 
class  IDeviceSpec
 Device specific knowledge to be passed to the optimizer. More...
 
class  IExecutionFrame
 ExecutionFrame interface to enqueue a workload computation. More...
 
class  IGpuAccTunedParameters
 Manages a set of GpuAcc parameters which have been tuned for maximum performance. More...
 
class  IGraphObservable
 
class  IInputSlot
 An input connection slot for a layer. More...
 
class  ILayerSupport
 
class  IMemoryManager
 
class  IMemoryOptimizerStrategy
 
struct  IMemoryOptimizerStrategyFactory
 
class  ImportMemGenericWorkload
 
class  INetwork
 Main network class which provides the interface for building up a neural network. More...
 
struct  INetworkProperties
 
class  InputLayer
 A layer user-provided data can be bound to (e.g. inputs, outputs). More...
 
class  InputSlot
 
struct  InstanceNormalizationDescriptor
 An InstanceNormalizationDescriptor for InstanceNormalizationLayer. More...
 
class  InstanceNormalizationLayer
 This layer represents an instance normalization operation. More...
 
struct  InstanceNormalizationQueueDescriptor
 
class  Instrument
 
class  Int32Decoder
 
class  Int32Encoder
 
class  Int32ToInt32tDecoder
 
class  Int32ToInt32tEncoder
 
class  InvalidArgumentException
 
class  IOptimizedNetwork
 
class  IOutputSlot
 An output connection slot for a layer. More...
 
class  IProfiler
 
class  IRuntime
 
struct  IsHalfType
 
struct  IsMemorySource
 
struct  IsMemorySource< MemorySource >
 
class  IStrategy
 
class  ISubgraphViewConverter
 
class  ITensorHandle
 
class  ITensorHandleFactory
 
class  IWorkload
 Workload interface to enqueue a layer computation. More...
 
class  IWorkloadFactory
 
struct  JsonChildObject
 
class  JsonPrinter
 
class  JsonUtils
 
struct  L2NormalizationDescriptor
 A L2NormalizationDescriptor for the L2NormalizationLayer. More...
 
class  L2NormalizationLayer
 This layer represents a L2 normalization operation. More...
 
struct  L2NormalizationQueueDescriptor
 
class  Layer
 
class  LayerSupportBase
 
class  LayerSupportHandle
 
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::Cast >
 
struct  LayerTypeOfImpl< LayerType::ChannelShuffle >
 
struct  LayerTypeOfImpl< LayerType::Comparison >
 
struct  LayerTypeOfImpl< LayerType::Concat >
 
struct  LayerTypeOfImpl< LayerType::Constant >
 
struct  LayerTypeOfImpl< LayerType::ConvertBf16ToFp32 >
 
struct  LayerTypeOfImpl< LayerType::ConvertFp16ToFp32 >
 
struct  LayerTypeOfImpl< LayerType::ConvertFp32ToBf16 >
 
struct  LayerTypeOfImpl< LayerType::ConvertFp32ToFp16 >
 
struct  LayerTypeOfImpl< LayerType::Convolution2d >
 
struct  LayerTypeOfImpl< LayerType::Convolution3d >
 
struct  LayerTypeOfImpl< LayerType::Debug >
 
struct  LayerTypeOfImpl< LayerType::DepthToSpace >
 
struct  LayerTypeOfImpl< LayerType::DepthwiseConvolution2d >
 
struct  LayerTypeOfImpl< LayerType::Dequantize >
 
struct  LayerTypeOfImpl< LayerType::DetectionPostProcess >
 
struct  LayerTypeOfImpl< LayerType::Division >
 
struct  LayerTypeOfImpl< LayerType::ElementwiseUnary >
 
struct  LayerTypeOfImpl< LayerType::FakeQuantization >
 
struct  LayerTypeOfImpl< LayerType::Fill >
 
struct  LayerTypeOfImpl< LayerType::Floor >
 
struct  LayerTypeOfImpl< LayerType::FullyConnected >
 
struct  LayerTypeOfImpl< LayerType::Gather >
 
struct  LayerTypeOfImpl< LayerType::Input >
 
struct  LayerTypeOfImpl< LayerType::InstanceNormalization >
 
struct  LayerTypeOfImpl< LayerType::L2Normalization >
 
struct  LayerTypeOfImpl< LayerType::LogicalBinary >
 
struct  LayerTypeOfImpl< LayerType::LogSoftmax >
 
struct  LayerTypeOfImpl< LayerType::Lstm >
 
struct  LayerTypeOfImpl< LayerType::Map >
 
struct  LayerTypeOfImpl< LayerType::Maximum >
 
struct  LayerTypeOfImpl< LayerType::Mean >
 
struct  LayerTypeOfImpl< LayerType::MemCopy >
 
struct  LayerTypeOfImpl< LayerType::MemImport >
 
struct  LayerTypeOfImpl< LayerType::Merge >
 
struct  LayerTypeOfImpl< LayerType::Minimum >
 
struct  LayerTypeOfImpl< LayerType::Multiplication >
 
struct  LayerTypeOfImpl< LayerType::Normalization >
 
struct  LayerTypeOfImpl< LayerType::Output >
 
struct  LayerTypeOfImpl< LayerType::Pad >
 
struct  LayerTypeOfImpl< LayerType::Permute >
 
struct  LayerTypeOfImpl< LayerType::Pooling2d >
 
struct  LayerTypeOfImpl< LayerType::Pooling3d >
 
struct  LayerTypeOfImpl< LayerType::PreCompiled >
 
struct  LayerTypeOfImpl< LayerType::Prelu >
 
struct  LayerTypeOfImpl< LayerType::QLstm >
 
struct  LayerTypeOfImpl< LayerType::Quantize >
 
struct  LayerTypeOfImpl< LayerType::QuantizedLstm >
 
struct  LayerTypeOfImpl< LayerType::Rank >
 
struct  LayerTypeOfImpl< LayerType::Reduce >
 
struct  LayerTypeOfImpl< LayerType::Reshape >
 
struct  LayerTypeOfImpl< LayerType::Resize >
 
struct  LayerTypeOfImpl< LayerType::Shape >
 
struct  LayerTypeOfImpl< LayerType::Slice >
 
struct  LayerTypeOfImpl< LayerType::Softmax >
 
struct  LayerTypeOfImpl< LayerType::SpaceToBatchNd >
 
struct  LayerTypeOfImpl< LayerType::SpaceToDepth >
 
struct  LayerTypeOfImpl< LayerType::Splitter >
 
struct  LayerTypeOfImpl< LayerType::Stack >
 
struct  LayerTypeOfImpl< LayerType::StandIn >
 
struct  LayerTypeOfImpl< LayerType::StridedSlice >
 
struct  LayerTypeOfImpl< LayerType::Subtraction >
 
struct  LayerTypeOfImpl< LayerType::Switch >
 
struct  LayerTypeOfImpl< LayerType::Transpose >
 
struct  LayerTypeOfImpl< LayerType::TransposeConvolution2d >
 
struct  LayerTypeOfImpl< LayerType::UnidirectionalSequenceLstm >
 
struct  LayerTypeOfImpl< LayerType::Unmap >
 
class  LayerValidationException
 
class  LayerVisitorBase
 Visitor base class with empty implementations. More...
 
class  LayerWithParameters
 
class  LoadedNetwork
 
struct  log
 
struct  LogicalBinaryDescriptor
 A LogicalBinaryDescriptor for the LogicalBinaryLayer. More...
 
struct  LogicalBinaryFunction
 
class  LogicalBinaryLayer
 This layer represents a Logical Binary operation. More...
 
struct  LogicalBinaryQueueDescriptor
 
struct  LogicalUnaryFunction
 
class  LogSink
 
class  LogSoftmaxLayer
 This layer represents a log softmax operation. More...
 
struct  LogSoftmaxQueueDescriptor
 
struct  LstmBasicParameters
 
struct  LstmDescriptor
 An LstmDescriptor for the LstmLayer. More...
 
struct  LstmInputParams
 
struct  LstmInputParamsInfo
 
class  LstmLayer
 This layer represents a LSTM operation. More...
 
struct  LstmOptCifgParameters
 
struct  LstmOptLayerNormParameters
 
struct  LstmOptPeepholeParameters
 
struct  LstmOptProjectionParameters
 
struct  LstmQueueDescriptor
 
class  LstmVisitor
 
class  ManagedConstTensorHandle
 
class  MapLayer
 This layer represents a memory copy operation. More...
 
struct  MapQueueDescriptor
 
class  MapWorkload
 
struct  maximum
 
class  MaximumLayer
 This layer represents a maximum operation. More...
 
struct  MaximumQueueDescriptor
 
struct  MeanDescriptor
 A MeanDescriptor for the MeanLayer. More...
 
class  MeanLayer
 This layer represents a mean operation. More...
 
struct  MeanQueueDescriptor
 
struct  Measurement
 
struct  MemBin
 
struct  MemBlock
 
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
 
class  MemoryManager
 
class  MemoryValidationException
 
struct  MemSyncQueueDescriptor
 
class  MergeLayer
 This layer dequantizes the input tensor. More...
 
struct  MergeQueueDescriptor
 
struct  minimum
 
class  MinimumLayer
 This layer represents a minimum operation. More...
 
struct  MinimumQueueDescriptor
 
class  MockBackend
 
class  MockBackendInitialiser
 
class  MockBackendProfilingContext
 
class  MockBackendProfilingService
 
class  MockImportBackend
 
class  MockImportBackendInitialiser
 
class  MockImportLayerSupport
 
class  MockLayerSupport
 
class  MockMemoryManager
 
class  MockTensorHandle
 
class  MockTensorHandleFactory
 
class  MockWorkloadFactory
 
class  MultiplicationLayer
 This layer represents a multiplication operation. More...
 
struct  MultiplicationQueueDescriptor
 
class  MultiTypedWorkload
 
class  NeonAbsWorkload
 
class  NeonActivationWorkload
 
class  NeonAdditionWorkload
 
class  NeonArgMinMaxWorkload
 
class  NeonBackend
 
class  NeonBackendModelContext
 The NeonBackendModelContext is used to pass in Neon specific backend ModelOptions. More...
 
class  NeonBaseWorkload
 
class  NeonBatchNormalizationWorkload
 
class  NeonBatchToSpaceNdWorkload
 
class  NeonCastWorkload
 
class  NeonChannelShuffleWorkload
 
class  NeonComparisonWorkload
 
class  NeonConcatWorkload
 
class  NeonConstantWorkload
 
class  NeonConvertBf16ToFp32Workload
 
class  NeonConvertFp16ToFp32Workload
 
class  NeonConvertFp32ToBf16Workload
 
class  NeonConvertFp32ToFp16Workload
 
class  NeonConvolution2dWorkload
 
class  NeonConvolution3dWorkload
 
class  NeonDepthToSpaceWorkload
 
class  NeonDepthwiseConvolutionWorkload
 
class  NeonDequantizeWorkload
 
class  NeonDetectionPostProcessWorkload
 
class  NeonDivisionWorkload
 
class  NeonExpWorkload
 
class  NeonFillWorkload
 
class  NeonFloorFloatWorkload
 
class  NeonFullyConnectedWorkload
 
class  NeonGatherWorkload
 
class  NeonInstanceNormalizationWorkload
 
class  NeonInterceptorScheduler
 
class  NeonL2NormalizationFloatWorkload
 
class  NeonLayerSupport
 
class  NeonLogicalAndWorkload
 
class  NeonLogicalNotWorkload
 
class  NeonLogicalOrWorkload
 
class  NeonLogSoftmaxWorkload
 
class  NeonLogWorkload
 
class  NeonLstmFloatWorkload
 
class  NeonMaximumWorkload
 
class  NeonMeanWorkload
 
class  NeonMemoryManager
 
class  NeonMinimumWorkload
 
class  NeonMultiplicationWorkload
 
class  NeonNegWorkload
 
class  NeonNormalizationFloatWorkload
 
class  NeonPadWorkload
 
class  NeonPermuteWorkload
 
class  NeonPooling2dWorkload
 
class  NeonPreluWorkload
 
class  NeonQLstmWorkload
 
class  NeonQuantizedLstmWorkload
 
class  NeonQuantizeWorkload
 
struct  NeonRankWorkload
 
class  NeonReduceWorkload
 
class  NeonReshapeWorkload
 
class  NeonResizeWorkload
 
class  NeonRsqrtWorkload
 
class  NeonSinWorkload
 
class  NeonSliceWorkload
 
class  NeonSoftmaxWorkload
 
class  NeonSpaceToBatchNdWorkload
 
class  NeonSpaceToDepthWorkload
 
class  NeonSplitterWorkload
 
class  NeonStackWorkload
 
class  NeonStridedSliceWorkload
 
class  NeonSubTensorHandle
 
class  NeonSubtractionWorkload
 
class  NeonTensorHandle
 
class  NeonTensorHandleFactory
 
class  NeonTimer
 
class  NeonTransposeConvolution2dWorkload
 
class  NeonTransposeWorkload
 
class  NeonWorkloadFactory
 
class  NetworkImpl
 Private implementation of INetwork. More...
 
class  NodeContent
 
struct  NormalizationDescriptor
 A NormalizationDescriptor for the NormalizationLayer. More...
 
class  NormalizationLayer
 This layer represents a normalization operation. More...
 
struct  NormalizationQueueDescriptor
 
struct  NoThrowStrategy
 
struct  NullDescriptor
 Null Descriptor used as a return value from the IConnectableLayer GetParameters method by layers which do not have a descriptor. More...
 
class  NullPointerException
 
class  NullWorkload
 
class  OpenClTimer
 OpenClTimer instrument that times all OpenCl kernels executed between calls to Start() and Stop(). More...
 
class  Optimization
 
struct  OptimizationResult
 
class  OptimizationViews
 
class  OptimizedNetworkImpl
 
class  OptimizeForConnection
 
class  OptimizeForConnectionImpl
 Wrapper Optimization class that calls Wrapped::Run for every connection BaseType -> ChildType. More...
 
class  OptimizeForExclusiveConnection
 
class  OptimizeForExclusiveConnectionImpl
 Wrapper Optimization class that calls Wrapped::Run for every connection BaseType -> ChildType. More...
 
class  OptimizeForType
 
class  OptimizeForTypeImpl
 Wrapper Optimization base class that calls Wrapped::Run() for every layer of type BaseType. More...
 
class  OptimizeForTypeImpl< Layer, Wrapped >
 Specialization that calls Wrapped::Run() for any layer type. More...
 
class  Optimizer
 
struct  OptimizerOptions
 ArmNN performs an optimization on each model/network before it gets loaded for execution. More...
 
class  Optional
 
class  OptionalBase
 OptionalBase is the common functionality between reference and non-reference optional types. More...
 
class  OptionalReferenceSwitch
 The default implementation is the non-reference case. More...
 
class  OptionalReferenceSwitch< true, T >
 This is the special case for reference types. More...
 
struct  OriginsDescriptor
 An OriginsDescriptor for the ConcatLayer. More...
 
class  OutputHandler
 
class  OutputLayer
 A layer user-provided data can be bound to (e.g. inputs, outputs). More...
 
class  OutputSlot
 
struct  PadDescriptor
 A PadDescriptor for the PadLayer. More...
 
class  PadLayer
 This layer represents a pad operation. More...
 
struct  PadQueueDescriptor
 
class  ParseException
 
class  PassthroughTensorHandle
 
class  PerAxisIterator
 PerAxisIterator for per-axis quantization. More...
 
class  PermutationVector
 
struct  PermuteDescriptor
 A PermuteDescriptor for the PermuteLayer. More...
 
class  PermuteLayer
 This layer represents a permutation operation. More...
 
struct  PermuteQueueDescriptor
 
class  PolymorphicDowncastException
 
struct  Pooling2dDescriptor
 A Pooling2dDescriptor for the Pooling2dLayer. More...
 
class  Pooling2dLayer
 This layer represents a pooling 2d operation. More...
 
struct  Pooling2dQueueDescriptor
 
struct  Pooling3dDescriptor
 A Pooling3dDescriptor for the Pooling3dLayer. More...
 
class  Pooling3dLayer
 This layer represents a pooling 3d operation. More...
 
struct  Pooling3dQueueDescriptor
 
struct  PreCompiledDescriptor
 A PreCompiledDescriptor for the PreCompiledLayer. More...
 
class  PreCompiledLayer
 
struct  PreCompiledQueueDescriptor
 
class  PredicateResult
 
class  PreluLayer
 
struct  PreluQueueDescriptor
 
class  ProfilerImpl
 
class  ProfilerManager
 
class  ProfilingDetails
 ProfilingDetails class records any details associated with the operator and passes on for outputting to the user. More...
 
struct  ProgramBuilder
 
class  QASymm8Decoder
 
class  QASymm8Encoder
 
class  QASymmS8Decoder
 
class  QASymmS8Encoder
 
struct  QLstmBasicParameters
 
struct  QLstmDescriptor
 A QLstmDescriptor for the QLstmLayer. More...
 
class  QLstmLayer
 This layer represents a QLstm operation. More...
 
struct  QLstmOptCifgParameters
 
struct  QLstmOptLayerNormParameters
 
struct  QLstmOptPeepholeParameters
 
struct  QLstmOptProjectionParameters
 
struct  QLstmQueueDescriptor
 
class  QSymm16Decoder
 
class  QSymm16Encoder
 
class  QSymm8PerAxisDecoder
 
class  QSymm8PerAxisEncoder
 
class  QSymmS8Decoder
 
class  QSymmS8Encoder
 
struct  QuantizationParametersAreEqual
 
struct  QuantizedLstmInputParams
 
struct  QuantizedLstmInputParamsInfo
 
class  QuantizedLstmLayer
 This layer represents a QuantizedLstm operation. More...
 
struct  QuantizedLstmParameters
 
struct  QuantizedLstmQueueDescriptor
 
struct  QuantizedMultiplierSmallerThanOne
 Performs multiplication of an integer with a multiplier which is less than one, using quantized integer arithmetic which is consistent with AndroidNN's CPU executor. More...
 
class  QuantizeLayer
 
struct  QuantizeQueueDescriptor
 
struct  QueueDescriptor
 
struct  QueueDescriptorWithParameters
 
class  RangeTracker
 
class  RankLayer
 
struct  RankQueueDescriptor
 
struct  ReduceDescriptor
 A ReduceDescriptor for the REDUCE operators. More...
 
class  ReduceLayer
 This layer represents a reduction operation. More...
 
struct  ReduceQueueDescriptor
 
class  RefActivationWorkload
 
class  RefArgMinMaxWorkload
 
class  RefBackend
 
class  RefBaseWorkload
 
class  RefBatchNormalizationWorkload
 
class  RefBatchToSpaceNdWorkload
 
class  RefCastWorkload
 
class  RefChannelShuffleWorkload
 
class  RefComparisonWorkload
 
class  RefConcatWorkload
 
class  RefConstantWorkload
 
class  RefConvertBf16ToFp32Workload
 
class  RefConvertFp16ToFp32Workload
 
class  RefConvertFp32ToBf16Workload
 
class  RefConvertFp32ToFp16Workload
 
class  RefConvolution2dWorkload
 
class  RefConvolution3dWorkload
 
class  RefDebugWorkload
 
class  RefDepthToSpaceWorkload
 
class  RefDepthwiseConvolution2dWorkload
 
class  RefDequantizeWorkload
 
class  RefDetectionPostProcessWorkload
 
class  RefElementwiseUnaryWorkload
 
class  RefElementwiseWorkload
 
class  RefFakeQuantizationFloat32Workload
 
class  RefFillWorkload
 
class  RefFloorWorkload
 
class  RefFullyConnectedWorkload
 
class  RefGatherWorkload
 
class  RefInstanceNormalizationWorkload
 
class  RefL2NormalizationWorkload
 
class  RefLayerSupport
 
class  RefLogicalBinaryWorkload
 
class  RefLogicalUnaryWorkload
 
class  RefLogSoftmaxWorkload
 
class  RefLstmWorkload
 
class  RefMeanWorkload
 
class  RefMemoryManager
 
class  RefNormalizationWorkload
 
class  RefPadWorkload
 
class  RefPermuteWorkload
 
class  RefPooling2dWorkload
 
class  RefPooling3dWorkload
 
class  RefPreluWorkload
 
class  RefQLstmWorkload
 
class  RefQuantizeWorkload
 
struct  RefRankWorkload
 
class  RefReduceWorkload
 
class  RefReshapeWorkload
 
class  RefResizeWorkload
 
struct  RefShapeWorkload
 
class  RefSliceWorkload
 
class  RefSoftmaxWorkload
 
class  RefSpaceToBatchNdWorkload
 
class  RefSpaceToDepthWorkload
 
class  RefSplitterWorkload
 
class  RefStackWorkload
 
class  RefStridedSliceWorkload
 
class  RefTensorHandle
 
class  RefTensorHandleFactory
 
class  RefTransposeConvolution2dWorkload
 
class  RefTransposeWorkload
 
class  RefUnidirectionalSequenceLstmWorkload
 
class  RefWorkloadFactory
 
struct  ReshapeDescriptor
 A ReshapeDescriptor for the ReshapeLayer. More...
 
class  ReshapeLayer
 This layer represents a reshape operation. More...
 
struct  ReshapeQueueDescriptor
 
struct  ResizeDescriptor
 A ResizeBilinearDescriptor for the ResizeBilinearLayer. More...
 
class  ResizeLayer
 This layer represents a resize operation. More...
 
struct  ResizeQueueDescriptor
 
struct  ResolveTypeImpl
 
struct  ResolveTypeImpl< DataType::BFloat16 >
 
struct  ResolveTypeImpl< DataType::Boolean >
 
struct  ResolveTypeImpl< DataType::Float16 >
 
struct  ResolveTypeImpl< DataType::Float32 >
 
struct  ResolveTypeImpl< DataType::QAsymmS8 >
 
struct  ResolveTypeImpl< DataType::QAsymmU8 >
 
struct  ResolveTypeImpl< DataType::QSymmS16 >
 
struct  ResolveTypeImpl< DataType::QSymmS8 >
 
struct  ResolveTypeImpl< DataType::Signed32 >
 
struct  ResolveTypeImpl< DataType::Signed64 >
 
struct  rsqrt
 
class  RsqrtLayer
 
struct  RsqrtQueueDescriptor
 
struct  Rule
 
class  RuntimeException
 
struct  RuntimeImpl
 
class  ScaledInt32Decoder
 
class  ScaledInt32PerAxisDecoder
 
class  ScopedProfilingEvent
 
struct  ScopedRecord
 
class  ScopedTensorHandle
 
class  ShapeLayer
 
struct  ShapeQueueDescriptor
 
struct  ShapesAreBroadcastCompatible
 
struct  ShapesAreSameRank
 
struct  ShapesAreSameTotalSize
 
class  SimpleLogger
 
struct  sin
 
class  SingleAxisPriorityList
 SingleAxisPriorityList sorts the MemBlocks according to some priority, then trys to place them into as few bins as possible. More...
 
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  StrategyBase
 Strategy base class with empty implementations. More...
 
struct  StrategyFactory
 
class  StrategyValidator
 
struct  StridedSliceDescriptor
 A StridedSliceDescriptor for the StridedSliceLayer. More...
 
class  StridedSliceLayer
 This layer represents a strided slice operation. More...
 
struct  StridedSliceQueueDescriptor
 
struct  StringifyLayerParameters
 StringifyLayerParameters allows serializing layer parameters to string. More...
 
struct  StringifyLayerParameters< ActivationDescriptor >
 
struct  StringifyLayerParameters< BatchNormalizationDescriptor >
 
struct  StringifyLayerParameters< BatchToSpaceNdDescriptor >
 
struct  StringifyLayerParameters< ChannelShuffleDescriptor >
 
struct  StringifyLayerParameters< ComparisonDescriptor >
 
struct  StringifyLayerParameters< Convolution2dDescriptor >
 
struct  StringifyLayerParameters< Convolution3dDescriptor >
 
struct  StringifyLayerParameters< DepthwiseConvolution2dDescriptor >
 
struct  StringifyLayerParameters< DetectionPostProcessDescriptor >
 
struct  StringifyLayerParameters< ElementwiseUnaryDescriptor >
 
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< Pooling3dDescriptor >
 
struct  StringifyLayerParameters< PreCompiledDescriptor >
 
struct  StringifyLayerParameters< ReduceDescriptor >
 
struct  StringifyLayerParameters< ReshapeDescriptor >
 
struct  StringifyLayerParameters< ResizeDescriptor >
 
struct  StringifyLayerParameters< SoftmaxDescriptor >
 
struct  StringifyLayerParameters< SpaceToBatchNdDescriptor >
 
struct  StringifyLayerParameters< SpaceToDepthDescriptor >
 
struct  StringifyLayerParameters< StackDescriptor >
 
struct  StringifyLayerParameters< StridedSliceDescriptor >
 
struct  StringifyLayerParameters< TransposeConvolution2dDescriptor >
 
struct  StringifyLayerParameters< TransposeDescriptor >
 
struct  StringifyLayerParameters< ViewsDescriptor >
 
struct  StringMapping
 StringMapping is helper class to be able to use strings as template parameters, so this allows simplifying code which only differs in a string, such as a debug string literal. More...
 
class  SubgraphView
 The SubgraphView class represents a subgraph of a Graph. More...
 
class  SubgraphViewSelector
 Algorithm that splits a Graph into Subgraphs based on a filtering of layers (e.g. More...
 
class  SubtractionLayer
 This layer represents a subtraction operation. More...
 
struct  SubtractionQueueDescriptor
 
class  SwitchLayer
 This layer calculates both true and false outputs for input. More...
 
struct  SwitchQueueDescriptor
 
class  SyncMemGenericWorkload
 
class  Tensor
 A tensor defined by a TensorInfo (shape and data type) and a mutable backing store. More...
 
class  TensorBufferArrayView
 
class  TensorHandle
 
class  TensorHandleFactoryRegistry
 
class  TensorInfo
 
struct  TensorMemory
 
struct  TensorNumDimensionsAreCorrect
 
class  TensorShape
 
class  TestBatchNormalizationLayerVisitor
 
class  TestConstantLayerVisitor
 
class  TestConvolution2dLayerVisitor
 
class  TestDepthwiseConvolution2dLayerVisitor
 
class  TestFullyConnectedLayerVistor
 
class  TestInputLayerVisitor
 
class  TestLayerVisitor
 
class  TestLstmLayerVisitor
 
class  TestOutputLayerVisitor
 
class  TestQLstmLayerVisitor
 
class  TestQuantizedLstmLayerVisitor
 
class  TestStrategy
 
struct  ThrowingStrategy
 
class  TimeoutException
 
class  TransformIterator
 
struct  TransposeConvolution2dDescriptor
 A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer. More...
 
class  TransposeConvolution2dLayer
 This layer represents a 2D transpose convolution operation. More...
 
struct  TransposeConvolution2dQueueDescriptor
 
struct  TransposeDescriptor
 A TransposeDescriptor for the TransposeLayer. More...
 
class  TransposeLayer
 This layer represents a transpose operation. More...
 
struct  TransposeQueueDescriptor
 
struct  TypeAnyOf
 
class  TypedIterator
 
class  TypedWorkload
 
struct  TypeIs
 
struct  TypeNotPerAxisQuantized
 
struct  TypesAreEqual
 
class  UnidirectionalSequenceLstmLayer
 This layer represents a LSTM operation. More...
 
struct  UnidirectionalSequenceLstmQueueDescriptor
 
class  UnimplementedException
 
class  UnmapLayer
 This layer represents a memory copy operation. More...
 
struct  UnmapQueueDescriptor
 
class  UnmapWorkload
 
struct  ViewsDescriptor
 A ViewsDescriptor for the SplitterLayer. More...
 
struct  VisitorNoThrowPolicy
 
struct  VisitorThrowingPolicy
 
class  WallClockTimer
 
class  WorkloadDataCollector
 
class  WorkloadFactoryBase
 
struct  WorkloadInfo
 Contains information about TensorInfos of a layer. More...
 

Typedefs

using BackendIdVector = std::vector< BackendId >
 
using BackendIdSet = std::unordered_set< BackendId >
 
using NetworkOptions = std::vector< BackendOptions >
 
using ModelOptions = std::vector< BackendOptions >
 
using BackendCapabilities = BackendOptions
 
using IBackendInternalUniquePtr = std::unique_ptr< IBackendInternal >
 
using MemoryOptimizerStrategiesMapRef = std::unordered_map< BackendId, std::shared_ptr< IMemoryOptimizerStrategy > >
 
using DynamicBackendPtr = std::unique_ptr< DynamicBackend >
 
using IBackendContextUniquePtr = std::unique_ptr< IBackendContext >
 
using ILayerSupportSharedPtr = std::shared_ptr< ILayerSupport >
 
using IMemoryManagerUniquePtr = std::unique_ptr< IMemoryManager >
 
using instead = ConstTensorHandle
 
template<typename QueueDescriptor >
using FloatWorkload = TypedWorkload< QueueDescriptor, armnn::DataType::Float16, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Float32Workload = TypedWorkload< QueueDescriptor, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Uint8Workload = TypedWorkload< QueueDescriptor, armnn::DataType::QAsymmU8 >
 
template<typename QueueDescriptor >
using Int32Workload = TypedWorkload< QueueDescriptor, armnn::DataType::Signed32 >
 
template<typename QueueDescriptor >
using BooleanWorkload = TypedWorkload< QueueDescriptor, armnn::DataType::Boolean >
 
template<typename QueueDescriptor >
using BaseFloat32ComparisonWorkload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean >
 
template<typename QueueDescriptor >
using BaseUint8ComparisonWorkload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::QAsymmU8, armnn::DataType::Boolean >
 
template<typename QueueDescriptor >
using BFloat16ToFloat32Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::BFloat16, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Float32ToBFloat16Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float32, armnn::DataType::BFloat16 >
 
template<typename QueueDescriptor >
using Float16ToFloat32Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float16, armnn::DataType::Float32 >
 
template<typename QueueDescriptor >
using Float32ToFloat16Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::Float32, armnn::DataType::Float16 >
 
template<typename QueueDescriptor >
using Uint8ToFloat32Workload = MultiTypedWorkload< QueueDescriptor, armnn::DataType::QAsymmU8, armnn::DataType::Float32 >
 
using InputQueueDescriptor = MemCopyQueueDescriptor
 
using OutputQueueDescriptor = MemCopyQueueDescriptor
 
using MergerQueueDescriptor = ConcatQueueDescriptor
 
using LogSoftmaxDescriptor = SoftmaxDescriptor
 A LogSoftmaxDescriptor for the LogSoftmaxLayer. More...
 
using DepthToSpaceDescriptor = SpaceToDepthDescriptor
 A DepthToSpaceDescriptor for the DepthToSpaceLayer. More...
 
using UnidirectionalSequenceLstmDescriptor = LstmDescriptor
 
using ConcatDescriptor = OriginsDescriptor
 
using MergerDescriptor = OriginsDescriptor
 MergerDescriptor is deprecated, use ConcatDescriptor instead. More...
 
using SplitterDescriptor = ViewsDescriptor
 
using INetworkPtr = std::unique_ptr< INetwork, void(*)(INetwork *network)>
 
using IOptimizedNetworkPtr = std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)>
 
using CompiledBlobDeleter = std::function< void(const void *)>
 
using CompiledBlobPtr = std::unique_ptr< void, CompiledBlobDeleter >
 
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 ImportedInputId = unsigned int
 
using ImportedOutputId = unsigned int
 
using LayerGuid = profiling::ProfilingGuid
 Define LayerGuid type. More...
 
using DebugCallbackFunction = std::function< void(LayerGuid guid, unsigned int slotIndex, ITensorHandle *tensorHandle)>
 Define the type of callback for the Debug layer to call. More...
 
using HighResolutionClock = std::chrono::high_resolution_clock::time_point
 Define a timer and associated inference ID for recording execution times. More...
 
using InferenceTimingPair = std::pair< HighResolutionClock, HighResolutionClock >
 
using TensorInfos = std::vector< TensorInfo >
 
using WorkloadQueue = std::vector< std::unique_ptr< IWorkload > >
 
using Coordinates = std::array< unsigned int, MaxNumOfTensorDimensions >
 
using Dimensions = std::array< unsigned int, MaxNumOfTensorDimensions >
 
using LayerPriority = unsigned int
 
using AdditionalInfoObjectPtr = std::shared_ptr< void >
 
using PreCompiledObjectDeleter = std::function< void(const void *)>
 
using PreCompiledObjectPtr = std::unique_ptr< void, PreCompiledObjectDeleter >
 
template<LayerType Type>
using LayerTypeOf = typename LayerTypeOfImpl< Type >::Type
 
using NetworkImplPtr = std::unique_ptr< NetworkImpl, void(*)(NetworkImpl *network)>
 
using BackendsMap = std::map< BackendId, std::unique_ptr< class IBackendInternal > >
 
template<DataType DT>
using ResolveType = typename ResolveTypeImpl< DT >::Type
 
using LoadedNetworks = std::unordered_map< NetworkId, std::unique_ptr< LoadedNetwork > >
 
using IReportStructure = profiling::IReportStructure
 
using ParameterStringifyFunction = std::function< void(const std::string &name, const std::string &value)>
 
using FactoryId = ITensorHandleFactory::FactoryId
 
using Half = half_float::half
 
using CopyAndImportFactoryPairs = std::map< ITensorHandleFactory::FactoryId, ITensorHandleFactory::FactoryId >
 
using ACLMemManagerOnDemand = std::shared_ptr< arm_compute::MemoryManagerOnDemand >
 
using RefDebugBFloat16Workload = RefDebugWorkload< DataType::BFloat16 >
 
using RefDebugFloat16Workload = RefDebugWorkload< DataType::Float16 >
 
using RefDebugFloat32Workload = RefDebugWorkload< DataType::Float32 >
 
using RefDebugQAsymmU8Workload = RefDebugWorkload< DataType::QAsymmU8 >
 
using RefDebugQAsymmS8Workload = RefDebugWorkload< DataType::QAsymmS8 >
 
using RefDebugQSymmS16Workload = RefDebugWorkload< DataType::QSymmS16 >
 
using RefDebugQSymmS8Workload = RefDebugWorkload< DataType::QSymmS8 >
 
using RefDebugSigned32Workload = RefDebugWorkload< DataType::Signed32 >
 
template<typename DataType = float>
using RefAdditionWorkload = RefElementwiseWorkload< std::plus< DataType >, AdditionQueueDescriptor, StringMapping::RefAdditionWorkload_Execute >
 
template<typename DataType = float>
using RefSubtractionWorkload = RefElementwiseWorkload< std::minus< DataType >, SubtractionQueueDescriptor, StringMapping::RefSubtractionWorkload_Execute >
 
template<typename DataType = float>
using RefMultiplicationWorkload = RefElementwiseWorkload< std::multiplies< DataType >, MultiplicationQueueDescriptor, StringMapping::RefMultiplicationWorkload_Execute >
 
template<typename DataType = float>
using RefDivisionWorkload = RefElementwiseWorkload< std::divides< DataType >, DivisionQueueDescriptor, StringMapping::RefDivisionWorkload_Execute >
 
template<typename DataType = float>
using RefMaximumWorkload = RefElementwiseWorkload< armnn::maximum< DataType >, MaximumQueueDescriptor, StringMapping::RefMaximumWorkload_Execute >
 
template<typename DataType = float>
using RefMinimumWorkload = RefElementwiseWorkload< armnn::minimum< DataType >, MinimumQueueDescriptor, StringMapping::RefMinimumWorkload_Execute >
 
using RefPermuteBFloat16Workload = RefPermuteWorkload< DataType::BFloat16 >
 
using RefPermuteFloat16Workload = RefPermuteWorkload< DataType::Float16 >
 
using RefPermuteFloat32Workload = RefPermuteWorkload< DataType::Float32 >
 
using RefPermuteQAsymmS8Workload = RefPermuteWorkload< DataType::QAsymmS8 >
 
using RefPermuteQAsymm8Workload = RefPermuteWorkload< DataType::QAsymmU8 >
 
using RefPermuteQSymm16Workload = RefPermuteWorkload< DataType::QSymmS16 >
 
using RefTransposeBFloat16Workload = RefTransposeWorkload< DataType::BFloat16 >
 
using RefTransposeFloat16Workload = RefTransposeWorkload< DataType::Float16 >
 
using RefTransposeFloat32Workload = RefTransposeWorkload< DataType::Float32 >
 
using RefTransposeQAsymmS8Workload = RefTransposeWorkload< DataType::QAsymmS8 >
 
using RefTransposeQAsymm8Workload = RefTransposeWorkload< DataType::QAsymmU8 >
 
using RefTransposeQSymm16Workload = RefTransposeWorkload< DataType::QSymmS16 >
 

Enumerations

enum  Compute { Undefined = 0, CpuRef = 1, CpuAcc = 2, GpuAcc = 3 }
 The Compute enum is now deprecated and it is now being replaced by BackendId. More...
 
enum  CapabilityClass { PaddingRequired = 1, FallbackImportDisabled = 2, CapabilityClassMax = 254 }
 Capability class to calculate in the GetCapabilities function so that only the capability in the scope can be choose to calculate. More...
 
enum  EdgeStrategy { Undefined, DirectCompatibility, ExportToTarget, CopyToTarget }
 
enum  BoostLogSeverityMapping {
  trace, debug, info, warning,
  error, fatal
}
 
enum  Status { Success = 0, Failure = 1 }
 enumeration More...
 
enum  DataType {
  Float16 = 0, Float32 = 1, QAsymmU8 = 2, Signed32 = 3,
  Boolean = 4, QSymmS16 = 5, QSymmS8 = 6, QAsymmS8 = 7,
  BFloat16 = 8, Signed64 = 9
}
 
enum  DataLayout { NCHW = 1, NHWC = 2, NDHWC = 3, NCDHW = 4 }
 
enum  ProfilingDetailsMethod { Undefined = 0, DetailsWithEvents = 1, DetailsOnly = 2 }
 Define the behaviour of the internal profiler when outputting network details. More...
 
enum  QosExecPriority { Low = 0, Medium = 1, High = 2 }
 
enum  ActivationFunction {
  Sigmoid = 0, TanH = 1, Linear = 2, ReLu = 3,
  BoundedReLu = 4, SoftReLu = 5, LeakyReLu = 6, Abs = 7,
  Sqrt = 8, Square = 9, Elu = 10, HardSwish = 11
}
 
enum  ArgMinMaxFunction { Min = 0, Max = 1 }
 
enum  ComparisonOperation {
  Equal = 0, Greater = 1, GreaterOrEqual = 2, Less = 3,
  LessOrEqual = 4, NotEqual = 5
}
 
enum  LogicalBinaryOperation { LogicalAnd = 0, LogicalOr = 1 }
 
enum  UnaryOperation {
  Abs = 0, Exp = 1, Sqrt = 2, Rsqrt = 3,
  Neg = 4, LogicalNot = 5, Log = 6, Sin = 7
}
 
enum  PoolingAlgorithm { Max = 0, Average = 1, L2 = 2 }
 
enum  ReduceOperation {
  Sum = 0, Max = 1, Mean = 2, Min = 3,
  Prod = 4
}
 
enum  ResizeMethod { Bilinear = 0, NearestNeighbor = 1 }
 
enum  Dimensionality { NotSpecified = 0, Specified = 1, Scalar = 2 }
 
enum  PaddingMethod { IgnoreValue = 0, Exclude = 1 }
 The padding method modifies the output of pooling layers. More...
 
enum  PaddingMode { Constant = 0, Reflect = 1, Symmetric = 2 }
 The padding mode controls whether the padding should be filled with constant values (Constant), or reflect the input, either including the border values (Symmetric) or not (Reflect). More...
 
enum  NormalizationAlgorithmChannel { Across = 0, Within = 1 }
 
enum  NormalizationAlgorithmMethod { LocalBrightness = 0, LocalContrast = 1 }
 
enum  OutputShapeRounding { Floor = 0, Ceiling = 1 }
 
enum  ShapeInferenceMethod { ValidateOnly = 0, InferAndValidate = 1 }
 The ShapeInferenceMethod modify how the output shapes are treated. More...
 
enum  MemorySource : uint32_t {
  Undefined = 0, Malloc = 1, DmaBuf = 2, DmaBufProtected = 4,
  Gralloc = 5
}
 Define the Memory Source to reduce copies. More...
 
enum  MemBlockStrategyType { SingleAxisPacking = 0, MultiAxisPacking = 1 }
 
enum  BackendCapability : uint32_t { NonConstWeights, AsyncExecution }
 BackendCapability class. More...
 
enum  LayerType {
  X, Activation, Addition, ArgMinMax,
  BatchNormalization, BatchToSpaceNd, Comparison, Concat,
  Constant, ConvertBf16ToFp32, ConvertFp16ToFp32, ConvertFp32ToBf16,
  ConvertFp32ToFp16, Convolution2d, Debug, DepthToSpace,
  DepthwiseConvolution2d, Dequantize, DetectionPostProcess, Division,
  ElementwiseUnary, FakeQuantization, Fill, Floor,
  FullyConnected, Gather, Input, InstanceNormalization,
  L2Normalization, LogicalBinary, LogSoftmax, Lstm,
  QLstm, Map, Maximum, Mean,
  MemCopy, MemImport, Merge, Minimum,
  Multiplication, Normalization, Output, Pad,
  Permute, Pooling2d, PreCompiled, Prelu,
  Quantize, QuantizedLstm, Reshape, Rank,
  Resize, Reduce, Slice, Softmax,
  SpaceToBatchNd, SpaceToDepth, Splitter, Stack,
  StandIn, StridedSlice, Subtraction, Switch,
  Transpose, TransposeConvolution2d, Unmap, Cast,
  Shape, UnidirectionalSequenceLstm, ChannelShuffle, Convolution3d,
  Pooling3d, FirstLayer = Activation, LastLayer = UnidirectionalSequenceLstm
}
 When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below. More...
 
enum  LogSeverity {
  Trace, Debug, Info, Warning,
  Error, Fatal
}
 
enum  GraphEvent { LayerAdded, LayerErased }
 
enum  JsonObjectType { Measurement, Event, ExecObjectDesc }
 
enum  TuningLevel { None, Rapid, Normal, Exhaustive }
 

Functions

LayerSupportHandle GetILayerSupportByBackendId (const armnn::BackendId &backend)
 Convenience function to retrieve the ILayerSupportHandle for a backend. More...
 
bool HasCapability (const std::string &name, const BackendCapabilities &capabilities)
 Convenience function to check if a capability exists in a BackendCapabilites struct. More...
 
bool HasCapability (const std::string &name, const armnn::BackendId &backend)
 Convenience function to check if a capability exists in a backend. More...
 
bool HasCapability (const BackendOptions::BackendOption &capability, const BackendCapabilities &capabilities)
 Convenience function to check if a given capability matches a capability in a BackendCapabilities struct. More...
 
bool HasCapability (const BackendOptions::BackendOption &backendOption, const armnn::BackendId &backend)
 Convenience function to check if a given capability matches a capability in a backend. More...
 
Optional< const BackendOptions::BackendOptionGetCapability (const std::string &backendCapabilityName, const BackendCapabilities &capabilities)
 Returns a BackendCapability if the backend lists the capability The BackendCapability must then be inspected to check whether or not that BackendCapability is supported Otherwise returns an EmptyOptional if the BackendCapability is unlisted. More...
 
Optional< const BackendOptions::BackendOptionGetCapability (const std::string &backendCapabilityName, const armnn::BackendId &backend)
 Returns a BackendCapability if the backend lists the capability The BackendCapability must then be inspected to check whether or not that BackendCapability is supported Otherwise returns an EmptyOptional if the BackendCapability is unlisted. More...
 
bool IsCapabilitySupported (const armnn::BackendId &backend, armnn::BackendCapability capability)
 Convenience function to check a capability on a backend. More...
 
unsigned int GetNumberOfCacheFiles (const armnn::BackendId &backend)
 Returns the number of cached files if backend supports caching. More...
 
constexpr char const * GetComputeDeviceAsCString (Compute compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const std::vector< Compute > &compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const std::set< Compute > &compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const Compute &compute)
 Deprecated function that will be removed together with the Compute enum. More...
 
std::ostream & operator<< (std::ostream &os, const BackendId &id)
 
template<template< typename... > class TContainer, typename... TContainerTemplateArgs>
std::ostream & operator<< (std::ostream &os, const TContainer< BackendId, TContainerTemplateArgs... > &ids)
 
template<typename F >
void ParseOptions (const std::vector< BackendOptions > &options, BackendId backend, F f)
 
bool ParseBooleanBackendOption (const armnn::BackendOptions::Var &value, bool defaultValue)
 
std::string ParseStringBackendOption (const armnn::BackendOptions::Var &value, std::string defaultValue)
 
int ParseIntBackendOption (const armnn::BackendOptions::Var &value, int defaultValue)
 
BackendRegistryBackendRegistryInstance ()
 
std::ostream & operator<< (std::ostream &os, const BackendVersion &backendVersion)
 
TensorShape GetUnpaddedTensorStrides (const TensorInfo &tensorInfo)
 
DataType GetBiasDataType (DataType inputDataType)
 
ARMNN_NO_DEPRECATE_WARN_BEGIN struct ARMNN_DEPRECATED_MSG_REMOVAL_DATE ("ResizeBilinearQueueDescriptor is deprecated use ResizeQueueDescriptor instead", "22.08") ResizeBilinearQueueDescriptor
 
template<typename TensorShapeIt >
OriginsDescriptor CreateDescriptorForConcatenation (TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
 Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing concatenation of a number of input tensors. More...
 
template<typename ExceptionType >
void ConditionalThrow (bool condition, const std::string &message)
 
template<typename ExceptionType >
void ConditionalThrow (bool condition)
 
template<typename ExceptionType , typename ComparedType >
void ConditionalThrowIfNotEqual (const std::string &message, const ComparedType &leftHandSide, const ComparedType &rightHandSide)
 ComparedType must support: operator==(const ComparedType&) operator<<(ostream&, const ComparedType&) More...
 
class ARMNN_DEPRECATED_MSG_REMOVAL_DATE ("Use ABI stable IStrategy instead.", "22.05") ILayerVisitor
 
IOptimizedNetworkPtr Optimize (const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
 Create an optimized version of the network. More...
 
bool IsActivationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsAdditionSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsBatchNormalizationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsBatchToSpaceNdSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConcatSupported (const BackendId &backend, const std::vector< const TensorInfo *> inputs, const TensorInfo &output, const OriginsDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConstantSupported (const BackendId &backend, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConvertFp16ToFp32Supported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConvertFp32ToFp16Supported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsConvolution2dSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDebugSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDepthwiseConvolutionSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDequantizeSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsDivisionSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsEqualSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsFakeQuantizationSupported (const BackendId &backend, const TensorInfo &input, const FakeQuantizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsFloorSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsFullyConnectedSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsGreaterSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsInputSupported (const BackendId &backend, const TensorInfo &input, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsL2NormalizationSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsLstmSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMaximumSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnSupported=nullptr, size_t reasonIfUnSupportedMaxLength=0)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMeanSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const MeanDescriptor &descriptor, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMemCopySupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool IsMergeSupported (const BackendId &backend, const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, char *reasonIfUnsupported=nullptr, size_t reasonIfUnsupportedMaxLength=1024)
 Deprecated in favor of IBackend and ILayerSupport interfaces. More...
 
bool 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 IsReduceSupported (const BackendId &backend, const TensorInfo &input, const TensorInfo &output, const ReduceDescriptor &descriptor, 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 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 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)
 
LogSeverity StringToLogLevel (std::string level)
 
void SetLogFilter (LogSeverity level)
 
void SetAllLoggingSinks (bool standardOut, bool debugOut, bool coloured)
 
constexpr LogSeverity ConvertLogSeverity (BoostLogSeverityMapping severity)
 
template<typename Arg , typename std::enable_if< IsMemorySource< Arg >::value >::type * = nullptr>
MemorySourceFlags Combine (Arg sourceA, Arg sourceB)
 
template<typename Arg , typename ... Args, typename std::enable_if< IsMemorySource< Arg >::value >::type * = nullptr>
MemorySourceFlags Combine (Arg source, Args... rest)
 
bool CheckFlag (MemorySourceFlags flags, MemorySource source)
 
template<typename T , class... Args>
Optional< T > MakeOptional (Args &&... args)
 Utility template that constructs an object of type T in-place and wraps it inside an Optional<T> object. More...
 
const char * GetLayerTypeAsCString (LayerType type)
 
constexpr char const * GetStatusAsCString (Status status)
 
constexpr char const * GetActivationFunctionAsCString (ActivationFunction activation)
 
constexpr char const * GetArgMinMaxFunctionAsCString (ArgMinMaxFunction function)
 
constexpr char const * GetComparisonOperationAsCString (ComparisonOperation operation)
 
constexpr char const * GetUnaryOperationAsCString (UnaryOperation operation)
 
constexpr char const * GetLogicalBinaryOperationAsCString (LogicalBinaryOperation operation)
 
constexpr char const * GetPoolingAlgorithmAsCString (PoolingAlgorithm pooling)
 
constexpr char const * GetOutputShapeRoundingAsCString (OutputShapeRounding rounding)
 
constexpr char const * GetPaddingMethodAsCString (PaddingMethod method)
 
constexpr char const * GetPaddingModeAsCString (PaddingMode mode)
 
constexpr char const * GetReduceOperationAsCString (ReduceOperation reduce_operation)
 
constexpr unsigned int GetDataTypeSize (DataType dataType)
 
template<unsigned N>
constexpr bool StrEqual (const char *strA, const char(&strB)[N])
 
constexpr armnn::Compute ParseComputeDevice (const char *str)
 Deprecated function that will be removed together with the Compute enum. More...
 
constexpr const char * GetDataTypeName (DataType dataType)
 
constexpr const char * GetDataLayoutName (DataLayout dataLayout)
 
constexpr const char * GetNormalizationAlgorithmChannelAsCString (NormalizationAlgorithmChannel channel)
 
constexpr const char * GetNormalizationAlgorithmMethodAsCString (NormalizationAlgorithmMethod method)
 
constexpr const char * GetResizeMethodAsCString (ResizeMethod method)
 
constexpr const char * GetMemBlockStrategyTypeName (MemBlockStrategyType memBlockStrategyType)
 
template<typename T >
constexpr bool IsQuantizedType ()
 
constexpr bool IsQuantized8BitType (DataType dataType)
 
constexpr bool IsQuantizedType (DataType dataType)
 
std::ostream & operator<< (std::ostream &os, Status stat)
 
std::ostream & operator<< (std::ostream &os, const armnn::TensorShape &shape)
 
template<typename QuantizedType >
QuantizedType Quantize (float value, float scale, int32_t offset)
 Quantize a floating point data type into an 8-bit data type. More...
 
template<typename QuantizedType >
float Dequantize (QuantizedType value, float scale, int32_t offset)
 Dequantize an 8-bit data type into a floating point data type. More...
 
void VerifyTensorInfoDataType (const armnn::TensorInfo &info, armnn::DataType dataType)
 
template<typename ... Ts>
void IgnoreUnused (Ts &&...)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_signed< Source >::value &&std::is_integral< Source >::value &&std::is_signed< Dest >::value &&std::is_integral< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_floating_point< Source >::value &&std::is_floating_point< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_floating_point< Source >::value &&std::is_signed< Dest >::value &&std::is_integral< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_signed< Source >::value &&std::is_integral< Source >::value &&std::is_floating_point< Dest >::value, Dest > numeric_cast (Source source)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_signed< Dest >::value &&std::is_integral< Dest >::value &&std::is_unsigned< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_floating_point< Dest >::value &&std::is_unsigned< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_unsigned< Dest >::value &&std::is_signed< Source >::value &&std::is_integral< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename Dest , typename Source >
std::enable_if_t< std::is_unsigned< Dest >::value &&std::is_floating_point< Source >::value, Dest > numeric_cast (Source sValue)
 
template<typename DestType , typename SourceType >
DestType PolymorphicDowncast (SourceType *value)
 Polymorphic downcast for build in pointers only. More...
 
template<typename DestType , typename SourceType >
auto PolymorphicPointerDowncast (const SourceType &value)
 Polymorphic downcast for shared pointers and build in pointers. More...
 
std::chrono::high_resolution_clock::time_point GetTimeNow ()
 
std::chrono::duration< double, std::milli > GetTimeDuration (std::chrono::high_resolution_clock::time_point start_time)
 
template<typename Function , typename Iterator >
constexpr TransformIterator< Function, Iterator > MakeTransformIterator (Iterator i, Function f)
 
void ConfigureLogging (bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
 Configures the logging behaviour of the ARMNN library. More...
 
bool NeonDetected ()
 
const std::string GetVersion ()
 
void swap (OriginsDescriptor &first, OriginsDescriptor &second)
 
void swap (ViewsDescriptor &first, ViewsDescriptor &second)
 
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 CastLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ChannelShuffleLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ComparisonLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConcatLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConstantLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertBf16ToFp32Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertFp16ToFp32Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertFp32ToBf16Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const ConvertFp32ToFp16Layer *)
 
template<>
constexpr LayerType LayerEnumOf (const Convolution2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const Convolution3dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DebugLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DepthToSpaceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DepthwiseConvolution2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DequantizeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DetectionPostProcessLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const DivisionLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ElementwiseUnaryLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FakeQuantizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FillLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FloorLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const FullyConnectedLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const GatherLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const InputLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const InstanceNormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const L2NormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LogicalBinaryLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LogSoftmaxLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const LstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MapLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MaximumLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MeanLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MemCopyLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MemImportLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MergeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MinimumLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const MultiplicationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const NormalizationLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const OutputLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PadLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PermuteLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const Pooling2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const Pooling3dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PreCompiledLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const PreluLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const QuantizeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const QLstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const QuantizedLstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const RankLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ReduceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ReshapeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ResizeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const ShapeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SliceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SoftmaxLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SpaceToBatchNdLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SpaceToDepthLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SplitterLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const StackLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const StandInLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const StridedSliceLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SubtractionLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const SwitchLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const TransposeLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const TransposeConvolution2dLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const UnidirectionalSequenceLstmLayer *)
 
template<>
constexpr LayerType LayerEnumOf (const UnmapLayer *)
 
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)
 
void CopyToOutputTensor (const Tensor &outputTensor, ITensorHandle *outputTensorHandle)
 
const armnn::ConstTensor GetInputTensor (const LayerBindingId layerId, const InputTensors &inputTensors)
 
const armnn::Tensor GetOutputTensor (const LayerBindingId layerId, const OutputTensors &outputTensors)
 
template<LogSeverity Level>
void SetLoggingSinks (bool standardOut, bool debugOut, bool coloured)
 
void ReportError (const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
 
void ReportWarning (const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
 
OptimizationResult ReturnWithError (OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
 
bool CheckScaleSetOnQuantizedType (Layer *layer, Optional< std::vector< std::string > &> errMessages)
 
template<typename LayerT >
LayerT * ConvertBf16ToFp32Weight (Layer *l)
 
OptimizationResult AttemptBackendAssignment (BackendSettings &backendSettings, Graph &graph, Layer *layer, BackendId backend, DataType dataTypeIn, DataType dataTypeOut, const std::vector< BackendId > &availablePreferredBackends, std::string &reasonIfUnsupported, Optional< std::vector< std::string > &> errMessages)
 
void AssignBackendsIConnectable (OptimizedNetworkImpl *optNetObjPtr, IConnectableLayer *it, Optional< std::vector< std::string > &> errMessages, OptimizationResult &result, BackendSettings &backendSettings, std::vector< BackendId > &availablePreferredBackends)
 
OptimizationResult AssignBackends (OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > &> errMessages)
 
OptimizationResult AssignBackends (OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, SubgraphView::IConnectableLayerIterator &firstLayer, SubgraphView::IConnectableLayerIterator &lastLayer, Optional< std::vector< std::string > &> errMessages)
 
OptimizationResult AssignBackends (OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
 
BackendsMap CreateSupportedBackends (TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
 
OptimizationResult ApplyBackendOptimizations (OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > &> errMessages)
 
bool RequiresCopy (ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
 
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput (BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry, bool importEnabled)
 
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput (BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
 
ITensorHandleFactory::FactoryId CalculateSlotOption (BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry &registry, bool importEnabled)
 
EdgeStrategy CalculateEdgeStrategy (BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry &registry, bool importEnabled)
 
OptimizationResult SelectTensorHandleStrategy (Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, bool importEnabled, Optional< std::vector< std::string > &> errMessages)
 
std::vector< ConvertBf16ToFp32Layer * > InsertConvertBf16ToFp32LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore (Graph &graph, Layer &layer, bool expectCorrectInputType)
 
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersAfter (Graph &graph, Layer &layer)
 
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter (Graph &graph, Layer &layer)
 
std::vector< DebugLayer * > InsertDebugLayerAfter (Graph &graph, Layer &layer)
 
template<typename T >
void Append (Optimizer::Optimizations &optimizations, T &&optimization)
 
template<typename Front , typename... Others>
void Append (Optimizer::Optimizations &optimizations, Front &&front, Others &&... others)
 
template<typename... Args>
Optimizer::Optimizations MakeOptimizations (Args &&... args)
 
Measurement FindMeasurement (const std::string &name, const Event *event)
 
std::vector< MeasurementFindKernelMeasurements (const Event *event)
 
const EventGetEventPtr (const Event *ptr)
 
const EventGetEventPtr (const std::unique_ptr< Event > &ptr)
 
int CalcLevel (const Event *eventPtr)
 
void ConfigureDetailsObject (JsonChildObject &detailsObject, std::string layerDetailsStr)
 
void ExtractJsonObjects (unsigned int inferenceIndex, const Event *parentEvent, JsonChildObject &parentObject, std::map< const Event *, std::vector< const Event *>> descendantsMap)
 
template<typename DescriptorType >
void ProfilingUpdateDescriptions (const std::string &name, const DescriptorType &desc, const WorkloadInfo &infos, const profiling::ProfilingGuid guid)
 
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)
 
 TEST_SUITE ("TestConstTensorLayerVisitor")
 
size_t GetProfilerEventSequenceSize (armnn::IProfiler *profiler)
 
void RuntimeLoadedNetworksReserve (armnn::RuntimeImpl *runtime)
 
 TEST_SUITE ("TestInputOutputLayerVisitor")
 
void CheckLayerBindingId (LayerBindingId visitorId, LayerBindingId id)
 
constexpr const char * MockBackendId ()
 
constexpr const char * MockTensorHandleFactoryId ()
 
GraphGetGraphForTesting (IOptimizedNetwork *optNet)
 
ModelOptionsGetModelOptionsForTesting (IOptimizedNetwork *optNet)
 
profiling::ProfilingServiceGetProfilingService (armnn::RuntimeImpl *runtime)
 
std::ostream & operator<< (std::ostream &os, const BFloat16 &b)
 
void ReportUntouchedLayers (OptimizationViews &optimizationViews, std::map< LayerGuid, Layer *> untouched)
 
template<typename LayerType >
LayerTypeFuseLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
 
template<typename LayerType >
LayerTypeFuseAdditionLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseSubtractionLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseDivisionLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseMultiplicationLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseBatchNormalizationLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseConvolution2dLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseDepthwiseConvolution2dLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
LayerTypeFuseFullyConnectedLayer (OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
 
template<typename LayerType >
std::vector< IConnectableLayer * > ChainReduceLayers (OptimizationViews &optimizationViews, LayerType *baseLayer, ReduceDescriptor &desc)
 
template<typename LayerType >
void ReplaceLayers (OptimizationViews &optimizationViews, LayerType *baseLayer, std::vector< IConnectableLayer *> &layers)
 
arm_compute::NormalizationLayerInfo CreateAclNormalizationLayerInfoForL2Normalization (const armnn::TensorInfo &tensorInfo, armnn::DataLayout dataLayout)
 
arm_compute::ActivationLayerInfo::ActivationFunction ConvertActivationFunctionToAclActivationFunction (ActivationFunction armnnFunction)
 
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo (const ActivationDescriptor &actDesc)
 
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo (const ActivationDescriptor *activationDescPtr)
 
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo (const QueueDescriptor &queueDescriptor)
 
arm_compute::ComparisonOperation ConvertComparisonOperationToAcl (const ComparisonDescriptor &descriptor)
 
arm_compute::PoolingType ConvertPoolingAlgorithmToAclPoolingType (PoolingAlgorithm poolingAlgorithm)
 
arm_compute::DimensionRoundingType ConvertOutputShapeRoundingToAclDimensionRoundingType (OutputShapeRounding rounding)
 
arm_compute::NormType ConvertNormalizationAlgorithmChannelToAclNormType (NormalizationAlgorithmChannel channelType)
 
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo (const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
 
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo (const FullyConnectedDescriptor &fullyConnectedDesc, arm_compute::ActivationLayerInfo activationLayerInfo)
 
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy (ResizeMethod resizeMethod)
 
template<typename T >
ComputeSoftmaxAclAxis (const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)
 
std::set< unsigned int > ComputeSplitAxis (const armnn::SplitterDescriptor &desc, const TensorShape &input)
 
int ComputeAclAxis (const int &armnnAxis, const armnn::TensorInfo &tensor)
 Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank, rank) More...
 
unsigned int ComputePositiveAxis (const int &axis, const armnn::TensorInfo &tensor)
 Function to convert axis to its positive equivalent value. More...
 
arm_compute::Conv3dInfo ComputeConv3DInfo (const armnn::Convolution3dDescriptor descriptor, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 Utility function used to setup an arm_compute::Conv3dInfo object from convolution3d descriptor. More...
 
arm_compute::Conv3dInfo ComputeConv3DInfo (const armnn::Convolution3dQueueDescriptor queueDescriptor, bool isFastMathEnabled)
 
arm_compute::PaddingMode ConvertPaddingModeToAcl (const PaddingMode &paddingMode)
 
arm_compute::ReductionOperation ConvertReductionOperationToAcl (const ReduceDescriptor &descriptor)
 
const TensorInfo ComputeReductionTensorShape (const armnn::TensorInfo &input, const std::vector< uint32_t > &vAxis, const bool keepDims)
 Function to compute the output tensor shape based on the axes and if keepDims is set. More...
 
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)
 
std::unique_ptr< IMemoryOptimizerStrategyGetMemoryOptimizerStrategy (const std::string &strategyName)
 
const std::vector< std::string > GetMemoryOptimizerStrategyNames ()
 
 TEST_SUITE ("MemoryManagerTests")
 
constexpr const char * MockImportBackendId ()
 
armnn::ConstTensor PermuteTensor (const ConstTensorHandle *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)
 
std::tuple< ConstTensor, unsigned int > Convert1HWOTensorToAcl (const ConstTensorHandle *weightTensor, const TensorInfo &inputInfo, const DataLayout dataLayout, void *permuteBuffer)
 Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a ConstCpuTensorHandle from [1,H,W,I*M] to [1,I*M,H,W] (if NCHW) or keeps it at [1,H,W,I*M] (if NHWC) as required by the compute library. More...
 
std::tuple< TensorInfo, unsigned int > Convert1HWOTensorInfoToAcl (const TensorInfo &weightInfo, const TensorInfo &inputInfo, const DataLayout dataLayout)
 Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a TensorInfo from [1,H,W,I*M] to [1,I*M,H,W] (if NCHW) or keeps it at [1,H,W,I*M] (if NHWC) as required by the compute library Returns a tuple of converted weights tensor info and depth multiplier. More...
 
std::tuple< ConstTensor, unsigned int > Convert1HWOtoMIHW (const ConstTensorHandle *weightTensor, const TensorInfo &inputInfo, const DataLayout &dataLayout, void *permuteBuffer)
 Converts a (weights) tensor from [1, H, W, I*M] = [1, H, W, O] to [M, I, H, W]. More...
 
armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl (const ConstTensorHandle *weightTensor, DataLayout dataLayout, void *permuteBuffer)
 
int32_t ConvertMaskToACLFormat (int32_t mask, int32_t numDim)
 
template<typename CopyFunc >
void CopyTensorContentsGeneric (const ITensorHandle *srcTensor, ITensorHandle *dstTensor, CopyFunc copy)
 
template<typename SrcTensorHandleType , typename DstTensorHandleType , typename DescriptorType >
void GatherTensorHandlePairs (const DescriptorType &descriptor, std::vector< std::pair< SrcTensorHandleType *, DstTensorHandleType *>> &tensorHandlePairs)
 
std::string LowerString (std::string value)
 
TuningLevel ParseTuningLevel (const BackendOptions::Var &value, TuningLevel defaultValue)
 
bool ParseBoolean (const BackendOptions::Var &value, bool defaultValue)
 
std::string ParseFile (const BackendOptions::Var &value, std::string defaultValue)
 
void ConfigureTuner (arm_compute::CLTuner &tuner, TuningLevel level)
 
constexpr const char * ClBackendId ()
 
flatbuffers::Offset< ClContext > CreateClContext (flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset< flatbuffers::Vector< flatbuffers::Offset< armnn::Program >>> programs=0)
 
flatbuffers::Offset< ClContext > CreateClContextDirect (flatbuffers::FlatBufferBuilder &_fbb, const std::vector< flatbuffers::Offset< armnn::Program >> *programs=nullptr)
 
flatbuffers::Offset< Program > CreateProgram (flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset< flatbuffers::String > name=0, flatbuffers::Offset< flatbuffers::Vector< uint8_t >> binary=0)
 
flatbuffers::Offset< Program > CreateProgramDirect (flatbuffers::FlatBufferBuilder &_fbb, const char *name=nullptr, const std::vector< uint8_t > *binary=nullptr)
 
const armnn::ClContext * GetClContext (const void *buf)
 
const armnn::ClContext * GetSizePrefixedClContext (const void *buf)
 
const char * ClContextIdentifier ()
 
bool ClContextBufferHasIdentifier (const void *buf)
 
bool VerifyClContextBuffer (flatbuffers::Verifier &verifier)
 
bool VerifySizePrefixedClContextBuffer (flatbuffers::Verifier &verifier)
 
const char * ClContextExtension ()
 
void FinishClContextBuffer (flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset< armnn::ClContext > root)
 
void FinishSizePrefixedClContextBuffer (flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset< armnn::ClContext > root)
 
constexpr const char * ClImportTensorHandleFactoryId ()
 
constexpr const char * ClTensorHandleFactoryId ()
 
arm_compute::Status ClAbsWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClActivationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor)
 
arm_compute::Status ClAdditionValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClArgMinMaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor)
 
arm_compute::Status ClBatchNormalizationValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClBatchToSpaceNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &descriptor)
 
arm_compute::Status ClCastValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClChannelShuffleValidate (const TensorInfo &input, const TensorInfo &output, const ChannelShuffleDescriptor &descriptor)
 
arm_compute::Status ClComparisonWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ComparisonDescriptor &descriptor)
 
arm_compute::Status ClConcatWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const OriginsDescriptor &descriptor)
 
arm_compute::Status ClConstantWorkloadValidate (const TensorInfo &output)
 
arm_compute::Status ClConvertFp16ToFp32WorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClConvertFp32ToFp16WorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClConvolution3dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution3dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClDepthToSpaceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthToSpaceDescriptor &descriptor)
 
arm_compute::Status ClDepthwiseConvolutionWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClDequantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClDivisionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClExpWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClFloorWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClFullyConnectedWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const Optional< TensorInfo > &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClGatherWorkloadValidate (const TensorInfo &input, const TensorInfo &indices, const TensorInfo &output, const GatherDescriptor &descriptor)
 
arm_compute::Status ClInstanceNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const InstanceNormalizationDescriptor &descriptor)
 
arm_compute::Status ClL2NormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor)
 
arm_compute::Status ClLogicalAndWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClLogicalNotWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClLogicalOrWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClLogSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const LogSoftmaxDescriptor &descriptor)
 
arm_compute::Status ClLogWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
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 &descriptor)
 
arm_compute::Status ClMinimumWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status ClMultiplicationWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClNegWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor)
 
arm_compute::Status ClPadValidate (const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
 
arm_compute::Status ClPermuteWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const PermuteDescriptor &descriptor)
 
arm_compute::Status ClPooling2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Pooling2dDescriptor &descriptor)
 
arm_compute::Status ClPreluWorkloadValidate (const TensorInfo &input, const TensorInfo &alpha, const TensorInfo &output)
 
arm_compute::Status ClQLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
 
arm_compute::Status ClQuantizedLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &previousCellStateIn, const TensorInfo &previousOutputIn, const TensorInfo &cellStateOut, const TensorInfo &output, const QuantizedLstmInputParamsInfo &paramsInfo)
 
arm_compute::Status ClQuantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status ClReduceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ReduceDescriptor &descriptor)
 
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 ClSinWorkloadValidate (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 &descriptor)
 
arm_compute::Status ClSplitterWorkloadValidate (const TensorInfo &input, const std::vector< std::reference_wrapper< TensorInfo >> &outputs, unsigned int splitAxis)
 
arm_compute::Status ClStackWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const StackDescriptor &descriptor)
 
arm_compute::Status ClStridedSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor)
 
arm_compute::Status ClSubtractionValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status ClTransposeConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
arm_compute::Status ClTransposeWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeDescriptor &descriptor)
 
std::string GetConvolutionMethodString (arm_compute::ConvolutionMethod &convolutionMethod)
 
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 ConstTensorHandle *handle)
 
RuntimeException WrapClError (const cl::Error &clError, const CheckLocation &location)
 
void RunClFunction (arm_compute::IFunction &function, const CheckLocation &location)
 
template<typename DataType , typename PayloadType >
DataTypeGetOutputTensorData (unsigned int idx, const PayloadType &data)
 
constexpr const char * NeonBackendId ()
 
constexpr const char * NeonTensorHandleFactoryId ()
 
arm_compute::Status NeonAbsWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonActivationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ActivationDescriptor &descriptor)
 
arm_compute::Status NeonAdditionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonArgMinMaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ArgMinMaxDescriptor &descriptor)
 
arm_compute::Status NeonBatchNormalizationValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonBatchToSpaceNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const BatchToSpaceNdDescriptor &descriptor)
 
arm_compute::Status NeonCastValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonChannelShuffleValidate (const TensorInfo &input, const TensorInfo &output, const ChannelShuffleDescriptor &descriptor)
 
arm_compute::Status NeonComparisonWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ComparisonDescriptor &descriptor)
 
arm_compute::Status NeonConcatWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const OriginsDescriptor &descriptor)
 
arm_compute::Status NeonConstantWorkloadValidate (const TensorInfo &output)
 
arm_compute::Status NeonConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonConvolution3dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Convolution3dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonDepthToSpaceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthToSpaceDescriptor &descriptor)
 
arm_compute::Status NeonDepthwiseConvolutionWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonDequantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::DetectionPostProcessLayerInfo MakeInfo (const DetectionPostProcessDescriptor &descriptor)
 
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 &descriptor)
 
arm_compute::Status NeonDivisionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonExpWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonFullyConnectedWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const Optional< TensorInfo > &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonGatherWorkloadValidate (const TensorInfo &input, const TensorInfo &indices, const TensorInfo &output, const GatherDescriptor &descriptor)
 
arm_compute::Status NeonInstanceNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const InstanceNormalizationDescriptor &descriptor)
 
arm_compute::Status NeonL2NormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor)
 
arm_compute::Status NeonLogicalAndWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status NeonLogicalNotWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonLogicalOrWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 
arm_compute::Status NeonLogSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const LogSoftmaxDescriptor &descriptor)
 
arm_compute::Status NeonLogWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
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 &descriptor)
 
arm_compute::Status NeonMinimumWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output)
 Validate function for validating the inputs and output. More...
 
arm_compute::Status NeonMultiplicationWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonNegWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonNormalizationWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor)
 
arm_compute::Status NeonPadWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
 
arm_compute::Status NeonPermuteWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const PermuteDescriptor &descriptor)
 
arm_compute::Status NeonPooling2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const Pooling2dDescriptor &descriptor)
 
arm_compute::Status NeonPreluWorkloadValidate (const TensorInfo &input, const TensorInfo &alpha, const TensorInfo &output)
 
arm_compute::Status NeonQLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
 
arm_compute::Status NeonQuantizedLstmWorkloadValidate (const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const QuantizedLstmInputParamsInfo &paramsInfo)
 
arm_compute::Status NeonQuantizeWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonReduceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const ReduceDescriptor &descriptor)
 
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 NeonSinWorkloadValidate (const TensorInfo &input, const TensorInfo &output)
 
arm_compute::Status NeonSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SliceDescriptor &descriptor)
 
arm_compute::Status NeonSoftmaxWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor)
 
arm_compute::Status NeonSpaceToBatchNdWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SpaceToBatchNdDescriptor &descriptor)
 
arm_compute::Status NeonSpaceToDepthWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const SpaceToDepthDescriptor &descriptor)
 
arm_compute::Status NeonSplitterWorkloadValidate (const TensorInfo &input, const std::vector< std::reference_wrapper< TensorInfo >> &outputs, unsigned int splitAxis)
 
arm_compute::Status NeonStackWorkloadValidate (const std::vector< const TensorInfo *> &inputs, const TensorInfo &output, const StackDescriptor &descriptor)
 
arm_compute::Status NeonStridedSliceWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor)
 
arm_compute::Status NeonSubtractionWorkloadValidate (const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
 
arm_compute::Status NeonTransposeConvolution2dWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases)
 
arm_compute::Status NeonTransposeWorkloadValidate (const TensorInfo &input, const TensorInfo &output, const TransposeDescriptor &descriptor)
 
template<typename T >
void CopyArmComputeTensorData (arm_compute::Tensor &dstTensor, const T *srcData)
 
void InitializeArmComputeTensorData (arm_compute::Tensor &tensor, const ConstTensorHandle *handle)
 
auto SetNeonStridedSliceData (const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)
 
auto SetNeonSliceData (const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)
 
constexpr const char * RefBackendId ()
 
constexpr const char * RefTensorHandleFactoryId ()
 
template<DataType ArmnnType>
bool IsDataType (const WorkloadInfo &info)
 
bool IsSigned32 (const WorkloadInfo &info)
 
bool IsBFloat16 (const WorkloadInfo &info)
 
bool IsFloat16 (const WorkloadInfo &info)
 
bool IsQSymmS16 (const WorkloadInfo &info)
 
bool IsQSymmS8 (const WorkloadInfo &info)
 
bool IsQAsymmS8 (const WorkloadInfo &info)
 
bool IsQAsymmU8 (const WorkloadInfo &info)
 
template<typename QueueDescriptorType >
constexpr bool IsOperationQueueDescriptor (const QueueDescriptorType &)
 
template<>
constexpr bool IsOperationQueueDescriptor (const MemCopyQueueDescriptor &)
 
template<>
constexpr bool IsOperationQueueDescriptor (const ConstantQueueDescriptor &)
 
template<>
constexpr bool IsOperationQueueDescriptor (const PermuteQueueDescriptor &)
 
float Activation (float in, ActivationFunction function, float a, float b)
 
void Activation (Decoder< float > &in, Encoder< float > &out, const TensorInfo &tensorInfo, ActivationFunction function, float a, float b)
 
template<typename OUT >
void ArgMinMax (Decoder< float > &in, OUT *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
 
template void ArgMinMax (Decoder< float > &in, int32_t *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
 
template void ArgMinMax (Decoder< float > &in, int64_t *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
 
void BatchNormImpl (const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
 
unsigned int Offset (const TensorShape &shape, unsigned int batch, unsigned int height, unsigned int width, unsigned int channels, const DataLayoutIndexed &dataLayout)
 
void BatchToSpaceNd (const DataLayoutIndexed &dataLayout, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, const std::vector< unsigned int > &blockShape, const std::vector< std::pair< unsigned int, unsigned int >> &cropsData, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
 
void Concatenate (const ConcatQueueDescriptor &data, std::vector< ITensorHandle *> inputs, std::vector< ITensorHandle *> outputs)
 
void Convolve3d (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 paddingFront, unsigned int xStride, unsigned int yStride, unsigned int zStride, unsigned int xDilation, unsigned int yDilation, unsigned int zDilation)
 
void Convolve (const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rFilterShape, Decoder< float > &rFilterDecoder, bool biasEnabled, Decoder< float > *pBiasDecoder, DataLayout dataLayout, unsigned int paddingTop, unsigned int paddingLeft, unsigned int xStride, unsigned int yStride, unsigned int xDilation, unsigned int yDilation, bool depthwise)
 
template<typename T >
void Debug (const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< BFloat16 > (const TensorInfo &inputInfo, const BFloat16 *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< Half > (const TensorInfo &inputInfo, const Half *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< float > (const TensorInfo &inputInfo, const float *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< uint8_t > (const TensorInfo &inputInfo, const uint8_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< int8_t > (const TensorInfo &inputInfo, const int8_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< int16_t > (const TensorInfo &inputInfo, const int16_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template void Debug< int32_t > (const TensorInfo &inputInfo, const int32_t *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
 
template<typename T >
std::unique_ptr< Decoder< T > > MakeDecoder (const TensorInfo &info, const void *data=nullptr)
 
template<>
std::unique_ptr< Decoder< float > > MakeDecoder (const TensorInfo &info, const void *data)
 
template<>
std::unique_ptr< Decoder< bool > > MakeDecoder (const TensorInfo &info, const void *data)
 
template<>
std::unique_ptr< Decoder< int32_t > > MakeDecoder (const TensorInfo &info, const void *data)
 
void DepthToSpace (const TensorInfo &inputInfo, const DepthToSpaceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
 
void Dequantize (Decoder< float > &inputDecoder, Encoder< float > &outputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo)
 
std::vector< unsigned int > GenerateRangeK (unsigned int k)
 
void TopKSort (unsigned int k, unsigned int *indices, const float *values, unsigned int numElement)
 
float IntersectionOverUnion (const float *boxI, const float *boxJ)
 
std::vector< unsigned int > NonMaxSuppression (unsigned int numBoxes, const std::vector< float > &boxCorners, const std::vector< float > &scores, float nmsScoreThreshold, unsigned int maxDetection, float nmsIouThreshold)
 
void AllocateOutputData (unsigned int numOutput, unsigned int numSelected, const std::vector< float > &boxCorners, const std::vector< unsigned int > &outputIndices, const std::vector< unsigned int > &selectedBoxes, const std::vector< unsigned int > &selectedClasses, const std::vector< float > &selectedScores, float *detectionBoxes, float *detectionScores, float *detectionClasses, float *numDetections)
 
void DetectionPostProcess (const TensorInfo &boxEncodingsInfo, const TensorInfo &scoresInfo, const TensorInfo &anchorsInfo, const TensorInfo &detectionBoxesInfo, const TensorInfo &detectionClassesInfo, const TensorInfo &detectionScoresInfo, const TensorInfo &numDetectionsInfo, const DetectionPostProcessDescriptor &desc, Decoder< float > &boxEncodings, Decoder< float > &scores, Decoder< float > &anchors, float *detectionBoxes, float *detectionClasses, float *detectionScores, float *numDetections)
 
template<typename T >
std::unique_ptr< Encoder< T > > MakeEncoder (const TensorInfo &info, void *data=nullptr)
 
template<>
std::unique_ptr< Encoder< float > > MakeEncoder (const TensorInfo &info, void *data)
 
template<>
std::unique_ptr< Encoder< bool > > MakeEncoder (const TensorInfo &info, void *data)
 
template<>
std::unique_ptr< Encoder< int32_t > > MakeEncoder (const TensorInfo &info, void *data)
 
void Fill (Encoder< float > &output, const TensorShape &desiredOutputShape, const float value)
 Creates a tensor and fills it with a scalar value. More...
 
void FullyConnected (const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > *rBiasDecoder, bool biasEnabled, unsigned int K, bool transposeWeights)
 Performs a matrix multiplication and optionally adds a bias. More...
 
void Gather (const TensorInfo &paramsInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo, Decoder< float > &params, const int32_t *indices, Encoder< float > &output, const int32_t axis)
 
void InstanceNorm (const InstanceNormalizationQueueDescriptor &data, const TensorInfo &inputInfo, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
 
void LogSoftmax (Decoder< float > &input, Encoder< float > &output, const TensorInfo &inputInfo, const LogSoftmaxDescriptor &descriptor)
 
void LstmImpl (const LstmDescriptor &descriptor, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const TensorShape &inputToOutputWeightsShape, const TensorShape &recurrentToOutputWeightsShape, std::unique_ptr< Decoder< float >> &inputData, std::unique_ptr< Decoder< float >> &outputStateIn, std::unique_ptr< Decoder< float >> &cellStateIn, std::unique_ptr< Encoder< float >> &outputStateOut, std::unique_ptr< Encoder< float >> &cellStateOut, std::unique_ptr< Encoder< float >> &output, std::unique_ptr< Decoder< float >> &cellStateOutDecoder, std::unique_ptr< Decoder< float >> &outputDecoder, std::unique_ptr< Decoder< float >> &inputToInputWeightsTensor, std::unique_ptr< Decoder< float >> &inputToForgetWeightsTensor, std::unique_ptr< Decoder< float >> &inputToCellWeightsTensor, std::unique_ptr< Decoder< float >> &inputToOutputWeightsTensor, std::unique_ptr< Decoder< float >> &recurrentToInputWeightsTensor, std::unique_ptr< Decoder< float >> &recurrentToForgetWeightsTensor, std::unique_ptr< Decoder< float >> &recurrentToCellWeightsTensor, std::unique_ptr< Decoder< float >> &recurrentToOutputWeightsTensor, std::unique_ptr< Decoder< float >> &cellToInputWeightsTensor, std::unique_ptr< Decoder< float >> &cellToForgetWeightsTensor, std::unique_ptr< Decoder< float >> &cellToOutputWeightsTensor, std::unique_ptr< Decoder< float >> &inputGateBiasTensor, std::unique_ptr< Decoder< float >> &forgetGateBiasTensor, std::unique_ptr< Decoder< float >> &cellBiasTensor, std::unique_ptr< Decoder< float >> &outputGateBiasTensor, std::unique_ptr< Decoder< float >> &projectionWeightsTensor, std::unique_ptr< Decoder< float >> &projectionBiasTensor, std::unique_ptr< Decoder< float >> &inputLayerNormWeights, std::unique_ptr< Decoder< float >> &forgetLayerNormWeights, std::unique_ptr< Decoder< float >> &cellLayerNormWeights, std::unique_ptr< Decoder< float >> &outputLayerNormWeights, std::unique_ptr< Encoder< float >> &inputGateScratch, std::unique_ptr< Encoder< float >> &cellScratch, std::unique_ptr< Encoder< float >> &forgetGateScratch, std::unique_ptr< Encoder< float >> &outputGateScratch, std::unique_ptr< Decoder< float >> &inputGateScratchDecoder, std::unique_ptr< Decoder< float >> &cellScratchDecoder, std::unique_ptr< Decoder< float >> &forgetGateScratchDecoder, std::unique_ptr< Decoder< float >> &outputGateScratchDecoder, float layerNormEpsilon)
 
void MirrorPad (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const ITensorHandle *inputHandle, ITensorHandle *outputHandle, const PadQueueDescriptor &data)
 
void Pad (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const ITensorHandle *inputHandle, ITensorHandle *outputHandle, const PadQueueDescriptor &data)
 
void Pooling2d (Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
 Computes the Pooling2d operation. More...
 
void Pooling3d (Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling3dDescriptor &params)
 Computes the Pooling3d operation. More...
 
void PreluImpl (const TensorInfo &inputInfo, const TensorInfo &alphaInfo, const TensorInfo &outputInfo, Decoder< float > &inputData, Decoder< float > &alphaData, Encoder< float > &outputData)
 
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 Reduce (const TensorInfo &inputInfo, const TensorInfo &outputInfo, Decoder< float > &input, Encoder< float > &output, const std::vector< uint32_t > axis, const ReduceOperation reduceOperation)
 
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 >
DataTypeGetOutputTensorData (ITensorHandle *tensorHandle)
 
template<typename PayloadType >
const float * GetInputTensorDataFloat (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
float * GetOutputTensorDataFloat (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
const HalfGetInputTensorDataHalf (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
HalfGetOutputTensorDataHalf (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
const BFloat16GetInputTensorDataBFloat16 (unsigned int idx, const PayloadType &data)
 
template<typename PayloadType >
BFloat16GetOutputTensorDataBFloat16 (unsigned int idx, const PayloadType &data)
 
template<typename T >
std::vector< float > Dequantize (const T *quant, const TensorInfo &info)
 u8 helpers More...
 
template<typename T >
void Dequantize (const T *inputData, float *outputData, const TensorInfo &info)
 
void Quantize (uint8_t *quant, const float *dequant, const TensorInfo &info)
 
void Resize (Decoder< float > &in, const TensorInfo &inputInfo, Encoder< float > &out, const TensorInfo &outputInfo, DataLayoutIndexed dataLayout, armnn::ResizeMethod resizeMethod, bool alignCorners, bool halfPixelCenters)
 
void Slice (const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
 
void Softmax (Decoder< float > &in, Encoder< float > &out, const TensorInfo &inputTensorInfo, float beta, int axis)
 Computes the softmax function on some inputs, into outputs, with a shape given by tensorInfo. More...
 
unsigned int GetOffset (const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
 
void SpaceToBatchNd (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToBatchNdDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
 
void SpaceToDepth (const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToDepthDescriptor &params, Decoder< float > &inputData, Encoder< float > &outputData)
 
void Split (const SplitterQueueDescriptor &data, std::vector< ITensorHandle *> inputs, std::vector< ITensorHandle *> outputs)
 
template<typename DataType >
void Splitter (const SplitterQueueDescriptor &data, std::vector< ITensorHandle *> inputs, std::vector< ITensorHandle *> outputs)
 
void Stack (const StackQueueDescriptor &data, std::vector< std::unique_ptr< Decoder< float >>> &inputs, Encoder< float > &output, const TensorInfo &inputInfo, const TensorInfo &outputInfo)
 
void StridedSlice (const TensorInfo &inputInfo, const StridedSliceDescriptor &params, const void *inputData, void *outputData, unsigned int dataTypeSize)
 
void TransposeConvolution2dImpl (const TransposeConvolution2dDescriptor &descriptor, const TensorShape &inputShape, Decoder< float > &inputDecoder, const TensorShape &outputShape, Encoder< float > &outputEncoder, const TensorShape &weightsShape, Decoder< float > &weightsDecoder, Decoder< float > *biasesDecoder)
 
std::istream & operator>> (std::istream &in, armnn::Compute &compute)
 
std::istream & operator>> (std::istream &in, armnn::BackendId &backend)
 

Variables

constexpr unsigned int MaxNumOfTensorDimensions = 5U
 
constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u
 The lowest performance data capture interval we support is 10 miliseconds. More...
 
constexpr unsigned int EXPIRE_RATE = 3U
 Variable to control expire rate of priority queue. More...
 
constexpr std::size_t g_ProfilingEventCountHint = 1024
 
constexpr bool g_WriteProfilingEventSequence = true
 
constexpr bool g_AggregateProfilingEventsByInference = true
 
constexpr bool g_WriteReportToStdOutOnProfilerDestruction = false
 
thread_local IProfilertl_Profiler = nullptr
 
constexpr size_t wordSize = sizeof(size_t) * 8
 
const BackendCapabilities gpuAccCapabilities ("GpuAcc", { {"NonConstWeights", false}, {"AsyncExecution", false}, {"ProtectedContentAllocation", true}, {"ConstantTensorsAsInputs", false}, {"PreImportIOTensors", false}, {"ExternallyManagedMemory", true}, {"MultiAxisPacking", false}, {"SingleAxisPacking", true} })
 
const BackendCapabilities cpuAccCapabilities ("CpuAcc", { {"NonConstWeights", false}, {"AsyncExecution", false}, {"ProtectedContentAllocation", false}, {"ConstantTensorsAsInputs", false}, {"PreImportIOTensors", false}, {"ExternallyManagedMemory", true}, {"MultiAxisPacking", false}, {"SingleAxisPacking", true} })
 
const std::set< armnn::LayerTypepaddingRequiredLayers
 
const BackendCapabilities cpuRefCapabilities ("CpuRef", { {"NonConstWeights", true}, {"AsyncExecution", true}, {"ProtectedContentAllocation", false}, {"ConstantTensorsAsInputs", true}, {"PreImportIOTensors", true}, {"ExternallyManagedMemory", true}, {"MultiAxisPacking", false}, {"SingleAxisPacking", true} })
 
const std::set< armnn::BackendCapabilityoldCpuRefCapabilities
 

Detailed Description

Copyright (c) 2021 ARM Limited and Contributors.

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

Create pages for each tool so they appear nicely in the doxygen tree-view.

All rights reserved.

SPDX-License-Identifier: MIT

Subpages are not listed there. Also we can overwrite the page name this way.

Subpages are not listed there.

Note: The parser, serializer and deserializer pages are created in 01_parsers.dox or 02_deserializer_serializer.dox

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

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

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

Typedef Documentation

◆ ACLMemManagerOnDemand

using ACLMemManagerOnDemand = std::shared_ptr<arm_compute::MemoryManagerOnDemand>

Definition at line 22 of file NeonFullyConnectedWorkload.cpp.

◆ AdditionalInfoObjectPtr

using AdditionalInfoObjectPtr = std::shared_ptr<void>

Definition at line 213 of file Layer.hpp.

◆ BackendCapabilities

Definition at line 19 of file BackendOptions.hpp.

◆ BackendIdSet

using BackendIdSet = std::unordered_set<BackendId>

Definition at line 193 of file BackendId.hpp.

◆ BackendIdVector

using BackendIdVector = std::vector<BackendId>

Definition at line 192 of file BackendId.hpp.

◆ BackendsMap

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

Definition at line 287 of file Network.hpp.

◆ BaseFloat32ComparisonWorkload

◆ BaseUint8ComparisonWorkload

◆ BFloat16ToFloat32Workload

◆ BindingPointInfo

Definition at line 274 of file Tensor.hpp.

◆ BooleanWorkload

◆ CompiledBlobDeleter

typedef std::function< void(const void *)> CompiledBlobDeleter

Definition at line 244 of file INetwork.hpp.

◆ CompiledBlobPtr

typedef std::unique_ptr< void, CompiledBlobDeleter > CompiledBlobPtr

Definition at line 245 of file INetwork.hpp.

◆ ConcatDescriptor

Definition at line 55 of file DescriptorsFwd.hpp.

◆ Coordinates

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

Definition at line 15 of file InternalTypes.hpp.

◆ CopyAndImportFactoryPairs

◆ 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 371 of file Types.hpp.

◆ DepthToSpaceDescriptor

A DepthToSpaceDescriptor for the DepthToSpaceLayer.

Definition at line 1075 of file Descriptors.hpp.

◆ Dimensions

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

Definition at line 16 of file InternalTypes.hpp.

◆ DynamicBackendPtr

using DynamicBackendPtr = std::unique_ptr<DynamicBackend>

Definition at line 52 of file DynamicBackend.hpp.

◆ FactoryId

◆ Float16ToFloat32Workload

◆ Float32ToBFloat16Workload

◆ Float32ToFloat16Workload

◆ Float32Workload

◆ FloatWorkload

◆ Half

using Half = half_float::half

Definition at line 18 of file Half.hpp.

◆ HighResolutionClock

using HighResolutionClock = std::chrono::high_resolution_clock::time_point

Define a timer and associated inference ID for recording execution times.

Definition at line 374 of file Types.hpp.

◆ IBackendContextUniquePtr

using IBackendContextUniquePtr = std::unique_ptr<IBackendContext>

Definition at line 34 of file IBackendContext.hpp.

◆ IBackendInternalUniquePtr

typedef std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr

Definition at line 26 of file BackendRegistry.hpp.

◆ IBackendSharedPtr

using IBackendSharedPtr = std::shared_ptr<IBackend>

Definition at line 250 of file Types.hpp.

◆ IBackendUniquePtr

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

Definition at line 251 of file Types.hpp.

◆ IGpuAccTunedParametersPtr

The following API is replaced by the backend options API.

Definition at line 293 of file IRuntime.hpp.

◆ ILayerSupportSharedPtr

using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>

Definition at line 572 of file ILayerSupport.hpp.

◆ IMemoryManagerUniquePtr

using IMemoryManagerUniquePtr = std::unique_ptr<IMemoryManager>

Definition at line 24 of file IMemoryManager.hpp.

◆ ImportedInputId

using ImportedInputId = unsigned int

Definition at line 278 of file Types.hpp.

◆ ImportedOutputId

using ImportedOutputId = unsigned int

Definition at line 279 of file Types.hpp.

◆ INetworkPtr

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

Definition at line 241 of file INetwork.hpp.

◆ InferenceTimingPair

Definition at line 375 of file Types.hpp.

◆ InputQueueDescriptor

Definition at line 79 of file WorkloadData.hpp.

◆ InputTensors

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

Definition at line 392 of file Tensor.hpp.

◆ instead

Definition at line 255 of file TensorHandle.hpp.

◆ Int32Workload

◆ IOptimizedNetworkPtr

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

Definition at line 242 of file INetwork.hpp.

◆ IReportStructure

Definition at line 28 of file Runtime.hpp.

◆ IRuntimePtr

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

Definition at line 31 of file IRuntime.hpp.

◆ LayerBindingId

using LayerBindingId = int

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

Definition at line 277 of file Types.hpp.

◆ LayerGuid

using LayerGuid = profiling::ProfilingGuid

Define LayerGuid type.

Definition at line 363 of file Types.hpp.

◆ LayerPriority

using LayerPriority = unsigned int

Definition at line 212 of file Layer.hpp.

◆ LayerTypeOf

using LayerTypeOf = typename LayerTypeOfImpl<Type>::Type

Definition at line 89 of file LayersFwd.hpp.

◆ LoadedNetworks

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

Definition at line 27 of file Runtime.hpp.

◆ LogSoftmaxDescriptor

A LogSoftmaxDescriptor for the LogSoftmaxLayer.

Definition at line 169 of file Descriptors.hpp.

◆ MemoryOptimizerStrategiesMapRef

using MemoryOptimizerStrategiesMapRef = std::unordered_map<BackendId, std::shared_ptr<IMemoryOptimizerStrategy> >

Definition at line 27 of file BackendRegistry.hpp.

◆ MemorySourceFlags

using MemorySourceFlags = unsigned int

Definition at line 15 of file MemorySources.hpp.

◆ MergerDescriptor

MergerDescriptor is deprecated, use ConcatDescriptor instead.

Definition at line 59 of file DescriptorsFwd.hpp.

◆ MergerQueueDescriptor

Definition at line 137 of file WorkloadData.hpp.

◆ ModelOptions

using ModelOptions = std::vector<BackendOptions>

Definition at line 18 of file BackendOptions.hpp.

◆ NetworkId

typedef int NetworkId

Definition at line 25 of file IRuntime.hpp.

◆ NetworkImplPtr

using NetworkImplPtr = std::unique_ptr<NetworkImpl, void (*)(NetworkImpl* network)>

Definition at line 28 of file Network.hpp.

◆ NetworkOptions

using NetworkOptions = std::vector<BackendOptions>

Definition at line 16 of file BackendOptions.hpp.

◆ OutputQueueDescriptor

Definition at line 80 of file WorkloadData.hpp.

◆ OutputTensors

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

Definition at line 393 of file Tensor.hpp.

◆ ParameterStringifyFunction

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

Definition at line 14 of file SerializeLayerParameters.hpp.

◆ PreCompiledObjectDeleter

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

Definition at line 19 of file PreCompiledLayer.hpp.

◆ PreCompiledObjectPtr

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

Definition at line 20 of file PreCompiledLayer.hpp.

◆ RefAdditionWorkload

◆ RefDebugBFloat16Workload

◆ RefDebugFloat16Workload

◆ RefDebugFloat32Workload

◆ RefDebugQAsymmS8Workload

◆ RefDebugQAsymmU8Workload

◆ RefDebugQSymmS16Workload

◆ RefDebugQSymmS8Workload

◆ RefDebugSigned32Workload

◆ RefDivisionWorkload

◆ RefMaximumWorkload

◆ RefMinimumWorkload

◆ RefMultiplicationWorkload

◆ RefPermuteBFloat16Workload

◆ RefPermuteFloat16Workload

◆ RefPermuteFloat32Workload

◆ RefPermuteQAsymm8Workload

◆ RefPermuteQAsymmS8Workload

◆ RefPermuteQSymm16Workload

◆ RefSubtractionWorkload

◆ RefTransposeBFloat16Workload

◆ RefTransposeFloat16Workload

◆ RefTransposeFloat32Workload

◆ RefTransposeQAsymm8Workload

◆ RefTransposeQAsymmS8Workload

◆ RefTransposeQSymm16Workload

◆ ResolveType

using ResolveType = typename ResolveTypeImpl<DT>::Type

Definition at line 79 of file ResolveType.hpp.

◆ SplitterDescriptor

Definition at line 60 of file DescriptorsFwd.hpp.

◆ TensorInfos

using TensorInfos = std::vector<TensorInfo>

Definition at line 151 of file BackendHelper.cpp.

◆ Uint8ToFloat32Workload

◆ Uint8Workload

◆ UnidirectionalSequenceLstmDescriptor

◆ WorkloadQueue

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

Definition at line 13 of file ExecutionFrame.hpp.

Enumeration Type Documentation

◆ ActivationFunction

enum ActivationFunction
strong
Enumerator
Sigmoid 
TanH 
Linear 
ReLu 
BoundedReLu 

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

SoftReLu 
LeakyReLu 
Abs 
Sqrt 
Square 
Elu 
HardSwish 

Definition at line 73 of file Types.hpp.

◆ ArgMinMaxFunction

enum ArgMinMaxFunction
strong
Enumerator
Min 
Max 

Definition at line 89 of file Types.hpp.

◆ BackendCapability

enum BackendCapability : uint32_t
strong

BackendCapability class.

Enumerator
NonConstWeights 

Constant weights can be accessed through the descriptors, On the other hand, non-const weights can be accessed through inputs.

AsyncExecution 

Asynchronous Execution.

Definition at line 254 of file Types.hpp.

254  : uint32_t
255 {
256  /// Constant weights can be accessed through the descriptors,
257  /// On the other hand, non-const weights can be accessed through inputs.
259 
260  /// Asynchronous Execution.
262 
263  // add new enum values here
264 };
Constant weights can be accessed through the descriptors, On the other hand, non-const weights can be...

◆ BoostLogSeverityMapping

◆ CapabilityClass

enum CapabilityClass
strong

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

Enumerator
PaddingRequired 
FallbackImportDisabled 
CapabilityClassMax 

Definition at line 20 of file ITensorHandleFactory.hpp.

◆ ComparisonOperation

enum ComparisonOperation
strong
Enumerator
Equal 
Greater 
GreaterOrEqual 
Less 
LessOrEqual 
NotEqual 

Definition at line 95 of file Types.hpp.

◆ Compute

enum Compute
strong

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

Enumerator
Undefined 
CpuRef 

CPU Execution: Reference C++ kernels.

CpuAcc 

CPU Execution: NEON: ArmCompute.

GpuAcc 

GPU Execution: OpenCL: ArmCompute.

Definition at line 21 of file BackendId.hpp.

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

◆ DataLayout

enum DataLayout
strong
Enumerator
NCHW 
NHWC 
NDHWC 
NCDHW 

Definition at line 49 of file Types.hpp.

◆ DataType

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

Definition at line 35 of file Types.hpp.

◆ Dimensionality

enum Dimensionality
strong
Enumerator
NotSpecified 
Specified 
Scalar 

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

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

Definition at line 20 of file JsonPrinter.hpp.

◆ LayerType

enum LayerType
strong

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

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

Definition at line 458 of file Types.hpp.

459 {
460 #define X(name) name,
462 #undef X
465 };
#define LIST_OF_LAYER_TYPE
This list uses X macro technique.
Definition: Types.hpp:380
float Activation(float in, ActivationFunction function, float a, float b)
Definition: Activation.cpp:13

◆ LogicalBinaryOperation

Enumerator
LogicalAnd 
LogicalOr 

Definition at line 105 of file Types.hpp.

◆ LogSeverity

enum LogSeverity
strong
Enumerator
Trace 
Debug 
Info 
Warning 
Error 
Fatal 

Definition at line 14 of file Utils.hpp.

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

◆ MemBlockStrategyType

enum MemBlockStrategyType
strong
Enumerator
SingleAxisPacking 
MultiAxisPacking 

Definition at line 226 of file Types.hpp.

227 {
228  // MemBlocks can be packed on the Y axis only, overlap allowed on X axis.
229  // In other words MemBlocks with overlapping lifetimes cannot use the same MemBin,
230  // equivalent to blob or pooling memory management.
231  SingleAxisPacking = 0,
232 
233  // MemBlocks can be packed on either Y or X axis but cannot overlap on both.
234  // In other words MemBlocks with overlapping lifetimes can use the same MemBin,
235  // equivalent to offset or slab memory management.
236  MultiAxisPacking = 1
237 };

◆ MemorySource

enum MemorySource : uint32_t
strong

Define the Memory Source to reduce copies.

Enumerator
Undefined 
Malloc 
DmaBuf 
DmaBufProtected 
Gralloc 

Definition at line 217 of file Types.hpp.

◆ NormalizationAlgorithmChannel

Enumerator
Across 
Within 

Definition at line 180 of file Types.hpp.

◆ NormalizationAlgorithmMethod

Enumerator
LocalBrightness 

Krichevsky 2012: Local Brightness Normalization.

LocalContrast 

Jarret 2009: Local Contrast Normalization.

Definition at line 186 of file Types.hpp.

187 {
188  /// Krichevsky 2012: Local Brightness Normalization
189  LocalBrightness = 0,
190  /// Jarret 2009: Local Contrast Normalization
191  LocalContrast = 1
192 };
Jarret 2009: Local Contrast Normalization.
Krichevsky 2012: Local Brightness Normalization.

◆ OutputShapeRounding

enum OutputShapeRounding
strong
Enumerator
Floor 
Ceiling 

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

162 {
163  /// The padding fields count, but are ignored
164  IgnoreValue = 0,
165  /// The padding fields don't count and are ignored
166  Exclude = 1
167 };
The padding fields don&#39;t count and are ignored.
The padding fields count, but are ignored.

◆ PaddingMode

enum PaddingMode
strong

The padding mode controls whether the padding should be filled with constant values (Constant), or reflect the input, either including the border values (Symmetric) or not (Reflect).

Enumerator
Constant 
Reflect 
Symmetric 

Definition at line 173 of file Types.hpp.

◆ PoolingAlgorithm

enum PoolingAlgorithm
strong
Enumerator
Max 
Average 
L2 

Definition at line 123 of file Types.hpp.

◆ ProfilingDetailsMethod

Define the behaviour of the internal profiler when outputting network details.

Enumerator
Undefined 
DetailsWithEvents 
DetailsOnly 

Definition at line 58 of file Types.hpp.

◆ QosExecPriority

enum QosExecPriority
strong
Enumerator
Low 
Medium 
High 

Definition at line 66 of file Types.hpp.

◆ ReduceOperation

enum ReduceOperation
strong
Enumerator
Sum 
Max 
Mean 
Min 
Prod 

Definition at line 130 of file Types.hpp.

◆ ResizeMethod

enum ResizeMethod
strong
Enumerator
Bilinear 
NearestNeighbor 

Definition at line 139 of file Types.hpp.

◆ ShapeInferenceMethod

enum ShapeInferenceMethod
strong

The ShapeInferenceMethod modify how the output shapes are treated.

When ValidateOnly is selected, the output shapes are inferred from the input parameters of the layer and any mismatch is reported. When InferAndValidate is selected 2 actions are performed: (1)infer output shape from inputs and (2)validate the shapes as in ValidateOnly. This option has been added to work with tensors which rank or dimension sizes are not specified explicitly, however this information can be calculated from the inputs.

Enumerator
ValidateOnly 

Validate all output shapes.

InferAndValidate 

Infer missing output shapes and validate all output shapes.

Definition at line 208 of file Types.hpp.

209 {
210  /// Validate all output shapes
211  ValidateOnly = 0,
212  /// Infer missing output shapes and validate all output shapes
213  InferAndValidate = 1
214 };
Validate all output shapes.
Infer missing output shapes and validate all output shapes.

◆ Status

enum Status
strong

enumeration

Enumerator
Success 
Failure 

Definition at line 29 of file Types.hpp.

◆ TuningLevel

enum TuningLevel
strong
Enumerator
None 
Rapid 
Normal 
Exhaustive 

Definition at line 70 of file ClBackendContext.cpp.

◆ UnaryOperation

enum UnaryOperation
strong
Enumerator
Abs 
Exp 
Sqrt 
Rsqrt 
Neg 
LogicalNot 
Log 
Sin 

Definition at line 111 of file Types.hpp.

Function Documentation

◆ Activation() [1/2]

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

Definition at line 13 of file Activation.cpp.

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

Referenced by Activation(), LstmImpl(), and TEST_SUITE().

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

◆ Activation() [2/2]

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

Definition at line 95 of file Activation.cpp.

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

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

◆ AllocateOutputData()

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

Definition at line 102 of file DetectionPostProcess.cpp.

References numeric_cast().

Referenced by DetectionPostProcess().

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

◆ AllTypesAreEqualImpl() [1/2]

bool armnn::AllTypesAreEqualImpl ( )

Definition at line 59 of file LayerSupportRules.hpp.

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

60 {
61  return true;
62 }

◆ AllTypesAreEqualImpl() [2/2]

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

Definition at line 65 of file LayerSupportRules.hpp.

References AllTypesAreEqualImpl().

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

◆ Append() [1/2]

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

Definition at line 30 of file Optimizer.hpp.

Referenced by Append(), and MakeOptimizations().

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

◆ Append() [2/2]

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

Definition at line 36 of file Optimizer.hpp.

References Append().

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

◆ ApplyBackendOptimizations()

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

Definition at line 1155 of file Network.cpp.

References ARMNN_ASSERT, ARMNN_SCOPED_PROFILING_EVENT, AssignBackends(), Layer::GetBackendId(), OptimizedNetworkImpl::GetGraph(), SubgraphView::GetIConnectableLayers(), Layer::GetType(), Input, OptimizationResult::m_Error, BackendSettings::m_SelectedBackends, Output, ReportWarning(), SubgraphViewSelector::SelectSubgraphs(), Graph::SubstituteSubgraph(), and Undefined.

Referenced by Optimize().

1160 {
1161  ARMNN_ASSERT(optNetObjPtr);
1162  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ApplyBackendOptimizations")
1163  OptimizationResult result;
1164 
1165  // Get the optimized graph
1166  Graph& optGraph = optNetObjPtr->GetGraph();
1167 
1168  // Run backend specific optimizations
1169  for (auto&& selectedBackend : backendSettings.m_SelectedBackends)
1170  {
1171  auto backendObjPtr = backends.find(selectedBackend)->second.get();
1172  ARMNN_ASSERT(backendObjPtr);
1173 
1174  // Select sub-graphs based on backend
1175  SubgraphViewSelector::Subgraphs subgraphs =
1176  SubgraphViewSelector::SelectSubgraphs(optGraph,
1177  // Select layers assigned to the requested backend
1178  [&backendObjPtr](const Layer& layer)
1179  {
1180 
1181  return layer.GetType() != LayerType::Input &&
1182  layer.GetType() != LayerType::Output &&
1183  layer.GetBackendId() == backendObjPtr->GetId();
1184  });
1185  if (subgraphs.empty())
1186  {
1187  // No sub-graphs found, try with next selected backend
1188  continue;
1189  }
1190 
1191  // Try to optimize each sub-graph
1192  for (auto& subgraph : subgraphs)
1193  {
1194  // Try to optimize the current sub-graph
1195  ARMNN_SCOPED_PROFILING_EVENT(backendObjPtr->GetId(), "Optimizer_OptimizeSubgraph");
1196  OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph, modelOptions);
1197  ARMNN_ASSERT(optimizationViews.Validate(*subgraph));
1198 
1199  // Optimization attempted, check the resulting optimized sub-graph
1200  for (auto& substitution : optimizationViews.GetSubstitutions())
1201  {
1202  // Sub-graph optimized, substitute the sub-graph with the new optimized one in the main optimized graph
1203  SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
1204  SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
1205  optGraph.SubstituteSubgraph(substitutableSubgraph, replacementSubgraph);
1206 
1207  // Assign the current backend to the optimized sub-graph
1208  const SubgraphView::IConnectableLayers& subgraphLayers = replacementSubgraph.GetIConnectableLayers();
1209  std::for_each(subgraphLayers.begin(), subgraphLayers.end(), [&selectedBackend](IConnectableLayer* l)
1210  {
1211  ARMNN_ASSERT(l);
1212  PolymorphicDowncast<Layer*>(l)->SetBackendId(selectedBackend);
1213  });
1214  }
1215 
1216  if (!optimizationViews.GetFailedSubgraphs().empty())
1217  {
1218  std::stringstream warningMsg;
1219  warningMsg << "Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() << " backend.";
1220  ReportWarning(warningMsg.str(), errMessages);
1221 
1222  // Failed to optimize the given sub-graph, re-assign the sub-graph layers to other available backends
1223  BackendSettings settingsCopy(backendSettings);
1224  if (!backendObjPtr->GetId().IsCpuRef())
1225  {
1226  // Add the current backend to the list of backends to ignore
1227  settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
1228  }
1229 
1230  int count=0;
1231  for (auto& failedSubgraph : optimizationViews.GetFailedSubgraphs())
1232  {
1233  // An error occurred: the optimization was attempted but not performed, try different backends
1234  std::stringstream subgraphMsg;
1235  subgraphMsg << "Re-assigning backends to " << failedSubgraph.GetIConnectableLayers().size()
1236  << " layers inside sub-graph " << count++;
1237  ReportWarning(subgraphMsg.str(), errMessages);
1238 
1239  OptimizationResult reassignmentResult = AssignBackends(optNetObjPtr,
1240  settingsCopy,
1241  *subgraph,
1242  errMessages);
1243  if (reassignmentResult.m_Error)
1244  {
1245  // Failed to re-assign one of the remaining backends to each layer of the sub-graph
1246  result.m_Error = true;
1247  return result;
1248  }
1249  }
1250  }
1251  }
1252  }
1253 
1254  return result;
1255 }
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
Definition: Network.cpp:584
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:1122

◆ ArgMinMax() [1/3]

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

Definition at line 16 of file ArgMinMax.cpp.

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

Referenced by TEST_SUITE().

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

◆ ArgMinMax() [2/3]

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

◆ ArgMinMax() [3/3]

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

◆ ARMNN_DEPRECATED_MSG_REMOVAL_DATE() [1/2]

class armnn::ARMNN_DEPRECATED_MSG_REMOVAL_DATE ( "Use ABI stable IStrategy instead."  ,
"22.05"   
)

Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
activationDescriptor- ActivationDescriptor to configure the activation.
name- Optional name for the layer.

Function that an addition layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that an arg min max layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
argMinMaxDescriptor- ArgMinMaxDescriptor to configure the activation.
name- Optional name for the layer.

Function that a batch normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
mean- Pre-calculated mean for each channel.
variance- Pre-calculated variance for each channel.
beta- Per-channel additive factor.
gamma- Per-channel multiplicative factor.
name- Optional name for the layer.

Function that a batch to space ND layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
batchToSpaceNdDescriptor- Description of the layer.
name- Optional name for the layer.

Function a Comparison layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
comparisonDescriptor- Description of the layer.
name- Optional name for the layer.

Function that a concat layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
concatDescriptor- ConcatDescriptor (synonym for OriginsDescriptor) 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....
name- Optional name for the layer.

Function a layer with no inputs and a single output, which always corresponds to the passed in constant tensor should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
input- Tensor to be provided as the only output of the layer. The layer will maintain its own copy of the tensor data, meaning the memory referenced by input can be freed or reused after this function is called.
name- Optional name for the layer.

Function that a 2D convolution layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
convolution2dDescriptor- Description of the 2D convolution layer.
weights- Tensor for the weights data.
biases- Optional tensor for the bias data. If specified, must match the output tensor shape.
name- Optional name for the layer.

Function a depth to space layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
depthToSpaceDescriptor- Parameters for the depth to space operation.
name- Optional name for the layer.

Function that a 2D depthwise convolution layer with biases should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
convolution2dDescriptor- Description of the 2D depthwise convolution layer.
weights- Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width].
biases- Optional tensor for the bias data. If specified, must match the output tensor shape.
name- Optional name for the layer.

Function that a Dequantize layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that a Detection PostProcess layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
descriptor- Description of the Detection PostProcess layer.
anchors- Tensor for the anchors.
name- Optional name for the layer.

Function a division layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function a ElementwiseUnary layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
elementwiseUnaryDescriptor- Description of the layer.
name- Optional name for the layer.

Function a fill layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
fillDescriptor- Description of the layer
name- Optional name for the layer.

Function a floor layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that a fully connected layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
fullyConnectedDescriptor- Description of the fully connected layer.
name- Optional name for the layer.

Function that a fully connected layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
fullyConnectedDescriptor- Description of the fully connected layer.
weights- Tensor for the weights data.
biases- Optional tensor for the bias data.
name- Optional name for the layer.

Function a Gather layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
gatherDescriptor- Parameters for the gather operation.
name- Optional name for the layer.

Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
id- User generated id to uniquely identify a particular input. The same id needs to be specified when passing the inputs to the IRuntime::EnqueueWorkload() function.
name- Optional name for the layer.

Function that an instance normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
desc- Parameters for the instance normalization operation.
name- Optional name for the layer.

Function that an L2 normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. Normalization is performed along dimension 1, but requires a 4d input.

Parameters
layer- pointer to the layer which is calling back to this visit function.
desc- Parameters for the L2 normalization operation.
name- Optional name for the layer.

Function that a log softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
logSoftmaxDescriptor- LogSoftmaxDescriptor to configure the log softmax.
name- Optional name for the layer.

Function that a logical binary layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
logicalBinaryDescriptor- LogicalBinaryDescriptor to configure the logical unary layer.
name- Optional name for the layer.

Function an Lstm layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
descriptor- Parameters controlling the operation of the Lstm operation.
params- The weights and biases for the LSTM cell.
name- Optional name for the layer.

Function a Maximum layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function a Mean layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
meanDescriptor- Parameters for the mean operation.
name- Optional name for the layer.

Function that a merge layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function a Minimum layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that a multiplication layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that a normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
normalizationDescriptor- NormalizationDescriptor to configure the normalization.
name- Optional name for the layer.

Function an output layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
id- User generated id to uniquely identify a particular output. The same id needs to be specified when passing the outputs to the IRuntime::EnqueueWorkload() function.
name- Optional name for the layer.

Function a pad layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
paddings- n by 2 tensor, where n is the rank of the input tensor, such that paddings[i,0] indicates the amount of padding to add in front of dimension i, and paddings[i,1] indicates the amount of padding to add after the end of dimension i
name- Optional name for the layer.

Function that a permute layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
permuteDescriptor- PermuteDescriptor to configure the permute.
name- Optional name for the layer.

Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
pooling2dDescriptor- Pooling2dDescriptor to configure the pooling.
name- Optional name for the layer.

Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
pooling3dDescriptor- Pooling3dDescriptor to configure the pooling.
name- Optional name for the layer.

Function that a PReLU activation layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function a quantize layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function a QLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
descriptor- Parameters controlling the operation of the QLstm operation.
params- The weights and biases for the layer
name- Optional name for the layer.

Function a QuantizedLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
params- The weights and biases for the Quantized LSTM cell
name- Optional name for the layer.

Function a rank layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that a reduce layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
ReduceDescriptor- Parameters for the reduce max operation.
name- Optional name for the layer.

Function a reshape layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
reshapeDescriptor- Parameters for the reshape operation.
name- Optional name for the layer.

Function that a resize layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
resizeDescriptor- Parameters for the resize operation.
name- Optional name for the layer.

Function that a slice layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
sliceDescriptor- SliceDescriptor to configure the slice operation.
name- Optional name for the layer.

Function that a softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
softmaxDescriptor- SoftmaxDescriptor to configure the softmax.
name- Optional name for the layer.

Function a space to batch layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
spaceToBatchNdDescriptor- Parameters for the space to batch operation.
name- Optional name for the layer.

Function a space to depth layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
spaceToDepthDescriptor- Parameters for the space to depth operation.
name- Optional name for the layer.

Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
splitterDescriptor- ViewsDescriptor 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....
name- Optional name for the layer.

Function a stack layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
stackDescriptor- Parameters for the stack operation.
name- Optional name for the layer.

Function a StandInLayer should call back to when its Accept(ILaterVisitor&) function is invoked

Parameters
layer- pointer to the layer which is calling back to this visit function.
standInDescriptor- Parameters for the stand-in layer.
name- Optional name for the layer.

Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
stridedSliceDescriptor- Parameters for the strided slice operation.
name- Optional name for the layer.

Function a subtraction layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function a switch layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
name- Optional name for the layer.

Function that a 2D transpose convolution layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
descriptor- Description of the 2D transpose convolution layer.
weights- Tensor for the weights data.
biases- Optional tensor for the bias data.
name- Optional name for the layer.

Function that a transpose layer should call back to when its Accept(ILayerVisitor&) function is invoked.

Parameters
layer- pointer to the layer which is calling back to this visit function.
transposeDescriptor- TransposeDescriptor to configure the transpose.
name- Optional name for the layer.

Definition at line 16 of file ILayerVisitor.hpp.

References ARMNN_DEPRECATED_MSG_REMOVAL_DATE().

17 {
18 protected:
19  ILayerVisitor() {}
20  virtual ~ILayerVisitor() {}
21 
22 public:
23 
24  /// Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked.
25  /// @param layer - pointer to the layer which is calling back to this visit function.
26  /// @param activationDescriptor - ActivationDescriptor to configure the activation.
27  /// @param name - Optional name for the layer.
28  virtual void VisitActivationLayer(const IConnectableLayer* layer,
29  const ActivationDescriptor& activationDescriptor,
30  const char* name = nullptr) = 0;
31 
32  /// Function that an addition layer should call back to when its Accept(ILayerVisitor&) function is invoked.
33  /// @param layer - pointer to the layer which is calling back to this visit function.
34  /// @param name - Optional name for the layer.
35  virtual void VisitAdditionLayer(const IConnectableLayer* layer,
36  const char* name = nullptr) = 0;
37 
38  /// Function that an arg min max layer should call back to when its Accept(ILayerVisitor&) function is invoked.
39  /// @param layer - pointer to the layer which is calling back to this visit function.
40  /// @param argMinMaxDescriptor - ArgMinMaxDescriptor to configure the activation.
41  /// @param name - Optional name for the layer.
42  virtual void VisitArgMinMaxLayer(const IConnectableLayer* layer,
43  const ArgMinMaxDescriptor& argMinMaxDescriptor,
44  const char* name = nullptr) = 0;
45 
46  /// Function that a batch normalization layer should call back to when its Accept(ILayerVisitor&)
47  /// function is invoked.
48  /// @param layer - pointer to the layer which is calling back to this visit function.
49  /// @param mean - Pre-calculated mean for each channel.
50  /// @param variance - Pre-calculated variance for each channel.
51  /// @param beta - Per-channel additive factor.
52  /// @param gamma - Per-channel multiplicative factor.
53  /// @param name - Optional name for the layer.
54  virtual void VisitBatchNormalizationLayer(const IConnectableLayer* layer,
55  const BatchNormalizationDescriptor& desc,
56  const ConstTensor& mean,
57  const ConstTensor& variance,
58  const ConstTensor& beta,
59  const ConstTensor& gamma,
60  const char* name = nullptr) = 0;
61 
62  /// Function that a batch to space ND layer should call back to when its Accept(ILayerVisitor&)
63  /// function is invoked.
64  /// @param layer - pointer to the layer which is calling back to this visit function.
65  /// @param batchToSpaceNdDescriptor - Description of the layer.
66  /// @param name - Optional name for the layer.
67  virtual void VisitBatchToSpaceNdLayer(const IConnectableLayer* layer,
68  const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor,
69  const char* name = nullptr) = 0;
70 
71  /// Function a Comparison layer should call back to when its Accept(ILayerVisitor&) function is invoked.
72  /// @param layer - pointer to the layer which is calling back to this visit function.
73  /// @param comparisonDescriptor - Description of the layer.
74  /// @param name - Optional name for the layer.
75  virtual void VisitComparisonLayer(const IConnectableLayer* layer,
76  const ComparisonDescriptor& comparisonDescriptor,
77  const char* name = nullptr) = 0;
78 
79  /// Function that a concat layer should call back to when its Accept(ILayerVisitor&) function is invoked.
80  /// @param layer - pointer to the layer which is calling back to this visit function.
81  /// @param concatDescriptor - ConcatDescriptor (synonym for OriginsDescriptor) to configure the concatenation
82  /// process. Number of Views must be equal to the number of inputs, and their order
83  /// must match - e.g. first view corresponds to the first input, second view to the
84  /// second input, etc....
85  /// @param name - Optional name for the layer.
86  virtual void VisitConcatLayer(const IConnectableLayer* layer,
87  const OriginsDescriptor& concatDescriptor,
88  const char* name = nullptr) = 0;
89 
90  /// Function a layer with no inputs and a single output, which always corresponds to
91  /// the passed in constant tensor should call back to when its Accept(ILayerVisitor&) function is invoked.
92  /// @param layer - pointer to the layer which is calling back to this visit function.
93  /// @param input - Tensor to be provided as the only output of the layer. The layer will maintain
94  /// its own copy of the tensor data, meaning the memory referenced by @a input can
95  /// be freed or reused after this function is called.
96  /// @param name - Optional name for the layer.
97  virtual void VisitConstantLayer(const IConnectableLayer* layer,
98  const ConstTensor& input,
99  const char* name = nullptr) = 0;
100 
101  /// Function that a 2D convolution layer should call back to when its Accept(ILayerVisitor&)
102  /// function is invoked.
103  /// @param layer - pointer to the layer which is calling back to this visit function.
104  /// @param convolution2dDescriptor - Description of the 2D convolution layer.
105  /// @param weights - Tensor for the weights data.
106  /// @param biases - Optional tensor for the bias data. If specified, must match the output tensor shape.
107  /// @param name - Optional name for the layer.
108  virtual void VisitConvolution2dLayer(const IConnectableLayer* layer,
109  const Convolution2dDescriptor& convolution2dDescriptor,
110  const ConstTensor& weights,
111  const Optional<ConstTensor>& biases,
112  const char* name = nullptr) = 0;
113 
114  /// Function a depth to space layer should call back to when its Accept(ILayerVisitor&) function is invoked.
115  /// @param layer - pointer to the layer which is calling back to this visit function.
116  /// @param depthToSpaceDescriptor - Parameters for the depth to space operation.
117  /// @param name - Optional name for the layer.
118  virtual void VisitDepthToSpaceLayer(const IConnectableLayer* layer,
119  const DepthToSpaceDescriptor& depthToSpaceDescriptor,
120  const char* name = nullptr) = 0;
121 
122  /// Function that a 2D depthwise convolution layer with biases should call back to when its
123  /// Accept(ILayerVisitor&) function is invoked.
124  /// @param layer - pointer to the layer which is calling back to this visit function.
125  /// @param convolution2dDescriptor - Description of the 2D depthwise convolution layer.
126  /// @param weights - Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width].
127  /// @param biases - Optional tensor for the bias data. If specified, must match the output tensor shape.
128  /// @param name - Optional name for the layer.
129  virtual void VisitDepthwiseConvolution2dLayer(const IConnectableLayer* layer,
130  const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
131  const ConstTensor& weights,
132  const Optional<ConstTensor>& biases,
133  const char* name = nullptr) = 0;
134 
135  /// Function that a Dequantize layer should call back to when its
136  /// Accept(ILayerVisitor&) function is invoked.
137  /// @param layer - pointer to the layer which is calling back to this visit function.
138  /// @param name - Optional name for the layer.
139  virtual void VisitDequantizeLayer(const IConnectableLayer* layer,
140  const char* name = nullptr) = 0;
141 
142  /// Function that a Detection PostProcess layer should call back to when its
143  /// Accept(ILayerVisitor&) function is invoked.
144  /// @param layer - pointer to the layer which is calling back to this visit function.
145  /// @param descriptor - Description of the Detection PostProcess layer.
146  /// @param anchors - Tensor for the anchors.
147  /// @param name - Optional name for the layer.
148  virtual void VisitDetectionPostProcessLayer(const IConnectableLayer* layer,
149  const DetectionPostProcessDescriptor& descriptor,
150  const ConstTensor& anchors,
151  const char* name = nullptr) = 0;
152 
153  /// Function a division layer should call back to when its Accept(ILayerVisitor&) function is invoked.
154  /// @param layer - pointer to the layer which is calling back to this visit function.
155  /// @param name - Optional name for the layer.
156  virtual void VisitDivisionLayer(const IConnectableLayer* layer,
157  const char* name = nullptr) = 0;
158 
159  /// Function a ElementwiseUnary layer should call back to when its Accept(ILayerVisitor&) function is invoked.
160  /// @param layer - pointer to the layer which is calling back to this visit function.
161  /// @param elementwiseUnaryDescriptor - Description of the layer.
162  /// @param name - Optional name for the layer.
163  virtual void VisitElementwiseUnaryLayer(const IConnectableLayer* layer,
164  const ElementwiseUnaryDescriptor& elementwiseUnaryDescriptor,
165  const char* name = nullptr) = 0;
166 
167  /// Function a fill layer should call back to when its Accept(ILayerVisitor&) function is invoked.
168  /// @param layer - pointer to the layer which is calling back to this visit function.
169  /// @param fillDescriptor - Description of the layer
170  /// @param name - Optional name for the layer.
171  virtual void VisitFillLayer(const IConnectableLayer* layer,
172  const FillDescriptor& fillDescriptor,
173  const char* name = nullptr) = 0;
174 
175  /// Function a floor layer should call back to when its Accept(ILayerVisitor&) function is invoked.
176  /// @param layer - pointer to the layer which is calling back to this visit function.
177  /// @param name - Optional name for the layer.
178  virtual void VisitFloorLayer(const IConnectableLayer* layer,
179  const char* name = nullptr) = 0;
180 
181 
182  /// Function that a fully connected layer should call back to when its Accept(ILayerVisitor&)
183  /// function is invoked.
184  /// @param layer - pointer to the layer which is calling back to this visit function.
185  /// @param fullyConnectedDescriptor - Description of the fully connected layer.
186  /// @param name - Optional name for the layer.
187  virtual void VisitFullyConnectedLayer(const IConnectableLayer* layer,
188  const FullyConnectedDescriptor& fullyConnectedDescriptor,
189  const char* name = nullptr) = 0;
190 
191  /// Function that a fully connected layer should call back to when its Accept(ILayerVisitor&)
192  /// function is invoked.
193  /// @param layer - pointer to the layer which is calling back to this visit function.
194  /// @param fullyConnectedDescriptor - Description of the fully connected layer.
195  /// @param weights - Tensor for the weights data.
196  /// @param biases - Optional tensor for the bias data.
197  /// @param name - Optional name for the layer.
198  ARMNN_DEPRECATED_MSG_REMOVAL_DATE("Use VisitFullyConnectedLayer without ConstTensors", "22.05")
199  virtual void VisitFullyConnectedLayer(const IConnectableLayer* layer,
200  const FullyConnectedDescriptor& fullyConnectedDescriptor,
201  const ConstTensor& weights,
202  const Optional<ConstTensor>& biases,
203  const char* name = nullptr) = 0;
204 
205  /// Function a Gather layer should call back to when its Accept(ILayerVisitor&) function is invoked.
206  /// @param layer - pointer to the layer which is calling back to this visit function.
207  /// @param gatherDescriptor - Parameters for the gather operation.
208  /// @param name - Optional name for the layer.
209  virtual void VisitGatherLayer(const IConnectableLayer* layer,
210  const GatherDescriptor& gatherDescriptor,
211  const char* name = nullptr) = 0;
212 
213  /// Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked.
214  /// @param layer - pointer to the layer which is calling back to this visit function.
215  /// @param id - User generated id to uniquely identify a particular input. The same id needs to be specified
216  /// when passing the inputs to the IRuntime::EnqueueWorkload() function.
217  /// @param name - Optional name for the layer.
218  virtual void VisitInputLayer(const IConnectableLayer* layer,
219  LayerBindingId id,
220  const char* name = nullptr) = 0;
221 
222  /// Function that an instance normalization layer should call back to when its Accept(ILayerVisitor&)
223  /// function is invoked.
224  /// @param layer - pointer to the layer which is calling back to this visit function.
225  /// @param desc - Parameters for the instance normalization operation.
226  /// @param name - Optional name for the layer.
227  virtual void VisitInstanceNormalizationLayer(const IConnectableLayer* layer,
228  const InstanceNormalizationDescriptor& desc,
229  const char* name = nullptr) = 0;
230 
231  /// Function that an L2 normalization layer should call back to when its Accept(ILayerVisitor&)
232  /// function is invoked. Normalization is performed along dimension 1, but requires a 4d input.
233  /// @param layer - pointer to the layer which is calling back to this visit function.
234  /// @param desc - Parameters for the L2 normalization operation.
235  /// @param name - Optional name for the layer.
236  virtual void VisitL2NormalizationLayer(const IConnectableLayer* layer,
237  const L2NormalizationDescriptor& desc,
238  const char* name = nullptr) = 0;
239 
240  /// Function that a log softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked.
241  /// @param layer - pointer to the layer which is calling back to this visit function.
242  /// @param logSoftmaxDescriptor - LogSoftmaxDescriptor to configure the log softmax.
243  /// @param name - Optional name for the layer.
244  virtual void VisitLogSoftmaxLayer(const IConnectableLayer* layer,
245  const LogSoftmaxDescriptor& logSoftmaxDescriptor,
246  const char* name = nullptr) = 0;
247 
248  /// Function that a logical binary layer should call back to when its Accept(ILayerVisitor&) function is invoked.
249  /// @param layer - pointer to the layer which is calling back to this visit function.
250  /// @param logicalBinaryDescriptor - LogicalBinaryDescriptor to configure the logical unary layer.
251  /// @param name - Optional name for the layer.
252  virtual void VisitLogicalBinaryLayer(const IConnectableLayer* layer,
253  const LogicalBinaryDescriptor& logicalBinaryDescriptor,
254  const char* name = nullptr) = 0;
255 
256  /// Function an Lstm layer should call back to when its Accept(ILayerVisitor&) function is invoked.
257  /// @param layer - pointer to the layer which is calling back to this visit function.
258  /// @param descriptor - Parameters controlling the operation of the Lstm operation.
259  /// @param params - The weights and biases for the LSTM cell.
260  /// @param name - Optional name for the layer.
261  virtual void VisitLstmLayer(const IConnectableLayer* layer,
262  const LstmDescriptor& descriptor,
263  const LstmInputParams& params,
264  const char* name = nullptr) = 0;
265 
266  /// Function a Maximum layer should call back to when its Accept(ILayerVisitor&) function is invoked.
267  /// @param layer - pointer to the layer which is calling back to this visit function.
268  /// @param name - Optional name for the layer.
269  virtual void VisitMaximumLayer(const IConnectableLayer* layer,
270  const char* name = nullptr) = 0;
271 
272  /// Function a Mean layer should call back to when its Accept(ILayerVisitor&) function is invoked.
273  /// @param layer - pointer to the layer which is calling back to this visit function.
274  /// @param meanDescriptor - Parameters for the mean operation.
275  /// @param name - Optional name for the layer.
276  virtual void VisitMeanLayer(const IConnectableLayer* layer,
277  const MeanDescriptor& meanDescriptor,
278  const char* name = nullptr) = 0;
279 
280  /// Function that a merge layer should call back to when its Accept(ILayerVisitor&) function is invoked.
281  /// @param layer - pointer to the layer which is calling back to this visit function.
282  /// @param name - Optional name for the layer.
283  virtual void VisitMergeLayer(const IConnectableLayer* layer,
284  const char* name = nullptr) = 0;
285 
286  /// Function a Minimum layer should call back to when its Accept(ILayerVisitor&) function is invoked.
287  /// @param layer - pointer to the layer which is calling back to this visit function.
288  /// @param name - Optional name for the layer.
289  virtual void VisitMinimumLayer(const IConnectableLayer* layer,
290  const char* name = nullptr) = 0;
291 
292  /// Function that a multiplication layer should call back to when its Accept(ILayerVisitor&) function is invoked.
293  /// @param layer - pointer to the layer which is calling back to this visit function.
294  /// @param name - Optional name for the layer.
295  virtual void VisitMultiplicationLayer(const IConnectableLayer* layer,
296  const char* name = nullptr) = 0;
297 
298  /// Function that a normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked.
299  /// @param layer - pointer to the layer which is calling back to this visit function.
300  /// @param normalizationDescriptor - NormalizationDescriptor to configure the normalization.
301  /// @param name - Optional name for the layer.
302  virtual void VisitNormalizationLayer(const IConnectableLayer* layer,
303  const NormalizationDescriptor& normalizationDescriptor,
304  const char* name = nullptr) = 0;
305 
306  /// Function an output layer should call back to when its Accept(ILayerVisitor&) function is invoked.
307  /// @param layer - pointer to the layer which is calling back to this visit function.
308  /// @param id - User generated id to uniquely identify a particular output. The same id needs to be specified
309  /// when passing the outputs to the IRuntime::EnqueueWorkload() function.
310  /// @param name - Optional name for the layer.
311  virtual void VisitOutputLayer(const IConnectableLayer* layer,
312  LayerBindingId id,
313  const char* name = nullptr) = 0;
314 
315  /// Function a pad layer should call back to when its Accept(ILayerVisitor&) function is invoked.
316  /// @param layer - pointer to the layer which is calling back to this visit function.
317  /// @param paddings - n by 2 tensor, where n is the rank of the input tensor,
318  /// such that paddings[i,0] indicates the amount of padding to add in front of dimension i, and
319  /// paddings[i,1] indicates the amount of padding to add after the end of dimension i
320  /// @param name - Optional name for the layer.
321  virtual void VisitPadLayer(const IConnectableLayer* layer,
322  const PadDescriptor& padDescriptor,
323  const char* name = nullptr) = 0;
324 
325  /// Function that a permute layer should call back to when its Accept(ILayerVisitor&) function is invoked.
326  /// @param layer - pointer to the layer which is calling back to this visit function.
327  /// @param permuteDescriptor - PermuteDescriptor to configure the permute.
328  /// @param name - Optional name for the layer.
329  virtual void VisitPermuteLayer(const IConnectableLayer* layer,
330  const PermuteDescriptor& permuteDescriptor,
331  const char* name = nullptr) = 0;
332 
333  /// Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked.
334  /// @param layer - pointer to the layer which is calling back to this visit function.
335  /// @param pooling2dDescriptor - Pooling2dDescriptor to configure the pooling.
336  /// @param name - Optional name for the layer.
337  virtual void VisitPooling2dLayer(const IConnectableLayer* layer,
338  const Pooling2dDescriptor& pooling2dDescriptor,
339  const char* name = nullptr) = 0;
340 
341  /// Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked.
342  /// @param layer - pointer to the layer which is calling back to this visit function.
343  /// @param pooling3dDescriptor - Pooling3dDescriptor to configure the pooling.
344  /// @param name - Optional name for the layer.
345  virtual void VisitPooling3dLayer(const IConnectableLayer* layer,
346  const Pooling3dDescriptor& pooling3dDescriptor,
347  const char* name = nullptr) = 0;
348 
349  /// Function that a PReLU activation layer should call back to when its Accept(ILayerVisitor&) function is invoked.
350  /// @param layer - pointer to the layer which is calling back to this visit function.
351  /// @param name - Optional name for the layer.
352  virtual void VisitPreluLayer(const IConnectableLayer* layer,
353  const char* name = nullptr) = 0;
354 
355  /// Function a quantize layer should call back to when its Accept(ILayerVisitor&) function is invoked.
356  /// @param layer - pointer to the layer which is calling back to this visit function.
357  /// @param name - Optional name for the layer.
358  virtual void VisitQuantizeLayer(const IConnectableLayer* layer,
359  const char* name = nullptr) = 0;
360 
361  /// Function a QLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked.
362  /// @param layer - pointer to the layer which is calling back to this visit function.
363  /// @param descriptor - Parameters controlling the operation of the QLstm operation.
364  /// @param params - The weights and biases for the layer
365  /// @param name - Optional name for the layer.
366  virtual void VisitQLstmLayer(const IConnectableLayer* layer,
367  const QLstmDescriptor& descriptor,
368  const LstmInputParams& params,
369  const char* name = nullptr) = 0;
370 
371  /// Function a QuantizedLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked.
372  /// @param layer - pointer to the layer which is calling back to this visit function.
373  /// @param params - The weights and biases for the Quantized LSTM cell
374  /// @param name - Optional name for the layer.
375  virtual void VisitQuantizedLstmLayer(const IConnectableLayer* layer,
376  const QuantizedLstmInputParams& params,
377  const char* name = nullptr) = 0;
378 
379  /// Function a rank layer should call back to when its Accept(ILayerVisitor&) function is invoked.
380  /// @param layer - pointer to the layer which is calling back to this visit function.
381  /// @param name - Optional name for the layer.
382  virtual void VisitRankLayer(const IConnectableLayer* layer,
383  const char* name = nullptr) = 0;
384 
385  /// Function that a reduce layer should call back to when its Accept(ILayerVisitor&) function is invoked.
386  /// @param layer - pointer to the layer which is calling back to this visit function.
387  /// @param ReduceDescriptor - Parameters for the reduce max operation.
388  /// @param name - Optional name for the layer.
389  virtual void VisitReduceLayer(const IConnectableLayer* layer,
390  const ReduceDescriptor& reduceDescriptor,
391  const char* name = nullptr) = 0;
392 
393  /// Function a reshape layer should call back to when its Accept(ILayerVisitor&) function is invoked.
394  /// @param layer - pointer to the layer which is calling back to this visit function.
395  /// @param reshapeDescriptor - Parameters for the reshape operation.
396  /// @param name - Optional name for the layer.
397  virtual void VisitReshapeLayer(const IConnectableLayer* layer,
398  const ReshapeDescriptor& reshapeDescriptor,
399  const char* name = nullptr) = 0;
400 
401  /// Function that a resize layer should call back to when its Accept(ILayerVisitor&) function is invoked.
402  /// @param layer - pointer to the layer which is calling back to this visit function.
403  /// @param resizeDescriptor - Parameters for the resize operation.
404  /// @param name - Optional name for the layer.
405  virtual void VisitResizeLayer(const IConnectableLayer* layer,
406  const ResizeDescriptor& resizeDescriptor,
407  const char* name = nullptr) = 0;
408 
409  /// Function that a slice layer should call back to when its Accept(ILayerVisitor&) function is invoked.
410  /// @param layer - pointer to the layer which is calling back to this visit function.
411  /// @param sliceDescriptor - SliceDescriptor to configure the slice operation.
412  /// @param name - Optional name for the layer.
413  virtual void VisitSliceLayer(const IConnectableLayer* layer,
414  const SliceDescriptor& sliceDescriptor,
415  const char* name = nullptr) = 0;
416 
417 
418  /// Function that a softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked.
419  /// @param layer - pointer to the layer which is calling back to this visit function.
420  /// @param softmaxDescriptor - SoftmaxDescriptor to configure the softmax.
421  /// @param name - Optional name for the layer.
422  virtual void VisitSoftmaxLayer(const IConnectableLayer* layer,
423  const SoftmaxDescriptor& softmaxDescriptor,
424  const char* name = nullptr) = 0;
425 
426  /// Function a space to batch layer should call back to when its Accept(ILayerVisitor&) function is invoked.
427  /// @param layer - pointer to the layer which is calling back to this visit function.
428  /// @param spaceToBatchNdDescriptor - Parameters for the space to batch operation.
429  /// @param name - Optional name for the layer.
430  virtual void VisitSpaceToBatchNdLayer(const IConnectableLayer* layer,
431  const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor,
432  const char* name = nullptr) = 0;
433 
434  /// Function a space to depth layer should call back to when its Accept(ILayerVisitor&) function is invoked.
435  /// @param layer - pointer to the layer which is calling back to this visit function.
436  /// @param spaceToDepthDescriptor - Parameters for the space to depth operation.
437  /// @param name - Optional name for the layer.
438  virtual void VisitSpaceToDepthLayer(const IConnectableLayer* layer,
439  const SpaceToDepthDescriptor& spaceToDepthDescriptor,
440  const char* name = nullptr) = 0;
441 
442  /// Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoked.
443  /// @param layer - pointer to the layer which is calling back to this visit function.
444  /// @param splitterDescriptor - ViewsDescriptor to configure the splitting process.
445  /// Number of Views must be equal to the number of outputs,
446  /// and their order must match - e.g. first view corresponds to
447  /// the first output, second view to the second output, etc....
448  /// @param name - Optional name for the layer.
449  virtual void VisitSplitterLayer(const IConnectableLayer* layer,
450  const ViewsDescriptor& splitterDescriptor,
451  const char* name = nullptr) = 0;
452 
453  /// Function a stack layer should call back to when its Accept(ILayerVisitor&) function is invoked.
454  /// @param layer - pointer to the layer which is calling back to this visit function.
455  /// @param stackDescriptor - Parameters for the stack operation.
456  /// @param name - Optional name for the layer.
457  virtual void VisitStackLayer(const IConnectableLayer* layer,
458  const StackDescriptor& stackDescriptor,
459  const char* name = nullptr) = 0;
460 
461  /// Function a StandInLayer should call back to when its Accept(ILaterVisitor&) function is invoked
462  /// @param layer - pointer to the layer which is calling back to this visit function.
463  /// @param standInDescriptor - Parameters for the stand-in layer.
464  /// @param name - Optional name for the layer.
465  virtual void VisitStandInLayer(const IConnectableLayer* layer,
466  const StandInDescriptor& standInDescriptor,
467  const char* name = nullptr) = 0;
468 
469  /// Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoked.
470  /// @param layer - pointer to the layer which is calling back to this visit function.
471  /// @param stridedSliceDescriptor - Parameters for the strided slice operation.
472  /// @param name - Optional name for the layer.
473  virtual void VisitStridedSliceLayer(const IConnectableLayer* layer,
474  const StridedSliceDescriptor& stridedSliceDescriptor,
475  const char* name = nullptr) = 0;
476 
477  /// Function a subtraction layer should call back to when its Accept(ILayerVisitor&) function is invoked.
478  /// @param layer - pointer to the layer which is calling back to this visit function.
479  /// @param name - Optional name for the layer.
480  virtual void VisitSubtractionLayer(const IConnectableLayer* layer,
481  const char* name = nullptr) = 0;
482 
483  /// Function a switch layer should call back to when its Accept(ILayerVisitor&) function is invoked.
484  /// @param layer - pointer to the layer which is calling back to this visit function.
485  /// @param name - Optional name for the layer.
486  virtual void VisitSwitchLayer(const IConnectableLayer* layer,
487  const char* name = nullptr) = 0;
488 
489  /// Function that a 2D transpose convolution layer should call back to when its Accept(ILayerVisitor&)
490  /// function is invoked.
491  /// @param layer - pointer to the layer which is calling back to this visit function.
492  /// @param descriptor - Description of the 2D transpose convolution layer.
493  /// @param weights - Tensor for the weights data.
494  /// @param biases - Optional tensor for the bias data.
495  /// @param name - Optional name for the layer.
496  virtual void VisitTransposeConvolution2dLayer(const IConnectableLayer* layer,
497  const TransposeConvolution2dDescriptor& descriptor,
498  const ConstTensor& weights,
499  const Optional<ConstTensor>& biases,
500  const char* name = nullptr) = 0;
501 
502  /// Function that a transpose layer should call back to when its Accept(ILayerVisitor&) function is invoked.
503  /// @param layer - pointer to the layer which is calling back to this visit function.
504  /// @param transposeDescriptor - TransposeDescriptor to configure the transpose.
505  /// @param name - Optional name for the layer.
506  virtual void VisitTransposeLayer(const IConnectableLayer* layer,
507  const TransposeDescriptor& transposeDescriptor,
508  const char* name = nullptr) = 0;
509 
510  virtual void StartVisit() {}
511  virtual void FinishVisit() {}
512 
513 };
const armnnSerializer::Pooling2dDescriptor * Pooling2dDescriptor
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:277
#define ARMNN_DEPRECATED_MSG_REMOVAL_DATE(message, removed_in_release)
Definition: Deprecated.hpp:44
SoftmaxDescriptor LogSoftmaxDescriptor
A LogSoftmaxDescriptor for the LogSoftmaxLayer.
SpaceToDepthDescriptor DepthToSpaceDescriptor
A DepthToSpaceDescriptor for the DepthToSpaceLayer.
const armnnSerializer::Pooling3dDescriptor * Pooling3dDescriptor

◆ ARMNN_DEPRECATED_MSG_REMOVAL_DATE() [2/2]

◆ AssignBackends() [1/3]

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

Definition at line 1034 of file Network.cpp.

References ARMNN_SCOPED_PROFILING_EVENT, AssignBackendsIConnectable(), BackendSettings::GetAvailablePreferredBackends(), Input, OptimizationResult::m_Error, ReportError(), and Undefined.

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

1039 {
1040  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AssignBackends");
1041  OptimizationResult result;
1042 
1043  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
1044  if (availablePreferredBackends.empty())
1045  {
1046  std::stringstream failureMsg;
1047  failureMsg << "No preferred backends are available";
1048  ReportError(failureMsg.str(), errMessages);
1049 
1050  result.m_Error = true;
1051  return result;
1052  }
1053 
1054  for (auto it = firstLayer; it != lastLayer; ++it)
1055  {
1056  AssignBackendsIConnectable(optNetObjPtr,
1057  *it,
1058  errMessages,
1059  result,
1060  backendSettings,
1061  availablePreferredBackends);
1062  }
1063 
1064  for (auto it = firstLayer; it != lastLayer; ++it)
1065  {
1066  auto layer = PolymorphicDowncast<Layer*>(*it);
1067 
1068  if(layer->GetType() == LayerType::Input)
1069  {
1070  BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1071  layer->SetBackendId(connectedBackendId);
1072  }
1073  }
1074 
1075  return result;
1076 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:572
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
void AssignBackendsIConnectable(OptimizedNetworkImpl *optNetObjPtr, IConnectableLayer *it, Optional< std::vector< std::string > &> errMessages, OptimizationResult &result, BackendSettings &backendSettings, std::vector< BackendId > &availablePreferredBackends)
Definition: Network.cpp:921

◆ AssignBackends() [2/3]

OptimizationResult AssignBackends ( OptimizedNetworkImpl optNetObjPtr,
BackendSettings backendSettings,
SubgraphView::IConnectableLayerIterator firstLayer,
SubgraphView::IConnectableLayerIterator lastLayer,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 1078 of file Network.cpp.

References ARMNN_SCOPED_PROFILING_EVENT, AssignBackendsIConnectable(), BackendSettings::GetAvailablePreferredBackends(), Input, OptimizationResult::m_Error, ReportError(), and Undefined.

1083 {
1084  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AssignBackends");
1085  OptimizationResult result;
1086 
1087  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
1088  if (availablePreferredBackends.empty())
1089  {
1090  std::stringstream failureMsg;
1091  failureMsg << "No preferred backends are available";
1092  ReportError(failureMsg.str(), errMessages);
1093 
1094  result.m_Error = true;
1095  return result;
1096  }
1097 
1098  for (auto it = firstLayer; it != lastLayer; ++it)
1099  {
1100  AssignBackendsIConnectable(optNetObjPtr,
1101  *it,
1102  errMessages,
1103  result,
1104  backendSettings,
1105  availablePreferredBackends);
1106  }
1107 
1108  for (auto it = firstLayer; it != lastLayer; ++it)
1109  {
1110  auto layer = PolymorphicDowncast<Layer*>(*it);
1111 
1112  if(layer->GetType() == LayerType::Input)
1113  {
1114  BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1115  layer->SetBackendId(connectedBackendId);
1116  }
1117  }
1118 
1119  return result;
1120 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:572
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
void AssignBackendsIConnectable(OptimizedNetworkImpl *optNetObjPtr, IConnectableLayer *it, Optional< std::vector< std::string > &> errMessages, OptimizationResult &result, BackendSettings &backendSettings, std::vector< BackendId > &availablePreferredBackends)
Definition: Network.cpp:921

◆ AssignBackends() [3/3]

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

Definition at line 1122 of file Network.cpp.

References AssignBackends(), SubgraphView::beginIConnectable(), and SubgraphView::endIConnectable().

1126 {
1127  SubgraphView::IConnectableLayerIterator firstLayer = subgraph.beginIConnectable();
1128  SubgraphView::IConnectableLayerIterator lastLayer = subgraph.endIConnectable();
1129  return AssignBackends(optNetObjPtr,
1130  backendSettings,
1131  firstLayer,
1132  lastLayer,
1133  errMessages);
1134 }
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:1122

◆ AssignBackendsIConnectable()

void armnn::AssignBackendsIConnectable ( OptimizedNetworkImpl optNetObjPtr,
IConnectableLayer it,
Optional< std::vector< std::string > &>  errMessages,
OptimizationResult result,
BackendSettings backendSettings,
std::vector< BackendId > &  availablePreferredBackends 
)

Definition at line 921 of file Network.cpp.

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

Referenced by AssignBackends().

927 {
928  auto ReturnError = [&](const Layer* layer)
929  {
930  return ReturnWithError(result, layer, backendSettings, errMessages);
931  };
932 
933  auto layer = PolymorphicDowncast<Layer*>(it);
934 
935  if (layer->GetType() == LayerType::Input)
936  {
937  return;
938  }
939 
940  DataType dataTypeIn = layer->GetNumInputSlots() == 0 ? DataType::Float32 :
941  layer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo().GetDataType();
942  DataType dataTypeOut = layer->GetNumOutputSlots() == 0 ? DataType::Float32 :
943  layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
944 
945  std::string reasonIfUnsupported;
946  bool found = false;
947  if (!CheckScaleSetOnQuantizedType(layer, errMessages))
948  {
949  // don't bomb immediately, find all the quantized outputs
950  // which haven't had a scale set and report them all back.
951  result.m_Error = true;
952  }
953 
954  // First try assign layer to hint backend
955  if (layer->GetBackendHint().has_value() &&
956  backendSettings.IsBackendSupported(layer->GetBackendHint().value()) &&
957  AttemptBackendAssignment(backendSettings,
958  optNetObjPtr->GetGraph(),
959  layer,
960  layer->GetBackendHint().value(),
961  dataTypeIn,
962  dataTypeOut,
963  availablePreferredBackends,
964  reasonIfUnsupported,
965  errMessages).IsOk())
966  {
967  found = true;
968  backendSettings.m_SelectedBackends.insert(layer->GetBackendHint().value());
969  }
970  else
971  {
972  // Try assign layer to prefered list of backends
973  for (const auto& backend : availablePreferredBackends)
974  {
975  if (layer->GetBackendHint().has_value() &&
976  layer->GetBackendHint().value() == backend)
977  {
978  continue; //Don't re-test the backend hint
979  }
980 
981  OptimizationResult res = AttemptBackendAssignment(backendSettings,
982  optNetObjPtr->GetGraph(),
983  layer,
984  backend,
985  dataTypeIn,
986  dataTypeOut,
987  availablePreferredBackends,
988  reasonIfUnsupported,
989  errMessages);
990 
991  if (res.IsOk())
992  {
993  found = true;
994  backendSettings.m_SelectedBackends.insert(backend);
995  break;
996  }
997  else if (res.IsError())
998  {
999  result = res; // Cannot continue.
1000  // Note: we don't need to log the error as it would already
1001  // be logged in AttemptBackendAssignment().
1002  }
1003  else
1004  {
1005  ARMNN_ASSERT_MSG(res.IsWarningOnly(), "OptimizationResult in unexpected state.");
1006  }
1007  }
1008  }
1009 
1010  // If the layer is unsupported by any devices, log and return a null network.
1011  if (!found)
1012  {
1013  // NOTE: if the layer is not an operation queue type AND we have not got CpuRef as a
1014  // fallback we should set the compute device on the layer to CpuRef (these are not
1015  // available as accelerated operations, or are only available under certain
1016  // conditions, currently they comprise MemCopy, Constant, Permute)
1017  armnn::LayerType layerType = layer->GetType();
1018  if (!backendSettings.IsCpuRefUsed() && (layerType == armnn::LayerType::MemCopy ||
1019  layerType == armnn::LayerType::Constant ||
1020  layerType == armnn::LayerType::Permute))
1021  {
1022  BackendId cpuBackendId(armnn::Compute::CpuRef);
1023  layer->SetBackendId(cpuBackendId);
1024  backendSettings.m_SelectedBackends.insert(cpuBackendId);
1025  }
1026  else
1027  {
1028  result = ReturnError(layer);
1029  }
1030  }
1031 
1032 }
CPU Execution: Reference C++ kernels.
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:596
DataType
Definition: Types.hpp:35
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:611
OptimizationResult AttemptBackendAssignment(BackendSettings &backendSettings, Graph &graph, Layer *layer, BackendId backend, DataType dataTypeIn, DataType dataTypeOut, const std::vector< BackendId > &availablePreferredBackends, std::string &reasonIfUnsupported, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:670
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ AssignSplitId()

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

Definition at line 309 of file SubgraphViewSelector.cpp.

References ForEachLayerInput().

Referenced by SubgraphViewSelector::SelectSubgraphs().

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

◆ AttemptBackendAssignment()

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

Definition at line 670 of file Network.cpp.

References BFloat16, Constant, ConvertBf16ToFp32, FloatingPointConverter::ConvertFloat16To32(), ConvertFp16ToFp32, ConvertFp32ToBf16, ConvertFp32ToFp16, Convolution2d, Float16, Float32, FullyConnected, BackendId::Get(), Layer::GetBackendId(), GetDataTypeName(), Layer::GetInputSlots(), GetLayerTypeAsCString(), Layer::GetOutputSlot(), Layer::GetType(), info, InsertConvertBf16ToFp32LayersBefore(), InsertConvertFp16ToFp32LayersBefore(), InsertConvertFp32ToBf16LayersAfter(), InsertConvertFp32ToFp16LayersAfter(), IWorkloadFactory::IsLayerSupported(), ConstantLayer::m_LayerOutput, ReportWarning(), ReturnWithError(), Layer::SetBackendId(), and OutputSlot::SetTensorInfo().

Referenced by AssignBackendsIConnectable().

679 {
680  OptimizationResult result;
681 
682  // Helper lambda to compose meaningful error message before returning with error
683  auto ReturnError = [&](const Layer* layer)
684  {
685  return ReturnWithError(result, layer, backendSettings, errMessages);
686  };
687 
688  // need to set the compute device on the layer
689  // before we can check if it is supported
690  layer->SetBackendId(backend);
691  if (!IWorkloadFactory::IsLayerSupported(*layer, EmptyOptional(), reasonIfUnsupported))
692  {
693  if (dataTypeIn == DataType::Float16 || dataTypeOut == DataType::Float16)
694  {
695  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
696  && layer->GetType() != LayerType::ConvertFp32ToFp16
697  && layer->GetType() != LayerType::ConvertFp16ToFp32)
698  {
699  auto ConstantLayerFromFp16ToFp32 = [](Layer& layer)
700  {
701  if (layer.GetType() == LayerType::Constant)
702  {
703  ConstantLayer* constantLayer = PolymorphicDowncast<ConstantLayer*>(&layer);
704 
705  auto& info = constantLayer->m_LayerOutput->GetTensorInfo();
706 
707  if (info.GetDataType() == DataType::Float16)
708  {
709  std::vector<float> newValues(info.GetNumElements());
710 
712  constantLayer->m_LayerOutput->GetConstTensor<Half>(),
713  info.GetNumElements(),
714  newValues.data());
715 
716  TensorInfo newInfo(info);
717  newInfo.SetDataType(DataType::Float32);
718  ConstTensor newInput(newInfo, newValues);
719  constantLayer->m_LayerOutput.reset(new ScopedTensorHandle(newInput));
720 
721  layer.GetOutputSlot(0).SetTensorInfo(newInfo);
722  }
723  }
724  };
725 
726  bool checkType = false;
727 
728  for (auto inputSlot : layer->GetInputSlots())
729  {
730  auto connectedOutputSlot = inputSlot.GetConnectedOutputSlot();
731  if (connectedOutputSlot->GetOwningLayer().GetType() == LayerType::Constant)
732  {
733  if (connectedOutputSlot->GetNumConnections() == 1)
734  {
735  checkType = true;
736  ConstantLayerFromFp16ToFp32(connectedOutputSlot->GetOwningLayer());
737  }
738  }
739  }
740 
741  // Insert FP16 -> FP32 conversion layer before current layer
742  std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
743  if (dataTypeIn == DataType::Float16)
744  {
745  convertFp16ToFp32Layers =
746  InsertConvertFp16ToFp32LayersBefore(graph, *layer, checkType);
747  }
748 
749  // Insert FP32 -> FP16 conversion layer after current layer
750  std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
751  if (dataTypeOut == DataType::Float16)
752  {
753  convertFp32ToFp16Layers =
754  InsertConvertFp32ToFp16LayersAfter(graph, *layer);
755  }
756 
757  // Assign a supported backend to the newly introduced conversion layers
758  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
759  {
760  bool supportedBackendFound = false;
761  std::string reasonIfUnsupported;
762 
763  // Try preferred backend first
764  layer->SetBackendId(preferredBackend);
765  if (IWorkloadFactory::IsLayerSupported(*layer,
766  EmptyOptional(),
767  reasonIfUnsupported))
768  {
769  supportedBackendFound = true;
770  }
771  else
772  {
773  for (const auto& backend : availablePreferredBackends)
774  {
775  // Skip preferred backend (we already determined that it is not supported)
776  if (backend == preferredBackend)
777  {
778  continue;
779  }
780 
781  layer->SetBackendId(backend);
782  if (IWorkloadFactory::IsLayerSupported(*layer,
783  EmptyOptional(),
784  reasonIfUnsupported))
785  {
786  supportedBackendFound = true;
787  break;
788  }
789  }
790  }
791 
792  return supportedBackendFound;
793  };
794 
795  for (ConvertFp16ToFp32Layer* convertLayer : convertFp16ToFp32Layers)
796  {
797  if (!AssignFirstSupportedBackend(convertLayer, backend))
798  {
799  return ReturnError(convertLayer);
800  }
801  }
802 
803  for (ConvertFp32ToFp16Layer* convertLayer : convertFp32ToFp16Layers)
804  {
805  if (!AssignFirstSupportedBackend(convertLayer, backend))
806  {
807  return ReturnError(convertLayer);
808  }
809  }
810 
811  return result;
812  }
813  }
814  else if (dataTypeIn == DataType::BFloat16 || dataTypeOut == DataType::BFloat16)
815  {
816  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
817  && layer->GetType() != LayerType::ConvertFp32ToBf16
818  && layer->GetType() != LayerType::ConvertBf16ToFp32)
819  {
820  // Insert BF16 -> FP32 conversion layer before current layer
821  std::vector<ConvertBf16ToFp32Layer*> convertBf16ToFp32Layers;
822  if (dataTypeIn == DataType::BFloat16)
823  {
824  convertBf16ToFp32Layers =
826  if (layer->GetType() == LayerType::Convolution2d)
827  {
828  ConvertBf16ToFp32Weight<Convolution2dLayer>(layer);
829  }
830  else if (layer->GetType() == LayerType::FullyConnected)
831  {
832  ConvertBf16ToFp32Weight<FullyConnectedLayer>(layer);
833  }
834  }
835 
836  // Insert FP32 -> BF16 conversion layer after current layer
837  std::vector<ConvertFp32ToBf16Layer*> convertFp32ToBf16Layers;
838  if (dataTypeOut == DataType::BFloat16)
839  {
840  convertFp32ToBf16Layers =
841  InsertConvertFp32ToBf16LayersAfter(graph, *layer);
842  }
843 
844  // Assign a supported backend to the newly introduced conversion layers
845  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
846  {
847  bool supportedBackendFound = false;
848  std::string reasonIfUnsupported;
849 
850  // Try preferred backend first
851  layer->SetBackendId(preferredBackend);
852  if (IWorkloadFactory::IsLayerSupported(*layer,
853  EmptyOptional(),
854  reasonIfUnsupported))
855  {
856  supportedBackendFound = true;
857  }
858  else
859  {
860  for (const auto& backend : availablePreferredBackends)
861  {
862  // Skip preferred backend (we already determined that it is not supported)
863  if (backend == preferredBackend)
864  {
865  continue;
866  }
867 
868  layer->SetBackendId(backend);
869  if (IWorkloadFactory::IsLayerSupported(*layer,
870  EmptyOptional(),
871  reasonIfUnsupported))
872  {
873  supportedBackendFound = true;
874  break;
875  }
876  }
877  }
878 
879  return supportedBackendFound;
880  };
881 
882  for (ConvertBf16ToFp32Layer* convertLayer : convertBf16ToFp32Layers)
883  {
884  if (!AssignFirstSupportedBackend(convertLayer, backend))
885  {
886  return ReturnError(convertLayer);
887  }
888  }
889 
890  for (ConvertFp32ToBf16Layer* convertLayer : convertFp32ToBf16Layers)
891  {
892  if (!AssignFirstSupportedBackend(convertLayer, backend))
893  {
894  return ReturnError(convertLayer);
895  }
896  }
897 
898  return result;
899  }
900  }
901 
902  std::stringstream warningMsg;
903  warningMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
904  << " is not supported on requested backend " << layer->GetBackendId().Get()
905  << " for input data type " << GetDataTypeName(dataTypeIn)
906  << " and output data type " << GetDataTypeName(dataTypeOut)
907  << " (reason: " << reasonIfUnsupported
908  << "), falling back to the next backend.";
909  ReportWarning(warningMsg.str(), errMessages);
910 
911  return OptimizationResult(true, false);
912  }
913  else
914  {
915  return result;
916  }
917 }
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:596
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:202
std::vector< ConvertBf16ToFp32Layer * > InsertConvertBf16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
std::vector< ConvertFp32ToBf16Layer * > InsertConvertFp32ToBf16LayersAfter(Graph &graph, Layer &layer)
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > &> warningMessages)
Definition: Network.cpp:584
half_float::half Half
Definition: Half.hpp:18
const char * GetLayerTypeAsCString(LayerType type)
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > *pBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.

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

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

◆ BatchToSpaceNd()

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

Definition at line 35 of file BatchToSpaceNd.cpp.

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

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

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

◆ CalcLevel()

int armnn::CalcLevel ( const Event eventPtr)

Definition at line 246 of file Profiling.cpp.

References Event::GetParentEvent().

Referenced by ProfilerImpl::AnalyzeEventsAndWriteResults(), and ProfilerImpl::PopulateParent().

247 {
248  int level = 0;
249  while (eventPtr != nullptr)
250  {
251  eventPtr = eventPtr->GetParentEvent();
252  level++;
253  }
254  return level;
255 }

◆ CalculateEdgeStrategy()

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

Definition at line 1522 of file Network.cpp.

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

Referenced by SelectTensorHandleStrategy().

1528 {
1529  auto toBackend = backends.find(connectedLayer.GetBackendId());
1530  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
1531 
1532  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1533 
1534  // Legacy API check for backward compatibility
1535  if (srcFactoryId == ITensorHandleFactory::LegacyFactoryId || dstPrefs.empty())
1536  {
1537  if (layer.GetBackendId() != connectedLayer.GetBackendId())
1538  {
1539  return EdgeStrategy::CopyToTarget;
1540  }
1541  else
1542  {
1543  return EdgeStrategy::DirectCompatibility;
1544  }
1545  }
1546 
1547  // TensorHandleFactory API present, so perform more sophisticated strategies.
1548  // Dst Output layers don't require copy because they use import or map/unmap
1549  if (connectedLayer.GetType() == LayerType::Output)
1550  {
1551  return EdgeStrategy::DirectCompatibility;
1552  }
1553 
1554  // Search for direct match in prefs
1555  for (auto&& pref : dstPrefs)
1556  {
1557  if (pref == srcFactoryId)
1558  {
1559  return EdgeStrategy::DirectCompatibility;
1560  }
1561  }
1562 
1563  // Search for export/import options
1564  ITensorHandleFactory* srcFactory = registry.GetFactory(srcFactoryId);
1565  if (srcFactory->GetExportFlags() != 0 && importEnabled)
1566  {
1567  for (auto&& pref : dstPrefs)
1568  {
1569  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1570 
1571  // Handles cases when a destPref is not listed in TensorHandleFactoryRegistry
1572  if (!dstFactory) {
1573  continue;
1574  }
1575  if ((dstFactory->GetImportFlags() & srcFactory->GetExportFlags()) != 0)
1576  {
1577  auto srcCapability = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::PaddingRequired);
1578  auto dstCapability = dstFactory->GetCapabilities(&connectedLayer,
1579  &connectedLayer,
1580  CapabilityClass::PaddingRequired);
1581  auto srcFallback = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1582  auto dstFallback = dstFactory->GetCapabilities(&connectedLayer,
1583  &connectedLayer,
1584  CapabilityClass::FallbackImportDisabled);
1585  // Do not require memory copy if the source and destination do not require padding.
1586  if (srcCapability.empty() && dstCapability.empty() && srcFallback.empty() && dstFallback.empty())
1587  {
1588  return EdgeStrategy::ExportToTarget;
1589  }
1590  }
1591  }
1592  }
1593 
1594  // Search for copy options via map/unmap
1595  if (srcFactory->SupportsMapUnmap())
1596  {
1597  for (auto&& pref : dstPrefs)
1598  {
1599  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1600  if (dstFactory && dstFactory->SupportsMapUnmap())
1601  {
1602  return EdgeStrategy::CopyToTarget;
1603  }
1604  }
1605  }
1606 
1607  return EdgeStrategy::Undefined;
1608 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ CalculateSlotOption()

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

Definition at line 1372 of file Network.cpp.

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

Referenced by SelectTensorHandleStrategy().

1376 {
1377  // First ensure the from backends can support the TensorHandeAPI
1378  Layer& layer = outputSlot.GetOwningLayer();
1379  auto frmBackend = backends.find(layer.GetBackendId());
1380  if (frmBackend == backends.end() ||
1381  !frmBackend->second->SupportsTensorAllocatorAPI())
1382  {
1383  return ITensorHandleFactory::LegacyFactoryId;
1384  }
1385 
1386  bool outputConnection = false;
1387  for (auto&& connection : outputSlot.GetConnections())
1388  {
1389  const Layer& connectedLayer = connection->GetOwningLayer();
1390  if (connectedLayer.GetType() == LayerType::Output)
1391  {
1392  outputConnection = true;
1393  }
1394  }
1395 
1396  IBackendInternal* srcBackend = frmBackend->second.get();
1397  auto srcPrefs = srcBackend->GetHandleFactoryPreferences();
1398 
1399  // Initialize the scores
1400  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1401  for (auto&& pref : srcPrefs)
1402  {
1403  if (importEnabled)
1404  {
1405  ITensorHandleFactory* factory = registry.GetFactory(pref);
1406  if (outputConnection)
1407  {
1408  // Check if this is fallback case
1409  bool fallbackConnection = false;
1410  for (auto&& inputSlot : layer.GetInputSlots())
1411  {
1412  if (inputSlot.GetConnectedOutputSlot()->GetOwningLayer().GetBackendId() != layer.GetBackendId())
1413  {
1414  fallbackConnection = true;
1415  }
1416  }
1417  if (fallbackConnection)
1418  {
1419  auto factoryCap = factory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1420  // Cannot use factory import if fallback import is not supported.
1421  if (!factoryCap.empty())
1422  {
1423  continue;
1424  }
1425  }
1426  else if (factory->GetExportFlags() == 0)
1427  {
1428  continue;
1429  }
1430  }
1431  if (!outputConnection)
1432  {
1433  auto factoryCap = factory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1434  // Cannot use factory import if fallback import is not supported.
1435  if (!factoryCap.empty())
1436  {
1437  continue;
1438  }
1439  }
1440 
1441  }
1442  else
1443  {
1444  // Only consider factories that support map/unmap
1445  ITensorHandleFactory* factory = registry.GetFactory(pref);
1446  if (!factory->SupportsMapUnmap())
1447  {
1448  // The current tensor handle factory does not support the map/unmap strategy, move to the next one
1449  continue;
1450  }
1451  }
1452 
1453 
1454  auto it = factoryScores.find(pref);
1455  if (it == factoryScores.end())
1456  {
1457  // Add new score to the table
1458  factoryScores[pref] = 0;
1459  }
1460  }
1461 
1462  // Score each handle factory based on how many times it requires copies on the slot connections
1463  for (auto&& connection : outputSlot.GetConnections())
1464  {
1465  const Layer& connectedLayer = connection->GetOwningLayer();
1466 
1467  auto toBackend = backends.find(connectedLayer.GetBackendId());
1468  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
1469 
1470  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1471  for (auto&& src : srcPrefs)
1472  {
1473  if (factoryScores.find(src) == factoryScores.end()) // Don't consider excluded factories
1474  {
1475  continue;
1476  }
1477 
1478  for (auto&& dst : dstPrefs)
1479  {
1480  if (RequiresCopy(src, dst, registry))
1481  {
1482  // Copy avoided, increase the score
1483  factoryScores[src]++;
1484  break;
1485  }
1486  }
1487  }
1488  }
1489 
1490  // Find the lowest score
1491  int minScore = std::numeric_limits<int>::max();
1492  for (auto it : factoryScores)
1493  {
1494  minScore = std::min(minScore, it.second);
1495  }
1496 
1497  // Collect factories matching the best(lowest) score
1498  std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
1499  for (auto it : factoryScores)
1500  {
1501  if (it.second == minScore)
1502  {
1503  optimalFactories.push_back(it.first);
1504  }
1505  }
1506 
1507  // For all compatible Factories matching the best score, find the preferred one for the current layer.
1508  for (auto&& srcPref : srcPrefs)
1509  {
1510  for (auto&& comp : optimalFactories)
1511  {
1512  if (comp == srcPref)
1513  {
1514  return comp;
1515  }
1516  }
1517  }
1518 
1519  return ITensorHandleFactory::LegacyFactoryId;
1520 }
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:1257
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ CalculateSlotOptionForInput()

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

Definition at line 1277 of file Network.cpp.

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

Referenced by SelectTensorHandleStrategy().

1281 {
1282  Layer& layer = slot.GetOwningLayer();
1283  ARMNN_ASSERT(layer.GetType() == LayerType::Input);
1284 
1285  // Explicitly select the tensorhandle factory for InputLayer because the rules for it are slightly different. It
1286  // doesn't matter which backend it is assigned to because they all use the same implementation, which
1287  // requires Map/Unmap support. This means that, so long as the handle type supports map/unmap semantics, we can
1288  // select a factory with maximum compatibility with the layers connected to the InputLayer.
1289 
1290  // First ensure the from backends can support the TensorHandeAPI
1291  auto frmBackend = backends.find(layer.GetBackendId());
1292  if (frmBackend == backends.end() ||
1293  !frmBackend->second->SupportsTensorAllocatorAPI())
1294  {
1295  return ITensorHandleFactory::LegacyFactoryId;
1296  }
1297 
1298  // Go through all connections to the output slot and determine the TensorHandleFactory which results in the
1299  // fewest copies.
1300  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1301  int topScore = 0;
1302  ITensorHandleFactory::FactoryId topChoice = ITensorHandleFactory::LegacyFactoryId;
1303 
1304  for (auto&& connection : slot.GetConnections())
1305  {
1306 
1307  const Layer& connectedLayer = connection->GetOwningLayer();
1308 
1309  auto toBackend = backends.find(connectedLayer.GetBackendId());
1310  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
1311 
1312  if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
1313  {
1314  // The destination backend does not support the tensor allocator API, move to the next one
1315  continue;
1316  }
1317 
1318  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1319  for (auto&& dst : dstPrefs)
1320  {
1321  // Input layers use the mem copy workload or import, so the selected factory must
1322  // support either the map/unmap API or Import API
1323  ITensorHandleFactory* factory = registry.GetFactory(dst);
1324  if (importEnabled && factory->GetImportFlags() == 0)
1325  {
1326  continue;
1327  }
1328  else if (!importEnabled && !factory->SupportsMapUnmap())
1329  {
1330  continue;
1331  }
1332 
1333  auto it = factoryScores.find(dst);
1334  if (it == factoryScores.end())
1335  {
1336  // Add new score to the table
1337  factoryScores[dst] = 0;
1338  if (topChoice == ITensorHandleFactory::LegacyFactoryId)
1339  {
1340  topChoice = dst;
1341  }
1342  }
1343  else
1344  {
1345  // Increase the score
1346  factoryScores[dst]++;
1347 
1348  // Track the best option
1349  if (factoryScores[dst] > topScore)
1350  {
1351  topScore = factoryScores[dst];
1352  topChoice = dst;
1353  }
1354  }
1355  }
1356  }
1357 
1358  return topChoice;
1359 }
ITensorHandleFactory::FactoryId FactoryId
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ CalculateSlotOptionForOutput()

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

Definition at line 1362 of file Network.cpp.

References ITensorHandleFactory::DeferredFactoryId, and IgnoreUnused().

Referenced by SelectTensorHandleStrategy().

1365 {
1366  IgnoreUnused(backends, slot, registry);
1367  return ITensorHandleFactory::DeferredFactoryId;
1368 }
void IgnoreUnused(Ts &&...)

◆ ChainReduceLayers()

std::vector<IConnectableLayer*> armnn::ChainReduceLayers ( OptimizationViews optimizationViews,
LayerType baseLayer,
ReduceDescriptor desc 
)

Definition at line 326 of file ArmComputeSubgraphUtils.hpp.

References ARMNN_ASSERT, ComputeReductionTensorShape(), OptimizationViews::GetINetwork(), Layer::GetInputSlot(), Layer::GetOutputSlot(), ReduceDescriptor::m_KeepDims, ReduceDescriptor::m_vAxis, and OutputSlot::SetTensorInfo().

329 {
330  // Vector of new chained layers, used for substitution.
331  std::vector<IConnectableLayer*> layers;
332 
333  // Vector of axes so each layer is reshaped correctly.
334  std::vector<uint32_t> axes;
335  unsigned int recalulatedAxis = 0;
336 
337  for (unsigned int i = 0; i != desc.m_vAxis.size(); ++i)
338  {
339  // Get TensorInfo from base layer and reduce shape using axis.
340  TensorInfo layerInfo = baseLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo();
341 
342  axes.emplace_back(desc.m_vAxis[i]);
343 
344  const TensorInfo& reducedTensorInfo = ComputeReductionTensorShape(layerInfo,
345  axes,
346  desc.m_KeepDims);
347 
348  // Create a vector for the single axis to be assigned to the descriptor.
349  // Update axis if keepDims is set reduce layers correctly.
350  std::vector<uint32_t> singleAxis(1, desc.m_vAxis[i] - recalulatedAxis);
351 
352  // Create a descriptor and assign single axis.
353  ReduceDescriptor newReduceDescriptor = baseLayer->GetParameters();
354  newReduceDescriptor.m_vAxis.assign(singleAxis.begin(), singleAxis.end());
355 
356  // Add new layer to graph.
357  std::string layerName = "reduce_layer_" + std::to_string(i);
358 
359  Layer* replacementLayer = PolymorphicDowncast<Layer*>(
360  optimizationViews.GetINetwork()->AddReduceLayer(newReduceDescriptor,
361  layerName.c_str()));
362 
363  // Connect previous layer with new layer.
364  // The first and last layer will be connected when the subgraph is replaced.
365  if (!layers.empty())
366  {
367  layers[i - 1]->GetOutputSlot(0).Connect(replacementLayer->GetInputSlot(0));
368  }
369 
370  // Set updated tensorInfo for new layer.
371  replacementLayer->GetOutputSlot(0).SetTensorInfo(reducedTensorInfo);
372 
373  if (!desc.m_KeepDims)
374  {
375  recalulatedAxis++;
376  }
377 
378  layers.emplace_back(replacementLayer);
379  }
380 
381  // Check if the TensorInfo from the last layer equals the inferred output from the original layer.
382  ARMNN_ASSERT(baseLayer->GetOutputSlot(0).GetTensorInfo() ==
383  PolymorphicDowncast<Layer*>(layers.back())->GetOutputSlot().GetTensorInfo());
384 
385  return layers;
386 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const TensorInfo ComputeReductionTensorShape(const armnn::TensorInfo &input, const std::vector< uint32_t > &vAxis, const bool keepDims)
Function to compute the output tensor shape based on the axes and if keepDims is set.

◆ CheckFlag()

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

Definition at line 41 of file MemorySources.hpp.

Referenced by LoadedNetwork::EnqueueWorkload(), LoadedNetwork::FreeWorkingMemory(), LoadedNetwork::ImportInputs(), and LoadedNetwork::ImportOutputs().

42 {
43  return (static_cast<MemorySourceFlags>(source) & flags) != 0;
44 }

◆ CheckLayerBindingId()

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

Definition at line 13 of file TestInputOutputLayerVisitor.hpp.

Referenced by TestInputLayerVisitor::ExecuteStrategy(), and TestOutputLayerVisitor::ExecuteStrategy().

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

◆ CheckScaleSetOnQuantizedType()

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

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

612 {
613  bool noErrors = true;
614  unsigned int numOutputs = layer->GetNumOutputSlots();
615  for (unsigned int i = 0; i < numOutputs; i++) {
616  OutputSlot& outputSlot = layer->GetOutputSlot(i);
617  TensorInfo info = outputSlot.GetTensorInfo();
618  if (DataType::QAsymmU8 == info.GetDataType()) {
619  if (0.f == info.GetQuantizationScale()) {
620  noErrors = false;
621  std::stringstream ss;
622  ss << "output " << i << " of layer " << GetLayerTypeAsCString(layer->GetType())
623  << " (" << layer->GetNameStr() << ") is of type"
624  << " Quantized 8 bit but its scale parameter has not been set";
625  ReportError(ss.str(), errMessages);
626  }
627  // Softmax under QuantisedAsymm8 must always be scale (1.0f/256.0f) and offset 0
628  if ((info.GetQuantizationScale() != (1.0f / 256.0f) ||
629  info.GetQuantizationOffset() != 0) &&
630  layer->GetType() == armnn::LayerType::Softmax)
631  {
632  std::stringstream ss;
633  ss << "Quantization parameters for Softmax layer (Scale: " <<
634  info.GetQuantizationScale() << " and Offset: " << info.GetQuantizationOffset() <<
635  ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
636  ARMNN_LOG(warning) << ss.str();
637  info.SetQuantizationScale((1.0f /256.0f));
638  info.SetQuantizationOffset(0);
639  outputSlot.SetTensorInfo(info);
640  }
641  }
642  }
643  return noErrors;
644 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:572
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205
const char * GetLayerTypeAsCString(LayerType type)

◆ CheckSupportRule()

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

Definition at line 38 of file LayerSupportRules.hpp.

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

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

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

◆ ClAbsWorkloadValidate()

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

Definition at line 19 of file ClAbsWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

◆ ClActivationWorkloadValidate()

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

Definition at line 17 of file ClActivationWorkload.cpp.

Referenced by ClLayerSupport::IsActivationSupported().

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

◆ ClAdditionValidate()

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

Definition at line 45 of file ClAdditionWorkload.cpp.

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

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

◆ ClArgMinMaxWorkloadValidate()

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

Definition at line 31 of file ClArgMinMaxWorkload.cpp.

Referenced by ClLayerSupport::IsArgMinMaxSupported().

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

◆ ClBackendId()

constexpr const char* armnn::ClBackendId ( )

Definition at line 10 of file ClBackendId.hpp.

Referenced by ClBackend::GetIdStatic().

10 { return "GpuAcc"; }

◆ ClBatchNormalizationValidate()

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

Definition at line 19 of file ClBatchNormalizationFloatWorkload.cpp.

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

27 {
28  const arm_compute::TensorInfo aclInputInfo =
29  armcomputetensorutils::BuildArmComputeTensorInfo(input, 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  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
42  activationDescriptor);
43 
44  return arm_compute::CLBatchNormalizationLayer::validate(&aclInputInfo,
45  &aclOutputInfo,
46  &aclMeanInfo,
47  &aclVarInfo,
48  &aclBetaInfo,
49  &aclGammaInfo,
50  descriptor.m_Eps,
51  activationInfo);
52 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClBatchToSpaceNdWorkloadValidate()

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

Definition at line 57 of file ClBatchToSpaceNdWorkload.cpp.

References BatchToSpaceNdDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsBatchToSpaceNdSupported().

60 {
61  DataLayout dataLayout = descriptor.m_DataLayout;
62  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
63 
64  // ArmNN blockShape is [H, W] Cl asks for W, H
65  int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
66  int32_t blockWidth = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[1]);
67 
68  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
69 
70  const arm_compute::Status aclStatus = arm_compute::CLBatchToSpaceLayer::validate(&aclInputInfo,
71  blockWidth,
72  blockHeight,
73  &aclOutputInfo);
74  return aclStatus;
75 }
DataLayout
Definition: Types.hpp:49
Status
enumeration
Definition: Types.hpp:29
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClCastValidate()

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

Definition at line 20 of file ClCastWorkload.cpp.

Referenced by ClLayerSupport::IsCastSupported().

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

◆ ClChannelShuffleValidate()

arm_compute::Status ClChannelShuffleValidate ( const TensorInfo input,
const TensorInfo output,
const ChannelShuffleDescriptor descriptor 
)

Definition at line 20 of file ClChannelShuffleWorkload.cpp.

Referenced by ClLayerSupport::IsChannelShuffleSupported().

23 {
24  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
25  arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
26 
27  // In Arm NN and in NNAPI, channel shuffle implementation is datalayout agnostic and it has axis as a parameter.
28  // The channel shuffle Implementation for Neon is dependent on datalayout and does not have axis as a parameter,
29  // it only supports channel shuffle for 4D tensors in dimension C (1 or 3).
30  arm_compute::DataLayout aclDataLayout;
31  if (input.GetNumDimensions() == 4)
32  {
33  switch (descriptor.m_Axis)
34  {
35  case 1:
36  aclDataLayout = ConvertDataLayout(armnn::DataLayout::NCHW);
37  break;
38  case 3:
39  aclDataLayout = ConvertDataLayout(armnn::DataLayout::NHWC);
40  break;
41  default:
42  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported axis"};
43  }
44  aclInputInfo.set_data_layout(aclDataLayout);
45  aclOutputInfo.set_data_layout(aclDataLayout);
46  return arm_compute::CLChannelShuffleLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_NumGroups);
47  }
48  else
49  {
50  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported number of dimensions"};
51  }
52 }
DataLayout
Definition: Types.hpp:49
Status
enumeration
Definition: Types.hpp:29

◆ ClComparisonWorkloadValidate()

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

Definition at line 24 of file ClComparisonWorkload.cpp.

Referenced by ClLayerSupport::IsComparisonSupported().

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

◆ ClConcatWorkloadValidate()

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

Definition at line 27 of file ClConcatWorkload.cpp.

Referenced by ClLayerSupport::IsConcatSupported().

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

◆ ClConstantWorkloadValidate()

arm_compute::Status ClConstantWorkloadValidate ( const TensorInfo output)

Definition at line 18 of file ClConstantWorkload.cpp.

Referenced by ClLayerSupport::IsConstantSupported().

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

◆ ClContextBufferHasIdentifier()

bool armnn::ClContextBufferHasIdentifier ( const void *  buf)
inline

Definition at line 152 of file ClContextSchema_generated.h.

References ClContextIdentifier().

152  {
153  return flatbuffers::BufferHasIdentifier(
154  buf, ClContextIdentifier());
155 }
const char * ClContextIdentifier()

◆ ClContextExtension()

const char* armnn::ClContextExtension ( )
inline

Definition at line 167 of file ClContextSchema_generated.h.

167  {
168  return "armnn";
169 }

◆ ClContextIdentifier()

const char* armnn::ClContextIdentifier ( )
inline

◆ ClConvertFp16ToFp32WorkloadValidate()

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

Definition at line 44 of file ClConvertFp16ToFp32Workload.cpp.

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

Referenced by ClLayerSupport::IsConvertFp16ToFp32Supported(), and ClConvertFp16ToFp32Workload::SupportsTensorHandleReplacement().

45 {
46  if (input.GetDataType() != DataType::Float16)
47  {
48  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Input should be Float16");
49  }
50  if (output.GetDataType() != DataType::Float32)
51  {
52  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Output should be Float32");
53  }
54 
55  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
56  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
57 
58  const arm_compute::Status aclStatus = arm_compute::CLDepthConvertLayer::validate(
59  &aclInputInfo, &aclOutputInfo, g_AclConvertPolicy, 0);
60 
61  return aclStatus;
62 }
Status
enumeration
Definition: Types.hpp:29

◆ ClConvertFp32ToFp16WorkloadValidate()

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

Definition at line 44 of file ClConvertFp32ToFp16Workload.cpp.

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

Referenced by ClLayerSupport::IsConvertFp32ToFp16Supported(), and ClConvertFp32ToFp16Workload::SupportsTensorHandleReplacement().

45 {
46  if (input.GetDataType() != DataType::Float32)
47  {
48  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Input should be Float32");
49  }
50  if (output.GetDataType() != DataType::Float16)
51  {
52  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Output should be Float16");
53  }
54 
55  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
56  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
57 
58  const arm_compute::Status aclStatus = arm_compute::CLDepthConvertLayer::validate(
59  &aclInputInfo, &aclOutputInfo, g_AclConvertPolicy, 0);
60 
61  return aclStatus;
62 }
Status
enumeration
Definition: Types.hpp:29

◆ ClConvolution2dWorkloadValidate()

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

Definition at line 23 of file ClConvolution2dWorkload.cpp.

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

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

◆ ClConvolution3dWorkloadValidate()

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

Definition at line 23 of file ClConvolution3dWorkload.cpp.

Referenced by ClLayerSupport::IsConvolution3dSupported().

30 {
31  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
32  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
33 
34  arm_compute::TensorInfo aclBiasesInfo;
35  arm_compute::TensorInfo* optionalAclBiasesInfo = nullptr;
36  if (descriptor.m_BiasEnabled)
37  {
38  ARMNN_ASSERT(biases.has_value());
39  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
40  optionalAclBiasesInfo = &aclBiasesInfo;
41  }
42 
43  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
44 
45  const arm_compute::Conv3dInfo aclConv3DInfo = ComputeConv3DInfo(descriptor,
46  isFastMathEnabled,
47  activationDescriptor);
48 
49  return arm_compute::CLConv3D::validate(&aclInputInfo,
50  &aclWeightsInfo,
51  optionalAclBiasesInfo,
52  &aclOutputInfo,
53  aclConv3DInfo);
54 }
arm_compute::Conv3dInfo ComputeConv3DInfo(const armnn::Convolution3dDescriptor descriptor, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
Utility function used to setup an arm_compute::Conv3dInfo object from convolution3d descriptor...
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ClDepthToSpaceWorkloadValidate()

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

Definition at line 22 of file ClDepthToSpaceWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsDepthToSpaceSupported().

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

◆ ClDepthwiseConvolutionWorkloadValidate()

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

Definition at line 26 of file ClDepthwiseConvolutionWorkload.cpp.

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

32 {
33  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
34  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
35 
36  // ArmNN's weight format is usually [ M, I, H, W ] but for depthwise its [ 1, H, W, I*M]
37  // Permute to [ 1, I * M, H, W ] (if NCHW) as required by the compute library
38  unsigned int aclDepthMultiplier;
39  TensorInfo weightsPermuted;
40  std::tie(weightsPermuted, aclDepthMultiplier) = Convert1HWOTensorInfoToAcl(weights, input,descriptor.m_DataLayout);
41 
42  // Convert the weights into the compute library format
43  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weightsPermuted, descriptor.m_DataLayout);
44 
45  arm_compute::TensorInfo aclBiasesInfo;
46  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
47 
48  if (descriptor.m_BiasEnabled)
49  {
50  ARMNN_ASSERT(biases.has_value());
51 
52  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
53  optionalAclBiasesInfo = &aclBiasesInfo;
54  }
55 
56  const arm_compute::PadStrideInfo aclPadStrideInfo = BuildArmComputePadStrideInfo(descriptor);
57  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
58  descriptor.m_DilationX,
59  descriptor.m_DilationY);
60 
61  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
62  activationDescriptor);
63 
64  return arm_compute::CLDepthwiseConvolutionLayer::validate(&aclInputInfo,
65  &aclWeightsInfo,
66  optionalAclBiasesInfo,
67  &aclOutputInfo,
68  aclPadStrideInfo,
69  aclDepthMultiplier,
70  activationInfo,
71  aclDilationInfo);
72 
73 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::tuple< TensorInfo, unsigned int > Convert1HWOTensorInfoToAcl(const TensorInfo &weightInfo, const TensorInfo &inputInfo, const DataLayout dataLayout)
Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a TensorInfo...
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ ClDequantizeWorkloadValidate()

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

Definition at line 22 of file ClDequantizeWorkload.cpp.

Referenced by ClLayerSupport::IsDequantizeSupported().

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

◆ ClDivisionWorkloadValidate()

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

Definition at line 18 of file ClDivisionWorkload.cpp.

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

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

◆ ClExpWorkloadValidate()

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

Definition at line 18 of file ClExpWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

◆ ClFloorWorkloadValidate()

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

Definition at line 14 of file ClFloorFloatWorkload.cpp.

Referenced by ClLayerSupport::IsFloorSupported().

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

◆ ClFullyConnectedWorkloadValidate()

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

Definition at line 19 of file ClFullyConnectedWorkload.cpp.

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

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

◆ ClGatherWorkloadValidate()

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

Definition at line 15 of file ClGatherWorkload.cpp.

Referenced by ClLayerSupport::IsGatherSupported().

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

◆ ClImportTensorHandleFactoryId()

constexpr const char* armnn::ClImportTensorHandleFactoryId ( )

Definition at line 15 of file ClImportTensorHandleFactory.hpp.

Referenced by ClImportTensorHandleFactory::GetIdStatic().

16 {
17  return "Arm/Cl/ImportTensorHandleFactory";
18 }

◆ ClInstanceNormalizationWorkloadValidate()

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

Definition at line 18 of file ClInstanceNormalizationWorkload.cpp.

Referenced by ClLayerSupport::IsInstanceNormalizationSupported().

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

◆ ClL2NormalizationWorkloadValidate()

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

Definition at line 17 of file ClL2NormalizationFloatWorkload.cpp.

Referenced by ClLayerSupport::IsL2NormalizationSupported().

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

◆ ClLogicalAndWorkloadValidate()

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

Definition at line 20 of file ClLogicalAndWorkload.cpp.

Referenced by ClLayerSupport::IsLogicalBinarySupported().

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

◆ ClLogicalNotWorkloadValidate()

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

Definition at line 20 of file ClLogicalNotWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

◆ ClLogicalOrWorkloadValidate()

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

Definition at line 20 of file ClLogicalOrWorkload.cpp.

Referenced by ClLayerSupport::IsLogicalBinarySupported().

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

◆ ClLogSoftmaxWorkloadValidate()

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

Definition at line 17 of file ClLogSoftmaxWorkload.cpp.

Referenced by ClLayerSupport::IsLogSoftmaxSupported().

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

◆ ClLogWorkloadValidate()

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

Definition at line 18 of file ClLogWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

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

Referenced by ClLayerSupport::IsLstmSupported().

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

◆ ClMaximumWorkloadValidate()

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

Definition at line 24 of file ClMaximumWorkload.cpp.

Referenced by ClLayerSupport::IsMaximumSupported().

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

◆ ClMeanValidate()

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

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  descriptor.m_Axis);
27 
28  return arm_compute::CLReduceMean::validate(&aclInputInfo, coords, descriptor.m_KeepDims, &aclOutputInfo);
29 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ ClMinimumWorkloadValidate()

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

Definition at line 24 of file ClMinimumWorkload.cpp.

Referenced by ClLayerSupport::IsMinimumSupported().

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

◆ ClMultiplicationWorkloadValidate()

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

Definition at line 18 of file ClMultiplicationWorkload.cpp.

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

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

◆ ClNegWorkloadValidate()

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

Definition at line 18 of file ClNegWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

◆ ClNormalizationWorkloadValidate()

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

Definition at line 19 of file ClNormalizationFloatWorkload.cpp.

Referenced by ClLayerSupport::IsNormalizationSupported().

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

◆ ClPadValidate()

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

Definition at line 62 of file ClPadWorkload.cpp.

Referenced by ClLayerSupport::IsPadSupported().

65 {
66  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
67  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
68 
69  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
70 
71  std::reverse_copy(std::begin(descriptor.m_PadList),
72  std::end(descriptor.m_PadList),
73  std::begin(reversed_PadList));
74 
75  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
76 
77  // PixelValue is currently unused when validating, but it's required to pass in PaddingMode.
78  arm_compute::PixelValue pixelValue = GetPixelValue(&aclInputInfo, descriptor.m_PadValue);
79  const arm_compute::Status aclStatus =
80  arm_compute::CLPadLayer::validate(&aclInputInfo,
81  &aclOutputInfo,
82  padList,
83  pixelValue,
84  ConvertPaddingModeToAcl(descriptor.m_PaddingMode));
85 
86  return aclStatus;
87 }
Status
enumeration
Definition: Types.hpp:29
arm_compute::PaddingMode ConvertPaddingModeToAcl(const PaddingMode &paddingMode)

◆ ClPermuteWorkloadValidate()

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

Definition at line 17 of file ClPermuteWorkload.cpp.

Referenced by ClLayerSupport::IsPermuteSupported().

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

◆ ClPooling2dWorkloadValidate()

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

Definition at line 18 of file ClPooling2dWorkload.cpp.

Referenced by ClLayerSupport::IsPooling2dSupported().

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

◆ ClPreluWorkloadValidate()

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

Definition at line 16 of file ClPreluWorkload.cpp.

Referenced by ClLayerSupport::IsPreluSupported().

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

◆ ClQLstmWorkloadValidate()

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

Definition at line 247 of file ClQLstmWorkload.cpp.

Referenced by ClLayerSupport::IsQLstmSupported().

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

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

◆ ClReduceWorkloadValidate()

arm_compute::Status ClReduceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ReduceDescriptor descriptor 
)

Definition at line 18 of file ClReduceWorkload.cpp.

References ReduceDescriptor::m_vAxis.

Referenced by ClLayerSupport::IsReduceSupported().

21 {
22  if (descriptor.m_vAxis.size() == 1 || descriptor.m_vAxis.empty())
23  {
24  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
25  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
26 
27  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
28  input.GetNumDimensions(),
29  descriptor.m_vAxis);
30 
31  return arm_compute::CLReductionOperation::validate(&aclInputInfo,
32  &aclOutputInfo,
33  static_cast<unsigned int>(coords[0]),
35  descriptor.m_KeepDims);
36  }
37  else
38  {
39  // Validate layer if there are multiple axes.
40  arm_compute::Status status;
41  IS_MULTI_AXES_REDUCE_SUPPORTED(ClReduceWorkloadValidate, input, descriptor, status);
42  return status;
43  }
44 }
#define IS_MULTI_AXES_REDUCE_SUPPORTED(func, input, desc, status)
Macro function check if layer with multiple axes is supported on each backend.
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
arm_compute::ReductionOperation ConvertReductionOperationToAcl(const ReduceDescriptor &descriptor)
Status
enumeration
Definition: Types.hpp:29
arm_compute::Status ClReduceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const ReduceDescriptor &descriptor)

◆ ClReshapeWorkloadValidate()

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

Definition at line 15 of file ClReshapeWorkload.cpp.

Referenced by ClLayerSupport::IsReshapeSupported().

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

◆ ClResizeWorkloadValidate()

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

Definition at line 22 of file ClResizeWorkload.cpp.

Referenced by ClLayerSupport::IsResizeSupported().

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

◆ ClRsqrtWorkloadValidate()

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

Definition at line 18 of file ClRsqrtWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

◆ ClSinWorkloadValidate()

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

Definition at line 18 of file ClSinWorkload.cpp.

Referenced by ClLayerSupport::IsElementwiseUnarySupported().

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

◆ ClSliceWorkloadValidate()

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

Definition at line 18 of file ClSliceWorkload.cpp.

Referenced by ClLayerSupport::IsSliceSupported().

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

◆ ClSoftmaxWorkloadValidate()

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

Definition at line 17 of file ClSoftmaxWorkload.cpp.

Referenced by ClLayerSupport::IsSoftmaxSupported().

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

◆ ClSpaceToBatchNdWorkloadValidate()

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

Definition at line 23 of file ClSpaceToBatchNdWorkload.cpp.

Referenced by ClLayerSupport::IsSpaceToBatchNdSupported().

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

◆ ClSpaceToDepthWorkloadValidate()

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

Definition at line 54 of file ClSpaceToDepthWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by ClLayerSupport::IsSpaceToDepthSupported().

57 {
58  DataLayout dataLayout = descriptor.m_DataLayout;
59  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
60 
61  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize);
62 
63  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
64 
65  const arm_compute::Status aclStatus = arm_compute::CLSpaceToDepthLayer::validate(&aclInputInfo,
66  &aclOutputInfo,
67  blockSize);
68  return aclStatus;
69 }
DataLayout
Definition: Types.hpp:49
Status
enumeration
Definition: Types.hpp:29
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ ClSplitterWorkloadValidate()

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

Definition at line 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 29 of file ClStackWorkload.cpp.

Referenced by ClLayerSupport::IsStackSupported().

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

◆ ClStridedSliceWorkloadValidate()

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

Definition at line 27 of file ClStridedSliceWorkload.cpp.

Referenced by ClLayerSupport::IsStridedSliceSupported().

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

◆ ClSubtractionValidate()

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

Definition at line 46 of file ClSubtractionWorkload.cpp.

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

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

◆ ClTensorHandleFactoryId()

constexpr const char* armnn::ClTensorHandleFactoryId ( )

Definition at line 15 of file ClTensorHandleFactory.hpp.

Referenced by ClTensorHandleFactory::GetIdStatic().

16 {
17  return "Arm/Cl/TensorHandleFactory";
18 }

◆ ClTransposeConvolution2dWorkloadValidate()

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

Definition at line 26 of file ClTransposeConvolution2dWorkload.cpp.

Referenced by ClLayerSupport::IsTransposeConvolution2dSupported().

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

◆ ClTransposeWorkloadValidate()

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

Definition at line 17 of file ClTransposeWorkload.cpp.

Referenced by ClLayerSupport::IsTransposeSupported().

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

◆ Combine() [1/2]

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

Definition at line 30 of file MemorySources.hpp.

Referenced by Combine().

31 {
32  return static_cast<MemorySourceFlags>(sourceA) | static_cast<MemorySourceFlags>(sourceB);
33 }
unsigned int MemorySourceFlags

◆ Combine() [2/2]

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

Definition at line 36 of file MemorySources.hpp.

References Combine().

37 {
38  return static_cast<MemorySourceFlags>(source) | Combine(rest...);
39 }
MemorySourceFlags Combine(Arg source, Args... rest)
unsigned int MemorySourceFlags

◆ ComputeAclAxis()

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

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

Definition at line 240 of file ArmComputeUtils.hpp.

References ARMNN_ASSERT, and TensorInfo::GetNumDimensions().

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

241 {
242  int rank = static_cast<int>(tensor.GetNumDimensions());
243 
244  ARMNN_ASSERT(rank != 0);
245  ARMNN_ASSERT((-1 * rank) <= armnnAxis);
246  ARMNN_ASSERT(armnnAxis < rank);
247 
248  int sign = (armnnAxis < 0) ? -1 : 1;
249  int aclAxis = sign * rank - 1 - armnnAxis;
250 
251  return aclAxis;
252 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195

◆ ComputeConv3DInfo() [1/2]

arm_compute::Conv3dInfo armnn::ComputeConv3DInfo ( const armnn::Convolution3dDescriptor  descriptor,
bool  isFastMathEnabled,
const ActivationDescriptor activationDescriptor 
)
inline

Utility function used to setup an arm_compute::Conv3dInfo object from convolution3d descriptor.

Definition at line 269 of file ArmComputeUtils.hpp.

References ConvertActivationDescriptorToAclActivationLayerInfo(), Convolution3dDescriptor::m_DilationX, Convolution3dDescriptor::m_DilationY, Convolution3dDescriptor::m_DilationZ, Convolution3dDescriptor::m_PadBack, Convolution3dDescriptor::m_PadBottom, Convolution3dDescriptor::m_PadFront, Convolution3dDescriptor::m_PadLeft, Convolution3dDescriptor::m_PadRight, Convolution3dDescriptor::m_PadTop, Convolution3dDescriptor::m_StrideX, Convolution3dDescriptor::m_StrideY, and Convolution3dDescriptor::m_StrideZ.

272 {
273  const arm_compute::Size3D stride{descriptor.m_StrideX, descriptor.m_StrideY, descriptor.m_StrideZ};
274  const arm_compute::Padding3D padding{descriptor.m_PadLeft, descriptor.m_PadRight,
275  descriptor.m_PadTop, descriptor.m_PadBottom,
276  descriptor.m_PadFront, descriptor.m_PadBack};
277  const arm_compute::Size3D dilation{descriptor.m_DilationX, descriptor.m_DilationY, descriptor.m_DilationZ};
278 
279  const arm_compute::ActivationLayerInfo activationInfo =
281  const auto roundType = arm_compute::DimensionRoundingType::FLOOR;
282 
283  return arm_compute::Conv3dInfo{stride, padding, activationInfo, dilation, roundType, isFastMathEnabled};
284 }
uint32_t m_PadBack
Padding back value in the depth dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_PadRight
Padding right value in the width dimension.
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor *activationDescPtr)
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_DilationZ
Dilation along z axis.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
uint32_t m_DilationY
Dilation along y axis.

◆ ComputeConv3DInfo() [2/2]

arm_compute::Conv3dInfo armnn::ComputeConv3DInfo ( const armnn::Convolution3dQueueDescriptor  queueDescriptor,
bool  isFastMathEnabled 
)
inline

Definition at line 286 of file ArmComputeUtils.hpp.

References ConvertAdditionalInfoToAclActivationLayerInfo(), QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Convolution3dDescriptor::m_StrideX.

288 {
289  auto descriptor = queueDescriptor.m_Parameters;
290  const arm_compute::Size3D stride{descriptor.m_StrideX, descriptor.m_StrideY, descriptor.m_StrideZ};
291  const arm_compute::Padding3D padding{descriptor.m_PadLeft, descriptor.m_PadRight,
292  descriptor.m_PadTop, descriptor.m_PadBottom,
293  descriptor.m_PadFront, descriptor.m_PadBack};
294  const arm_compute::Size3D dilation{descriptor.m_DilationX, descriptor.m_DilationY, descriptor.m_DilationZ};
295 
296  const arm_compute::ActivationLayerInfo activationInfo =
298  const auto roundType = arm_compute::DimensionRoundingType::FLOOR;
299 
300  return arm_compute::Conv3dInfo{stride, padding, activationInfo, dilation, roundType, isFastMathEnabled};
301 }
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)

◆ ComputePositiveAxis()

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

Function to convert axis to its positive equivalent value.

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

Definition at line 256 of file ArmComputeUtils.hpp.

References ARMNN_ASSERT, and TensorInfo::GetNumDimensions().

257 {
258  int rank = static_cast<int>(tensor.GetNumDimensions());
259 
260  ARMNN_ASSERT(rank != 0);
261  ARMNN_ASSERT((-1 * rank) <= axis);
262  ARMNN_ASSERT(axis < rank);
263 
264  int positiveAxis = (axis < 0) ? rank + axis : axis;
265  return static_cast<unsigned int>(positiveAxis);
266 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195

◆ ComputeReductionTensorShape()

const TensorInfo armnn::ComputeReductionTensorShape ( const armnn::TensorInfo input,
const std::vector< uint32_t > &  vAxis,
const bool  keepDims 
)
inline

Function to compute the output tensor shape based on the axes and if keepDims is set.

Definition at line 328 of file ArmComputeUtils.hpp.

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

Referenced by ChainReduceLayers().

331 {
332  auto reducedTensorInfo = input;
333  unsigned int rank = reducedTensorInfo.GetNumDimensions();
334  unsigned int outputRank = 0;
335  // Calculate output dimension
336  if (keepDims)
337  {
338  outputRank = rank;
339  }
340  else if (vAxis.empty())
341  {
342  outputRank = 1;
343  }
344  else if (vAxis.size() > reducedTensorInfo.GetNumDimensions())
345  {
346  throw LayerValidationException("ReduceLayer: Dimensions to reduce can not be bigger than input dimensions");
347  }
348  else
349  {
350  outputRank = reducedTensorInfo.GetNumDimensions() - armnn::numeric_cast<unsigned int>(vAxis.size());
351  if (outputRank == 0)
352  {
353  outputRank = 1;
354  }
355  }
356  std::vector<unsigned int> dimSizes(outputRank, 1);
357  if (!vAxis.empty())
358  {
359  // Skip the dimension that has been reduced unless keepDims is true.
360  unsigned int outputIndex = 0;
361  for (unsigned int i = 0; i < reducedTensorInfo.GetNumDimensions(); ++i)
362  {
363  if (std::find(vAxis.begin(), vAxis.end(), i) == vAxis.end())
364  {
365  dimSizes[outputIndex] = armnn::numeric_cast<unsigned int>(reducedTensorInfo.GetShape()[i]);
366  ++outputIndex;
367  }
368  else if (keepDims)
369  {
370  dimSizes[outputIndex] = 1;
371  ++outputIndex;
372  }
373  }
374  }
375  const TensorShape inferredShape = TensorShape(outputRank, dimSizes.data());
376  reducedTensorInfo.SetShape(inferredShape);
377  return reducedTensorInfo;
378 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195

◆ ComputeSoftmaxAclAxis()

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

Definition at line 201 of file ArmComputeUtils.hpp.

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

202 {
203  // Detect the Android default value of -1 and return the ACL default value of 0.
204  if (softmaxDesc.m_Axis == -1)
205  {
206  return 0;
207  }
208 
209  unsigned int dim = tensor.GetNumDimensions();
210 
211  ARMNN_ASSERT(dim != 0);
212 
213  // Currently ArmNN support axis 1.
214  auto aclAxis = (static_cast<T>(dim) - 1);
215  aclAxis = aclAxis > 0 ? aclAxis -1 : aclAxis;
216 
217  return aclAxis;
218 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195

◆ ComputeSplitAxis()

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

Definition at line 220 of file ArmComputeUtils.hpp.

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

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

221 {
222  unsigned int numSplit = desc.GetNumViews();
223  unsigned int numDimensions = desc.GetNumDimensions();
224  std::set<unsigned int> splitAxis;
225 
226  for (unsigned int i = 0; i < numSplit; ++i)
227  {
228  for (unsigned int dimIdx = 0; dimIdx < numDimensions; ++dimIdx)
229  {
230  if (desc.GetViewSizes(i)[dimIdx] != input[dimIdx])
231  {
232  splitAxis.insert(dimIdx);
233  }
234  }
235  }
236  return splitAxis;
237 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
uint32_t GetNumViews() const
Get the number of views.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.

◆ Concatenate()

void Concatenate ( const ConcatQueueDescriptor data,
std::vector< ITensorHandle *>  inputs,
std::vector< ITensorHandle *>  outputs 
)

Definition at line 14 of file Concatenate.cpp.

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

Referenced by RefConcatWorkload::ExecuteAsync().

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

◆ ConditionalThrow() [1/2]

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

Definition at line 171 of file Exceptions.hpp.

172 {
173  if (!condition)
174  {
175  throw ExceptionType(message);
176  }
177 }

◆ ConditionalThrow() [2/2]

void armnn::ConditionalThrow ( bool  condition)

Definition at line 180 of file Exceptions.hpp.

181 {
182  if (!condition)
183  {
184  throw ExceptionType();
185  }
186 }

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

198 {
199  if (!(leftHandSide == rightHandSide))
200  {
201  std::stringstream ss;
202  ss << message << " : " << leftHandSide << " != " << rightHandSide;
203  throw ExceptionType(ss.str());
204  }
205 }

◆ ConfigureDetailsObject()

void armnn::ConfigureDetailsObject ( JsonChildObject detailsObject,
std::string  layerDetailsStr 
)

Definition at line 295 of file Profiling.cpp.

References ExecObjectDesc, JsonChildObject::SetAndParseDetails(), and JsonChildObject::SetType().

297 {
298  detailsObject.SetType(JsonObjectType::ExecObjectDesc);
299  detailsObject.SetAndParseDetails(layerDetailsStr);
300 
301 }

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

Examples:
AsyncExecutionSample.cpp, CustomMemoryAllocatorSample.cpp, and SimpleSample.cpp.

Definition at line 18 of file Utils.cpp.

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

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

19 {
20  SetAllLoggingSinks(printToStandardOutput, printToDebugOutput, false);
21  SetLogFilter(severity);
22 }
void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured)
Definition: Logging.cpp:191
void SetLogFilter(LogSeverity level)
Definition: Logging.cpp:73

◆ ConfigureTuner()

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

Definition at line 115 of file ClBackendContext.cpp.

References ARMNN_LOG, Exhaustive, info, None, Normal, and Rapid.

Referenced by ClBackendContext::ClBackendContext().

116 {
117  tuner.set_tune_new_kernels(true); // Turn on tuning initially.
118 
119  switch (level)
120  {
121  case TuningLevel::Rapid:
122  ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Rapid (1)";
123  tuner.set_tuner_mode(arm_compute::CLTunerMode::RAPID);
124  break;
125  case TuningLevel::Normal:
126  ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Normal (2)";
127  tuner.set_tuner_mode(arm_compute::CLTunerMode::NORMAL);
128  break;
129  case TuningLevel::Exhaustive:
130  ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Exhaustive (3)";
131  tuner.set_tuner_mode(arm_compute::CLTunerMode::EXHAUSTIVE);
132  break;
133  case TuningLevel::None:
134  default:
135  tuner.set_tune_new_kernels(false); // Turn off tuning. Set to "use" only mode.
136  break;
137  }
138 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205

◆ Convert1HWOTensorInfoToAcl()

std::tuple< TensorInfo, unsigned int > Convert1HWOTensorInfoToAcl ( const TensorInfo weightInfo,
const TensorInfo inputInfo,
const DataLayout  dataLayout 
)

Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a TensorInfo from [1,H,W,I*M] to [1,I*M,H,W] (if NCHW) or keeps it at [1,H,W,I*M] (if NHWC) as required by the compute library Returns a tuple of converted weights tensor info and depth multiplier.

Definition at line 169 of file WorkloadUtils.cpp.

References GetDataLayoutName(), TensorInfo::GetShape(), NCHW, NHWC, and armnnUtils::Permuted().

Referenced by GatherTensorHandlePairs().

172 {
173  unsigned int aclDepthMultiplier = 1;
174  TensorInfo weightsPermuted;
175  if (dataLayout == armnn::DataLayout::NHWC)
176  {
177  // No permutation required. Data layouts are the same.
178  aclDepthMultiplier = weightInfo.GetShape()[3] / inputInfo.GetShape()[3];
179  weightsPermuted = weightInfo;
180  }
181  else if (dataLayout == armnn::DataLayout::NCHW)
182  {
183  // [ 1, H, W, I*M] --> [ 1, I * M, H, W ]
184  aclDepthMultiplier = weightInfo.GetShape()[3] / inputInfo.GetShape()[1];
185  PermutationVector permutationVector{ 0, 2, 3, 1 };
186  weightsPermuted = armnnUtils::Permuted(weightInfo, permutationVector);
187  }
188  else
189  {
190  throw InvalidArgumentException(fmt::format("Unknown data layout for tensor info conversion: {}",
191  GetDataLayoutName(dataLayout)));
192  }
193 
194  return std::make_tuple(weightsPermuted, aclDepthMultiplier);
195 }
constexpr const char * GetDataLayoutName(DataLayout dataLayout)
Definition: TypesUtils.hpp:222
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98

◆ Convert1HWOTensorToAcl()

std::tuple< ConstTensor, unsigned int > Convert1HWOTensorToAcl ( const ConstTensorHandle weightTensor,
const TensorInfo inputInfo,
const DataLayout  dataLayout,
void *  permuteBuffer 
)

Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a ConstCpuTensorHandle from [1,H,W,I*M] to [1,I*M,H,W] (if NCHW) or keeps it at [1,H,W,I*M] (if NHWC) as required by the compute library.

Parameters
weightTensor- ConstTensorHandle of weights tensor
inputInfo- TensorInfo of input tensor
dataLayout- DataLayout of the input tensor
permuteBuffer- Pointer to memory with the size of tensor. Used for the permutation
Returns
tuple of transformed weights-ConstTensor and depthwise multiplier

Definition at line 138 of file WorkloadUtils.cpp.

References GetDataLayoutName(), TensorInfo::GetShape(), ConstTensorHandle::GetTensorInfo(), NCHW, NHWC, and PermuteTensor().

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

142 {
143  TensorInfo weightsInfo = weightTensor->GetTensorInfo();
144  unsigned int depthMultiplier = 1;
145  PermutationVector permutationVector{};
146  if (dataLayout == armnn::DataLayout::NHWC)
147  {
148  // No permutation required. Data layouts are the same.
149 
150  depthMultiplier = weightsInfo.GetShape()[3] / inputInfo.GetShape()[3];
151  }
152  else if (dataLayout == armnn::DataLayout::NCHW)
153  {
154  // [ 1, H, W, I*M] --> [ 1, I * M, H, W ]
155  depthMultiplier = weightsInfo.GetShape()[3] / inputInfo.GetShape()[1];
156  permutationVector = { 0, 2, 3, 1 };
157  }
158  else
159  {
160  throw InvalidArgumentException(fmt::format("Unknown data layout for tensor conversion: {}",
161  GetDataLayoutName(dataLayout)));
162  }
163 
164  ConstTensor weightsPermuted = PermuteTensor(weightTensor, permutationVector, permuteBuffer);
165 
166  return std::make_tuple(weightsPermuted, depthMultiplier);
167 }
armnn::ConstTensor PermuteTensor(const ConstTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
constexpr const char * GetDataLayoutName(DataLayout dataLayout)
Definition: TypesUtils.hpp:222

◆ Convert1HWOtoMIHW()

std::tuple< ConstTensor, unsigned int > Convert1HWOtoMIHW ( const ConstTensorHandle weightTensor,
const TensorInfo inputInfo,
const DataLayout dataLayout,
void *  permuteBuffer 
)

Converts a (weights) tensor from [1, H, W, I*M] = [1, H, W, O] to [M, I, H, W].

Parameters
weightTensor- ConstTensorHandle of the weight tensor that should be converted
inputInfo- TensorInfo of the corresponding input tensor
dataLayout- DataLayout of the input tensor e.g. NHWC or NCHW
permuteBuffer- Memory location with the same size as the weight tensor to write converted data to
Returns
- A tuple of ConstTensor and unsigned int which is the converted weightTensor and the depthMultiplier

Definition at line 198 of file WorkloadUtils.cpp.

References DataLayoutIndexed::GetChannelsIndex(), TensorInfo::GetShape(), ConstTensorHandle::GetTensorInfo(), TensorInfo::HasPerAxisQuantization(), PermuteTensor(), and TensorInfo::SetShape().

Referenced by GatherTensorHandlePairs().

202 {
203  TensorInfo weightsInfo = weightTensor->GetTensorInfo();
204 
205  if (weightsInfo.HasPerAxisQuantization())
206  {
207  throw InvalidArgumentException("Can't convert tensor from [1,H,W,Cout] to [M,Cin,H,W] when per channel "
208  "quantization is applied.");
209  }
210 
211  // Reshape weights [ 1, H, W, I*M ] --> [ H, W, I, M ]
212  auto weightsShape = weightsInfo.GetShape();
213  auto channelIndex = armnnUtils::DataLayoutIndexed(dataLayout).GetChannelsIndex();
214  unsigned int depthMultiplier = weightsShape[3] / inputInfo.GetShape()[channelIndex];
215  weightsInfo.SetShape({ weightsShape[1],
216  weightsShape[2],
217  inputInfo.GetShape()[channelIndex],
218  depthMultiplier});
219 
220  // Permute [ H, W, I, M ] --> [ M, I, H, W ]
221  PermutationVector permutationVector = { 2, 3, 1, 0 };
222  ConstTensor weightsPermuted = PermuteTensor(weightTensor, permutationVector, permuteBuffer);
223 
224  return std::make_tuple(weightsPermuted, depthMultiplier);
225 }
armnn::ConstTensor PermuteTensor(const ConstTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
unsigned int GetChannelsIndex() const

◆ ConvertActivationDescriptorToAclActivationLayerInfo() [1/2]

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

◆ ConvertActivationDescriptorToAclActivationLayerInfo() [2/2]

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

Definition at line 92 of file ArmComputeUtils.hpp.

References ConvertActivationDescriptorToAclActivationLayerInfo().

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

◆ ConvertActivationFunctionToAclActivationFunction()

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

Definition at line 61 of file ArmComputeUtils.hpp.

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

Referenced by ConvertActivationDescriptorToAclActivationLayerInfo().

62 {
63  using AclActivationFunction = arm_compute::ActivationLayerInfo::ActivationFunction;
64 
65  switch (armnnFunction)
66  {
67  case ActivationFunction::Linear: return AclActivationFunction::LINEAR;
68  // Arm compute's 'logistic' function is non-parameterized, so it is exactly a sigmoid function.
69  case ActivationFunction::Sigmoid: return AclActivationFunction::LOGISTIC;
70  case ActivationFunction::ReLu: return AclActivationFunction::RELU;
71  case ActivationFunction::BoundedReLu: return AclActivationFunction::LU_BOUNDED_RELU;
72  case ActivationFunction::SoftReLu: return AclActivationFunction::SOFT_RELU;
73  case ActivationFunction::LeakyReLu: return AclActivationFunction::LEAKY_RELU;
74  case ActivationFunction::Abs: return AclActivationFunction::ABS;
75  case ActivationFunction::Sqrt: return AclActivationFunction::SQRT;
76  case ActivationFunction::Square: return AclActivationFunction::SQUARE;
77  case ActivationFunction::TanH: return AclActivationFunction::TANH;
78  case ActivationFunction::Elu: return AclActivationFunction::ELU;
79  case ActivationFunction::HardSwish: return AclActivationFunction::HARD_SWISH;
80  default: throw InvalidArgumentException("Unsupported activation function");
81  }
82 }
ActivationFunction
Definition: Types.hpp:73

◆ ConvertAdditionalInfoToAclActivationLayerInfo()

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

Definition at line 103 of file ArmComputeUtils.hpp.

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

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

104 {
105  const ActivationDescriptor* activationDescPtr = queueDescriptor.GetAdditionalInformation<ActivationDescriptor>();
106 
107  if (activationDescPtr != nullptr)
108  {
109  return ConvertActivationDescriptorToAclActivationLayerInfo(static_cast<ActivationDescriptor>(
110  *activationDescPtr));
111  }
112  return arm_compute::ActivationLayerInfo();
113 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor *activationDescPtr)

◆ ConvertBf16ToFp32Weight()

LayerT* armnn::ConvertBf16ToFp32Weight ( Layer l)

Definition at line 647 of file Network.cpp.

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

648 {
649  LayerT* layer = PolymorphicDowncast<LayerT*>(l);
650  if ((layer->GetType() == LayerType::Convolution2d || layer->GetType() == LayerType::FullyConnected)
651  && layer->m_Weight)
652  {
653  const TensorInfo& info = layer->m_Weight->GetTensorInfo();
654 
655  if (info.GetDataType() == DataType::BFloat16)
656  {
657  std::vector<float> newValues(info.GetNumElements());
658 
660  layer->m_Weight->template GetConstTensor<armnn::BFloat16>(), info.GetNumElements(), newValues.data());
661 
662  TensorInfo newInfo(info.GetShape(), DataType::Float32);
663  ConstTensor newInput(newInfo, newValues);
664  layer->m_Weight.reset(new ScopedTensorHandle(newInput));
665  }
666  }
667  return layer;
668 }
static void ConvertBFloat16ToFloat32(const void *srcBFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > *pBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.

◆ ConvertComparisonOperationToAcl()

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

Definition at line 115 of file ArmComputeUtils.hpp.

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

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

116 {
117  switch (descriptor.m_Operation)
118  {
119  case ComparisonOperation::Greater: return arm_compute::ComparisonOperation::Greater;
120  case ComparisonOperation::GreaterOrEqual: return arm_compute::ComparisonOperation::GreaterEqual;
121  case ComparisonOperation::Less: return arm_compute::ComparisonOperation::Less;
122  case ComparisonOperation::LessOrEqual: return arm_compute::ComparisonOperation::LessEqual;
123  case ComparisonOperation::Equal: return arm_compute::ComparisonOperation::Equal;
124  case ComparisonOperation::NotEqual: return arm_compute::ComparisonOperation::NotEqual;
125  default: throw InvalidArgumentException("Unsupported comparison function");
126  }
127 }

◆ ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo() [1/2]

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

Definition at line 168 of file ArmComputeUtils.hpp.

References ConvertActivationDescriptorToAclActivationLayerInfo(), and FullyConnectedDescriptor::m_TransposeWeightMatrix.

170 {
171  arm_compute::FullyConnectedLayerInfo fc_info;
172  fc_info.transpose_weights = fullyConnectedDesc.m_TransposeWeightMatrix;
173  fc_info.activation_info = ConvertActivationDescriptorToAclActivationLayerInfo(activationDesc);
174  return fc_info;
175 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor *activationDescPtr)

◆ ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo() [2/2]

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

Definition at line 178 of file ArmComputeUtils.hpp.

References FullyConnectedDescriptor::m_TransposeWeightMatrix.

180 {
181  arm_compute::FullyConnectedLayerInfo fc_info;
182  fc_info.transpose_weights = fullyConnectedDesc.m_TransposeWeightMatrix;
183  fc_info.activation_info = activationLayerInfo;
184  return fc_info;
185 }

◆ ConvertLogSeverity()

constexpr LogSeverity armnn::ConvertLogSeverity ( BoostLogSeverityMapping  severity)

Definition at line 199 of file Logging.hpp.

200 {
201  return static_cast<LogSeverity>(severity);
202 }
LogSeverity
Definition: Utils.hpp:14

◆ ConvertMaskToACLFormat()

int32_t ConvertMaskToACLFormat ( int32_t  mask,
int32_t  numDim 
)

Definition at line 283 of file WorkloadUtils.cpp.

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

284 {
285  int32_t reversedMask = 0;
286  for (unsigned int i = 0; i < armnn::numeric_cast<unsigned int>(numDim); ++i)
287  {
288  // Check if bit set in mask for each dimension
289  int32_t bit = (mask & 1 << i) != 0;
290  // Increment the new mask with the bits reversed
291  reversedMask += (bit << std::max(numDim-(armnn::numeric_cast<int>(i)+1), 0));
292  }
293 
294  return reversedMask;
295 }

◆ ConvertNormalizationAlgorithmChannelToAclNormType()

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

Definition at line 156 of file ArmComputeUtils.hpp.

References Across, and Within.

157 {
158  using arm_compute::NormType;
159  switch (channelType)
160  {
161  case NormalizationAlgorithmChannel::Across: return NormType::CROSS_MAP;
162  case NormalizationAlgorithmChannel::Within: return NormType::IN_MAP_2D;
163  default: throw InvalidArgumentException("Unsupported normalization algorithm channel type");
164  }
165 }

◆ ConvertOutputShapeRoundingToAclDimensionRoundingType()

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

Definition at line 142 of file ArmComputeUtils.hpp.

References Ceiling, and Floor.

144 {
145  using arm_compute::DimensionRoundingType;
146 
147  switch (rounding)
148  {
149  case OutputShapeRounding::Ceiling: return DimensionRoundingType::CEIL;
150  case OutputShapeRounding::Floor: return DimensionRoundingType::FLOOR;
151  default: throw InvalidArgumentException("Unsupported Output Shape Rounding type");
152  }
153 }

◆ ConvertPaddingModeToAcl()

arm_compute::PaddingMode armnn::ConvertPaddingModeToAcl ( const PaddingMode paddingMode)
inline

Definition at line 303 of file ArmComputeUtils.hpp.

References Constant, Reflect, and Symmetric.

304 {
305  switch (paddingMode)
306  {
307  case PaddingMode::Constant: return arm_compute::PaddingMode::CONSTANT;
308  case PaddingMode::Reflect: return arm_compute::PaddingMode::REFLECT;
309  case PaddingMode::Symmetric: return arm_compute::PaddingMode::SYMMETRIC;
310  default: throw InvalidArgumentException("Unsupported Padding Mode");
311  }
312 }

◆ ConvertPoolingAlgorithmToAclPoolingType()

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

Definition at line 129 of file ArmComputeUtils.hpp.

References Average, L2, and Max.

130 {
131  using arm_compute::PoolingType;
132 
133  switch (poolingAlgorithm)
134  {
135  case PoolingAlgorithm::Max: return PoolingType::MAX;
136  case PoolingAlgorithm::Average: return PoolingType::AVG;
137  case PoolingAlgorithm::L2: return PoolingType::L2;
138  default: throw InvalidArgumentException("Unsupported pooling algorithm");
139  }
140 }

◆ ConvertReductionOperationToAcl()

arm_compute::ReductionOperation armnn::ConvertReductionOperationToAcl ( const ReduceDescriptor descriptor)
inline

Definition at line 314 of file ArmComputeUtils.hpp.

References ReduceDescriptor::m_ReduceOperation, Max, Mean, Min, Prod, and Sum.

315 {
316  switch (descriptor.m_ReduceOperation)
317  {
318  case ReduceOperation::Sum: return arm_compute::ReductionOperation::SUM;
319  case ReduceOperation::Mean: return arm_compute::ReductionOperation::MEAN_SUM;
320  case ReduceOperation::Max: return arm_compute::ReductionOperation::MAX;
321  case ReduceOperation::Min: return arm_compute::ReductionOperation::MIN;
322  case ReduceOperation::Prod: return arm_compute::ReductionOperation::PROD;
323  default: throw InvalidArgumentException("Unsupported Reduction operation");
324  }
325 }

◆ ConvertResizeMethodToAclInterpolationPolicy()

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

Definition at line 187 of file ArmComputeUtils.hpp.

References Bilinear, and NearestNeighbor.

188 {
189  switch (resizeMethod)
190  {
191  case ResizeMethod::Bilinear:
192  return arm_compute::InterpolationPolicy::BILINEAR;
193  case ResizeMethod::NearestNeighbor:
194  return arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR;
195  default:
196  throw InvalidArgumentException("Unsupported resize method");
197  }
198 }

◆ ConvertWeightTensorFromArmnnToAcl()

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

Definition at line 227 of file WorkloadUtils.cpp.

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

Referenced by GatherTensorHandlePairs().

230 {
231  ARMNN_ASSERT_MSG(weightTensor, "Invalid input tensor");
232  ARMNN_ASSERT_MSG(permuteBuffer, "Invalid permute buffer");
233 
234  auto multiplier = weightTensor->GetTensorInfo().GetShape()[0];
235  auto inputChannels = weightTensor->GetTensorInfo().GetShape()[1];
236 
237  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
238  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
239 
240  // 1. Permute the weights if necessary
241  // If the data layout is NCHW no permutation is necessary, as a reshape to [ 1, I * M, H, W ] can be better done
242  // starting from the current shape of [ M, I, H, W ]
243  // If no permutation is necessary, leave the permutation vector empty
244  PermutationVector permutationVector{};
245  if (dataLayout == DataLayout::NHWC)
246  {
247  // The data layout is NHWC, then permute the weights from [ M, I, H, W ] to [ H, W, I, M ]
248  permutationVector = { 3, 2, 0, 1 };
249  }
250  ConstTensor weightPermuted = PermuteTensor(weightTensor, permutationVector, permuteBuffer);
251 
252  // Shuffle the weights data to obtain the channel order needed used by Acl
253  if (multiplier > 1 && inputChannels > 1 && dataLayout == DataLayout::NCHW)
254  {
255  switch (weightPermuted.GetDataType())
256  {
257  case DataType::Float32:
258  weightPermuted = ReorderWeightChannelsForAcl<float>(weightPermuted, dataLayout, permuteBuffer);
259  break;
260  case DataType::Float16:
261  weightPermuted =
262  ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
263  break;
264  case DataType::QAsymmS8:
265  case DataType::QAsymmU8:
266  weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
267  break;
268  case DataType::QSymmS8:
269  weightPermuted = ReorderWeightChannelsForAcl<int8_t>(weightPermuted, dataLayout, permuteBuffer);
270  break;
271  default:
272  break;
273  }
274  }
275 
276  // 2. Reshape the weights
277  ReshapeWeightsForAcl(weightPermuted.GetInfo(), dataLayout);
278 
279  // 3. Return both the tensor and the allocated storage to ensure that the data stays alive
280  return weightPermuted;
281 }
armnn::ConstTensor PermuteTensor(const ConstTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
void ReshapeWeightsForAcl(TensorInfo &weightInfo, DataLayout dataLayout)

◆ ConvertWeightTensorInfoFromArmnnToAcl()

TensorInfo ConvertWeightTensorInfoFromArmnnToAcl ( const TensorInfo weightInfo,
DataLayout  dataLayout 
)

Definition at line 114 of file WorkloadUtils.cpp.

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

Referenced by GatherTensorHandlePairs().

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

◆ Convolve()

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

Definition at line 71 of file ConvImpl.cpp.

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

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

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

◆ Convolve3d()

void Convolve3d ( 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  paddingFront,
unsigned int  xStride,
unsigned int  yStride,
unsigned int  zStride,
unsigned int  xDilation,
unsigned int  yDilation,
unsigned int  zDilation 
)

Definition at line 11 of file Conv3dImpl.cpp.

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

Referenced by RefConvolution3dWorkload::ExecuteAsync().

29 {
30  if (biasEnabled && !pBiasDecoder)
31  {
32  throw InvalidArgumentException("Bias is enabled but the bias data is invalid");
33  }
34  const armnnUtils::DataLayoutIndexed dataLayoutIndexed(dataLayout);
35 
36  const unsigned int channelsIndex = dataLayoutIndexed.GetChannelsIndex();
37  const unsigned int heightIndex = dataLayoutIndexed.GetHeightIndex();
38  const unsigned int widthIndex = dataLayoutIndexed.GetWidthIndex();
39  const unsigned int depthIndex = dataLayoutIndexed.GetDepthIndex();
40 
41  const unsigned int inChannels = rInputShape[channelsIndex];
42  const unsigned int outChannels = rOutputShape[channelsIndex];
43 
44  const unsigned int batchSize = rOutputShape[0];
45  const unsigned int outputHeight = rOutputShape[heightIndex];
46  const unsigned int outputWidth = rOutputShape[widthIndex];
47  const unsigned int outputDepth = rOutputShape[depthIndex];
48  const unsigned int inputHeight = rInputShape[heightIndex];
49  const unsigned int inputWidth = rInputShape[widthIndex];
50  const unsigned int inputDepth = rInputShape[depthIndex];
51 
52  // Conv3d weights layout: [D,H,W,I,O]
53  const unsigned int filterDepth = rFilterShape[0];
54  const unsigned int filterHeight = rFilterShape[1];
55  const unsigned int filterWidth = rFilterShape[2];
56 
57  const std::vector<float> inputVec = rInputDecoder.DecodeTensor(rInputShape);
58  const std::vector<float> filterVec = rFilterDecoder.DecodeTensor(rFilterShape);
59 
60  const TensorShape biasShape{outChannels};
61  const std::vector<float> biasVec = biasEnabled ? pBiasDecoder->DecodeTensor(biasShape) : std::vector<float>();
62 
63  for (unsigned int batchIdx = 0; batchIdx < batchSize; batchIdx++)
64  {
65  for (unsigned int zOutput = 0; zOutput < outputDepth; zOutput++)
66  {
67  for (unsigned int xOutput = 0; xOutput < outputWidth; xOutput++)
68  {
69  for (unsigned int yOutput = 0; yOutput < outputHeight; yOutput++)
70  {
71  for (unsigned int cOutput = 0; cOutput < outChannels; cOutput++)
72  {
73  // This loop goes over each output element.
74  float sum = 0.0f;
75 
76  // Loop over each input channel.
77  for (unsigned int zFilter = 0; zFilter < filterDepth; zFilter++)
78  {
79  for (unsigned int yFilter = 0; yFilter < filterHeight; yFilter++)
80  {
81  for (unsigned int xFilter = 0; xFilter < filterWidth; xFilter++)
82  {
83  for (unsigned int cInput = 0; cInput < inChannels; cInput++)
84  {
85  // This loop goes over each input element for each output element.
86  unsigned int filterIndex = 0;
87 
88  // Conv3d weights layout: [D,H,W,I,O]
89  // Keep this implementation, as using DataLayoutIndexed::GetIndex
90  // causes large performance regression.
91  filterIndex = zFilter * filterHeight * filterWidth * inChannels * outChannels +
92  yFilter * filterWidth * inChannels * outChannels +
93  xFilter * inChannels * outChannels +
94  cInput * outChannels +
95  cOutput;
96 
97  unsigned int yInput = yOutput * yStride + yFilter * yDilation;
98  unsigned int xInput = xOutput * xStride + xFilter * xDilation;
99  unsigned int zInput = zOutput * zStride + zFilter * zDilation;
100 
101  float inputValue;
102 
103  // Check if we're in the padding.
104  if (yInput < paddingTop || yInput >= inputHeight + paddingTop ||
105  xInput < paddingLeft || xInput >= inputWidth + paddingLeft ||
106  zInput < paddingFront || zInput >= inputDepth + paddingFront)
107  {
108  inputValue = 0.0f;
109  }
110  else
111  {
112  unsigned int inputIndex = 0;
113 
114  // Keep this implementation, as using DataLayoutIndexed::GetIndex
115  // causes large performance regression.
116  if (dataLayoutIndexed.GetDataLayout() == DataLayout::NDHWC)
117  {
118  inputIndex =
119  batchIdx * inputDepth * inputHeight * inputWidth * inChannels +
120  (zInput-paddingFront) * inputHeight * inputWidth * inChannels +
121  (yInput-paddingTop) * inputWidth * inChannels +
122  (xInput-paddingLeft) * inChannels +
123  cInput;
124  }
125  else
126  {
127  // NCDHW DataLayout
128  inputIndex =
129  batchIdx * inputDepth * inputHeight * inputWidth * inChannels +
130  inputDepth * inputHeight * inputWidth * cInput +
131  (zInput-paddingFront) * inputHeight * inputWidth +
132  (yInput-paddingTop) * inputWidth +
133  xInput-paddingLeft;
134  }
135 
136  inputValue = inputVec[inputIndex];
137  }
138 
139  sum += filterVec[filterIndex] * inputValue;
140  }
141  }
142  }
143  }
144 
145  if (biasEnabled)
146  {
147  sum += biasVec[cOutput];
148  }
149 
150  unsigned int outIdx;
151  if (dataLayoutIndexed.GetDataLayout() == DataLayout::NDHWC)
152  {
153  outIdx = batchIdx * outputDepth * outputHeight * outputWidth * outChannels +
154  zOutput * outputHeight * outputWidth * outChannels +
155  yOutput * outputWidth * outChannels +
156  xOutput * outChannels +
157  cOutput;
158  }
159  else
160  {
161  // NCDHW DataLayout
162  outIdx = batchIdx * outputDepth * outputHeight * outputWidth * outChannels +
163  cOutput * outputDepth * outputHeight * outputWidth +
164  zOutput * outputHeight * outputWidth +
165  yOutput * outputWidth +
166  xOutput;
167  }
168 
169  rOutputEncoder[outIdx];
170  rOutputEncoder.Set(sum);
171  }
172  }
173  }
174  }
175  }
176 }
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, bool isDepthwise=false)=0
virtual void Set(IType right)=0
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...

◆ CopyArmComputeClTensorData()

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

Definition at line 55 of file ClWorkloadUtils.hpp.

References ARMNN_SCOPED_PROFILING_EVENT_CL.

Referenced by ClConstantWorkload::Execute().

56 {
57  {
58  ARMNN_SCOPED_PROFILING_EVENT_CL("MapClTensorForWriting");
59  dstTensor.map(true);
60  }
61 
62  {
63  ARMNN_SCOPED_PROFILING_EVENT_CL("CopyToClTensor");
64  armcomputetensorutils::CopyArmComputeITensorData<T>(srcData, dstTensor);
65  }
66 
67  dstTensor.unmap();
68 }
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)

◆ CopyArmComputeTensorData()

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

Definition at line 54 of file NeonWorkloadUtils.hpp.

Referenced by InitializeArmComputeTensorData().

55 {
56  InitialiseArmComputeTensorEmpty(dstTensor);
57  CopyArmComputeITensorData(srcData, dstTensor);
58 }

◆ CopyTensorContentsGeneric()

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

Definition at line 46 of file WorkloadUtils.hpp.

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

Referenced by CopyToOutputTensor(), NeonConvertBf16ToFp32Workload::Execute(), NeonConvertFp32ToBf16Workload::Execute(), NeonConvertFp16ToFp32Workload::Execute(), NeonConvertFp32ToFp16Workload::Execute(), CopyMemGenericWorkload::Execute(), CopyMemGenericWorkload::ExecuteAsync(), and LoadedNetwork::FreeWorkingMemory().

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

◆ CopyToOutputTensor()

void armnn::CopyToOutputTensor ( const Tensor outputTensor,
ITensorHandle outputTensorHandle 
)

Definition at line 1265 of file LoadedNetwork.cpp.

References CopyTensorContentsGeneric(), BaseTensor< MemoryType >::GetInfo(), and BaseTensor< MemoryType >::GetMemoryArea().

Referenced by LoadedNetwork::Execute().

1266 {
1267  auto copyFunc = [](void* dst, const void* src, size_t size)
1268  {
1269  memcpy(dst, src, size);
1270  };
1271 
1272  std::unique_ptr<ITensorHandle> tensorHandle =
1273  std::make_unique<PassthroughTensorHandle>(outputTensor.GetInfo(),
1274  outputTensor.GetMemoryArea());
1275 
1276  CopyTensorContentsGeneric(outputTensorHandle, tensorHandle.get(), copyFunc);
1277 }
void CopyTensorContentsGeneric(const ITensorHandle *srcTensor, ITensorHandle *dstTensor, CopyFunc copy)

◆ CreateAclNormalizationLayerInfoForL2Normalization()

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

Definition at line 28 of file ArmComputeUtils.hpp.

References TensorInfo::GetShape(), and NCHW.

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

◆ CreateClContext()

flatbuffers::Offset<ClContext> armnn::CreateClContext ( flatbuffers::FlatBufferBuilder &  _fbb,
flatbuffers::Offset< flatbuffers::Vector< flatbuffers::Offset< armnn::Program >>>  programs = 0 
)
inline

Definition at line 57 of file ClContextSchema_generated.h.

References ClContextBuilder::add_programs(), and ClContextBuilder::Finish().

Referenced by CreateClContextDirect(), and ClContextSerializer::Serialize().

59  {
60  ClContextBuilder builder_(_fbb);
61  builder_.add_programs(programs);
62  return builder_.Finish();
63 }

◆ CreateClContextDirect()

flatbuffers::Offset<ClContext> armnn::CreateClContextDirect ( flatbuffers::FlatBufferBuilder &  _fbb,
const std::vector< flatbuffers::Offset< armnn::Program >> *  programs = nullptr 
)
inline

Definition at line 65 of file ClContextSchema_generated.h.

References CreateClContext().

67  {
68  auto programs__ = programs ? _fbb.CreateVector<flatbuffers::Offset<armnn::Program>>(*programs) : 0;
70  _fbb,
71  programs__);
72 }
flatbuffers::Offset< ClContext > CreateClContext(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset< flatbuffers::Vector< flatbuffers::Offset< armnn::Program >>> programs=0)

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

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

Referenced by ConcatDifferentInputOutputQParamTest(), CreateDescriptorForConcat(), and TEST_SUITE().

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

◆ CreateProgram()

flatbuffers::Offset<Program> armnn::CreateProgram ( flatbuffers::FlatBufferBuilder &  _fbb,
flatbuffers::Offset< flatbuffers::String >  name = 0,
flatbuffers::Offset< flatbuffers::Vector< uint8_t >>  binary = 0 
)
inline

Definition at line 118 of file ClContextSchema_generated.h.

References ProgramBuilder::add_binary(), ProgramBuilder::add_name(), and ProgramBuilder::Finish().

Referenced by CreateProgramDirect(), and ClContextSerializer::Serialize().

121  {
122  ProgramBuilder builder_(_fbb);
123  builder_.add_binary(binary);
124  builder_.add_name(name);
125  return builder_.Finish();
126 }

◆ CreateProgramDirect()

flatbuffers::Offset<Program> armnn::CreateProgramDirect ( flatbuffers::FlatBufferBuilder &  _fbb,
const char *  name = nullptr,
const std::vector< uint8_t > *  binary = nullptr 
)
inline

Definition at line 128 of file ClContextSchema_generated.h.

References CreateProgram().

131  {
132  auto name__ = name ? _fbb.CreateString(name) : 0;
133  auto binary__ = binary ? _fbb.CreateVector<uint8_t>(*binary) : 0;
134  return armnn::CreateProgram(
135  _fbb,
136  name__,
137  binary__);
138 }
flatbuffers::Offset< Program > CreateProgram(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset< flatbuffers::String > name=0, flatbuffers::Offset< flatbuffers::Vector< uint8_t >> binary=0)

◆ CreateSupportedBackends()

BackendsMap CreateSupportedBackends ( TensorHandleFactoryRegistry handleFactoryRegistry,
BackendSettings backendSettings 
)

Definition at line 1136 of file Network.cpp.

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

Referenced by Optimize().

1138 {
1139  BackendsMap backends;
1140  auto const& backendRegistry = BackendRegistryInstance();
1141  for (auto&& selectedBackend : backendSettings.m_SupportedBackends)
1142  {
1143  auto backendFactory = backendRegistry.GetFactory(selectedBackend);
1144  auto backendObjPtr = backendFactory();
1145  ARMNN_ASSERT(backendObjPtr);
1146 
1147  backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
1148 
1149  backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
1150  }
1151 
1152  return backends;
1153 }
BackendRegistry & BackendRegistryInstance()
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:287

◆ 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< BFloat16 >(), Debug< float >(), Debug< Half >(), Debug< int16_t >(), Debug< int32_t >(), Debug< int8_t >(), Debug< uint8_t >(), TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), and TensorInfo::GetShape().

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

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  << static_cast<float>(*std::min_element(inputData, inputData + numElements)) << ", ";
56 
57  std::cout << "\"max\": "
58  << static_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 << static_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< BFloat16 >()

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

Referenced by Debug().

◆ Debug< float >()

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

Referenced by Debug().

◆ Debug< Half >()

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

Referenced by Debug().

◆ Debug< int16_t >()

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

Referenced by Debug().

◆ Debug< int32_t >()

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

Referenced by Debug().

◆ Debug< int8_t >()

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

Referenced by Debug().

◆ Debug< uint8_t >()

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

Referenced by Debug().

◆ DepthToSpace()

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

Definition at line 18 of file DepthToSpace.cpp.

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

Referenced by DepthToSpace(), and TEST_SUITE().

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

◆ Dequantize() [1/4]

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

Definition at line 13 of file Dequantize.cpp.

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

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

◆ Dequantize() [2/4]

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

u8 helpers

Definition at line 95 of file RefWorkloadUtils.hpp.

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

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

◆ Dequantize() [3/4]

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

Definition at line 106 of file RefWorkloadUtils.hpp.

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

107 {
108  for (unsigned int i = 0; i < info.GetNumElements(); i++)
109  {
110  outputData[i] = Dequantize<T>(inputData[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
111  }
112 }

◆ Dequantize() [4/4]

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

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

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

Definition at line 46 of file TypesUtils.cpp.

References ARMNN_ASSERT.

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

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

◆ DetectionPostProcess()

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

Definition at line 140 of file DetectionPostProcess.cpp.

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

Referenced by TEST_SUITE().

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

◆ ExtractJsonObjects()

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

Definition at line 303 of file Profiling.cpp.

References JsonChildObject::AddChild(), JsonChildObject::AddMeasurement(), ARMNN_ASSERT, Event, JsonChildObject::GetChild(), Event::GetMeasurements(), Event::GetProfilingGuid(), OptionalBase::has_value(), Measurement, JsonChildObject::NumChildren(), JsonChildObject::SetGuid(), JsonChildObject::SetType(), JsonChildObject::SetUnit(), and OptionalReferenceSwitch< IsReference, T >::value().

Referenced by ProfilerImpl::Print().

307 {
308  ARMNN_ASSERT(parentEvent);
309 
310  // If profiling GUID is entered, process it
311  if (parentEvent->GetProfilingGuid().has_value())
312  {
313  profiling::ProfilingGuid profilingGuid;
314  profilingGuid = parentEvent->GetProfilingGuid().value();
315  parentObject.SetGuid(profilingGuid);
316  }
317  std::vector<Measurement> instrumentMeasurements = parentEvent->GetMeasurements();
318  unsigned int childIdx = 0;
319  for (size_t measurementIndex = 0; measurementIndex < instrumentMeasurements.size(); ++measurementIndex, ++childIdx)
320  {
321  if (inferenceIndex == 0)
322  {
323  // Only add kernel measurement once, in case of multiple inferences
324  JsonChildObject measurementObject{ instrumentMeasurements[measurementIndex].m_Name };
325  measurementObject.SetUnit(instrumentMeasurements[measurementIndex].m_Unit);
326  measurementObject.SetType(JsonObjectType::Measurement);
327 
328  ARMNN_ASSERT(parentObject.NumChildren() == childIdx);
329  parentObject.AddChild(measurementObject);
330  }
331 
332  parentObject.GetChild(childIdx).AddMeasurement(instrumentMeasurements[measurementIndex].m_Value);
333  }
334 
335  auto childEventsIt = descendantsMap.find(parentEvent);
336  if (childEventsIt != descendantsMap.end())
337  {
338  for (auto childEvent : childEventsIt->second)
339  {
340  if (inferenceIndex == 0)
341  {
342  // Only add second level once, in case of multiple inferences
343  JsonChildObject childObject{ childEvent->GetName() };
344  childObject.SetType(JsonObjectType::Event);
345  parentObject.AddChild(childObject);
346  }
347 
348  // Recursively process children. In reality this won't be very deep recursion. ~4-6 levels deep.
349  ExtractJsonObjects(inferenceIndex, childEvent, parentObject.GetChild(childIdx), descendantsMap);
350 
351  childIdx++;
352  }
353  }
354 }
void ExtractJsonObjects(unsigned int inferenceIndex, const Event *parentEvent, JsonChildObject &parentObject, std::map< const Event *, std::vector< const Event *>> descendantsMap)
Definition: Profiling.cpp:303
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ FakeQuantization()

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

Definition at line 17 of file RefFakeQuantizationFloat32Workload.cpp.

References numeric_cast().

Referenced by TEST_SUITE().

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

◆ FalseFunc()

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

Definition at line 62 of file LayerSupportCommon.hpp.

References IgnoreUnused().

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

◆ FalseFuncF16()

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

Definition at line 70 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseFuncF32()

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

Definition at line 78 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseFuncI32()

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

Definition at line 94 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseFuncU8()

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

Definition at line 86 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseInputFuncF16()

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

Definition at line 110 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseInputFuncF32()

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

Definition at line 102 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseOutputFuncF16()

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

Definition at line 126 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ FalseOutputFuncF32()

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

Definition at line 118 of file LayerSupportCommon.hpp.

References IgnoreUnused(), and SetValueChecked().

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

◆ Fill()

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

Creates a tensor and fills it with a scalar value.

Definition at line 13 of file Fill.cpp.

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

Referenced by TEST_SUITE().

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

◆ FindKernelMeasurements()

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

Definition at line 62 of file Profiling.cpp.

References ARMNN_ASSERT, and Event::GetMeasurements().

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

◆ FindMeasurement()

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

Definition at line 43 of file Profiling.cpp.

References ARMNN_ASSERT, and Event::GetMeasurements().

Referenced by ProfilerImpl::AnalyzeEventSequenceAndWriteResults(), and ProfilerImpl::CalculateProfilingEventStats().

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

◆ FinishClContextBuffer()

void armnn::FinishClContextBuffer ( flatbuffers::FlatBufferBuilder &  fbb,
flatbuffers::Offset< armnn::ClContext >  root 
)
inline

Definition at line 171 of file ClContextSchema_generated.h.

References ClContextIdentifier().

173  {
174  fbb.Finish(root, ClContextIdentifier());
175 }
const char * ClContextIdentifier()

◆ FinishSizePrefixedClContextBuffer()

void armnn::FinishSizePrefixedClContextBuffer ( flatbuffers::FlatBufferBuilder &  fbb,
flatbuffers::Offset< armnn::ClContext >  root 
)
inline

Definition at line 177 of file ClContextSchema_generated.h.

References ClContextIdentifier().

179  {
180  fbb.FinishSizePrefixed(root, ClContextIdentifier());
181 }
const char * ClContextIdentifier()

◆ ForEachLayerInput()

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

Definition at line 267 of file SubgraphViewSelector.cpp.

References ARMNN_ASSERT_MSG, and Layer::GetInputSlots().

Referenced by AssignSplitId(), and IsReadyForSplitAssignment().

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

◆ ForEachLayerOutput()

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

Definition at line 288 of file SubgraphViewSelector.cpp.

References Layer::GetOutputSlots().

Referenced by SubgraphViewSelector::SelectSubgraphs().

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

◆ FullyConnected()

void FullyConnected ( const TensorShape rInputShape,
Decoder< float > &  rInputDecoder,
const TensorShape rOutputShape,
Encoder< float > &  rOutputEncoder,
const TensorShape rWeightsShape,
Decoder< float > &  rWeightDecoder,
Decoder< float > *  pBiasDecoder,
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 ARMNN_ASSERT, Decoder< IType >::DecodeTensor(), and Encoder< IType >::Set().

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

◆ FuseAdditionLayer()

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

Definition at line 116 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

121 {
122  IConnectableLayer* replacement = optimizationViews.GetINetwork()->AddAdditionLayer(name.c_str());
123  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
124 
125  FuseLayer(optimizationViews,
126  baseLayer,
127  replacementLayer,
128  activationLayer,
129  activationDesc);
130 
131  return replacementLayer;
132 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseBatchNormalizationLayer()

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

Definition at line 192 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

197 {
198  IConnectableLayer* replacement =
199  optimizationViews.GetINetwork()->AddBatchNormalizationLayer(baseLayer->GetParameters(),
200  ConstTensor(),
201  ConstTensor(),
202  ConstTensor(),
203  ConstTensor(),
204  name.c_str());
205  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
206 
207  FuseLayer(optimizationViews,
208  baseLayer,
209  replacementLayer,
210  activationLayer,
211  activationDesc);
212 
213  SubgraphView substitutionSubgraph({baseLayer, activationLayer},
214  CreateIInputsFrom({baseLayer}),
215  CreateIOutputsFrom({activationLayer}));
216  SubgraphView replacementSubgraph(replacementLayer);
217 
218  return replacementLayer;
219 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseConvolution2dLayer()

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

Definition at line 222 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

227 {
228  std::shared_ptr<ConstTensorHandle> weightHandle = baseLayer->m_Weight;
229  TensorInfo weightInfo = weightHandle->GetTensorInfo();
230 
231  std::shared_ptr<ConstTensorHandle> biasHandle = baseLayer->m_Bias;
232  ConstTensor biasTensor;
233  if (!biasHandle)
234  {
235  biasTensor = ConstTensor();
236  }
237  else
238  {
239  biasTensor = ConstTensor(biasHandle->GetTensorInfo(), biasHandle->Map(true));
240  }
241 
242  IConnectableLayer* replacement =
243  optimizationViews.GetINetwork()->
244  AddConvolution2dLayer(baseLayer->GetParameters(),
245  ConstTensor(weightInfo, weightHandle->Map(true)),
246  Optional<ConstTensor>(biasTensor),
247  name.c_str());
248  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
249 
250  FuseLayer(optimizationViews,
251  baseLayer,
252  replacementLayer,
253  activationLayer,
254  activationDesc);
255 
256  return replacementLayer;
257 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseDepthwiseConvolution2dLayer()

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

Definition at line 260 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

265 {
266  std::shared_ptr<ConstTensorHandle> weightHandle = baseLayer->m_Weight;
267  TensorInfo weightInfo = weightHandle->GetTensorInfo();
268 
269  std::shared_ptr<ConstTensorHandle> biasHandle = baseLayer->m_Bias;
270  ConstTensor biasTensor;
271  if (!biasHandle)
272  {
273  biasTensor = ConstTensor();
274  }
275  else
276  {
277  biasTensor = ConstTensor(biasHandle->GetTensorInfo(), biasHandle->Map(true));
278  }
279 
280  IConnectableLayer* replacement =
281  optimizationViews.GetINetwork()->
282  AddDepthwiseConvolution2dLayer(baseLayer->GetParameters(),
283  ConstTensor(weightInfo, weightHandle->Map(true)),
284  Optional<ConstTensor>(biasTensor),
285  name.c_str());
286  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
287 
288  FuseLayer(optimizationViews,
289  baseLayer,
290  replacementLayer,
291  activationLayer,
292  activationDesc);
293 
294  return replacementLayer;
295 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseDivisionLayer()

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

Definition at line 154 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

159 {
160  IConnectableLayer* replacement = optimizationViews.GetINetwork()->AddDivisionLayer(name.c_str());
161  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
162 
163  FuseLayer(optimizationViews,
164  baseLayer,
165  replacementLayer,
166  activationLayer,
167  activationDesc);
168 
169  return replacementLayer;
170 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseFullyConnectedLayer()

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

Definition at line 298 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

303 {
304  IConnectableLayer* replacement =
305  optimizationViews.GetINetwork()->AddFullyConnectedLayer(baseLayer->GetParameters(),
306  name.c_str());
307  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
308 
309  FuseLayer(optimizationViews,
310  baseLayer,
311  replacementLayer,
312  activationLayer,
313  activationDesc);
314 
315  replacementLayer->m_Weight = std::move(baseLayer->m_Weight);
316  replacementLayer->m_Bias = std::move(baseLayer->m_Bias);
317 
318  return replacementLayer;
319 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseLayer()

LayerType* armnn::FuseLayer ( OptimizationViews optimizationViews,
LayerType baseLayer,
LayerType replacementLayer,
ActivationLayer activationLayer,
ActivationDescriptor activationDesc 
)

Definition at line 96 of file ArmComputeSubgraphUtils.hpp.

References OptimizationViews::AddSubstitution().

Referenced by FuseAdditionLayer(), FuseBatchNormalizationLayer(), FuseConvolution2dLayer(), FuseDepthwiseConvolution2dLayer(), FuseDivisionLayer(), FuseFullyConnectedLayer(), FuseMultiplicationLayer(), and FuseSubtractionLayer().

101 {
102  replacementLayer->SetAdditionalInfoForObject(
103  std::make_shared<ActivationDescriptor>(activationDesc));
104 
105  SubgraphView substitutionSubgraph({baseLayer, activationLayer},
106  CreateIInputsFrom({baseLayer}),
107  CreateIOutputsFrom({activationLayer}));
108  SubgraphView replacementSubgraph(replacementLayer);
109 
110  optimizationViews.AddSubstitution({substitutionSubgraph, replacementSubgraph});
111 
112  return replacementLayer;
113 }

◆ FuseMultiplicationLayer()

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

Definition at line 173 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

178 {
179  IConnectableLayer* replacement = optimizationViews.GetINetwork()->AddMultiplicationLayer(name.c_str());
180  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
181 
182  FuseLayer(optimizationViews,
183  baseLayer,
184  replacementLayer,
185  activationLayer,
186  activationDesc);
187 
188  return replacementLayer;
189 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ FuseSubtractionLayer()

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

Definition at line 135 of file ArmComputeSubgraphUtils.hpp.

References FuseLayer(), and OptimizationViews::GetINetwork().

140 {
141  IConnectableLayer* replacement = optimizationViews.GetINetwork()->AddSubtractionLayer(name.c_str());
142  LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
143 
144  FuseLayer(optimizationViews,
145  baseLayer,
146  replacementLayer,
147  activationLayer,
148  activationDesc);
149 
150  return replacementLayer;
151 }
LayerType * FuseLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458

◆ Gather()

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

Definition at line 17 of file Gather.cpp.

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

Referenced by TEST_SUITE().

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

◆ GatherTensorHandlePairs()

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

Definition at line 189 of file WorkloadUtils.hpp.

References Convert1HWOTensorInfoToAcl(), Convert1HWOTensorToAcl(), Convert1HWOtoMIHW(), ConvertMaskToACLFormat(), ConvertWeightTensorFromArmnnToAcl(), ConvertWeightTensorInfoFromArmnnToAcl(), PermuteTensor(), and ReshapeWeightsForAcl().

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

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

◆ GenerateRangeK()

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

Definition at line 17 of file DetectionPostProcess.cpp.

Referenced by DetectionPostProcess(), and NonMaxSuppression().

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

◆ GetActivationFunctionAsCString()

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

Definition at line 27 of file TypesUtils.hpp.

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

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

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

◆ GetArgMinMaxFunctionAsCString()

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

Definition at line 47 of file TypesUtils.hpp.

References Max, and Min.

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

◆ GetBiasDataType()

DataType GetBiasDataType ( DataType  inputDataType)

Definition at line 27 of file WorkloadData.cpp.

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

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

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

◆ GetBiasTypeFromWeightsType()

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

Definition at line 14 of file LayerSupportRules.hpp.

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

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

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

◆ GetCapability() [1/2]

Optional< const BackendOptions::BackendOption > GetCapability ( const std::string &  backendCapabilityName,
const BackendCapabilities capabilities 
)

Returns a BackendCapability if the backend lists the capability The BackendCapability must then be inspected to check whether or not that BackendCapability is supported Otherwise returns an EmptyOptional if the BackendCapability is unlisted.

Definition at line 30 of file BackendHelper.cpp.

References BackendOptions::GetOption(), and BackendOptions::GetOptionCount().

Referenced by GetCapability(), HasCapability(), LayerSupportHandle::IsFullyConnectedSupported(), LayerSupportHandle::LayerSupportHandle(), and TEST_SUITE().

32 {
33  for (size_t i=0; i < capabilities.GetOptionCount(); i++)
34  {
35  const auto& capability = capabilities.GetOption(i);
36  if (backendCapabilityName == capability.GetName())
37  {
38  return capability;
39  }
40  }
41  return EmptyOptional();
42 }

◆ GetCapability() [2/2]

Optional< const BackendOptions::BackendOption > GetCapability ( const std::string &  backendCapabilityName,
const armnn::BackendId backend 
)

Returns a BackendCapability if the backend lists the capability The BackendCapability must then be inspected to check whether or not that BackendCapability is supported Otherwise returns an EmptyOptional if the BackendCapability is unlisted.

Definition at line 44 of file BackendHelper.cpp.

References BackendRegistryInstance(), and GetCapability().

46 {
47  auto const& backendRegistry = armnn::BackendRegistryInstance();
48  if (backendRegistry.IsBackendRegistered(backend))
49  {
50  auto factoryFunc = backendRegistry.GetFactory(backend);
51  auto backendObject = factoryFunc();
52  auto capabilities = backendObject->GetCapabilities();
53  return GetCapability(backendCapabilityName, capabilities);
54  }
55  return EmptyOptional();
56 }
Optional< const BackendOptions::BackendOption > GetCapability(const std::string &backendCapabilityName, const BackendCapabilities &capabilities)
Returns a BackendCapability if the backend lists the capability The BackendCapability must then be in...
BackendRegistry & BackendRegistryInstance()

◆ GetClContext()

const armnn::ClContext* armnn::GetClContext ( const void *  buf)
inline

Definition at line 140 of file ClContextSchema_generated.h.

Referenced by ClContextDeserializer::DeserializeFromBinary().

140  {
141  return flatbuffers::GetRoot<armnn::ClContext>(buf);
142 }

◆ GetComparisonOperationAsCString()

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

Definition at line 57 of file TypesUtils.hpp.

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

Referenced by armnnTfLiteParser::ComputeWrappedIndex(), RefComparisonWorkload::ExecuteAsync(), and StringifyLayerParameters< ComparisonDescriptor >::Serialize().

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

◆ GetComputeDeviceAsCString()

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

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

Definition at line 34 of file BackendId.hpp.

References CpuAcc, CpuRef, and GpuAcc.

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

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

◆ GetConvolutionMethodString()

std::string GetConvolutionMethodString ( arm_compute::ConvolutionMethod &  convolutionMethod)
inline

Definition at line 37 of file ClWorkloadUtils.hpp.

38 {
39  switch (convolutionMethod)
40  {
41  case arm_compute::ConvolutionMethod::FFT:
42  return "FFT";
43  case arm_compute::ConvolutionMethod::DIRECT:
44  return "Direct";
45  case arm_compute::ConvolutionMethod::GEMM:
46  return "GEMM";
47  case arm_compute::ConvolutionMethod::WINOGRAD:
48  return "Winograd";
49  default:
50  return "Unknown";
51  }
52 }

◆ GetDataLayoutName()

◆ GetDataTypeName()

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

Definition at line 202 of file TypesUtils.hpp.

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

Referenced by AttemptBackendAssignment(), CompareConstTensor(), ProfilingDetails::DetailsExist(), GetBiasDataType(), TfLiteParserImpl::GetBuffer(), RefPermuteWorkload< DataType >::GetName(), RefTransposeWorkload< DataType >::GetName(), RefDebugWorkload< DataType >::GetName(), armnnUtils::GetPerAxisParams(), TEST_SUITE(), LayerVerifierBase::VerifyConstTensors(), LayerVerifierBase::VerifyNameAndConnections(), and VerifyTensorInfoDataType().

203 {
204  switch (dataType)
205  {
206  case DataType::Float16: return "Float16";
207  case DataType::Float32: return "Float32";
208  case DataType::Signed64: return "Signed64";
209  case DataType::QAsymmU8: return "QAsymmU8";
210  case DataType::QAsymmS8: return "QAsymmS8";
211  case DataType::QSymmS8: return "QSymmS8";
212  case DataType::QSymmS16: return "QSymm16";
213  case DataType::Signed32: return "Signed32";
214  case DataType::Boolean: return "Boolean";
215  case DataType::BFloat16: return "BFloat16";
216 
217  default:
218  return "Unknown";
219  }
220 }

◆ GetDataTypeSize()

constexpr unsigned int armnn::GetDataTypeSize ( DataType  dataType)

Definition at line 151 of file TypesUtils.hpp.

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

Referenced by MockTensorHandle::CanBeImported(), RefTensorHandle::CanBeImported(), DepthwiseConvolution2dDepthMul64Test(), RefDepthToSpaceWorkload::ExecuteAsync(), RefStridedSliceWorkload::ExecuteAsync(), RefSliceWorkload::ExecuteAsync(), RefShapeWorkload::ExecuteAsync(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), TensorInfo::GetNumBytes(), GetUnpaddedTensorStrides(), PermuteTensor(), and TEST_SUITE().

152 {
153  switch (dataType)
154  {
155  case DataType::BFloat16:
156  case DataType::Float16: return 2U;
157  case DataType::Float32:
158  case DataType::Signed32: return 4U;
159  case DataType::Signed64: return 8U;
160  case DataType::QAsymmU8: return 1U;
161  case DataType::QAsymmS8: return 1U;
162  case DataType::QSymmS8: return 1U;
163  case DataType::QSymmS16: return 2U;
164  case DataType::Boolean: return 1U;
165  default: return 0U;
166  }
167 }

◆ GetEventPtr() [1/2]

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

Definition at line 109 of file Profiling.cpp.

Referenced by ProfilerImpl::AnalyzeEventSequenceAndWriteResults().

109 { return ptr;}

◆ GetEventPtr() [2/2]

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

Definition at line 110 of file Profiling.cpp.

110 {return ptr.get(); }

◆ GetGraphForTesting()

Graph & GetGraphForTesting ( IOptimizedNetwork optNet)

Definition at line 47 of file TestUtils.cpp.

References IOptimizedNetwork::pOptimizedNetworkImpl.

Referenced by CheckRelatedLayers(), and TEST_SUITE().

48 {
49  return optNet->pOptimizedNetworkImpl->GetGraph();
50 }
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:828

◆ GetILayerSupportByBackendId()

LayerSupportHandle GetILayerSupportByBackendId ( const armnn::BackendId backend)

Convenience function to retrieve the ILayerSupportHandle for a backend.

Definition at line 16 of file BackendHelper.cpp.

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

Referenced by LayerSupportHandle::LayerSupportHandle(), and TEST_SUITE().

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

◆ GetInputTensor()

const armnn::ConstTensor armnn::GetInputTensor ( const LayerBindingId  layerId,
const InputTensors inputTensors 
)

Definition at line 1280 of file LoadedNetwork.cpp.

1281 {
1282  for (auto inputTensorPair : inputTensors)
1283  {
1284  LayerBindingId id = inputTensorPair.first;
1285  if (id == layerId)
1286  {
1287  return inputTensorPair.second;
1288  }
1289  }
1290  throw InvalidArgumentException("Input does not exist.");
1291 }
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:277

◆ GetInputTensorData()

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

Definition at line 35 of file RefWorkloadUtils.hpp.

References GetOutputTensorData(), and ITensorHandle::Map().

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

◆ GetInputTensorDataBFloat16()

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

Definition at line 79 of file RefWorkloadUtils.hpp.

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

◆ GetInputTensorDataFloat()

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

Definition at line 55 of file RefWorkloadUtils.hpp.

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

◆ GetInputTensorDataHalf()

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

Definition at line 67 of file RefWorkloadUtils.hpp.

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

◆ GetLayerTypeAsCString()

char const * GetLayerTypeAsCString ( LayerType  type)

Definition at line 13 of file InternalTypes.cpp.

References ARMNN_ASSERT_MSG, and LIST_OF_LAYER_TYPE.

Referenced by AttemptBackendAssignment(), CheckScaleSetOnQuantizedType(), Connect(), TestInputLayerVisitor::ExecuteStrategy(), StrategyBase< NoThrowStrategy >::ExecuteStrategy(), TestConvolution2dLayerVisitor::ExecuteStrategy(), TestOutputLayerVisitor::ExecuteStrategy(), TestDepthwiseConvolution2dLayerVisitor::ExecuteStrategy(), TestFullyConnectedLayerVistor::ExecuteStrategy(), TestBatchNormalizationLayerVisitor::ExecuteStrategy(), TestConstantLayerVisitor::ExecuteStrategy(), TestLstmLayerVisitor::ExecuteStrategy(), TestQLstmLayerVisitor::ExecuteStrategy(), TestQuantizedLstmLayerVisitor::ExecuteStrategy(), ElementwiseBaseLayer::InferOutputShapes(), Layer::InferOutputShapes(), Graph::InferTensorInfos(), Graph::Print(), ReturnWithError(), Layer::SerializeLayerParameters(), Graph::SerializeToDot(), TEST_SUITE(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), Graph::VerifyConstantLayerSetTensorInfo(), and Layer::VerifyLayerConnections().

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

◆ GetLogicalBinaryOperationAsCString()

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

Definition at line 87 of file TypesUtils.hpp.

References LogicalAnd, and LogicalOr.

Referenced by RefLogicalBinaryWorkload::ExecuteAsync().

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

◆ GetMemBlockStrategyTypeName()

constexpr const char* armnn::GetMemBlockStrategyTypeName ( MemBlockStrategyType  memBlockStrategyType)

Definition at line 264 of file TypesUtils.hpp.

References MultiAxisPacking, and SingleAxisPacking.

Referenced by RuntimeImpl::RuntimeImpl().

265 {
266  switch (memBlockStrategyType)
267  {
268  case MemBlockStrategyType::SingleAxisPacking: return "SingleAxisPacking";
269  case MemBlockStrategyType::MultiAxisPacking: return "MultiAxisPacking";
270  default: return "Unknown";
271  }
272 }

◆ GetMemoryOptimizerStrategy()

std::unique_ptr<IMemoryOptimizerStrategy> armnn::GetMemoryOptimizerStrategy ( const std::string &  strategyName)

Definition at line 36 of file MemoryOptimizerStrategyLibrary.hpp.

Referenced by main(), RuntimeImpl::RuntimeImpl(), and TEST_SUITE().

37 {
38  const auto& strategyFactoryMap = GetStrategyFactories();
39  auto strategyFactory = strategyFactoryMap.find(strategyName);
40  if (strategyFactory != GetStrategyFactories().end())
41  {
42  return strategyFactory->second->CreateMemoryOptimizerStrategy();
43  }
44  return nullptr;
45 }

◆ GetMemoryOptimizerStrategyNames()

const std::vector<std::string> armnn::GetMemoryOptimizerStrategyNames ( )

Definition at line 47 of file MemoryOptimizerStrategyLibrary.hpp.

Referenced by ParseOptions(), and TEST_SUITE().

48 {
49  const auto& strategyFactoryMap = GetStrategyFactories();
50  std::vector<std::string> strategyNames;
51  for (const auto& strategyFactory : strategyFactoryMap)
52  {
53  strategyNames.emplace_back(strategyFactory.first);
54  }
55  return strategyNames;
56 }

◆ GetModelOptionsForTesting()

ModelOptions & GetModelOptionsForTesting ( IOptimizedNetwork optNet)

Definition at line 52 of file TestUtils.cpp.

References IOptimizedNetwork::pOptimizedNetworkImpl.

Referenced by CheckRelatedLayers(), and TEST_SUITE().

53 {
54  return optNet->pOptimizedNetworkImpl->GetModelOptions();
55 }
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:828

◆ GetNormalizationAlgorithmChannelAsCString()

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

Definition at line 234 of file TypesUtils.hpp.

References Across, and Within.

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

235 {
236  switch (channel)
237  {
238  case NormalizationAlgorithmChannel::Across: return "Across";
239  case NormalizationAlgorithmChannel::Within: return "Within";
240  default: return "Unknown";
241  }
242 }

◆ GetNormalizationAlgorithmMethodAsCString()

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

Definition at line 244 of file TypesUtils.hpp.

References LocalBrightness, and LocalContrast.

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

245 {
246  switch (method)
247  {
248  case NormalizationAlgorithmMethod::LocalBrightness: return "LocalBrightness";
249  case NormalizationAlgorithmMethod::LocalContrast: return "LocalContrast";
250  default: return "Unknown";
251  }
252 }

◆ GetNumberOfCacheFiles()

unsigned int GetNumberOfCacheFiles ( const armnn::BackendId backend)

Returns the number of cached files if backend supports caching.

Definition at line 129 of file BackendHelper.cpp.

References BackendRegistryInstance().

Referenced by LayerSupportHandle::LayerSupportHandle().

130 {
131  auto const& backendRegistry = armnn::BackendRegistryInstance();
132  if (backendRegistry.IsBackendRegistered(backend))
133  {
134  auto factoryFunc = backendRegistry.GetFactory(backend);
135  auto backendObject = factoryFunc();
136  return backendObject->GetNumberOfCacheFiles();
137  }
138  return 0;
139 }
BackendRegistry & BackendRegistryInstance()

◆ GetOffset()

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

Definition at line 15 of file SpaceToBatchNd.cpp.

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

Referenced by SpaceToBatchNd(), and SpaceToDepth().

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

◆ GetOutputShapeRoundingAsCString()

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

Definition at line 108 of file TypesUtils.hpp.

References Ceiling, and Floor.

Referenced by StringifyLayerParameters< Pooling2dDescriptor >::Serialize(), and StringifyLayerParameters< Pooling3dDescriptor >::Serialize().

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

◆ GetOutputTensor()

const armnn::Tensor armnn::GetOutputTensor ( const LayerBindingId  layerId,
const OutputTensors outputTensors 
)

Definition at line 1293 of file LoadedNetwork.cpp.

1294 {
1295  for (auto outputTensorPair : outputTensors)
1296  {
1297  LayerBindingId id = outputTensorPair.first;
1298  if (id == layerId)
1299  {
1300  return outputTensorPair.second;
1301  }
1302  }
1303  throw InvalidArgumentException("Output does not exist.");
1304 }
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:277

◆ GetOutputTensorData() [1/2]

DataType* armnn::GetOutputTensorData ( ITensorHandle tensorHandle)

Definition at line 49 of file RefWorkloadUtils.hpp.

References ITensorHandle::Map().

50 {
51  return reinterpret_cast<DataType*>(tensorHandle->Map());
52 }
DataType
Definition: Types.hpp:35

◆ GetOutputTensorData() [2/2]

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

Definition at line 168 of file ClWorkloadUtils.hpp.

References ITensorHandle::Map().

Referenced by GetInputTensorData(), and SetNeonSliceData().

169 {
170  ITensorHandle* tensorHandle = data.m_Outputs[idx];
171  return reinterpret_cast<DataType*>(tensorHandle->Map());
172 }
DataType
Definition: Types.hpp:35

◆ GetOutputTensorDataBFloat16()

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

Definition at line 85 of file RefWorkloadUtils.hpp.

86 {
87  return GetOutputTensorData<BFloat16>(idx, data);
88 }

◆ GetOutputTensorDataFloat()

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

Definition at line 61 of file RefWorkloadUtils.hpp.

62 {
63  return GetOutputTensorData<float>(idx, data);
64 }

◆ GetOutputTensorDataHalf()

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

Definition at line 73 of file RefWorkloadUtils.hpp.

74 {
75  return GetOutputTensorData<Half>(idx, data);
76 }

◆ GetPaddingMethodAsCString()

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

Definition at line 118 of file TypesUtils.hpp.

References Exclude, and IgnoreValue.

Referenced by StringifyLayerParameters< Pooling2dDescriptor >::Serialize(), and StringifyLayerParameters< Pooling3dDescriptor >::Serialize().

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

◆ GetPaddingModeAsCString()

constexpr char const* armnn::GetPaddingModeAsCString ( PaddingMode  mode)

Definition at line 128 of file TypesUtils.hpp.

References Constant, Reflect, and Symmetric.

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

129 {
130  switch (mode)
131  {
132  case PaddingMode::Constant: return "Exclude";
133  case PaddingMode::Symmetric: return "Symmetric";
134  case PaddingMode::Reflect: return "Reflect";
135  default: return "Unknown";
136  }
137 }

◆ GetPoolingAlgorithmAsCString()

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

Definition at line 97 of file TypesUtils.hpp.

References Average, L2, and Max.

Referenced by StringifyLayerParameters< Pooling2dDescriptor >::Serialize(), and StringifyLayerParameters< Pooling3dDescriptor >::Serialize().

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

◆ GetProfilerEventSequenceSize()

size_t armnn::GetProfilerEventSequenceSize ( armnn::IProfiler profiler)

Definition at line 19 of file ProfilerTests.cpp.

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

Referenced by TEST_SUITE().

20 {
21  if (!profiler)
22  {
23  return static_cast<size_t>(-1);
24  }
25 
26  return profiler->pProfilerImpl->m_EventSequence.size();
27 }

◆ GetProfilingService()

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

Definition at line 57 of file TestUtils.cpp.

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

58 {
59  return runtime->m_ProfilingService;
60 }

◆ GetReduceOperationAsCString()

constexpr char const* armnn::GetReduceOperationAsCString ( ReduceOperation  reduce_operation)

Definition at line 139 of file TypesUtils.hpp.

References Max, Mean, Min, Prod, and Sum.

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

140 {
141  switch (reduce_operation)
142  {
143  case ReduceOperation::Sum: return "Sum";
144  case ReduceOperation::Max: return "Max";
145  case ReduceOperation::Mean: return "Mean";
146  case ReduceOperation::Min: return "Min";
147  case ReduceOperation::Prod: return "Prod";
148  default: return "Unknown";
149  }
150 }

◆ GetResizeMethodAsCString()

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

Definition at line 254 of file TypesUtils.hpp.

References Bilinear, and NearestNeighbor.

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

255 {
256  switch (method)
257  {
258  case ResizeMethod::Bilinear: return "Bilinear";
259  case ResizeMethod::NearestNeighbor: return "NearestNeighbour";
260  default: return "Unknown";
261  }
262 }

◆ GetSizePrefixedClContext()

const armnn::ClContext* armnn::GetSizePrefixedClContext ( const void *  buf)
inline

Definition at line 144 of file ClContextSchema_generated.h.

144  {
145  return flatbuffers::GetSizePrefixedRoot<armnn::ClContext>(buf);
146 }

◆ GetStatusAsCString()

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

Definition at line 17 of file TypesUtils.hpp.

References Failure, and Success.

Referenced by operator<<().

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

◆ GetTensorInfo()

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

float32 helpers

Definition at line 26 of file RefWorkloadUtils.hpp.

References RefTensorHandle::GetTensorInfo().

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

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

◆ GetTimeDuration()

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

Definition at line 19 of file Timer.hpp.

References GetTimeNow().

Referenced by CheckInferenceTimeThreshold(), RuntimeImpl::EnqueueWorkload(), RuntimeImpl::Execute(), InferenceModel< IParser, TDataType >::InferenceModel(), MainImpl(), InferenceModel< IParser, TDataType >::Run(), InferenceModel< IParser, TDataType >::RunAsync(), RuntimeImpl::RuntimeImpl(), and RuntimeImpl::~RuntimeImpl().

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

◆ GetTimeNow()

◆ GetUnaryOperationAsCString()

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

Definition at line 71 of file TypesUtils.hpp.

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

Referenced by armnnTfLiteParser::ComputeWrappedIndex(), RefLogicalUnaryWorkload::ExecuteAsync(), RefElementwiseUnaryWorkload::ExecuteAsync(), StringifyLayerParameters< ElementwiseUnaryDescriptor >::Serialize(), and TEST_SUITE().

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

◆ GetUnpaddedTensorStrides()

TensorShape GetUnpaddedTensorStrides ( const TensorInfo tensorInfo)

Definition at line 15 of file TensorHandle.cpp.

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

Referenced by MockTensorHandle::GetStrides(), SampleTensorHandle::GetStrides(), RefTensorHandle::GetStrides(), and ConstTensorHandle::GetStrides().

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

◆ GetVersion()

const std::string GetVersion ( )

Definition at line 77 of file Utils.cpp.

References ARMNN_VERSION.

78 {
79  return ARMNN_VERSION;
80 }
#define ARMNN_VERSION
ARMNN_VERSION: "X.Y.Z" where: X = Major version number Y = Minor version number Z = Patch version num...
Definition: Version.hpp:22

◆ HasCapability() [1/4]

bool HasCapability ( const std::string &  name,
const BackendCapabilities capabilities 
)

Convenience function to check if a capability exists in a BackendCapabilites struct.

Definition at line 58 of file BackendHelper.cpp.

References GetCapability().

Referenced by HasCapability(), LoadedNetwork::ImportInputs(), LoadedNetwork::ImportOutputs(), LayerSupportHandle::LayerSupportHandle(), LoadedNetwork::MakeLoadedNetwork(), RuntimeImpl::RuntimeImpl(), and TEST_SUITE().

59 {
60  return GetCapability(name, capabilities).has_value();
61 }
Optional< const BackendOptions::BackendOption > GetCapability(const std::string &backendCapabilityName, const BackendCapabilities &capabilities)
Returns a BackendCapability if the backend lists the capability The BackendCapability must then be in...

◆ HasCapability() [2/4]

bool HasCapability ( const std::string &  name,
const armnn::BackendId backend 
)

Convenience function to check if a capability exists in a backend.

Definition at line 63 of file BackendHelper.cpp.

References GetCapability().

64 {
65  return GetCapability(name, backend).has_value();
66 }
Optional< const BackendOptions::BackendOption > GetCapability(const std::string &backendCapabilityName, const BackendCapabilities &capabilities)
Returns a BackendCapability if the backend lists the capability The BackendCapability must then be in...

◆ HasCapability() [3/4]

bool HasCapability ( const BackendOptions::BackendOption capability,
const BackendCapabilities capabilities 
)

Convenience function to check if a given capability matches a capability in a BackendCapabilities struct.

Definition at line 68 of file BackendHelper.cpp.

References BackendOptions::Var::AsBool(), BackendOptions::Var::AsFloat(), BackendOptions::Var::AsInt(), BackendOptions::Var::AsString(), BackendOptions::Var::AsUnsignedInt(), BackendOptions::BackendOption::GetName(), BackendOptions::GetOption(), BackendOptions::GetOptionCount(), BackendOptions::BackendOption::GetValue(), BackendOptions::Var::IsBool(), BackendOptions::Var::IsFloat(), BackendOptions::Var::IsInt(), BackendOptions::Var::IsString(), and BackendOptions::Var::IsUnsignedInt().

69 {
70  for (size_t i=0; i < capabilities.GetOptionCount(); i++)
71  {
72  const auto& backendCapability = capabilities.GetOption(i);
73  if (capability.GetName() == backendCapability.GetName())
74  {
75  if (capability.GetValue().IsBool() && backendCapability.GetValue().IsBool())
76  {
77  return capability.GetValue().AsBool() == backendCapability.GetValue().AsBool();
78  }
79  else if(capability.GetValue().IsFloat() && backendCapability.GetValue().IsFloat())
80  {
81  return capability.GetValue().AsFloat() == backendCapability.GetValue().AsFloat();
82  }
83  else if(capability.GetValue().IsInt() && backendCapability.GetValue().IsInt())
84  {
85  return capability.GetValue().AsInt() == backendCapability.GetValue().AsInt();
86  }
87  else if(capability.GetValue().IsString() && backendCapability.GetValue().IsString())
88  {
89  return capability.GetValue().AsString() == backendCapability.GetValue().AsString();
90  }
91  else if(capability.GetValue().IsUnsignedInt() && backendCapability.GetValue().IsUnsignedInt())
92  {
93  return capability.GetValue().AsUnsignedInt() == backendCapability.GetValue().AsUnsignedInt();
94  }
95  }
96  }
97  return false;
98 }

◆ HasCapability() [4/4]

bool HasCapability ( const BackendOptions::BackendOption backendOption,
const armnn::BackendId backend 
)

Convenience function to check if a given capability matches a capability in a backend.

Definition at line 100 of file BackendHelper.cpp.

References BackendRegistryInstance(), and HasCapability().

101 {
102  auto const& backendRegistry = armnn::BackendRegistryInstance();
103  if (backendRegistry.IsBackendRegistered(backend))
104  {
105  auto factoryFunc = backendRegistry.GetFactory(backend);
106  auto backendObject = factoryFunc();
107  auto capabilities = backendObject->GetCapabilities();
108  return HasCapability(backendOption, capabilities);
109  }
110  return false;
111 }
bool HasCapability(const std::string &name, const BackendCapabilities &capabilities)
Convenience function to check if a capability exists in a BackendCapabilites struct.
BackendRegistry & BackendRegistryInstance()

◆ IgnoreUnused()

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

Definition at line 14 of file IgnoreUnused.hpp.

Referenced by ChannelShuffleLayer::Accept(), ConvertFp32ToFp16Layer::Accept(), DebugLayer::Accept(), FakeQuantizationLayer::Accept(), MapLayer::Accept(), MemCopyLayer::Accept(), MemImportLayer::Accept(), ConvertBf16ToFp32Layer::Accept(), CastLayer::Accept(), ConvertFp32ToBf16Layer::Accept(), ConvertFp16ToFp32Layer::Accept(), UnmapLayer::Accept(), PreCompiledLayer::Accept(), ShapeLayer::Accept(), Convolution3dLayer::Accept(), UnidirectionalSequenceLstmLayer::Accept(), IInferenceTestCaseProvider::AddCommandLineOptions(), AdditionAfterMaxPoolTest(), AdditionBroadcast1ElementTestImpl(), AdditionBroadcastTestImpl(), ClBackendDefaultAllocator::allocate(), DefaultAllocator::allocate(), ArgMinMax(), BoundedReLuTestCommon(), BoundedReLuUint8UpperAndLowerBoundTest(), CalculateSlotOptionForOutput(), ITensorHandle::CanBeImported(), NeonTensorHandle::CanBeImported(), ClTensorHandle::CanBeImported(), CastTest(), ParserFlatbuffersSerializeFixture::CheckTensors(), ClassifierTestCase< TTestCaseDatabase, TModel >::ClassifierTestCase(), ClContextControl::ClContextControl(), ClConvolution3dWorkload::ClConvolution3dWorkload(), SpaceToBatchNdLayer::Clone(), SpaceToDepthLayer::Clone(), CompareActivationTestImpl(), CompareAdditionTest(), CompareBatchNormTest(), CompareMultiplicationTest(), CompareVector(), ConcatDifferentInputOutputQParamTest(), ConcatTest(), ConcatUint16Test(), ConcatUint8DifferentQParamsTest(), ConcatUint8Test(), ConstantLinearActivationTestCommon(), ConvertBf16ToFp32Test(), ConvertFp32ToBf16Test(), Convolution2d3x3Stride2x2BFloat16SmallValueTest(), Convolution2d3x3Stride2x2BFloat16Test(), CopyTensorContentsGeneric(), MockBackend::CreateBackendProfilingContext(), SampleDynamicTensorHandleFactory::CreateSubTensorHandle(), RefTensorHandleFactory::CreateSubTensorHandle(), SampleDynamicWorkloadFactory::CreateSubTensorHandle(), RefWorkloadFactory::CreateSubTensorHandle(), SampleDynamicTensorHandleFactory::CreateTensorHandle(), RefTensorHandleFactory::CreateTensorHandle(), MockTensorHandleFactory::CreateTensorHandle(), ClWorkloadFactory::CreateTensorHandle(), ITensorHandleFactory::CreateTensorHandle(), RefWorkloadFactory::CreateTensorHandle(), MockWorkloadFactory::CreateTensorHandle(), OutputLayer::CreateTensorHandles(), MapLayer::CreateWorkload(), InputLayer::CreateWorkload(), MemCopyLayer::CreateWorkload(), MemImportLayer::CreateWorkload(), OutputLayer::CreateWorkload(), MergeLayer::CreateWorkload(), UnmapLayer::CreateWorkload(), StandInLayer::CreateWorkload(), MockBackend::CreateWorkloadFactory(), IBackendInternal::CreateWorkloadFactory(), QASymm8Decoder::DecodeTensor(), QASymmS8Decoder::DecodeTensor(), QSymmS8Decoder::DecodeTensor(), QSymm16Decoder::DecodeTensor(), BFloat16Decoder::DecodeTensor(), Float16Decoder::DecodeTensor(), Float32Decoder::DecodeTensor(), ScaledInt32Decoder::DecodeTensor(), Int32Decoder::DecodeTensor(), Int32ToInt32tDecoder::DecodeTensor(), BooleanDecoder::DecodeTensor(), BooleanDecoderBool::DecodeTensor(), QSymm8PerAxisDecoder::DecodeTensor(), Dequantize(), SelectiveQuantizer< T, false >::Dequantize(), SelectiveQuantizer< armnn::Half, false >::Dequantize(), SelectiveQuantizer< armnn::BFloat16, false >::Dequantize(), DetectionPostProcess(), DivisionByZeroTest(), ProfilerImpl::EndEvent(), LoadedNetwork::EnqueueWorkload(), RefStridedSliceWorkload::ExecuteAsync(), SerializerStrategy::ExecuteStrategy(), TestInputLayerVisitor::ExecuteStrategy(), LayerVerifierBase::ExecuteStrategy(), StrategyBase< NoThrowStrategy >::ExecuteStrategy(), FakeQuantizationLayer::ExecuteStrategy(), MemCopyLayer::ExecuteStrategy(), TestConvolution2dLayerVisitor::ExecuteStrategy(), MemImportLayer::ExecuteStrategy(), PreCompiledLayer::ExecuteStrategy(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), TestOutputLayerVisitor::ExecuteStrategy(), TestDepthwiseConvolution2dLayerVisitor::ExecuteStrategy(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), TestFullyConnectedLayerVistor::ExecuteStrategy(), TestBatchNormalizationLayerVisitor::ExecuteStrategy(), TestConstantLayerVisitor::ExecuteStrategy(), TestLstmLayerVisitor::ExecuteStrategy(), TestQLstmLayerVisitor::ExecuteStrategy(), TestQuantizedLstmLayerVisitor::ExecuteStrategy(), ExecutionFrame::ExecuteWorkloads(), exit_capture(), FakeQuantizationTest(), FalseFunc(), FalseFuncF16(), FalseFuncF32(), FalseFuncI32(), FalseFuncU8(), FalseInputFuncF16(), FalseInputFuncF32(), FalseOutputFuncF16(), FalseOutputFuncF32(), Gather(), ClImportTensorHandleFactory::GetCapabilities(), NeonTensorHandleFactory::GetCapabilities(), ITensorHandleFactory::GetCapabilities(), MockCounterDirectory::GetCounter(), MockCounterDirectory::GetCounterSet(), MockCounterDirectory::GetDevice(), armnnSerializer::GetFlatBufferArgMinMaxFunction(), GetImageDataInArmNnLayoutAsNormalizedFloats(), DefaultAllocator::GetMemoryRegionAtOffset(), ClBackendDefaultAllocator::GetMemoryRegionAtOffset(), ICustomAllocator::GetMemoryRegionAtOffset(), IDeserializer::DeserializerImpl::GetNetworkInputBindingInfo(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), IDeserializer::DeserializerImpl::GetNormalizationDescriptor(), LoadedNetwork::GetOutputTensorInfo(), IDeserializer::DeserializerImpl::GetPooling2dDescriptor(), IDeserializer::DeserializerImpl::GetPooling3dDescriptor(), MockProfilingConnectionFactory::GetProfilingConnection(), ITensorHandle::Import(), ClTensorHandle::Import(), ShapeLayer::InferOutputShapes(), SliceLayer::InferOutputShapes(), StackLayer::InferOutputShapes(), StandInLayer::InferOutputShapes(), ReshapeLayer::InferOutputShapes(), SplitterLayer::InferOutputShapes(), NeonLayerSupport::IsActivationSupported(), MockImportLayerSupport::IsAdditionSupported(), RefLayerSupport::IsArgMinMaxSupported(), RefLayerSupport::IsBatchNormalizationSupported(), RefLayerSupport::IsBatchToSpaceNdSupported(), RefLayerSupport::IsChannelShuffleSupported(), RefLayerSupport::IsComparisonSupported(), RefLayerSupport::IsConcatSupported(), NeonLayerSupport::IsConvertBf16ToFp32Supported(), NeonLayerSupport::IsConvertFp16ToFp32Supported(), NeonLayerSupport::IsConvertFp32ToBf16Supported(), NeonLayerSupport::IsConvertFp32ToFp16Supported(), RefLayerSupport::IsConvolution2dSupported(), RefLayerSupport::IsConvolution3dSupported(), RefLayerSupport::IsDepthToSpaceSupported(), RefLayerSupport::IsDepthwiseConvolutionSupported(), RefLayerSupport::IsDetectionPostProcessSupported(), RefLayerSupport::IsElementwiseUnarySupported(), RefLayerSupport::IsFakeQuantizationSupported(), ClLayerSupport::IsFillSupported(), NeonLayerSupport::IsFillSupported(), RefLayerSupport::IsFillSupported(), NeonLayerSupport::IsFloorSupported(), RefLayerSupport::IsFloorSupported(), MockImportLayerSupport::IsInputSupported(), RefLayerSupport::IsInstanceNormalizationSupported(), RefLayerSupport::IsL2NormalizationSupported(), ILayerSupport::IsLayerSupported(), ClLayerSupport::IsLogicalBinarySupported(), RefLayerSupport::IsLogicalBinarySupported(), RefLayerSupport::IsLogSoftmaxSupported(), RefLayerSupport::IsLstmSupported(), RefLayerSupport::IsNormalizationSupported(), ProfilingStateMachine::IsOneOfStates(), MockImportLayerSupport::IsOutputSupported(), RefLayerSupport::IsPadSupported(), RefLayerSupport::IsPermuteSupported(), RefLayerSupport::IsPooling2dSupported(), RefLayerSupport::IsPooling3dSupported(), RefLayerSupport::IsQLstmSupported(), RefLayerSupport::IsRankSupported(), RefLayerSupport::IsReduceSupported(), ClLayerSupport::IsReshapeSupported(), NeonLayerSupport::IsReshapeSupported(), RefLayerSupport::IsReshapeSupported(), RefLayerSupport::IsResizeSupported(), RefLayerSupport::IsShapeSupported(), RefLayerSupport::IsSliceSupported(), RefLayerSupport::IsSoftmaxSupported(), RefLayerSupport::IsSpaceToBatchNdSupported(), RefLayerSupport::IsSpaceToDepthSupported(), ClLayerSupport::IsSplitterSupported(), NeonLayerSupport::IsSplitterSupported(), RefLayerSupport::IsSplitterSupported(), RefLayerSupport::IsStackSupported(), RefLayerSupport::IsStridedSliceSupported(), RefLayerSupport::IsTransposeConvolution2dSupported(), RefLayerSupport::IsTransposeSupported(), RefLayerSupport::IsUnidirectionalSequenceLstmSupported(), Layer::Layer(), LogSoftmax(), ClImportTensorHandle::Map(), ClBackend::ClBackendCustomAllocatorMemoryRegion::map(), ClImportSubTensorHandle::Map(), MaximumSimpleTest(), MinimumBroadcast1ElementTest1(), MirrorPad2dTestCommon(), MirrorPad3dTestCommon(), MirrorPad4dTestCommon(), NeonConvolution3dWorkload::NeonConvolution3dWorkload(), StubCommandHandler::operator()(), TestFunctorA::operator()(), TfLiteParserImpl::OutputShapeOfSqueeze(), Pad2dTestCommon(), Pad3dTestCommon(), Pad4dTestCommon(), PadQAsymmTestCommon(), PermuteInputsForConcat(), PermuteTensorData(), RefConvolution3dWorkload::PostAllocationConfigure(), PreluTest(), IInferenceTestCaseProvider::ProcessCommandLineOptions(), YoloTestCase< Model >::ProcessResult(), SelectiveQuantizer< T, false >::Quantize(), SelectiveQuantizer< armnn::Half, false >::Quantize(), SelectiveQuantizer< armnn::BFloat16, false >::Quantize(), RankTest(), MockProfilingConnection::ReadPacket(), TestProfilingConnectionArmnnError::ReadPacket(), TestProfilingConnectionBadAckPacket::ReadPacket(), CounterDirectory::RegisterCounter(), MockCounterDirectory::RegisterCounter(), BaseWorkload< Convolution2dQueueDescriptor >::ReplaceInputTensorHandle(), BaseWorkload< Convolution2dQueueDescriptor >::ReplaceOutputTensorHandle(), OptimizeInverseConversionsImpl::Run(), RedirectMembersToConstantInputsImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), SquashEqualSiblingsImpl< Comparable >::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), ConvertConstants< Converter, Predicate >::Run(), MockSendCounterPacket::SendCounterDirectoryPacket(), MockSendCounterPacket::SendPeriodicCounterCapturePacket(), MockSendCounterPacket::SendPeriodicCounterSelectionPacket(), ILocalPacketHandler::SetConnection(), SetLogFilter(), ClImportTensorHandle::SetMemoryGroup(), ClImportSubTensorHandle::SetMemoryGroup(), ShapeTest(), SimpleActivationTest(), SimpleConvertFp16ToFp32Test(), SimpleConvertFp32ToFp16Test(), SimpleConvolution2d3x3NhwcTestCommon(), SimpleConvolution2d3x3Stride2x2TestCommon(), SimpleConvolution2dNhwcTestImpl(), SimpleConvolution2dTestImpl(), SimpleFillTest(), SimpleFloorTest(), SimplePermuteTestImpl(), SimpleTransposeTestImpl(), Slice(), SqrtNNTest(), OpenClTimer::Start(), MemoryManager::StoreMemToAllocate(), Graph::SubstituteSubgraph(), TEST_SUITE(), TestDynamicBackendId(), TrueFunc(), UnidirectionalSequenceLstmInt8WithCifgWithPeepholeNoProjectionTest(), UnidirectionalSequenceLstmLayerInt8NoCifgWithPeepholeWithProjectionTest(), UnidirectionalSequenceLstmLayerInt8NoCifgWithPeepholeWithProjectionWithLayerNormTest(), UnidirectionalSequenceLstmLayerInt8Test(), UnidirectionalSequenceLstmLayerInt8TimeMajorTest(), UnidirectionalSequenceLstmLayerNoCifgWithPeepholeWithProjectionTest(), UnidirectionalSequenceLstmLayerNoCifgWithPeepholeWithProjectionWithLayerNormTest(), UnidirectionalSequenceLstmWithCifgWithPeepholeNoProjectionTest(), ClBackend::ClBackendCustomAllocatorMemoryRegion::unmap(), ClBackend::UseCustomMemoryAllocator(), IBackendInternal::UseCustomMemoryAllocator(), MockProfilingServiceStatus::WaitForProfilingServiceActivation(), WorkingMemHandle::WorkingMemHandle(), TestProfilingConnectionBase::WritePacket(), Graph::LayerInGraph< InputLayer >::~LayerInGraph(), Graph::LayerInGraph< OutputLayer >::~LayerInGraph(), and ScopedProfilingEvent::~ScopedProfilingEvent().

14 {}

◆ InitializeArmComputeClTensorData()

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

Definition at line 115 of file ClWorkloadUtils.hpp.

References ARMNN_ASSERT.

117 {
118  ARMNN_ASSERT(handle);
119 
120  armcomputetensorutils::InitialiseArmComputeTensorEmpty(clTensor);
121  switch(handle->GetTensorInfo().GetDataType())
122  {
123  case DataType::Float16:
124  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<armnn::Half>());
125  break;
126  case DataType::Float32:
127  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<float>());
128  break;
129  case DataType::QAsymmU8:
130  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<uint8_t>());
131  break;
132  case DataType::QAsymmS8:
133  case DataType::QSymmS8:
134  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int8_t>());
135  break;
136  case DataType::QSymmS16:
137  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int16_t>());
138  break;
139  case DataType::Signed32:
140  CopyArmComputeClTensorData(clTensor, handle->GetConstTensor<int32_t>());
141  break;
142  default:
143  ARMNN_ASSERT_MSG(false, "Unexpected tensor type.");
144  }
145 };
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void CopyArmComputeClTensorData(arm_compute::CLTensor &dstTensor, const T *srcData)
half_float::half Half
Definition: Half.hpp:18

◆ InitializeArmComputeTensorData()

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

Definition at line 60 of file NeonWorkloadUtils.hpp.

References ARMNN_ASSERT, ARMNN_ASSERT_MSG, CopyArmComputeTensorData(), Float16, Float32, ConstTensorHandle::GetConstTensor(), TensorInfo::GetDataType(), ConstTensorHandle::GetTensorInfo(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, and Signed32.

62 {
63  ARMNN_ASSERT(handle);
64 
65  switch(handle->GetTensorInfo().GetDataType())
66  {
67  case DataType::Float16:
68  CopyArmComputeTensorData(tensor, handle->GetConstTensor<armnn::Half>());
69  break;
70  case DataType::Float32:
71  CopyArmComputeTensorData(tensor, handle->GetConstTensor<float>());
72  break;
73  case DataType::QAsymmU8:
74  CopyArmComputeTensorData(tensor, handle->GetConstTensor<uint8_t>());
75  break;
76  case DataType::QSymmS8:
77  case DataType::QAsymmS8:
78  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int8_t>());
79  break;
80  case DataType::Signed32:
81  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int32_t>());
82  break;
83  case DataType::QSymmS16:
84  CopyArmComputeTensorData(tensor, handle->GetConstTensor<int16_t>());
85  break;
86  default:
87  ARMNN_ASSERT_MSG(false, "Unexpected tensor type.");
88  }
89 };
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void CopyArmComputeTensorData(arm_compute::Tensor &dstTensor, const T *srcData)
half_float::half Half
Definition: Half.hpp:18

◆ InsertConvertBf16ToFp32LayersBefore()

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

Definition at line 51 of file NetworkUtils.cpp.

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

Referenced by AttemptBackendAssignment().

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

◆ InsertConvertFp16ToFp32LayersBefore()

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

Definition at line 129 of file NetworkUtils.cpp.

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

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

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

◆ InsertConvertFp32ToBf16LayersAfter()

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

Definition at line 168 of file NetworkUtils.cpp.

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

Referenced by AttemptBackendAssignment().

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

◆ InsertConvertFp32ToBf16LayersBefore()

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

Definition at line 90 of file NetworkUtils.cpp.

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

Referenced by ConvertFp32NetworkToBf16Impl::Run().

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

◆ InsertConvertFp32ToFp16LayersAfter()

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

Definition at line 201 of file NetworkUtils.cpp.

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

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

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

◆ InsertDebugLayerAfter()

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

Definition at line 234 of file NetworkUtils.cpp.

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

Referenced by AddDebugImpl::Run().

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

◆ InstanceNorm()

void InstanceNorm ( const InstanceNormalizationQueueDescriptor data,
const TensorInfo inputInfo,
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(), DataLayoutIndexed::GetWidthIndex(), InstanceNormalizationDescriptor::m_Beta, InstanceNormalizationDescriptor::m_DataLayout, InstanceNormalizationDescriptor::m_Eps, InstanceNormalizationDescriptor::m_Gamma, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Encoder< IType >::Set().

Referenced by RefInstanceNormalizationWorkload::ExecuteAsync().

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

◆ IntersectionOverUnion()

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

Definition at line 30 of file DetectionPostProcess.cpp.

Referenced by NonMaxSuppression(), and TEST_SUITE().

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

◆ IsActivationSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported(), and ILayerSupport::~ILayerSupport().

◆ IsAdditionSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported(), and MockLayerSupport::IsLayerSupported().

◆ IsBatchNormalizationSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsBatchToSpaceNdSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsBFloat16()

bool armnn::IsBFloat16 ( const WorkloadInfo info)

Definition at line 53 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

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

◆ IsCapabilitySupported()

bool IsCapabilitySupported ( const armnn::BackendId backend,
armnn::BackendCapability  capability 
)

Convenience function to check a capability on a backend.

Definition at line 114 of file BackendHelper.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, and BackendRegistryInstance().

Referenced by LayerSupportHandle::LayerSupportHandle().

115 {
116  bool hasCapability = false;
117  auto const& backendRegistry = armnn::BackendRegistryInstance();
118  if (backendRegistry.IsBackendRegistered(backend))
119  {
120  auto factoryFunc = backendRegistry.GetFactory(backend);
121  auto backendObject = factoryFunc();
123  hasCapability = backendObject->HasCapability(capability);
125  }
126  return hasCapability;
127 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
BackendRegistry & BackendRegistryInstance()
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34

◆ IsConcatSupported()

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

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsConstantSupported()

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

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsConvertFp16ToFp32Supported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsConvertFp32ToFp16Supported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsConvolution2dSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported(), and MockLayerSupport::IsLayerSupported().

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

Referenced by ILayerSupport::IsLayerSupported().

◆ IsDepthwiseConvolutionSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsDequantizeSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsDivisionSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsEqualSupported()

bool armnn::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.

◆ IsFakeQuantizationSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsFloat16()

bool armnn::IsFloat16 ( const WorkloadInfo info)

Definition at line 58 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

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

◆ IsFloorSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsFullyConnectedSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsGreaterSupported()

bool armnn::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.

◆ IsInputSupported()

bool armnn::IsInputSupported ( const BackendId backend,
const TensorInfo input,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by ILayerSupport::IsLayerSupported(), and MockLayerSupport::IsLayerSupported().

◆ IsL2NormalizationSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsLstmSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsMaximumSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsMeanSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsMemCopySupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsMergeSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsMinimumSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsMultiplicationSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsNormalizationSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsOperationQueueDescriptor() [1/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const QueueDescriptorType &  )

Definition at line 18 of file RefWorkloadFactory.hpp.

18 { return true; }

◆ IsOperationQueueDescriptor() [2/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const MemCopyQueueDescriptor )

Definition at line 21 of file RefWorkloadFactory.hpp.

21 { return false; }

◆ IsOperationQueueDescriptor() [3/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const ConstantQueueDescriptor )

Definition at line 24 of file RefWorkloadFactory.hpp.

24 { return false; }

◆ IsOperationQueueDescriptor() [4/4]

constexpr bool armnn::IsOperationQueueDescriptor ( const PermuteQueueDescriptor )

Definition at line 27 of file RefWorkloadFactory.hpp.

27 { return false; }

◆ IsOutputSupported()

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

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by ILayerSupport::IsLayerSupported(), and MockLayerSupport::IsLayerSupported().

◆ IsPadSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsPermuteSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsPooling2dSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

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

Referenced by ILayerSupport::IsLayerSupported().

◆ IsPreluSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsQAsymmS8()

bool armnn::IsQAsymmS8 ( const WorkloadInfo info)

Definition at line 73 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

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

◆ IsQAsymmU8()

bool armnn::IsQAsymmU8 ( const WorkloadInfo info)

Definition at line 78 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

79 {
80  return IsDataType<DataType::QAsymmU8>(info);
81 }

◆ IsQSymmS16()

bool armnn::IsQSymmS16 ( const WorkloadInfo info)

Definition at line 63 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

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

◆ IsQSymmS8()

bool armnn::IsQSymmS8 ( const WorkloadInfo info)

Definition at line 68 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

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

◆ IsQuantized8BitType()

constexpr bool armnn::IsQuantized8BitType ( DataType  dataType)

Definition at line 285 of file TypesUtils.hpp.

References QAsymmS8, QAsymmU8, and QSymmS8.

Referenced by GetBiasDataType(), RefLayerSupport::IsConvolution2dSupported(), RefLayerSupport::IsConvolution3dSupported(), RefLayerSupport::IsDepthwiseConvolutionSupported(), IsQuantizedType(), and RefLayerSupport::IsTransposeConvolution2dSupported().

286 {
287  return dataType == DataType::QAsymmU8 ||
288  dataType == DataType::QAsymmS8 ||
289  dataType == DataType::QSymmS8;
290 }

◆ IsQuantizedLstmSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsQuantizedType() [1/2]

◆ IsQuantizedType() [2/2]

constexpr bool armnn::IsQuantizedType ( DataType  dataType)

Definition at line 292 of file TypesUtils.hpp.

References IsQuantized8BitType(), and QSymmS16.

293 {
294  return dataType == DataType::QSymmS16 || IsQuantized8BitType(dataType);
295 }
constexpr bool IsQuantized8BitType(DataType dataType)
Definition: TypesUtils.hpp:285

◆ IsReadyForSplitAssignment()

bool armnn::IsReadyForSplitAssignment ( LayerSelectionInfo::LayerInfoContainer &  layerInfos,
LayerSelectionInfo &  layerInfo 
)

Definition at line 374 of file SubgraphViewSelector.cpp.

References ForEachLayerInput().

Referenced by SubgraphViewSelector::SelectSubgraphs().

375 {
376  bool ready = true;
377  ForEachLayerInput(layerInfos, layerInfo,
378  [&ready](LayerSelectionInfo& parentInfo)
379  {
380  if (!parentInfo.m_IsProcessed)
381  {
382  ready = false;
383  }
384  });
385  return ready;
386 }
void ForEachLayerInput(LayerSelectionInfo::LayerInfoContainer &layerInfos, LayerSelectionInfo &layerInfo, Delegate function)

◆ IsReduceSupported()

bool armnn::IsReduceSupported ( const BackendId backend,
const TensorInfo input,
const TensorInfo output,
const ReduceDescriptor descriptor,
char *  reasonIfUnsupported = nullptr,
size_t  reasonIfUnsupportedMaxLength = 1024 
)

Deprecated in favor of IBackend and ILayerSupport interfaces.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsReshapeSupported()

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 ILayerSupport::IsLayerSupported().

◆ IsResizeSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsRsqrtSupported()

bool armnn::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.

◆ IsSigned32()

bool armnn::IsSigned32 ( const WorkloadInfo info)

Definition at line 48 of file RefWorkloadFactory.cpp.

References info.

Referenced by RefWorkloadFactory::CreateWorkload().

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

◆ IsSoftmaxSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsSpaceToBatchNdSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsSpaceToDepthSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsSplitterSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

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

Referenced by ILayerSupport::IsLayerSupported().

◆ IsStridedSliceSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsSubtractionSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

◆ IsSupportedForDataTypeGeneric()

bool armnn::IsSupportedForDataTypeGeneric ( Optional< std::string &>  reasonIfUnsupported,
DataType  dataType,
Float16Func  float16FuncPtr,
Float32Func  float32FuncPtr,
Uint8Func  uint8FuncPtr,
Int32Func  int32FuncPtr,
BooleanFunc  booleanFuncPtr,
Params &&...  params 
)

Definition at line 27 of file LayerSupportCommon.hpp.

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

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

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

◆ IsSwitchSupported()

bool armnn::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.

Referenced by ILayerSupport::IsLayerSupported().

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

Referenced by ILayerSupport::IsLayerSupported().

◆ LayerEnumOf() [1/73]

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

◆ LayerEnumOf() [2/73]

constexpr LayerType armnn::LayerEnumOf ( const ActivationLayer )

Definition at line 109 of file LayersFwd.hpp.

◆ LayerEnumOf() [3/73]

constexpr LayerType armnn::LayerEnumOf ( const AdditionLayer )

Definition at line 110 of file LayersFwd.hpp.

◆ LayerEnumOf() [4/73]

constexpr LayerType armnn::LayerEnumOf ( const ArgMinMaxLayer )

Definition at line 111 of file LayersFwd.hpp.

◆ LayerEnumOf() [5/73]

constexpr LayerType armnn::LayerEnumOf ( const BatchNormalizationLayer )

Definition at line 112 of file LayersFwd.hpp.

◆ LayerEnumOf() [6/73]

constexpr LayerType armnn::LayerEnumOf ( const BatchToSpaceNdLayer )

Definition at line 113 of file LayersFwd.hpp.

◆ LayerEnumOf() [7/73]

constexpr LayerType armnn::LayerEnumOf ( const CastLayer )

Definition at line 114 of file LayersFwd.hpp.

◆ LayerEnumOf() [8/73]

constexpr LayerType armnn::LayerEnumOf ( const ChannelShuffleLayer )

Definition at line 115 of file LayersFwd.hpp.

◆ LayerEnumOf() [9/73]

constexpr LayerType armnn::LayerEnumOf ( const ComparisonLayer )

Definition at line 116 of file LayersFwd.hpp.

◆ LayerEnumOf() [10/73]

constexpr LayerType armnn::LayerEnumOf ( const ConcatLayer )

Definition at line 117 of file LayersFwd.hpp.

◆ LayerEnumOf() [11/73]

constexpr LayerType armnn::LayerEnumOf ( const ConstantLayer )

Definition at line 118 of file LayersFwd.hpp.

◆ LayerEnumOf() [12/73]

constexpr LayerType armnn::LayerEnumOf ( const ConvertBf16ToFp32Layer )

Definition at line 119 of file LayersFwd.hpp.

◆ LayerEnumOf() [13/73]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp16ToFp32Layer )

Definition at line 120 of file LayersFwd.hpp.

◆ LayerEnumOf() [14/73]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp32ToBf16Layer )

Definition at line 121 of file LayersFwd.hpp.

◆ LayerEnumOf() [15/73]

constexpr LayerType armnn::LayerEnumOf ( const ConvertFp32ToFp16Layer )

Definition at line 122 of file LayersFwd.hpp.

◆ LayerEnumOf() [16/73]

constexpr LayerType armnn::LayerEnumOf ( const Convolution2dLayer )

Definition at line 123 of file LayersFwd.hpp.

◆ LayerEnumOf() [17/73]

constexpr LayerType armnn::LayerEnumOf ( const Convolution3dLayer )

Definition at line 124 of file LayersFwd.hpp.

◆ LayerEnumOf() [18/73]

constexpr LayerType armnn::LayerEnumOf ( const DebugLayer )

Definition at line 125 of file LayersFwd.hpp.

◆ LayerEnumOf() [19/73]

constexpr LayerType armnn::LayerEnumOf ( const DepthToSpaceLayer )

Definition at line 126 of file LayersFwd.hpp.

◆ LayerEnumOf() [20/73]

constexpr LayerType armnn::LayerEnumOf ( const DepthwiseConvolution2dLayer )

Definition at line 127 of file LayersFwd.hpp.

◆ LayerEnumOf() [21/73]

constexpr LayerType armnn::LayerEnumOf ( const DequantizeLayer )

Definition at line 128 of file LayersFwd.hpp.

◆ LayerEnumOf() [22/73]

constexpr LayerType armnn::LayerEnumOf ( const DetectionPostProcessLayer )

Definition at line 129 of file LayersFwd.hpp.

◆ LayerEnumOf() [23/73]

constexpr LayerType armnn::LayerEnumOf ( const DivisionLayer )

Definition at line 130 of file LayersFwd.hpp.

◆ LayerEnumOf() [24/73]

constexpr LayerType armnn::LayerEnumOf ( const ElementwiseUnaryLayer )

Definition at line 131 of file LayersFwd.hpp.

◆ LayerEnumOf() [25/73]

constexpr LayerType armnn::LayerEnumOf ( const FakeQuantizationLayer )

Definition at line 132 of file LayersFwd.hpp.

◆ LayerEnumOf() [26/73]

constexpr LayerType armnn::LayerEnumOf ( const FillLayer )

Definition at line 133 of file LayersFwd.hpp.

◆ LayerEnumOf() [27/73]

constexpr LayerType armnn::LayerEnumOf ( const FloorLayer )

Definition at line 134 of file LayersFwd.hpp.

◆ LayerEnumOf() [28/73]

constexpr LayerType armnn::LayerEnumOf ( const FullyConnectedLayer )

Definition at line 135 of file LayersFwd.hpp.

◆ LayerEnumOf() [29/73]

constexpr LayerType armnn::LayerEnumOf ( const GatherLayer )

Definition at line 136 of file LayersFwd.hpp.

◆ LayerEnumOf() [30/73]

constexpr LayerType armnn::LayerEnumOf ( const InputLayer )

Definition at line 137 of file LayersFwd.hpp.

◆ LayerEnumOf() [31/73]

constexpr LayerType armnn::LayerEnumOf ( const InstanceNormalizationLayer )

Definition at line 138 of file LayersFwd.hpp.

◆ LayerEnumOf() [32/73]

constexpr LayerType armnn::LayerEnumOf ( const L2NormalizationLayer )

Definition at line 139 of file LayersFwd.hpp.

◆ LayerEnumOf() [33/73]

constexpr LayerType armnn::LayerEnumOf ( const LogicalBinaryLayer )

Definition at line 140 of file LayersFwd.hpp.

◆ LayerEnumOf() [34/73]

constexpr LayerType armnn::LayerEnumOf ( const LogSoftmaxLayer )

Definition at line 141 of file LayersFwd.hpp.

◆ LayerEnumOf() [35/73]

constexpr LayerType armnn::LayerEnumOf ( const LstmLayer )

Definition at line 142 of file LayersFwd.hpp.

◆ LayerEnumOf() [36/73]

constexpr LayerType armnn::LayerEnumOf ( const MapLayer )

Definition at line 143 of file LayersFwd.hpp.

◆ LayerEnumOf() [37/73]

constexpr LayerType armnn::LayerEnumOf ( const MaximumLayer )

Definition at line 144 of file LayersFwd.hpp.

◆ LayerEnumOf() [38/73]

constexpr LayerType armnn::LayerEnumOf ( const MeanLayer )

Definition at line 145 of file LayersFwd.hpp.

◆ LayerEnumOf() [39/73]

constexpr LayerType armnn::LayerEnumOf ( const MemCopyLayer )

Definition at line 146 of file LayersFwd.hpp.

◆ LayerEnumOf() [40/73]

constexpr LayerType armnn::LayerEnumOf ( const MemImportLayer )

Definition at line 147 of file LayersFwd.hpp.

◆ LayerEnumOf() [41/73]

constexpr LayerType armnn::LayerEnumOf ( const MergeLayer )

Definition at line 148 of file LayersFwd.hpp.

◆ LayerEnumOf() [42/73]

constexpr LayerType armnn::LayerEnumOf ( const MinimumLayer )

Definition at line 149 of file LayersFwd.hpp.

◆ LayerEnumOf() [43/73]

constexpr LayerType armnn::LayerEnumOf ( const MultiplicationLayer )

Definition at line 150 of file LayersFwd.hpp.

◆ LayerEnumOf() [44/73]

constexpr LayerType armnn::LayerEnumOf ( const NormalizationLayer )

Definition at line 151 of file LayersFwd.hpp.

◆ LayerEnumOf() [45/73]

constexpr LayerType armnn::LayerEnumOf ( const OutputLayer )

Definition at line 152 of file LayersFwd.hpp.

◆ LayerEnumOf() [46/73]

constexpr LayerType armnn::LayerEnumOf ( const PadLayer )

Definition at line 153 of file LayersFwd.hpp.

◆ LayerEnumOf() [47/73]

constexpr LayerType armnn::LayerEnumOf ( const PermuteLayer )

Definition at line 154 of file LayersFwd.hpp.

◆ LayerEnumOf() [48/73]

constexpr LayerType armnn::LayerEnumOf ( const Pooling2dLayer )

Definition at line 155 of file LayersFwd.hpp.

◆ LayerEnumOf() [49/73]

constexpr LayerType armnn::LayerEnumOf ( const Pooling3dLayer )

Definition at line 156 of file LayersFwd.hpp.

◆ LayerEnumOf() [50/73]

constexpr LayerType armnn::LayerEnumOf ( const PreCompiledLayer )

Definition at line 157 of file LayersFwd.hpp.

◆ LayerEnumOf() [51/73]

constexpr LayerType armnn::LayerEnumOf ( const PreluLayer )

Definition at line 158 of file LayersFwd.hpp.

◆ LayerEnumOf() [52/73]

constexpr LayerType armnn::LayerEnumOf ( const QuantizeLayer )

Definition at line 159 of file LayersFwd.hpp.

◆ LayerEnumOf() [53/73]

constexpr LayerType armnn::LayerEnumOf ( const QLstmLayer )

Definition at line 160 of file LayersFwd.hpp.

◆ LayerEnumOf() [54/73]

constexpr LayerType armnn::LayerEnumOf ( const QuantizedLstmLayer )

Definition at line 161 of file LayersFwd.hpp.

◆ LayerEnumOf() [55/73]

constexpr LayerType armnn::LayerEnumOf ( const RankLayer )

Definition at line 162 of file LayersFwd.hpp.

◆ LayerEnumOf() [56/73]

constexpr LayerType armnn::LayerEnumOf ( const ReduceLayer )

Definition at line 163 of file LayersFwd.hpp.

◆ LayerEnumOf() [57/73]

constexpr LayerType armnn::LayerEnumOf ( const ReshapeLayer )

Definition at line 164 of file LayersFwd.hpp.

◆ LayerEnumOf() [58/73]

constexpr LayerType armnn::LayerEnumOf ( const ResizeLayer )

Definition at line 165 of file LayersFwd.hpp.

◆ LayerEnumOf() [59/73]

constexpr LayerType armnn::LayerEnumOf ( const ShapeLayer )

Definition at line 166 of file LayersFwd.hpp.

◆ LayerEnumOf() [60/73]

constexpr LayerType armnn::LayerEnumOf ( const SliceLayer )

Definition at line 167 of file LayersFwd.hpp.

◆ LayerEnumOf() [61/73]

constexpr LayerType armnn::LayerEnumOf ( const SoftmaxLayer )

Definition at line 168 of file LayersFwd.hpp.

◆ LayerEnumOf() [62/73]

constexpr LayerType armnn::LayerEnumOf ( const SpaceToBatchNdLayer )

Definition at line 169 of file LayersFwd.hpp.

◆ LayerEnumOf() [63/73]

constexpr LayerType armnn::LayerEnumOf ( const SpaceToDepthLayer )

Definition at line 170 of file LayersFwd.hpp.

◆ LayerEnumOf() [64/73]

constexpr LayerType armnn::LayerEnumOf ( const SplitterLayer )

Definition at line 171 of file LayersFwd.hpp.

◆ LayerEnumOf() [65/73]

constexpr LayerType armnn::LayerEnumOf ( const StackLayer )

Definition at line 172 of file LayersFwd.hpp.

◆ LayerEnumOf() [66/73]

constexpr LayerType armnn::LayerEnumOf ( const StandInLayer )

Definition at line 173 of file LayersFwd.hpp.

◆ LayerEnumOf() [67/73]

constexpr LayerType armnn::LayerEnumOf ( const StridedSliceLayer )

Definition at line 174 of file LayersFwd.hpp.

◆ LayerEnumOf() [68/73]

constexpr LayerType armnn::LayerEnumOf ( const SubtractionLayer )

Definition at line 175 of file LayersFwd.hpp.

◆ LayerEnumOf() [69/73]

constexpr LayerType armnn::LayerEnumOf ( const SwitchLayer )

Definition at line 176 of file LayersFwd.hpp.

◆ LayerEnumOf() [70/73]

constexpr LayerType armnn::LayerEnumOf ( const TransposeLayer )

Definition at line 177 of file LayersFwd.hpp.

◆ LayerEnumOf() [71/73]

constexpr LayerType armnn::LayerEnumOf ( const TransposeConvolution2dLayer )

Definition at line 178 of file LayersFwd.hpp.

◆ LayerEnumOf() [72/73]

constexpr LayerType armnn::LayerEnumOf ( const UnidirectionalSequenceLstmLayer )

Definition at line 179 of file LayersFwd.hpp.

◆ LayerEnumOf() [73/73]

constexpr LayerType armnn::LayerEnumOf ( const UnmapLayer )

Definition at line 180 of file LayersFwd.hpp.

◆ LevelToString()

std::string armnn::LevelToString ( LogSeverity  level)
inline

Definition at line 15 of file Logging.hpp.

References Debug, Error, Fatal, Info, Trace, and Warning.

Referenced by ScopedRecord::ScopedRecord().

16 {
17  switch(level)
18  {
19  case LogSeverity::Trace:
20  return "Trace";
21  case LogSeverity::Debug:
22  return "Debug";
23  case LogSeverity::Info:
24  return "Info";
25  case LogSeverity::Warning:
26  return "Warning";
27  case LogSeverity::Error:
28  return "Error";
29  case LogSeverity::Fatal:
30  return "Fatal";
31  default:
32  return "Log";
33  }
34 }
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 29 of file LogSoftmax.cpp.

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

Referenced by TEST_SUITE().

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

◆ LowerString()

std::string armnn::LowerString ( std::string  value)

Definition at line 62 of file ClBackendContext.cpp.

63 {
64  std::transform(value.begin(), value.end(), value.begin(),
65  [](unsigned char c){ return std::tolower(c); });
66 
67  return value;
68 }

◆ LstmImpl()

void LstmImpl ( const LstmDescriptor descriptor,
const TensorInfo inputInfo,
const TensorInfo outputInfo,
const TensorShape inputToOutputWeightsShape,
const TensorShape recurrentToOutputWeightsShape,
std::unique_ptr< Decoder< float >> &  inputData,
std::unique_ptr< Decoder< float >> &  outputStateIn,
std::unique_ptr< Decoder< float >> &  cellStateIn,
std::unique_ptr< Encoder< float >> &  outputStateOut,
std::unique_ptr< Encoder< float >> &  cellStateOut,
std::unique_ptr< Encoder< float >> &  output,
std::unique_ptr< Decoder< float >> &  cellStateOutDecoder,
std::unique_ptr< Decoder< float >> &  outputDecoder,
std::unique_ptr< Decoder< float >> &  inputToInputWeightsTensor,
std::unique_ptr< Decoder< float >> &  inputToForgetWeightsTensor,
std::unique_ptr< Decoder< float >> &  inputToCellWeightsTensor,
std::unique_ptr< Decoder< float >> &  inputToOutputWeightsTensor,
std::unique_ptr< Decoder< float >> &  recurrentToInputWeightsTensor,
std::unique_ptr< Decoder< float >> &  recurrentToForgetWeightsTensor,
std::unique_ptr< Decoder< float >> &  recurrentToCellWeightsTensor,
std::unique_ptr< Decoder< float >> &  recurrentToOutputWeightsTensor,
std::unique_ptr< Decoder< float >> &  cellToInputWeightsTensor,
std::unique_ptr< Decoder< float >> &  cellToForgetWeightsTensor,
std::unique_ptr< Decoder< float >> &  cellToOutputWeightsTensor,
std::unique_ptr< Decoder< float >> &  inputGateBiasTensor,
std::unique_ptr< Decoder< float >> &  forgetGateBiasTensor,
std::unique_ptr< Decoder< float >> &  cellBiasTensor,
std::unique_ptr< Decoder< float >> &  outputGateBiasTensor,
std::unique_ptr< Decoder< float >> &  projectionWeightsTensor,
std::unique_ptr< Decoder< float >> &  projectionBiasTensor,
std::unique_ptr< Decoder< float >> &  inputLayerNormWeights,
std::unique_ptr< Decoder< float >> &  forgetLayerNormWeights,
std::unique_ptr< Decoder< float >> &  cellLayerNormWeights,
std::unique_ptr< Decoder< float >> &  outputLayerNormWeights,
std::unique_ptr< Encoder< float >> &  inputGateScratch,
std::unique_ptr< Encoder< float >> &  cellScratch,
std::unique_ptr< Encoder< float >> &  forgetGateScratch,
std::unique_ptr< Encoder< float >> &  outputGateScratch,
std::unique_ptr< Decoder< float >> &  inputGateScratchDecoder,
std::unique_ptr< Decoder< float >> &  cellScratchDecoder,
std::unique_ptr< Decoder< float >> &  forgetGateScratchDecoder,
std::unique_ptr< Decoder< float >> &  outputGateScratchDecoder,
float  layerNormEpsilon 
)

Definition at line 13 of file Lstm.cpp.

References Activation(), ClipVector(), CopyVector(), TensorInfo::GetDataType(), TensorInfo::GetShape(), LstmDescriptor::m_ActivationFunc, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, LstmDescriptor::m_LayerNormEnabled, LstmDescriptor::m_PeepholeEnabled, LstmDescriptor::m_ProjectionEnabled, MatrixBatchVectorMultiplyAccumulate(), MeanStddevNormalization(), SetActivationParameters(), Sigmoid, Sub1Vector(), VectorBatchVectorAdd(), VectorBatchVectorAssign(), VectorBatchVectorCwiseProduct(), VectorBatchVectorCwiseProductAccumulate(), VectorVectorCwiseProduct(), VectorVectorCwiseProductAccumulate(), and ZeroVector().

Referenced by RefLstmWorkload::ExecuteAsync(), and RefUnidirectionalSequenceLstmWorkload::ExecuteAsync().

56 {
57  // This is a porting of the LSTM::Eval() method in the Android code base
58  // Refer to: android/frameworks/ml/nn/common/operations/LSTM.cpp
59 
60  const TensorShape& inputShape = inputInfo.GetShape();
61  const DataType& outputType = outputInfo.GetDataType();
62 
63  const uint32_t nBatch = inputShape[0];
64  const uint32_t nInput = inputShape[1];
65 
66  const uint32_t nCell = inputToOutputWeightsShape[0];
67  const uint32_t nOutput = recurrentToOutputWeightsShape[1];
68 
69  const bool useCifg = descriptor.m_CifgEnabled;
70  const bool usePeephole = descriptor.m_PeepholeEnabled;
71  const bool useLayerNorm = descriptor.m_LayerNormEnabled;
72 
73  if (!useLayerNorm)
74  {
75  // Initialize scratch buffers with bias.
76  if (!useCifg)
77  {
78  VectorBatchVectorAssign(*inputGateBiasTensor,
79  nCell, nBatch, *inputGateScratch);
80  }
81  VectorBatchVectorAssign(*forgetGateBiasTensor,
82  nCell, nBatch, *forgetGateScratch);
83  VectorBatchVectorAssign(*cellBiasTensor,
84  nCell, nBatch, *cellScratch);
85  VectorBatchVectorAssign(*outputGateBiasTensor,
86  nCell, nBatch, *outputGateScratch);
87  }
88  else
89  {
90  // Initialize scratch buffers with zeroes.
91  if (!useCifg)
92  {
93  ZeroVector(*inputGateScratch, nCell * nBatch);
94  }
95  ZeroVector(*forgetGateScratch, nCell * nBatch);
96  ZeroVector(*cellScratch , nCell * nBatch);
97  ZeroVector(*outputGateScratch, nCell * nBatch);
98  }
99 
100  // For each batch and cell: compute input_weight * input.
101  if (!useCifg)
102  {
103  MatrixBatchVectorMultiplyAccumulate(*inputToInputWeightsTensor,
104  nCell, nInput, *inputData, nBatch, *inputGateScratch);
105  }
106  MatrixBatchVectorMultiplyAccumulate(*inputToForgetWeightsTensor,
107  nCell, nInput, *inputData, nBatch, *forgetGateScratch);
108  MatrixBatchVectorMultiplyAccumulate(*inputToCellWeightsTensor,
109  nCell, nInput, *inputData, nBatch, *cellScratch);
110  MatrixBatchVectorMultiplyAccumulate(*inputToOutputWeightsTensor,
111  nCell, nInput, *inputData, nBatch, *outputGateScratch);
112 
113  // For each batch and cell: compute recurrent_weight * output_state.
114  if (!useCifg)
115  {
116  MatrixBatchVectorMultiplyAccumulate(*recurrentToInputWeightsTensor,
117  nCell, nOutput, *outputStateIn, nBatch, *inputGateScratch);
118  }
119  MatrixBatchVectorMultiplyAccumulate(*recurrentToForgetWeightsTensor,
120  nCell, nOutput, *outputStateIn, nBatch, *forgetGateScratch);
121  MatrixBatchVectorMultiplyAccumulate(*recurrentToCellWeightsTensor,
122  nCell, nOutput, *outputStateIn, nBatch, *cellScratch);
123  MatrixBatchVectorMultiplyAccumulate(*recurrentToOutputWeightsTensor,
124  nCell, nOutput, *outputStateIn, nBatch, *outputGateScratch);
125 
126  // For each batch and cell: update input gate.
127  if (!useCifg)
128  {
129  if (usePeephole)
130  {
131  VectorBatchVectorCwiseProductAccumulate(*cellToInputWeightsTensor,
132  nCell, *cellStateIn, nBatch, *inputGateScratch);
133  }
134  if (useLayerNorm)
135  {
136  MeanStddevNormalization(*inputGateScratchDecoder,
137  *inputGateScratch, nCell, nBatch, layerNormEpsilon);
138  VectorBatchVectorCwiseProduct(*inputLayerNormWeights,
139  nCell, *inputGateScratchDecoder, nBatch, *inputGateScratch);
140  VectorBatchVectorAdd(*inputGateBiasTensor,
141  nCell, *inputGateScratchDecoder, nBatch, *inputGateScratch);
142  }
143  Activation(*inputGateScratchDecoder, *inputGateScratch,
144  TensorInfo({nCell, nBatch}, outputType),
145  ActivationFunction::Sigmoid, 0, 0);
146  }
147 
148  // For each batch and cell: update forget gate.
149  if (usePeephole)
150  {
151  VectorBatchVectorCwiseProductAccumulate(*cellToForgetWeightsTensor, nCell,
152  *cellStateIn, nBatch, *forgetGateScratch);
153  }
154  if (useLayerNorm)
155  {
156  MeanStddevNormalization(*forgetGateScratchDecoder,
157  *forgetGateScratch, nCell, nBatch, layerNormEpsilon);
158  VectorBatchVectorCwiseProduct(*forgetLayerNormWeights,
159  nCell, *forgetGateScratchDecoder, nBatch, *forgetGateScratch);
160  VectorBatchVectorAdd(*forgetGateBiasTensor,
161  nCell, *forgetGateScratchDecoder, nBatch, *forgetGateScratch);
162  }
163  Activation(*forgetGateScratchDecoder, *forgetGateScratch,
164  TensorInfo({nCell, nBatch}, outputType),
165  ActivationFunction::Sigmoid, 0, 0);
166 
167  // For each batch and cell: update the cell.
168  if (useLayerNorm)
169  {
170  MeanStddevNormalization(*cellScratchDecoder,
171  *cellScratch, nCell, nBatch, layerNormEpsilon);
172  VectorBatchVectorCwiseProduct(*cellLayerNormWeights,
173  nCell, *cellScratchDecoder, nBatch, *cellScratch);
174  VectorBatchVectorAdd(*cellBiasTensor,
175  nCell, *cellScratchDecoder, nBatch, *cellScratch);
176  }
177 
178  VectorVectorCwiseProduct(*forgetGateScratchDecoder, *cellStateIn, nBatch * nCell, *cellStateOut);
179 
180  ActivationFunction armnnActivationFunc = ActivationFunction::Sigmoid;
181  float a = 0;
182  float b = 0;
183  SetActivationParameters(descriptor.m_ActivationFunc, armnnActivationFunc, a, b);
184 
185  if (descriptor.m_ActivationFunc > 0)
186  {
187  Activation(*cellScratchDecoder, *cellScratch,
188  TensorInfo({nCell, nBatch}, outputType),
189  armnnActivationFunc, a, b);
190  }
191  if (useCifg)
192  {
193  Sub1Vector(*forgetGateScratchDecoder, nBatch * nCell, *forgetGateScratch);
195  *cellScratchDecoder, *forgetGateScratchDecoder, nBatch * nCell, *cellStateOut);
196  }
197  else
198  {
200  *cellScratchDecoder, *inputGateScratchDecoder, nBatch * nCell, *cellStateOut);
201  }
202  if (descriptor.m_ClippingThresCell > 0.0)
203  {
204  ClipVector(*cellStateOutDecoder, nBatch * nCell, descriptor.m_ClippingThresCell, *cellStateOut);
205  }
206 
207  // For each batch and cell: update the output gate.
208  if (usePeephole)
209  {
210  VectorBatchVectorCwiseProductAccumulate(*cellToOutputWeightsTensor,
211  nCell, *cellStateOutDecoder, nBatch, *outputGateScratch);
212  }
213  if (useLayerNorm)
214  {
215  MeanStddevNormalization(*outputGateScratchDecoder,
216  *outputGateScratch, nCell, nBatch, layerNormEpsilon);
217  VectorBatchVectorCwiseProduct(*outputLayerNormWeights,
218  nCell, *outputGateScratchDecoder, nBatch, *outputGateScratch);
219  VectorBatchVectorAdd(*outputGateBiasTensor,
220  nCell, *outputGateScratchDecoder, nBatch, *outputGateScratch);
221  }
222  Activation(*outputGateScratchDecoder, *outputGateScratch,
223  TensorInfo({nCell, nBatch}, outputType),
224  ActivationFunction::Sigmoid, 0, 0);
225 
226  if (descriptor.m_ActivationFunc > 0)
227  {
228  Activation(*cellStateOutDecoder, *cellScratch,
229  TensorInfo({nCell, nBatch}, outputType),
230  armnnActivationFunc, a, b);
231  }
232 
233  VectorVectorCwiseProduct(*outputGateScratchDecoder, *cellScratchDecoder, nBatch * nCell, *outputGateScratch);
234 
235  // For each batch: update the projection and output_state.
236  if (descriptor.m_ProjectionEnabled)
237  {
238  if (projectionBiasTensor)
239  {
240  VectorBatchVectorAssign(*projectionBiasTensor,
241  nOutput, nBatch, *output);
242  }
243  MatrixBatchVectorMultiplyAccumulate(*projectionWeightsTensor,
244  nOutput, nCell, *outputGateScratchDecoder, nBatch, *output);
245 
246  if (descriptor.m_ClippingThresProj > 0.0)
247  {
248  ClipVector(*outputDecoder, nBatch * nOutput, descriptor.m_ClippingThresProj, *output);
249  }
250  }
251  else
252  {
253  CopyVector(*outputGateScratchDecoder, nBatch * nOutput, *output);
254  }
255 
256  CopyVector(*outputDecoder, nBatch * nOutput, *outputStateOut);
257 }
void MeanStddevNormalization(armnn::Decoder< float > &input_vector, armnn::Encoder< float > &output_vector, uint32_t v_size, uint32_t n_batch, float normalization_epsilon)
Definition: LstmUtils.cpp:40
void VectorBatchVectorAdd(armnn::Decoder< float > &vector, uint32_t vSize, armnn::Decoder< float > &batchVector, uint32_t nBatch, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:16
void ClipVector(armnn::Decoder< float > &vector, uint32_t vSize, float absLimit, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:229
void Sub1Vector(armnn::Decoder< float > &vector, uint32_t vSize, armnn::Encoder< float > &result)
Definition: LstmUtils.cpp:173
void CopyVector(armnn::Decoder< float > &vector, uint32_t vSize, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:244
void VectorBatchVectorCwiseProductAccumulate(armnn::Decoder< float > &vector, uint32_t vSize, armnn::Decoder< float > &batchVector, uint32_t nBatch, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:131
void ZeroVector(armnn::Encoder< float > &vector, uint32_t vSize)
Definition: LstmUtils.cpp:76
void VectorVectorCwiseProduct(armnn::Decoder< float > &vector1, armnn::Decoder< float > &vector2, uint32_t vSize, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:187
void VectorBatchVectorCwiseProduct(armnn::Decoder< float > &vector, uint32_t vSize, armnn::Decoder< float > &batchVector, uint32_t nBatch, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:152
void MatrixBatchVectorMultiplyAccumulate(armnn::Decoder< float > &matrix, uint32_t mRows, uint32_t mCols, armnn::Decoder< float > &vector, uint32_t nBatch, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:87
DataType
Definition: Types.hpp:35
float Activation(float in, ActivationFunction function, float a, float b)
Definition: Activation.cpp:13
void VectorVectorCwiseProductAccumulate(armnn::Decoder< float > &vector1, armnn::Decoder< float > &vector2, uint32_t vSize, armnn::Encoder< float > &outResult)
Definition: LstmUtils.cpp:204
void VectorBatchVectorAssign(armnn::Decoder< float > &vector, uint32_t vSize, uint32_t nBatch, armnn::Encoder< float > &outBatchVector)
Definition: LstmUtils.cpp:113
void SetActivationParameters(uint32_t activation, armnn::ActivationFunction &outArmnnActivation, float &outA, float &outB)
Definition: LstmUtils.cpp:258
ActivationFunction
Definition: Types.hpp:73

◆ MakeDecoder() [1/4]

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

Definition at line 66 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, BFloat16, Boolean, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, and Signed32.

67 {
68  switch(info.GetDataType())
69  {
70  case DataType::QAsymmS8:
71  {
72  return std::make_unique<QASymmS8Decoder>(
73  static_cast<const int8_t*>(data),
74  info.GetQuantizationScale(),
75  info.GetQuantizationOffset());
76  }
77  case DataType::QAsymmU8:
78  {
79  return std::make_unique<QASymm8Decoder>(
80  static_cast<const uint8_t*>(data),
81  info.GetQuantizationScale(),
82  info.GetQuantizationOffset());
83  }
84  case DataType::QSymmS16:
85  {
86  return std::make_unique<QSymm16Decoder>(
87  static_cast<const int16_t*>(data),
88  info.GetQuantizationScale(),
89  info.GetQuantizationOffset());
90  }
91  case DataType::BFloat16:
92  {
93  return std::make_unique<BFloat16Decoder>(static_cast<const BFloat16*>(data));
94  }
95  case DataType::Float16:
96  {
97  return std::make_unique<Float16Decoder>(static_cast<const Half*>(data));
98  }
99  case DataType::Float32:
100  {
101  return std::make_unique<Float32Decoder>(static_cast<const float*>(data));
102  }
103  case DataType::Signed32:
104  {
105  return MakeSigned32Decoder(info, data);
106  }
107  case DataType::QSymmS8:
108  {
109  if (info.HasPerAxisQuantization())
110  {
111  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
112  return std::make_unique<QSymm8PerAxisDecoder>(static_cast<const int8_t*>(data), info);
113  }
114  else
115  {
116  return std::make_unique<QSymmS8Decoder>(
117  static_cast<const int8_t*>(data),
118  info.GetQuantizationScale(),
119  info.GetQuantizationOffset());
120  }
121  }
123  {
124  return std::make_unique<BooleanDecoder>(static_cast<const uint8_t*>(data));
125  }
126  default:
127  {
128  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
129  break;
130  }
131  }
132  return nullptr;
133 }
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:18

◆ MakeDecoder() [2/4]

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

Definition at line 66 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, BFloat16, Boolean, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, and Signed32.

67 {
68  switch(info.GetDataType())
69  {
70  case DataType::QAsymmS8:
71  {
72  return std::make_unique<QASymmS8Decoder>(
73  static_cast<const int8_t*>(data),
74  info.GetQuantizationScale(),
75  info.GetQuantizationOffset());
76  }
77  case DataType::QAsymmU8:
78  {
79  return std::make_unique<QASymm8Decoder>(
80  static_cast<const uint8_t*>(data),
81  info.GetQuantizationScale(),
82  info.GetQuantizationOffset());
83  }
84  case DataType::QSymmS16:
85  {
86  return std::make_unique<QSymm16Decoder>(
87  static_cast<const int16_t*>(data),
88  info.GetQuantizationScale(),
89  info.GetQuantizationOffset());
90  }
91  case DataType::BFloat16:
92  {
93  return std::make_unique<BFloat16Decoder>(static_cast<const BFloat16*>(data));
94  }
95  case DataType::Float16:
96  {
97  return std::make_unique<Float16Decoder>(static_cast<const Half*>(data));
98  }
99  case DataType::Float32:
100  {
101  return std::make_unique<Float32Decoder>(static_cast<const float*>(data));
102  }
103  case DataType::Signed32:
104  {
105  return MakeSigned32Decoder(info, data);
106  }
107  case DataType::QSymmS8:
108  {
109  if (info.HasPerAxisQuantization())
110  {
111  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
112  return std::make_unique<QSymm8PerAxisDecoder>(static_cast<const int8_t*>(data), info);
113  }
114  else
115  {
116  return std::make_unique<QSymmS8Decoder>(
117  static_cast<const int8_t*>(data),
118  info.GetQuantizationScale(),
119  info.GetQuantizationOffset());
120  }
121  }
123  {
124  return std::make_unique<BooleanDecoder>(static_cast<const uint8_t*>(data));
125  }
126  default:
127  {
128  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
129  break;
130  }
131  }
132  return nullptr;
133 }
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:18

◆ MakeDecoder() [3/4]

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

Definition at line 136 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, Boolean, and TensorInfo::GetDataType().

137 {
138  switch(info.GetDataType())
139  {
140  case DataType::Boolean:
141  {
142  return std::make_unique<BooleanDecoderBool>(static_cast<const uint8_t*>(data));
143  }
144  default:
145  {
146  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
147  break;
148  }
149  }
150  return nullptr;
151 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeDecoder() [4/4]

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

Definition at line 154 of file Decoders.hpp.

References ARMNN_ASSERT_MSG, TensorInfo::GetDataType(), and Signed32.

155 {
156  switch(info.GetDataType())
157  {
158  case DataType::Signed32:
159  {
160  return std::make_unique<Int32ToInt32tDecoder>(static_cast<const int32_t*>(data));
161  }
162  default:
163  {
164  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
165  break;
166  }
167  }
168  return nullptr;
169 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeEncoder() [1/4]

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

Definition at line 21 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, BFloat16, Boolean, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, and Signed32.

22 {
23  switch(info.GetDataType())
24  {
26  {
27  return std::make_unique<QASymmS8Encoder>(
28  static_cast<int8_t*>(data),
29  info.GetQuantizationScale(),
30  info.GetQuantizationOffset());
31  }
33  {
34  return std::make_unique<QASymm8Encoder>(
35  static_cast<uint8_t*>(data),
36  info.GetQuantizationScale(),
37  info.GetQuantizationOffset());
38  }
39  case DataType::QSymmS8:
40  {
41  if (info.HasPerAxisQuantization())
42  {
43  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
44  return std::make_unique<QSymm8PerAxisEncoder>(
45  static_cast<int8_t*>(data),
46  params.second,
47  params.first);
48  }
49  else
50  {
51  return std::make_unique<QSymmS8Encoder>(
52  static_cast<int8_t*>(data),
53  info.GetQuantizationScale(),
54  info.GetQuantizationOffset());
55  }
56  }
58  {
59  return std::make_unique<QSymm16Encoder>(
60  static_cast<int16_t*>(data),
61  info.GetQuantizationScale(),
62  info.GetQuantizationOffset());
63  }
65  {
66  return std::make_unique<Int32Encoder>(static_cast<int32_t*>(data));
67  }
69  {
70  return std::make_unique<BFloat16Encoder>(static_cast<armnn::BFloat16*>(data));
71  }
73  {
74  return std::make_unique<Float16Encoder>(static_cast<Half*>(data));
75  }
77  {
78  return std::make_unique<Float32Encoder>(static_cast<float*>(data));
79  }
80  default:
81  {
82  ARMNN_ASSERT_MSG(false, "Unsupported target Data Type!");
83  break;
84  }
85  }
86  return nullptr;
87 }
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:18

◆ MakeEncoder() [2/4]

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

Definition at line 21 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, BFloat16, Float16, Float32, TensorInfo::GetDataType(), armnnUtils::GetPerAxisParams(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::HasPerAxisQuantization(), QAsymmS8, QAsymmU8, QSymmS16, QSymmS8, and Signed32.

22 {
23  switch(info.GetDataType())
24  {
26  {
27  return std::make_unique<QASymmS8Encoder>(
28  static_cast<int8_t*>(data),
29  info.GetQuantizationScale(),
30  info.GetQuantizationOffset());
31  }
33  {
34  return std::make_unique<QASymm8Encoder>(
35  static_cast<uint8_t*>(data),
36  info.GetQuantizationScale(),
37  info.GetQuantizationOffset());
38  }
39  case DataType::QSymmS8:
40  {
41  if (info.HasPerAxisQuantization())
42  {
43  std::pair<unsigned int, std::vector<float>> params = armnnUtils::GetPerAxisParams(info);
44  return std::make_unique<QSymm8PerAxisEncoder>(
45  static_cast<int8_t*>(data),
46  params.second,
47  params.first);
48  }
49  else
50  {
51  return std::make_unique<QSymmS8Encoder>(
52  static_cast<int8_t*>(data),
53  info.GetQuantizationScale(),
54  info.GetQuantizationOffset());
55  }
56  }
58  {
59  return std::make_unique<QSymm16Encoder>(
60  static_cast<int16_t*>(data),
61  info.GetQuantizationScale(),
62  info.GetQuantizationOffset());
63  }
65  {
66  return std::make_unique<Int32Encoder>(static_cast<int32_t*>(data));
67  }
69  {
70  return std::make_unique<BFloat16Encoder>(static_cast<armnn::BFloat16*>(data));
71  }
73  {
74  return std::make_unique<Float16Encoder>(static_cast<Half*>(data));
75  }
77  {
78  return std::make_unique<Float32Encoder>(static_cast<float*>(data));
79  }
80  default:
81  {
82  ARMNN_ASSERT_MSG(false, "Unsupported target Data Type!");
83  break;
84  }
85  }
86  return nullptr;
87 }
std::pair< unsigned int, std::vector< float > > GetPerAxisParams(const armnn::TensorInfo &info)
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
half_float::half Half
Definition: Half.hpp:18

◆ MakeEncoder() [3/4]

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

Definition at line 90 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, Boolean, and TensorInfo::GetDataType().

91 {
92  switch(info.GetDataType())
93  {
95  {
96  return std::make_unique<BooleanEncoder>(static_cast<uint8_t*>(data));
97  }
98  default:
99  {
100  ARMNN_ASSERT_MSG(false, "Cannot encode from boolean. Not supported target Data Type!");
101  break;
102  }
103  }
104  return nullptr;
105 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeEncoder() [4/4]

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

Definition at line 108 of file Encoders.hpp.

References ARMNN_ASSERT_MSG, TensorInfo::GetDataType(), and Signed32.

109 {
110  switch(info.GetDataType())
111  {
112  case DataType::Signed32:
113  {
114  return std::make_unique<Int32ToInt32tEncoder>(static_cast<int32_t*>(data));
115  }
116  default:
117  {
118  ARMNN_ASSERT_MSG(false, "Unsupported Data Type!");
119  break;
120  }
121  }
122  return nullptr;
123 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ MakeInfo()

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

Definition at line 17 of file NeonDetectionPostProcessWorkload.cpp.

References DetectionPostProcessDescriptor::m_DetectionsPerClass, DetectionPostProcessDescriptor::m_MaxClassesPerDetection, DetectionPostProcessDescriptor::m_MaxDetections, DetectionPostProcessDescriptor::m_NmsIouThreshold, DetectionPostProcessDescriptor::m_NmsScoreThreshold, DetectionPostProcessDescriptor::m_NumClasses, and DetectionPostProcessDescriptor::m_UseRegularNms.

Referenced by NeonDetectionPostProcessValidate().

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

◆ MakeOptimizations()

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

Definition at line 43 of file Optimizer.hpp.

References Append().

Referenced by Optimize(), and TEST_SUITE().

44 {
45  Optimizer::Optimizations optimizations;
46 
47  Append(optimizations, std::forward<Args>(args)...);
48 
49  return optimizations;
50 }
void Append(Optimizer::Optimizations &optimizations, Front &&front, Others &&... others)
Definition: Optimizer.hpp:36

◆ MakeOptional()

Optional<T> armnn::MakeOptional ( Args &&...  args)

Utility template that constructs an object of type T in-place and wraps it inside an Optional<T> object.

Definition at line 305 of file Optional.hpp.

References CONSTRUCT_IN_PLACE.

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

◆ MakeTransformIterator()

constexpr TransformIterator<Function, Iterator> armnn::MakeTransformIterator ( Iterator  i,
Function  f 
)

Definition at line 81 of file TransformIterator.hpp.

Referenced by TEST_SUITE().

82 {
83  return TransformIterator<Function, Iterator>(i, f);
84 }

◆ MirrorPad()

void MirrorPad ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const ITensorHandle inputHandle,
ITensorHandle outputHandle,
const PadQueueDescriptor data 
)

Definition at line 59 of file MirrorPad.cpp.

References TensorShape::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), PadDescriptor::m_PaddingMode, PadDescriptor::m_PadList, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, ITensorHandle::Map(), Reflect, Encoder< IType >::Set(), and Symmetric.

Referenced by RefPadWorkload::ExecuteAsync().

64 {
65  auto padList = data.m_Parameters.m_PadList;
66  PaddingMode paddingMode = data.m_Parameters.m_PaddingMode;
67 
68  TensorShape outputShape = outputInfo.GetShape();
69  TensorShape inputShape = inputInfo.GetShape();
70 
71  unsigned int numOutputElements = outputInfo.GetNumElements();
72  unsigned int numInputDimensions = inputShape.GetNumDimensions();
73  assert(numInputDimensions == outputShape.GetNumDimensions());
74 
75  // If padding mode is Reflect then both paddings must be no greater than inputShape(i) - 1.
76  // If padding mode is Symmetric then both paddings must be no greater than inputShape(i).
77  const unsigned int isReflect = static_cast<unsigned int>(paddingMode == PaddingMode::Reflect);
78  for(unsigned int i = 0; i < padList.size(); ++i)
79  {
80  if(padList.at(i).first > (inputShape[i] - isReflect) ||
81  padList.at(i).second > (inputShape[i] - isReflect))
82  {
83  throw armnn::InvalidArgumentException("Paddings must be less (Reflect) or "
84  "equal (Symmetric) to the dimension size.");
85  }
86  }
87 
88  auto inputData = MakeDecoder<float>(inputInfo, inputHandle->Map());
89  auto outData = MakeEncoder<float>(outputInfo, outputHandle->Map());
90 
91  Decoder<float>& input = *inputData;
92  Encoder<float>& output = *outData;
93 
94  for(unsigned int idx = 0; idx < numOutputElements; ++idx)
95  {
96  // Get the coordinates of the current index in vector form. E.g inx 1 = [0, 0, 0, 1 ]
97  const std::vector<unsigned int> coord = IndexToCoord(outputShape, idx);
98 
99  std::vector<unsigned int> dimensions;
100  std::vector<unsigned int> coords;
101 
102  for(unsigned int i = 0; i < numInputDimensions; ++i)
103  {
104  dimensions.emplace_back(i);
105  coords.emplace_back(coord[i]);
106  }
107 
108  auto isInPadding = [&](unsigned int i)
109  {
110  return (coords[i] < padList[i].first || coords[i] > inputShape[i] + padList[i].first - 1);
111  };
112 
113  auto getReflectIndex = [&](unsigned int i) -> unsigned int
114  {
115  if(isInPadding(i))
116  {
117  if(coords[i] < padList[i].first)
118  {
119  return padList[i].first - coords[i];
120  }
121  else
122  {
123  return 2 * inputShape[i] + padList[i].first - 2 - coords[i];
124  }
125  }
126  return coords[i] - padList[i].first;
127  };
128 
129  auto getSymmetricIndex = [&](unsigned int i) -> unsigned int
130  {
131  if(isInPadding(i))
132  {
133  if(coords[i] < padList[i].first)
134  {
135  return padList[i].first - coords[i] - 1;
136  }
137  else
138  {
139  return 2 * inputShape[i] + padList[i].first - 1 - coords[i];
140  }
141  }
142  return coords[i] - padList[i].first;
143  };
144 
145  // Location of the value in the input tensor to use in the output.
146  std::vector<unsigned int> coordOfInput;
147 
148  // any_of works as a loop here to check if any of the dimensions are in the padding.
149  // If dimensions is in the padding area, then create the coordinates of the location in the
150  // input tensor to use in the output.
151  // E.g.
152  // Input tensor = [ 1, 2, 3 ], Rank = 1.
153  // Output tensor = [ 2, 1, 2, 3, 1 ] if Reflect or [ 1, 1, 2, 3, 3 ] if Symmetric with a padding of (1, 1).
154  // So it will either return [ 1 ] or [ 0 ] which is used to set the first value in the output tensor and so on.
155  if(std::any_of(dimensions.begin(), dimensions.end(), isInPadding))
156  {
157  switch(paddingMode)
158  {
159  case PaddingMode::Reflect:
160  {
161  for(unsigned int i = 0; i < numInputDimensions; ++i)
162  {
163  coordOfInput.emplace_back(getReflectIndex(i));
164  }
165  break;
166  }
167  case PaddingMode::Symmetric:
168  {
169  for(unsigned int i = 0; i < numInputDimensions; ++i)
170  {
171  coordOfInput.emplace_back(getSymmetricIndex(i));
172  }
173  break;
174  }
175  default:
176  throw InvalidArgumentException("Padding mode not supported.");
177  break;
178  }
179  }
180  else
181  {
182  for(unsigned int i = 0; i < numInputDimensions; ++i)
183  {
184  coordOfInput.emplace_back(coord[i] - padList[i].first);
185  }
186  }
187 
188  // Set output value using the coordinate of the input value to use.
189  const unsigned int indexOfInput = CoordToIndex(inputShape, coordOfInput);
190 
191  input[indexOfInput];
192  auto inputValue = input.Get();
193 
194  output[idx];
195  output.Set(inputValue);
196  }
197 }
PaddingMode
The padding mode controls whether the padding should be filled with constant values (Constant)...
Definition: Types.hpp:173

◆ MockBackendId()

constexpr const char * MockBackendId ( )

◆ MockImportBackendId()

constexpr const char* armnn::MockImportBackendId ( )

Definition at line 12 of file MockImportBackend.hpp.

Referenced by MockImportBackend::GetIdStatic(), and TEST_SUITE().

12 { return "MockRef"; }

◆ MockTensorHandleFactoryId()

constexpr const char* armnn::MockTensorHandleFactoryId ( )

Definition at line 14 of file MockTensorHandleFactory.hpp.

Referenced by MockTensorHandleFactory::GetIdStatic().

15 {
16  return "Arm/Mock/TensorHandleFactory";
17 }

◆ NeonAbsWorkloadValidate()

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

Definition at line 17 of file NeonAbsWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

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

◆ NeonActivationWorkloadValidate()

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

Definition at line 17 of file NeonActivationWorkload.cpp.

Referenced by NeonLayerSupport::IsActivationSupported().

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

◆ NeonAdditionWorkloadValidate()

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

Definition at line 20 of file NeonAdditionWorkload.cpp.

Referenced by NeonLayerSupport::IsAdditionSupported(), and NeonBackend::OptimizeSubgraphView().

24 {
25  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
26  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
27  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
28 
29  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
30  activationDescriptor);
31 
32  return arm_compute::NEArithmeticAddition::validate(&aclInput0,
33  &aclInput1,
34  &aclOutput,
35  arm_compute::ConvertPolicy::SATURATE,
36  activationInfo);
37 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonArgMinMaxWorkloadValidate()

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

Definition at line 31 of file NeonArgMinMaxWorkload.cpp.

Referenced by NeonLayerSupport::IsArgMinMaxSupported().

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

◆ NeonBackendId()

constexpr const char* armnn::NeonBackendId ( )

Definition at line 10 of file NeonBackendId.hpp.

Referenced by NeonBackend::GetIdStatic().

10 { return "CpuAcc"; }

◆ NeonBatchNormalizationValidate()

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

Definition at line 24 of file NeonBatchNormalizationWorkload.cpp.

Referenced by NeonLayerSupport::IsBatchNormalizationSupported(), and NeonBackend::OptimizeSubgraphView().

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

◆ NeonBatchToSpaceNdWorkloadValidate()

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

Definition at line 20 of file NeonBatchToSpaceNdWorkload.cpp.

Referenced by NeonLayerSupport::IsBatchToSpaceNdSupported().

23 {
24  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
25  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
26 
27  // ArmNN blockShape is [H, W] Cl asks for W, H
28  int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
29  int32_t blockWidth = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[1]);
30 
31  const arm_compute::Status aclStatus = arm_compute::NEBatchToSpaceLayer::validate(&aclInputInfo,
32  blockWidth,
33  blockHeight,
34  &aclOutputInfo);
35  return aclStatus;
36 }
Status
enumeration
Definition: Types.hpp:29
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonCastValidate()

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

Definition at line 19 of file NeonCastWorkload.cpp.

Referenced by NeonLayerSupport::IsCastSupported().

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

◆ NeonChannelShuffleValidate()

arm_compute::Status NeonChannelShuffleValidate ( const TensorInfo input,
const TensorInfo output,
const ChannelShuffleDescriptor descriptor 
)

Definition at line 17 of file NeonChannelShuffleWorkload.cpp.

Referenced by NeonLayerSupport::IsChannelShuffleSupported().

20 {
21  arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  // In Arm NN and in NNAPI, channel shuffle implementation is datalayout agnostic and it has axis as a parameter.
25  // The channel shuffle Implementation for Neon is dependent on datalayout and does not have axis as a parameter,
26  // it only supports channel shuffle for 4D tensors in dimension C (1 or 3).
27  arm_compute::DataLayout aclDataLayout;
28  if (input.GetNumDimensions() == 4)
29  {
30  switch (descriptor.m_Axis)
31  {
32  case 1:
33  aclDataLayout = ConvertDataLayout(armnn::DataLayout::NCHW);
34  break;
35  case 3:
36  aclDataLayout = ConvertDataLayout(armnn::DataLayout::NHWC);
37  break;
38  default:
39  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported axis"};
40  }
41  aclInputInfo.set_data_layout(aclDataLayout);
42  aclOutputInfo.set_data_layout(aclDataLayout);
43  return arm_compute::NEChannelShuffleLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_NumGroups);
44  }
45  else
46  {
47  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported number of dimensions"};
48  }
49 }
DataLayout
Definition: Types.hpp:49
Status
enumeration
Definition: Types.hpp:29

◆ NeonComparisonWorkloadValidate()

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

Definition at line 16 of file NeonComparisonWorkload.cpp.

Referenced by NeonLayerSupport::IsComparisonSupported().

20 {
21  const arm_compute::TensorInfo aclInput0 = BuildArmComputeTensorInfo(input0);
22  const arm_compute::TensorInfo aclInput1 = BuildArmComputeTensorInfo(input1);
23  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
24 
25  const arm_compute::ComparisonOperation comparisonOperation = ConvertComparisonOperationToAcl(descriptor);
26 
27  const arm_compute::Status aclStatus = arm_compute::NEElementwiseComparison::validate(&aclInput0,
28  &aclInput1,
29  &aclOutput,
30  comparisonOperation);
31  return aclStatus;
32 }
ComparisonOperation
Definition: Types.hpp:95
Status
enumeration
Definition: Types.hpp:29
arm_compute::ComparisonOperation ConvertComparisonOperationToAcl(const ComparisonDescriptor &descriptor)

◆ NeonConcatWorkloadValidate()

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

Definition at line 27 of file NeonConcatWorkload.cpp.

Referenced by NeonLayerSupport::IsConcatSupported().

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

◆ NeonConstantWorkloadValidate()

arm_compute::Status NeonConstantWorkloadValidate ( const TensorInfo output)

Definition at line 20 of file NeonConstantWorkload.cpp.

Referenced by NeonLayerSupport::IsConstantSupported().

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

◆ NeonConvolution2dWorkloadValidate()

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

Definition at line 24 of file NeonConvolution2dWorkload.cpp.

Referenced by NeonLayerSupport::IsConvolution2dSupported(), and NeonBackend::OptimizeSubgraphView().

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

◆ NeonConvolution3dWorkloadValidate()

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

Definition at line 24 of file NeonConvolution3dWorkload.cpp.

Referenced by NeonLayerSupport::IsConvolution3dSupported().

31 {
32  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
33  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
34  arm_compute::TensorInfo aclBiasesInfo;
35  arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr;
36  if (descriptor.m_BiasEnabled)
37  {
38  ARMNN_ASSERT(biases.has_value());
39 
40  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
41  optionalAclBiasesInfo = &aclBiasesInfo;
42  }
43  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
44 
45  const arm_compute::Conv3dInfo aclConv3DInfo = ComputeConv3DInfo(descriptor,
46  isFastMathEnabled,
47  activationDescriptor);
48 
49  return arm_compute::NEConv3D::validate(&aclInputInfo,
50  &aclWeightsInfo,
51  optionalAclBiasesInfo,
52  &aclOutputInfo,
53  aclConv3DInfo);
54 }
arm_compute::Conv3dInfo ComputeConv3DInfo(const armnn::Convolution3dDescriptor descriptor, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
Utility function used to setup an arm_compute::Conv3dInfo object from convolution3d descriptor...
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ NeonDepthToSpaceWorkloadValidate()

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

Definition at line 19 of file NeonDepthToSpaceWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by NeonLayerSupport::IsDepthToSpaceSupported().

22 {
23  DataLayout dataLayout = descriptor.m_DataLayout;
24  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout);
25  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout);
26 
27  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize);
28 
29  return arm_compute::NEDepthToSpaceLayer::validate(&aclInput, &aclOutput, blockSize);
30 }
DataLayout
Definition: Types.hpp:49
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonDepthwiseConvolutionWorkloadValidate()

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

Definition at line 29 of file NeonDepthwiseConvolutionWorkload.cpp.

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

35 {
36  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
37  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
38 
39  // ArmNN's weight format is usually [ M, I, H, W ] but for depthwise its [ 1, H, W, I*M]
40  // Permute to [ 1, I * M, H, W ] (if NCHW), as required by the compute library
41  unsigned int aclDepthMultiplier;
42  TensorInfo weightsPermuted;
43  std::tie(weightsPermuted, aclDepthMultiplier) = Convert1HWOTensorInfoToAcl(weights, input, descriptor.m_DataLayout);
44 
45  // Convert the weights into the compute library format
46  const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weightsPermuted, descriptor.m_DataLayout);
47 
48  arm_compute::TensorInfo aclBiasesInfo;
49  arm_compute::TensorInfo* optionalAclBiasesInfo = nullptr;
50 
51  if (descriptor.m_BiasEnabled)
52  {
53  ARMNN_ASSERT(biases.has_value());
54 
55  aclBiasesInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
56  optionalAclBiasesInfo = &aclBiasesInfo;
57  }
58 
59  arm_compute::PadStrideInfo aclPadStrideInfo = BuildArmComputePadStrideInfo(descriptor);
60  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
61  descriptor.m_DilationX, descriptor.m_DilationY);
62 
63  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
64  activationDescriptor);
65 
66  return arm_compute::NEDepthwiseConvolutionLayer::validate(&aclInputInfo,
67  &aclWeightsInfo,
68  optionalAclBiasesInfo,
69  &aclOutputInfo,
70  aclPadStrideInfo,
71  aclDepthMultiplier,
72  activationInfo,
73  aclDilationInfo);
74 }
bool m_BiasEnabled
Enable/disable bias.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_DilationY
Dilation factor value for height dimension.
uint32_t m_DilationX
Dilation factor value for width dimension.
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::tuple< TensorInfo, unsigned int > Convert1HWOTensorInfoToAcl(const TensorInfo &weightInfo, const TensorInfo &inputInfo, const DataLayout dataLayout)
Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a TensorInfo...
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonDequantizeWorkloadValidate()

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

Definition at line 22 of file NeonDequantizeWorkload.cpp.

Referenced by NeonLayerSupport::IsDequantizeSupported().

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

◆ NeonDetected()

bool NeonDetected ( )

Definition at line 37 of file Utils.cpp.

38 {
39 #if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
40  auto hwcaps= getauxval(AT_HWCAP);
41 #endif
42 
43 #if !defined(BARE_METAL) && defined(__aarch64__)
44 
45  if (hwcaps & HWCAP_ASIMD)
46  {
47  // On an arm64 device with Neon.
48  return true;
49  }
50  else
51  {
52  // On an arm64 device without Neon.
53  return false;
54  }
55 
56 #endif
57 #if !defined(BARE_METAL) && defined(__arm__)
58 
59  if (hwcaps & HWCAP_NEON)
60  {
61  // On an armhf device with Neon.
62  return true;
63  }
64  else
65  {
66  // On an armhf device without Neon.
67  return false;
68  }
69 
70 #endif
71 
72  // This method of Neon detection is only supported on Linux so in order to prevent a false negative
73  // we will return true in cases where detection did not run.
74  return true;
75 }

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

Definition at line 32 of file NeonDetectionPostProcessWorkload.cpp.

References info, and MakeInfo().

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

◆ NeonDivisionWorkloadValidate()

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

Definition at line 18 of file NeonDivisionWorkload.cpp.

Referenced by NeonLayerSupport::IsDivisionSupported(), and NeonBackend::OptimizeSubgraphView().

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

◆ NeonExpWorkloadValidate()

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

Definition at line 17 of file NeonExpWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

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

◆ NeonFullyConnectedWorkloadValidate()

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

Definition at line 24 of file NeonFullyConnectedWorkload.cpp.

Referenced by NeonLayerSupport::IsFullyConnectedSupported(), and NeonBackend::OptimizeSubgraphView().

30 {
31  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
32  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
33  const arm_compute::TensorInfo aclWeights = BuildArmComputeTensorInfo(weights);
34 
35  arm_compute::TensorInfo aclBiases;
36  arm_compute::TensorInfo* optionalAclBiases = nullptr;
37  if (descriptor.m_BiasEnabled)
38  {
39  ARMNN_ASSERT(biases.has_value());
40  aclBiases = BuildArmComputeTensorInfo(biases.value());
41  optionalAclBiases = &aclBiases;
42  }
43 
44  const arm_compute::FullyConnectedLayerInfo fullyConnectedLayerInfo =
45  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor, activationDescriptor);
46 
47  return arm_compute::NEFullyConnectedLayer::validate(&aclInput,
48  &aclWeights,
49  optionalAclBiases,
50  &aclOutput,
51  fullyConnectedLayerInfo);
52 }
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ NeonGatherWorkloadValidate()

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

Definition at line 13 of file NeonGatherWorkload.cpp.

Referenced by NeonLayerSupport::IsGatherSupported().

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

◆ NeonInstanceNormalizationWorkloadValidate()

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

Definition at line 19 of file NeonInstanceNormalizationWorkload.cpp.

Referenced by NeonLayerSupport::IsInstanceNormalizationSupported().

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

◆ NeonL2NormalizationWorkloadValidate()

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

Definition at line 19 of file NeonL2NormalizationFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsL2NormalizationSupported().

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

◆ NeonLogicalAndWorkloadValidate()

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

Definition at line 18 of file NeonLogicalAndWorkload.cpp.

Referenced by NeonLayerSupport::IsLogicalBinarySupported().

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

◆ NeonLogicalNotWorkloadValidate()

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

Definition at line 19 of file NeonLogicalNotWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

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

◆ NeonLogicalOrWorkloadValidate()

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

Definition at line 18 of file NeonLogicalOrWorkload.cpp.

Referenced by NeonLayerSupport::IsLogicalBinarySupported().

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

◆ NeonLogSoftmaxWorkloadValidate()

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

Definition at line 19 of file NeonLogSoftmaxWorkload.cpp.

Referenced by NeonLayerSupport::IsLogSoftmaxSupported().

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

◆ NeonLogWorkloadValidate()

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

Definition at line 17 of file NeonLogWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

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

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

Referenced by NeonLayerSupport::IsLstmSupported().

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

◆ NeonMaximumWorkloadValidate()

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

Definition at line 14 of file NeonMaximumWorkload.cpp.

Referenced by NeonLayerSupport::IsMaximumSupported().

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

◆ NeonMeanWorkloadValidate()

arm_compute::Status NeonMeanWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const MeanDescriptor descriptor 
)

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  descriptor.m_Axis);
28 
29  return arm_compute::NEReduceMean::validate(&aclInputInfo, coords, descriptor.m_KeepDims, &aclOutputInfo);
30 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ NeonMinimumWorkloadValidate()

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

Validate function for validating the inputs and output.

Parameters
[in]input0The input0 value to be validated.
[in]input1The input1 value to be validated.
[in]outputThe output value to be validated.

Definition at line 15 of file NeonMinimumWorkload.cpp.

Referenced by NeonLayerSupport::IsMinimumSupported().

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

◆ NeonMultiplicationWorkloadValidate()

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

Definition at line 19 of file NeonMultiplicationWorkload.cpp.

Referenced by NeonLayerSupport::IsMultiplicationSupported(), and NeonBackend::OptimizeSubgraphView().

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

◆ NeonNegWorkloadValidate()

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

Definition at line 17 of file NeonNegWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

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

◆ NeonNormalizationWorkloadValidate()

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

Definition at line 49 of file NeonNormalizationFloatWorkload.cpp.

Referenced by NeonLayerSupport::IsNormalizationSupported().

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

◆ NeonPadWorkloadValidate()

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

Definition at line 59 of file NeonPadWorkload.cpp.

Referenced by NeonLayerSupport::IsPadSupported().

62 {
63  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
64  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
65 
66  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
67 
68  std::reverse_copy(std::begin(descriptor.m_PadList),
69  std::end(descriptor.m_PadList),
70  std::begin(reversed_PadList));
71 
72  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
73 
74  // PixelValue is currently unused when validating, but it's required to pass in PaddingMode.
75  arm_compute::PixelValue pixelValue = GetPixelValue(&aclInputInfo, descriptor.m_PadValue);
76  return arm_compute::NEPadLayer::validate(&aclInputInfo,
77  &aclOutputInfo,
78  padList,
79  pixelValue,
80  ConvertPaddingModeToAcl(descriptor.m_PaddingMode));
81 }
arm_compute::PaddingMode ConvertPaddingModeToAcl(const PaddingMode &paddingMode)

◆ NeonPermuteWorkloadValidate()

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

Definition at line 15 of file NeonPermuteWorkload.cpp.

Referenced by NeonLayerSupport::IsPermuteSupported().

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

◆ NeonPooling2dWorkloadValidate()

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

Definition at line 22 of file NeonPooling2dWorkload.cpp.

Referenced by NeonLayerSupport::IsPooling2dSupported().

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

◆ NeonPreluWorkloadValidate()

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

Definition at line 17 of file NeonPreluWorkload.cpp.

Referenced by NeonLayerSupport::IsPreluSupported().

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

◆ NeonQLstmWorkloadValidate()

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

Definition at line 243 of file NeonQLstmWorkload.cpp.

Referenced by NeonLayerSupport::IsQLstmSupported().

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

◆ 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 131 of file NeonQuantizedLstmWorkload.cpp.

Referenced by NeonLayerSupport::IsQuantizedLstmSupported().

137 {
138  // The inputs and outputs
139  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
140  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
141  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
142  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
143  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
144 
145  // Basic parameters
146  const arm_compute::TensorInfo aclInputToInputWeightsInfo
147  = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
148  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
149  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
150  const arm_compute::TensorInfo aclInputToCellWeightsInfo
151  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
152  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
153  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
154 
155  const arm_compute::TensorInfo aclRecurrentToInputWeightsInfo
156  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
157  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
158  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
159  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
160  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
161  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
162  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
163 
164  const arm_compute::TensorInfo aclInputGateBiasInfo
165  = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
166  const arm_compute::TensorInfo aclForgetGateBiasInfo
167  = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
168  const arm_compute::TensorInfo aclCellBiasInfo
169  = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
170  const arm_compute::TensorInfo aclOutputGateBiasInfo
171  = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
172 
173  return arm_compute::NELSTMLayerQuantized::validate(&aclInputInfo,
174  &aclInputToInputWeightsInfo,
175  &aclInputToForgetWeightsInfo,
176  &aclInputToCellWeightsInfo,
177  &aclInputToOutputWeightsInfo,
178  &aclRecurrentToInputWeightsInfo,
179  &aclRecurrentToForgetWeightsInfo,
180  &aclRecurrentToCellWeightsInfo,
181  &aclRecurrentToOutputWeightsInfo,
182  &aclInputGateBiasInfo,
183  &aclForgetGateBiasInfo,
184  &aclCellBiasInfo,
185  &aclOutputGateBiasInfo,
186  &aclCellStateInInfo,
187  &aclOutputStateInInfo,
188  &aclCellStateOutInfo,
189  &aclOutputStateOutInfo);
190 }

◆ NeonQuantizeWorkloadValidate()

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

Definition at line 18 of file NeonQuantizeWorkload.cpp.

Referenced by NeonLayerSupport::IsQuantizeSupported().

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

◆ NeonReduceWorkloadValidate()

arm_compute::Status NeonReduceWorkloadValidate ( const TensorInfo input,
const TensorInfo output,
const ReduceDescriptor descriptor 
)

Definition at line 19 of file NeonReduceWorkload.cpp.

References ReduceDescriptor::m_vAxis.

Referenced by NeonLayerSupport::IsReduceSupported().

22 {
23  if ( descriptor.m_vAxis.size()==1 || descriptor.m_vAxis.empty())
24  {
25  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
26  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
27 
28  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
29  input.GetNumDimensions(),
30  descriptor.m_vAxis);
31 
32  return arm_compute::NEReductionOperation::validate(&aclInputInfo,
33  &aclOutputInfo,
34  static_cast<unsigned int>(coords[0]),
36  descriptor.m_KeepDims);
37  }
38  else
39  {
40  // Validate layer if there are multiple axes.
41  arm_compute::Status status;
43  return status;
44  }
45 }
#define IS_MULTI_AXES_REDUCE_SUPPORTED(func, input, desc, status)
Macro function check if layer with multiple axes is supported on each backend.
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
arm_compute::Status NeonReduceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const ReduceDescriptor &descriptor)
arm_compute::ReductionOperation ConvertReductionOperationToAcl(const ReduceDescriptor &descriptor)
Status
enumeration
Definition: Types.hpp:29

◆ NeonReshapeWorkloadValidate()

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

Definition at line 17 of file NeonReshapeWorkload.cpp.

Referenced by NeonLayerSupport::IsReshapeSupported().

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

◆ NeonResizeWorkloadValidate()

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

Definition at line 22 of file NeonResizeWorkload.cpp.

Referenced by NeonLayerSupport::IsResizeSupported().

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

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

◆ NeonSinWorkloadValidate()

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

Definition at line 17 of file NeonSinWorkload.cpp.

Referenced by NeonLayerSupport::IsElementwiseUnarySupported().

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

◆ NeonSliceWorkloadValidate()

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

Definition at line 21 of file NeonSliceWorkload.cpp.

Referenced by NeonLayerSupport::IsSliceSupported().

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

◆ NeonSoftmaxWorkloadValidate()

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

Definition at line 19 of file NeonSoftmaxWorkload.cpp.

Referenced by NeonLayerSupport::IsSoftmaxSupported().

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

◆ NeonSpaceToBatchNdWorkloadValidate()

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

Definition at line 20 of file NeonSpaceToBatchNdWorkload.cpp.

Referenced by NeonLayerSupport::IsSpaceToBatchNdSupported().

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

◆ NeonSpaceToDepthWorkloadValidate()

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

Definition at line 19 of file NeonSpaceToDepthWorkload.cpp.

References SpaceToDepthDescriptor::m_DataLayout.

Referenced by NeonLayerSupport::IsSpaceToDepthSupported().

22 {
23  DataLayout dataLayout = descriptor.m_DataLayout;
24  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout);
25  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout);
26 
27  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize);
28 
29  return arm_compute::NESpaceToDepthLayer::validate(&aclInput, &aclOutput, blockSize);
30 }
DataLayout
Definition: Types.hpp:49
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonSplitterWorkloadValidate()

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

Definition at line 32 of file NeonSplitterWorkload.cpp.

Referenced by NeonLayerSupport::IsSplitterSupported().

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

◆ NeonStackWorkloadValidate()

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

Definition at line 27 of file NeonStackWorkload.cpp.

Referenced by NeonLayerSupport::IsStackSupported().

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

◆ NeonStridedSliceWorkloadValidate()

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

Definition at line 19 of file NeonStridedSliceWorkload.cpp.

Referenced by NeonLayerSupport::IsStridedSliceSupported().

22 {
23  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
29 
30  std::tie(starts, ends, strides) = SetNeonStridedSliceData(descriptor.m_Begin,
31  descriptor.m_End,
32  descriptor.m_Stride);
33 
34  auto numDimensions = armnn::numeric_cast<int>(input.GetNumDimensions());
35  int32_t begin_mask = ConvertMaskToACLFormat(descriptor.m_BeginMask, numDimensions);
36  int32_t end_mask = ConvertMaskToACLFormat(descriptor.m_EndMask, numDimensions);
37  int32_t shrink_axis_mask = ConvertMaskToACLFormat(descriptor.m_ShrinkAxisMask, numDimensions);
38 
39  return arm_compute::NEStridedSlice::validate(&aclInput,
40  &aclOutput,
41  starts,
42  ends,
43  strides,
44  begin_mask,
45  end_mask,
46  shrink_axis_mask);
47 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
auto SetNeonStridedSliceData(const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)
int32_t ConvertMaskToACLFormat(int32_t mask, int32_t numDim)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ NeonSubtractionWorkloadValidate()

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

Definition at line 22 of file NeonSubtractionWorkload.cpp.

Referenced by NeonLayerSupport::IsSubtractionSupported(), and NeonBackend::OptimizeSubgraphView().

26 {
27  const arm_compute::TensorInfo aclInput0 = armcomputetensorutils::BuildArmComputeTensorInfo(input0);
28  const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input1);
29  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
30 
31  const arm_compute::ActivationLayerInfo activationInfo = ConvertActivationDescriptorToAclActivationLayerInfo(
32  activationDescriptor);
33 
34  return arm_compute::NEArithmeticSubtraction::validate(&aclInput0,
35  &aclInput1,
36  &aclOutput,
37  arm_compute::ConvertPolicy::SATURATE,
38  activationInfo);
39 }
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)

◆ NeonTensorHandleFactoryId()

constexpr const char* armnn::NeonTensorHandleFactoryId ( )

Definition at line 14 of file NeonTensorHandleFactory.hpp.

Referenced by NeonTensorHandleFactory::GetIdStatic().

14 { return "Arm/Neon/TensorHandleFactory"; }

◆ NeonTransposeConvolution2dWorkloadValidate()

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

Definition at line 25 of file NeonTransposeConvolution2dWorkload.cpp.

Referenced by NeonLayerSupport::IsTransposeConvolution2dSupported().

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

◆ NeonTransposeWorkloadValidate()

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

Definition at line 15 of file NeonTransposeWorkload.cpp.

Referenced by NeonLayerSupport::IsTransposeSupported().

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

◆ NextIndex()

bool armnn::NextIndex ( const unsigned int  numDims,
const armnn::TensorShape dims,
std::vector< unsigned int > &  current 
)

Definition at line 19 of file Reduce.cpp.

Referenced by Reduce().

20 {
21  unsigned int carry = 1;
22 
23  for (unsigned int idx = numDims; idx-- > 0; )
24  {
25  unsigned int current_val = current[idx] + carry;
26  if (dims[idx] == current_val)
27  {
28  current[idx] = 0;
29  }
30  else
31  {
32  current[idx] = current_val;
33  carry = 0;
34  break;
35  }
36  }
37  return (carry == 0);
38 }

◆ NonMaxSuppression()

std::vector< unsigned int > NonMaxSuppression ( unsigned int  numBoxes,
const std::vector< float > &  boxCorners,
const std::vector< float > &  scores,
float  nmsScoreThreshold,
unsigned int  maxDetection,
float  nmsIouThreshold 
)

Definition at line 49 of file DetectionPostProcess.cpp.

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

Referenced by DetectionPostProcess(), and TEST_SUITE().

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

◆ numeric_cast() [1/9]

std::enable_if_t< std::is_unsigned<Source>::value && std::is_unsigned<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 35 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

Referenced by AllocateOutputData(), ArgMinMax(), CheckInferenceTimeThreshold(), ClArgMinMaxWorkload::ClArgMinMaxWorkload(), ClSpaceToBatchNdWorkload::ClSpaceToBatchNdWorkload(), ClStridedSliceWorkload::ClStridedSliceWorkload(), ComputeReductionTensorShape(), armnnTfLiteParser::ComputeWrappedIndex(), OutputSlot::Connect(), CreateNetworkImpl< IParser >::Create(), SendCounterPacket::CreateCategoryRecord(), SendCounterPacket::CreateEventRecord(), OnnxParserImpl::CreateNetworkFromString(), DepthwiseConvolution2dAsymmetricTestImpl(), DepthwiseConvolution2dTestImpl(), DetectionPostProcess(), RefL2NormalizationWorkload::ExecuteAsync(), armnnUtils::ExpandDims(), FakeQuantization(), Gather(), CounterDirectory::GetCategoryCount(), MockCounterDirectory::GetCategoryCount(), CounterDirectory::GetCounterCount(), MockCounterDirectory::GetCounterCount(), CounterDirectory::GetCounterSetCount(), MockCounterDirectory::GetCounterSetCount(), CounterDirectory::GetDeviceCount(), MockCounterDirectory::GetDeviceCount(), IDeserializer::DeserializerImpl::GetNetworkOutputBindingInfo(), OutputSlot::GetNumConnections(), SubgraphView::GetNumInputSlots(), SubgraphView::GetNumOutputSlots(), StridedSliceDescriptor::GetStartForAxis(), StridedSliceDescriptor::GetStopForAxis(), GetStreamMetaDataPacketSize(), Cifar10Database::GetTestCaseData(), YoloDatabase::GetTestCaseData(), armnnUtils::GetUnsignedAxis(), RequestCountersPacketHandler::HandlePacket(), InferenceTestImage::InferenceTestImage(), PreluLayer::InferOutputShapes(), RefLayerSupport::IsMeanSupported(), TfLiteParserImpl::LoadModel(), LogSoftmax(), main(), LoadedNetwork::MakeLoadedNetwork(), NeonArgMinMaxWorkload::NeonArgMinMaxWorkload(), NeonSpaceToBatchNdWorkload::NeonSpaceToBatchNdWorkload(), NeonStridedSliceWorkload::NeonStridedSliceWorkload(), NonMaxSuppression(), ClassifierTestCaseProvider< TDatabase, InferenceModel >::OnInferenceTestFinished(), IDeserializer::DeserializerImpl::OutputShapeOfReshape(), TfLiteParserImpl::OutputShapeOfReshape(), ParseArray(), ParseDataArray< armnn::DataType::QAsymmS8 >(), ParseDataArray< armnn::DataType::QAsymmU8 >(), ParseDataArray< armnn::DataType::QSymmS8 >(), Pooling2d(), Pooling3d(), ClassifierTestCase< TTestCaseDatabase, TModel >::ProcessResult(), Reduce(), InferenceModel< IParser, TDataType >::Run(), InferenceModel< IParser, TDataType >::RunAsync(), ClContextSerializer::SaveSerializedToStream(), ISerializer::SerializerImpl::SaveSerializedToStream(), SendCounterPacket::SendPeriodicCounterCapturePacket(), SendCounterPacket::SendPeriodicCounterSelectionPacket(), SendCounterPacket::SendStreamMetaDataPacket(), SimpleConvolution2dNhwcTestImpl(), SimpleConvolution2dTestImpl(), SimpleConvolution3dTestImpl(), InferenceTestImage::StbResize(), StridedSlice(), Graph::SubstituteSubgraph(), TEST_SUITE(), MeanQueueDescriptor::Validate(), ReduceLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), VerifyTimelineLabelBinaryPacketData(), WorkingMemHandle::WorkingMemHandle(), armnn::profiling::WriteTimelineLabelBinaryPacket(), and armnn::profiling::WriteTimelineMessageDirectoryPackage().

36 {
37 #if ENABLE_NUMERIC_CAST_CHECKS
38  if (source > std::numeric_limits<Dest>::max())
39  {
40  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to "
41  "narrower unsigned type. Overflow detected.");
42  }
43 #endif // ENABLE_NUMERIC_CAST_CHECKS
44 
45  return static_cast<Dest>(source);
46 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [2/9]

std::enable_if_t< std::is_signed<Source>::value && std::is_integral<Source>::value && std::is_signed<Dest>::value && std::is_integral<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 58 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

59 {
60 #if ENABLE_NUMERIC_CAST_CHECKS
61  if (source > std::numeric_limits<Dest>::max())
62  {
63  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed integral type to narrower signed type. "
64  "Overflow detected.");
65  }
66 
67  if (source < std::numeric_limits<Dest>::lowest())
68  {
69  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed integral type to narrower signed type. "
70  "Underflow detected.");
71  }
72 #endif // ENABLE_NUMERIC_CAST_CHECKS
73 
74  return static_cast<Dest>(source);
75 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [3/9]

std::enable_if_t< std::is_floating_point<Source>::value && std::is_floating_point<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 83 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

84 {
85 #if ENABLE_NUMERIC_CAST_CHECKS
86  if (source > std::numeric_limits<Dest>::max())
87  {
88  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
89  "Overflow detected.");
90  }
91 
92  if (source < std::numeric_limits<Dest>::lowest())
93  {
94  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
95  "Underflow detected.");
96  }
97 #endif // ENABLE_NUMERIC_CAST_CHECKS
98 
99  return static_cast<Dest>(source);
100 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [4/9]

std::enable_if_t< std::is_floating_point<Source>::value && std::is_signed<Dest>::value && std::is_integral<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 109 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

110 {
111 #if ENABLE_NUMERIC_CAST_CHECKS
112  if (source > static_cast<Source>(std::numeric_limits<Dest>::max()))
113  {
114  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
115  "Overflow detected.");
116  }
117 
118  if (source < static_cast<Source>(std::numeric_limits<Dest>::lowest()))
119  {
120  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to narrower signed type. "
121  "Underflow detected.");
122  }
123 #endif // ENABLE_NUMERIC_CAST_CHECKS
124 
125  return static_cast<Dest>(source);
126 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [5/9]

std::enable_if_t< std::is_signed<Source>::value && std::is_integral<Source>::value && std::is_floating_point<Dest>::value, Dest> armnn::numeric_cast ( Source  source)

Definition at line 135 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

136 {
137 #if ENABLE_NUMERIC_CAST_CHECKS
138  Dest sourceConverted = static_cast<Dest>(source);
139 
140  if (sourceConverted > std::numeric_limits<Dest>::max())
141  {
142  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to narrower floating point type. "
143  "Overflow detected.");
144  }
145 
146  if (sourceConverted < std::numeric_limits<Dest>::lowest())
147  {
148  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to narrower floating point type. "
149  "Underflow detected.");
150  }
151 #endif // ENABLE_NUMERIC_CAST_CHECKS
152 
153  return static_cast<Dest>(source);
154 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [6/9]

std::enable_if_t< std::is_signed<Dest>::value && std::is_integral<Dest>::value && std::is_unsigned<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 165 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

166 {
167 #if ENABLE_NUMERIC_CAST_CHECKS
168  if (sValue > static_cast< typename std::make_unsigned<Dest>::type >(std::numeric_limits<Dest>::max()))
169  {
170  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to signed type. "
171  "Overflow detected.");
172  }
173 #endif // ENABLE_NUMERIC_CAST_CHECKS
174 
175  return static_cast<Dest>(sValue);
176 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [7/9]

std::enable_if_t< std::is_floating_point<Dest>::value && std::is_unsigned<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 184 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

185 {
186 #if ENABLE_NUMERIC_CAST_CHECKS
187  if (static_cast<Dest>(sValue) > std::numeric_limits<Dest>::max())
188  {
189  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting unsigned type to floating point type. "
190  "Overflow detected.");
191  }
192 #endif // ENABLE_NUMERIC_CAST_CHECKS
193 
194  return static_cast<Dest>(sValue);
195 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [8/9]

std::enable_if_t< std::is_unsigned<Dest>::value && std::is_signed<Source>::value && std::is_integral<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 206 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

207 {
208 #if ENABLE_NUMERIC_CAST_CHECKS
209  if (sValue < 0)
210  {
211  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting negative value to unsigned type. "
212  "Underflow detected.");
213  }
214 
215  if (static_cast< typename std::make_unsigned<Source>::type >(sValue) > std::numeric_limits<Dest>::max())
216  {
217  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting signed type to unsigned type. "
218  "Overflow detected.");
219  }
220 #endif // ENABLE_NUMERIC_CAST_CHECKS
221  return static_cast<Dest>(sValue);
222 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ numeric_cast() [9/9]

std::enable_if_t< std::is_unsigned<Dest>::value && std::is_floating_point<Source>::value, Dest> armnn::numeric_cast ( Source  sValue)

Definition at line 230 of file NumericCast.hpp.

References ARMNN_NUMERIC_CAST_CHECK.

231 {
232 #if ENABLE_NUMERIC_CAST_CHECKS
233  if (sValue < 0)
234  {
235  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting negative value to unsigned type. "
236  "Underflow detected.");
237  }
238 
239  if (sValue > static_cast<Source>(std::numeric_limits<Dest>::max()))
240  {
241  ARMNN_NUMERIC_CAST_CHECK(false, "numeric_cast failed casting floating point type to unsigned type. "
242  "Overflow detected.");
243  }
244 #endif // ENABLE_NUMERIC_CAST_CHECKS
245  return static_cast<Dest>(sValue);
246 }
#define ARMNN_NUMERIC_CAST_CHECK(cond, msg)
Definition: NumericCast.hpp:25

◆ Offset()

unsigned int armnn::Offset ( const TensorShape shape,
unsigned int  batch,
unsigned int  height,
unsigned int  width,
unsigned int  channels,
const DataLayoutIndexed dataLayout 
)
inline

Definition at line 19 of file BatchToSpaceNd.cpp.

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

Referenced by BatchToSpaceNd().

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

◆ operator<<() [1/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const std::vector< Compute > &  compute 
)
inline

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

Definition at line 47 of file BackendId.hpp.

References GetComputeDeviceAsCString().

48 {
49  for (const Compute& comp : compute)
50  {
51  os << GetComputeDeviceAsCString(comp) << " ";
52  }
53  return os;
54 }
Compute
The Compute enum is now deprecated and it is now being replaced by BackendId.
Definition: BackendId.hpp:21
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34

◆ operator<<() [2/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const std::set< Compute > &  compute 
)
inline

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

Definition at line 58 of file BackendId.hpp.

References GetComputeDeviceAsCString().

59 {
60  for (const Compute& comp : compute)
61  {
62  os << GetComputeDeviceAsCString(comp) << " ";
63  }
64  return os;
65 }
Compute
The Compute enum is now deprecated and it is now being replaced by BackendId.
Definition: BackendId.hpp:21
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34

◆ operator<<() [3/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const BackendVersion backendVersion 
)
inline

Definition at line 67 of file IBackendInternal.hpp.

References BackendVersion::m_Major, and BackendVersion::m_Minor.

68 {
69  os << "[" << backendVersion.m_Major << "." << backendVersion.m_Minor << "]";
70 
71  return os;
72 }

◆ operator<<() [4/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const Compute compute 
)
inline

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

Definition at line 69 of file BackendId.hpp.

References GetComputeDeviceAsCString().

70 {
71  os << GetComputeDeviceAsCString(compute);
72  return os;
73 }
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34

◆ operator<<() [5/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const BFloat16 b 
)
inline

Definition at line 122 of file BFloat16.hpp.

References BFloat16::ToFloat32(), and BFloat16::Val().

123 {
124  os << b.ToFloat32() << "(0x" << std::hex << b.Val() << ")";
125  return os;
126 }

◆ operator<<() [6/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const BackendId id 
)
inline

Definition at line 176 of file BackendId.hpp.

177 {
178  os << id.Get();
179  return os;
180 }

◆ operator<<() [7/9]

std::ostream& armnn::operator<< ( std::ostream &  os,
const TContainer< BackendId, TContainerTemplateArgs... > &  ids 
)

Definition at line 183 of file BackendId.hpp.

185 {
186  os << '[';
187  for (const auto& id : ids) { os << id << " "; }
188  os << ']';
189  return os;
190 }

◆ operator<<() [8/9]

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

Definition at line 297 of file TypesUtils.hpp.

References GetStatusAsCString().

298 {
299  os << GetStatusAsCString(stat);
300  return os;
301 }
constexpr char const * GetStatusAsCString(Status status)
Definition: TypesUtils.hpp:17

◆ operator<<() [9/9]

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

Definition at line 304 of file TypesUtils.hpp.

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

305 {
306  os << "[";
307  for (uint32_t i=0; i<shape.GetNumDimensions(); ++i)
308  {
309  if (i!=0)
310  {
311  os << ",";
312  }
313  os << shape[i];
314  }
315  os << "]";
316  return os;
317 }
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174

◆ operator>>() [1/2]

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

Definition at line 23 of file InferenceTest.hpp.

References ParseComputeDevice(), and Undefined.

24 {
25  std::string token;
26  in >> token;
27  compute = armnn::ParseComputeDevice(token.c_str());
28  if (compute == armnn::Compute::Undefined)
29  {
30  in.setstate(std::ios_base::failbit);
31  throw cxxopts::OptionException(fmt::format("Unrecognised compute device: {}", token));
32  }
33  return in;
34 }
constexpr armnn::Compute ParseComputeDevice(const char *str)
Deprecated function that will be removed together with the Compute enum.
Definition: TypesUtils.hpp:182

◆ operator>>() [2/2]

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

Definition at line 36 of file InferenceTest.hpp.

References ParseComputeDevice(), and Undefined.

37 {
38  std::string token;
39  in >> token;
40  armnn::Compute compute = armnn::ParseComputeDevice(token.c_str());
41  if (compute == armnn::Compute::Undefined)
42  {
43  in.setstate(std::ios_base::failbit);
44  throw cxxopts::OptionException(fmt::format("Unrecognised compute device: {}", token));
45  }
46  backend = compute;
47  return in;
48 }
Compute
The Compute enum is now deprecated and it is now being replaced by BackendId.
Definition: BackendId.hpp:21
constexpr armnn::Compute ParseComputeDevice(const char *str)
Deprecated function that will be removed together with the Compute enum.
Definition: TypesUtils.hpp:182

◆ 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.
Examples:
AsyncExecutionSample.cpp, CustomMemoryAllocatorSample.cpp, DynamicSample.cpp, and SimpleSample.cpp.

Definition at line 1680 of file Network.cpp.

References Graph::AddCompatibilityLayers(), ApplyBackendOptimizations(), ARMNN_LOG, ARMNN_SCOPED_PROFILING_EVENT, AssignBackends(), Graph::begin(), CreateSupportedBackends(), debug, IOptimizedNetwork::Destroy(), Graph::end(), BackendSettings::GetAvailablePreferredBackends(), ProfilerManager::GetInstance(), InferAndValidate, Graph::InferTensorInfos(), IOptimizedNetwork::IOptimizedNetwork(), OptimizerOptions::m_Debug, OptimizationResult::m_Error, OptimizerOptions::m_ImportEnabled, OptimizerOptions::m_ModelOptions, OptimizerOptions::m_ProfilingEnabled, OptimizerOptions::m_ReduceFp32ToBf16, OptimizerOptions::m_ReduceFp32ToFp16, OptimizerOptions::m_shapeInferenceMethod, BackendSettings::m_SupportedBackends, MakeOptimizations(), Optimizer::Pass(), INetwork::pNetworkImpl, IOptimizedNetwork::pOptimizedNetworkImpl, ProfilerManager::RegisterProfiler(), ReportError(), SelectTensorHandleStrategy(), OptimizerOptions::ToString(), Undefined, and ValidateOnly.

Referenced by armnn::experimental::AsyncEndToEndTestImpl(), armnn::experimental::AsyncThreadedEndToEndTestImpl(), GetSoftmaxProfilerJson(), InferenceModel< IParser, TDataType >::InferenceModel(), ParserFlatbuffersFixture::loadNetwork(), main(), QLstmEndToEnd(), QuantizedLstmEndToEnd(), ParserPrototxtFixture< TParser >::Setup(), ParserFlatbuffersSerializeFixture::Setup(), ParserPrototxtFixture< TParser >::SetupOptimizedNetwork(), TEST_CASE_FIXTURE(), TEST_SUITE(), VerifyPostOptimisationStructureTestImpl(), and IMemoryOptimizerStrategy::~IMemoryOptimizerStrategy().

1685 {
1686  ARMNN_LOG(debug) << options.ToString();
1687 
1688  // Enable profiling
1689  auto profiler = inNetwork.pNetworkImpl->GetGraph().GetProfiler();
1690  ProfilerManager::GetInstance().RegisterProfiler(profiler.get());
1691  profiler->EnableProfiling(options.m_ProfilingEnabled);
1692 
1693  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer");
1694  if (backendPreferences.empty())
1695  {
1696  throw InvalidArgumentException("Invoked Optimize with no backends specified");
1697  }
1698 
1699  if (options.m_ReduceFp32ToFp16 && options.m_ReduceFp32ToBf16)
1700  {
1701  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
1702  }
1703 
1704  // Ensure TensorInfo is set on all output slots of ConstantLayers in the graph
1705  inNetwork.pNetworkImpl->GetGraph().VerifyConstantLayerSetTensorInfo();
1706 
1707  std::unique_ptr<Graph> graph = std::make_unique<Graph>(inNetwork.pNetworkImpl->GetGraph());
1708 
1709  auto optNet = IOptimizedNetworkPtr(new IOptimizedNetwork(std::move(graph), options.m_ModelOptions),
1710  &IOptimizedNetwork::Destroy);
1711 
1712  IOptimizedNetwork* optNetObjPtr = optNet.get();
1713 
1714  // Get the optimized graph
1715  Graph& optGraph = optNetObjPtr->pOptimizedNetworkImpl->GetGraph();
1716 
1717  if(options.m_shapeInferenceMethod == ShapeInferenceMethod::InferAndValidate)
1718  {
1719  // Infer the tensor infos for all output slots. Throws an exception on failure
1720  optGraph.InferTensorInfos();
1721  }
1722 
1723  // Perform AddBroadcastReshapeLayer optimisation
1724  using namespace optimizations;
1725  Optimizer::Pass(optGraph, MakeOptimizations(AddBroadcastReshapeLayer()));
1726 
1727  if(options.m_shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly)
1728  {
1729  // Validate the tensor infos for all output slots. Throws an exception on failure
1730  optGraph.InferTensorInfos();
1731  }
1732 
1733  // Perform optimisation passes
1734  Optimizer::Pass(optGraph, MakeOptimizations(SquashEqualPermuteSiblings(),
1739  MovePermuteUp(),
1740  MoveTransposeUp(),
1741  PermuteAsReshape(),
1754 
1755  // If Fp32 to Fp16 optimization is set convert Fp32 network to Fp16
1756  if (options.m_ReduceFp32ToFp16)
1757  {
1758  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ReduceFp32ToFp16");
1759  Optimizer::Pass(optGraph, MakeOptimizations(Fp32NetworkToFp16Converter()));
1760  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
1761  }
1762 
1763  // If Fp32 to Bf16 optimization is set convert Fp32 network to Bf16
1764  // Convert input of Convolution2d and FullyConnected from Fp32 to Bf16
1765  // Only Constant weight of Convolution2d and FullyConnected are converted from Fp32 to Bf16
1766  if (options.m_ReduceFp32ToBf16)
1767  {
1768  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ReduceFp32ToBf16");
1769  Optimizer::Pass(optGraph, MakeOptimizations(Fp32NetworkToBf16Converter()));
1770  }
1771 
1772  // Initialize backend settings
1773  BackendSettings backendSettings(backendPreferences, deviceSpec);
1774  if (backendSettings.GetAvailablePreferredBackends().empty())
1775  {
1776  std::stringstream failureMsg;
1777  failureMsg << "None of the preferred backends " << backendPreferences
1778  << " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
1779  ReportError(failureMsg.str(), messages);
1780  throw InvalidArgumentException(failureMsg.str());
1781  }
1782 
1783  // Create a map to temporarily hold initialized backend objects
1784  TensorHandleFactoryRegistry tensorHandleFactoryRegistry;
1785  BackendsMap backends = CreateSupportedBackends(tensorHandleFactoryRegistry, backendSettings);
1786 
1787  // Assign an available backend to each layer
1788  Graph::Iterator firstLayer = optGraph.begin();
1789  Graph::Iterator lastLayer = optGraph.end();
1790  OptimizationResult assignBackendsResult = AssignBackends(optNetObjPtr->pOptimizedNetworkImpl.get(),
1791  backendSettings,
1792  firstLayer,
1793  lastLayer,
1794  messages);
1795  if (assignBackendsResult.m_Error)
1796  {
1797  // Failed to assign a backend to each layer
1798  throw InvalidArgumentException("Failed to assign a backend to each layer");
1799  }
1800 
1801  Optimizer::Pass(optGraph, MakeOptimizations(OptimizeInverseConversionsFp16(),
1803 
1804  // Apply the backend-specific optimizations
1805  OptimizationResult backendOptimizationResult = ApplyBackendOptimizations(optNetObjPtr->pOptimizedNetworkImpl.get(),
1806  backendSettings,
1807  backends,
1808  options.m_ModelOptions,
1809  messages);
1810  if (backendOptimizationResult.m_Error)
1811  {
1812  // Failed to apply the backend-specific optimizations
1813  throw InvalidArgumentException("Failed to apply the backend-specific optimizations");
1814  }
1815 
1816  // If the debug flag is set, then insert a DebugLayer after each layer
1817  // Doing this after applying the backend optimizations as they might have changed some layers
1818  if (options.m_Debug)
1819  {
1820  Optimizer::Pass(optGraph, MakeOptimizations(InsertDebugLayer()));
1821  }
1822 
1823  // Calculate the compatibility strategies for tensor handles
1824  OptimizationResult strategyResult = SelectTensorHandleStrategy(optGraph,
1825  backends,
1826  tensorHandleFactoryRegistry,
1827  options.m_ImportEnabled,
1828  messages);
1829  if (strategyResult.m_Error)
1830  {
1831  // Failed to apply the backend-specific optimizations
1832  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
1833  }
1834 
1835  // Based on the tensor handle strategy determined above, insert copy layers where required.
1836  {
1837  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AddCompatibilityLayers");
1838  optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
1839  }
1840 
1841  // Convert constants
1842  {
1843  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ConvertConstants");
1844  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
1845  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsHalfToFloat()));
1846  }
1847  return optNet;
1848 }
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:572
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl< PermuteLayer > > OptimizeInversePermutes
OptimizeForExclusiveConnection< PadLayer, Convolution2dLayer, pad_fold::FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
OptimizeForConnection< TransposeLayer, TransposeLayer, OptimizeInversePermutesImpl< TransposeLayer > > OptimizeInverseTransposes
OptimizeForExclusiveConnection< PadLayer, DepthwiseConvolution2dLayer, pad_fold::FoldPadIntoDepthwiseConvolution2dImpl > FoldPadIntoDepthwiseConvolution2d
OptimizeForConnection< TransposeLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< TransposeLayer > > TransposeAndBatchToSpaceAsDepthToSpace
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoDepthwiseConvolution2DFloat32
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoDepthwiseConvolution2DFloat16
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoConvolution2DFloat16
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoConvolution2DFloat32
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
OptimizeForConnection< Layer, TransposeLayer, MoveTransposeUpImpl > MoveTransposeUp
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
Definition: AddDebug.hpp:34
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteLayer > > PermuteAndBatchToSpaceAsDepthToSpace
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
OptimizeForType< TransposeLayer, TransposeAsReshapeImpl > TransposeAsReshape
OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:1155
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:242
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
OptimizeForConnection< Layer, TransposeLayer, SquashEqualSiblingsImpl< TransposeLayer > > SquashEqualTransposeSiblings
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
Definition: Network.cpp:1136
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
OptimizeForExclusiveConnection< PadLayer, Pooling2dLayer, pad_fold::FoldPadIntoPooling2dImpl > FoldPadIntoPooling2d
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, bool importEnabled, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:1611
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
OptimizeForType< Layer, ConvertFp32NetworkToBf16Impl > Fp32NetworkToBf16Converter
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > &> errMessages)
Definition: Network.cpp:1122
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:287
OptimizeForType< FullyConnectedLayer, RedirectMembersToConstantInputsImpl > RedirectMembersToConstantInputs

◆ Pad()

void Pad ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const ITensorHandle inputHandle,
ITensorHandle outputHandle,
const PadQueueDescriptor data 
)

Definition at line 39 of file Pad.cpp.

References Decoder< IType >::Get(), TensorShape::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), PadDescriptor::m_PadList, PadDescriptor::m_PadValue, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, ITensorHandle::Map(), and Encoder< IType >::Set().

Referenced by TEST_SUITE().

44 {
45  auto padList = data.m_Parameters.m_PadList;
46  auto padValue = data.m_Parameters.m_PadValue;
47 
48  unsigned int numOutputElements = outputInfo.GetNumElements();
49 
50  TensorShape outputShape = outputInfo.GetShape();
51  TensorShape inputShape = inputInfo.GetShape();
52 
53  unsigned int numInputDimensions = inputShape.GetNumDimensions();
54 
55 #ifndef NDEBUG
56 
57  unsigned int numOutputDimensions = outputShape.GetNumDimensions();
58  assert(numInputDimensions == numOutputDimensions);
59 
60 #endif
61 
62  unsigned int inputBatches = 0;
63  unsigned int inputChannels = 0;
64  unsigned int inputHeight = 0;
65  unsigned int inputWidth = 0;
66 
67  unsigned int outputChannels = 0;
68  unsigned int outputHeight = 0;
69  unsigned int outputWidth = 0;
70 
71  auto inputData = MakeDecoder<float>(inputInfo, inputHandle->Map());
72  auto outData = MakeEncoder<float>(outputInfo, outputHandle->Map());
73 
74  // Fill the output tensor with Pad value first
75  if (outputInfo.IsQuantized())
76  {
77  // For Quantized types Pad Value should not be quantized with scale and offset of the tensor info
78  auto temporaryInfo = TensorInfo(outputInfo.GetShape(), outputInfo.GetDataType(), 1.0f, 0);
79  auto outputData = MakeEncoder<float>(temporaryInfo, outputHandle->Map());
80  FillOutputWithPadValue(*outputData, padValue, numOutputElements);
81  }
82  else
83  {
84  FillOutputWithPadValue(*outData, padValue, numOutputElements);
85  }
86 
87  Decoder<float>& input = *inputData;
88  Encoder<float>& output = *outData;
89 
90  switch(numInputDimensions) {
91 
92  case 1:
93  inputWidth = inputShape[0];
94  for (unsigned int w = 0; w < inputWidth ; w++)
95  {
96  input[w];
97  auto inputValue = input.Get();
98  auto outputIndex = w + std::get<0>(padList[0]);
99  output[outputIndex];
100  output.Set(inputValue);
101  }
102 
103  break;
104  case 2 :
105  inputHeight = inputShape[0];
106  inputWidth = inputShape[1];
107  outputWidth = outputShape[1];
108 
109  for (unsigned int h = 0; h < inputHeight; h++)
110  {
111  for (unsigned int w = 0; w < inputWidth ; w++)
112  {
113  input[h * inputWidth + w];
114  auto inputValue = input.Get();
115  auto outputIndex = (h + std::get<0>(padList[0])) * outputWidth + (w + std::get<0>(padList[1]));
116  output[outputIndex];
117  output.Set(inputValue);
118  }
119  }
120 
121  break;
122  case 3 :
123  inputChannels = inputShape[0];
124  inputHeight = inputShape[1];
125  inputWidth = inputShape[2];
126  outputHeight = outputShape[1];
127  outputWidth = outputShape[2];
128 
129  for (unsigned int c = 0; c < inputChannels; c++)
130  {
131  for (unsigned int h = 0; h < inputHeight; h++)
132  {
133  for (unsigned int w = 0; w < inputWidth ; w++)
134  {
135  input[c * inputHeight * inputWidth + h * inputWidth + w];
136  auto inputValue = input.Get();
137  auto outputIndex = (c + std::get<0>(padList[0])) * outputHeight * outputWidth
138  + (h + std::get<0>(padList[1])) * outputWidth
139  + (w + std::get<0>(padList[2]));
140  output[outputIndex];
141  output.Set(inputValue);
142  }
143  }
144  }
145 
146  break;
147  case 4 :
148  inputBatches = inputShape[0];
149  inputChannels = inputShape[1];
150  inputHeight = inputShape[2];
151  inputWidth = inputShape[3];
152  outputChannels = outputShape[1];
153  outputHeight = outputShape[2];
154  outputWidth = outputShape[3];
155 
156  for (unsigned int b = 0; b < inputBatches; b++)
157  {
158  for (unsigned int c = 0; c < inputChannels; c++)
159  {
160  for (unsigned int h = 0; h < inputHeight; h++)
161  {
162  for (unsigned int w = 0; w < inputWidth ; w++)
163  {
164  input[b * inputChannels * inputHeight * inputWidth
165  + c * inputHeight * inputWidth
166  + h * inputWidth
167  + w];
168  auto inputValue = input.Get();
169  auto outputIndex = (b + std::get<0>(padList[0]))
170  * outputChannels * outputHeight * outputWidth
171  + (c + std::get<0>(padList[1])) * outputHeight * outputWidth
172  + (h + std::get<0>(padList[2])) * outputWidth
173  + (w + std::get<0>(padList[3]));
174  output[outputIndex];
175  output.Set(inputValue);
176  }
177  }
178  }
179  }
180 
181  break;
182  default :
183  break;
184  }
185 }

◆ ParseBoolean()

bool armnn::ParseBoolean ( const BackendOptions::Var value,
bool  defaultValue 
)

Definition at line 97 of file ClBackendContext.cpp.

References BackendOptions::Var::AsBool(), and BackendOptions::Var::IsBool().

98 {
99  if (value.IsBool())
100  {
101  return value.AsBool();
102  }
103  return defaultValue;
104 }

◆ ParseBooleanBackendOption()

bool armnn::ParseBooleanBackendOption ( const armnn::BackendOptions::Var value,
bool  defaultValue 
)
inline

Definition at line 312 of file BackendOptions.hpp.

References BackendOptions::Var::AsBool(), and BackendOptions::Var::IsBool().

313 {
314  if (value.IsBool())
315  {
316  return value.AsBool();
317  }
318  return defaultValue;
319 }
bool AsBool() const
Value getters.
bool IsBool() const
Type getters.

◆ ParseComputeDevice()

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

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

Definition at line 182 of file TypesUtils.hpp.

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

Referenced by operator>>().

183 {
184  if (armnn::StrEqual(str, "CpuAcc"))
185  {
186  return armnn::Compute::CpuAcc;
187  }
188  else if (armnn::StrEqual(str, "CpuRef"))
189  {
190  return armnn::Compute::CpuRef;
191  }
192  else if (armnn::StrEqual(str, "GpuAcc"))
193  {
194  return armnn::Compute::GpuAcc;
195  }
196  else
197  {
199  }
200 }
CPU Execution: Reference C++ kernels.
constexpr bool StrEqual(const char *strA, const char(&strB)[N])
Definition: TypesUtils.hpp:170
GPU Execution: OpenCL: ArmCompute.
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(), and ClBackendModelContext::ClBackendModelContext().

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

◆ ParseIntBackendOption()

int armnn::ParseIntBackendOption ( const armnn::BackendOptions::Var value,
int  defaultValue 
)
inline

Definition at line 330 of file BackendOptions.hpp.

References BackendOptions::Var::AsInt(), and BackendOptions::Var::IsInt().

Referenced by ClBackendModelContext::ClBackendModelContext().

331 {
332  if (value.IsInt())
333  {
334  return value.AsInt();
335  }
336  return defaultValue;
337 }

◆ ParseOptions()

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

Definition at line 297 of file BackendOptions.hpp.

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

Referenced by ClBackendContext::ClBackendContext(), ClBackendModelContext::ClBackendModelContext(), NeonBackendModelContext::NeonBackendModelContext(), and RuntimeImpl::RuntimeImpl().

298 {
299  for (auto optionsGroup : options)
300  {
301  if (optionsGroup.GetBackendId() == backend)
302  {
303  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
304  {
305  const BackendOptions::BackendOption option = optionsGroup.GetOption(i);
306  f(option.GetName(), option.GetValue());
307  }
308  }
309  }
310 }

◆ ParseStringBackendOption()

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

Definition at line 321 of file BackendOptions.hpp.

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

322 {
323  if (value.IsString())
324  {
325  return value.AsString();
326  }
327  return defaultValue;
328 }
std::string AsString() const

◆ ParseTuningLevel()

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

Definition at line 79 of file ClBackendContext.cpp.

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

Referenced by ClBackendContext::ClBackendContext().

80 {
81  if (value.IsInt())
82  {
83  int v = value.AsInt();
84  if (v > static_cast<int>(TuningLevel::Exhaustive) ||
85  v < static_cast<int>(TuningLevel::None))
86  {
87  ARMNN_LOG(warning) << "Invalid GpuAcc tuning level ("<< v << ") selected. "
88  "Using default(" << static_cast<int>(defaultValue) << ")";
89  } else
90  {
91  return static_cast<TuningLevel>(v);
92  }
93  }
94  return defaultValue;
95 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205

◆ PermuteTensor()

armnn::ConstTensor PermuteTensor ( const ConstTensorHandle tensor,
const PermutationVector permutationVector,
void *  permuteBuffer 
)

Definition at line 17 of file WorkloadUtils.cpp.

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

Referenced by Convert1HWOTensorToAcl(), Convert1HWOtoMIHW(), ConvertWeightTensorFromArmnnToAcl(), and GatherTensorHandlePairs().

19 {
20  ARMNN_ASSERT_MSG(tensor, "Invalid input tensor");
21  ARMNN_ASSERT_MSG(permuteBuffer, "Invalid permute buffer");
22 
23  TensorInfo tensorInfo = tensor->GetTensorInfo();
24 
25  if (permutationVector.GetSize() > 0)
26  {
27  tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector);
28  armnnUtils::Permute(tensorInfo.GetShape(), permutationVector,
29  tensor->GetConstTensor<void>(), permuteBuffer,
30  GetDataTypeSize(tensorInfo.GetDataType()));
31  }
32  else
33  {
34  ::memcpy(permuteBuffer, tensor->GetConstTensor<void>(), tensorInfo.GetNumBytes());
35  }
36  tensorInfo.SetConstant(true);
37  return ConstTensor(tensorInfo, permuteBuffer);
38 }
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:151

◆ PolymorphicDowncast()

DestType armnn::PolymorphicDowncast ( SourceType *  value)

Polymorphic downcast for build in pointers only.

Usage: Child* pChild = PolymorphicDowncast<Child*>(pBase);

Template Parameters
DestTypePointer type to the target object (Child pointer type)
SourceTypePointer type to the source object (Base pointer type)
Parameters
valuePointer to the source object
Returns
Pointer of type DestType (Pointer of type child)

Definition at line 74 of file PolymorphicDowncast.hpp.

References ARMNN_POLYMORPHIC_CAST_CHECK.

75 {
76  static_assert(std::is_pointer<DestType>::value,
77  "PolymorphicDowncast only works with pointer types.");
78 
79  ARMNN_POLYMORPHIC_CAST_CHECK(dynamic_cast<DestType>(value) == value);
80  return static_cast<DestType>(value);
81 }
#define ARMNN_POLYMORPHIC_CAST_CHECK(cond)

◆ PolymorphicPointerDowncast()

auto armnn::PolymorphicPointerDowncast ( const SourceType &  value)

Polymorphic downcast for shared pointers and build in pointers.

Usage: auto pChild = PolymorphicPointerDowncast<Child>(pBase)

Template Parameters
DestTypeType of the target object (Child type)
SourceTypePointer type to the source object (Base (shared) pointer type)
Parameters
valuePointer to the source object
Returns
Pointer of type DestType ((Shared) pointer of type child)

Definition at line 93 of file PolymorphicDowncast.hpp.

References ARMNN_POLYMORPHIC_CAST_CHECK.

94 {
95  ARMNN_POLYMORPHIC_CAST_CHECK(utility::DynamicPointerCast<DestType>(value)
96  == value);
97  return utility::StaticPointerCast<DestType>(value);
98 }
#define ARMNN_POLYMORPHIC_CAST_CHECK(cond)

◆ Pooling2d()

void Pooling2d ( Decoder< float > &  rInputDecoder,
Encoder< float > &  rOutputEncoder,
const TensorInfo inputInfo,
const TensorInfo outputInfo,
const Pooling2dDescriptor params 
)

Computes the Pooling2d operation.

Definition at line 142 of file Pooling2d.cpp.

References Decoder< IType >::DecodeTensor(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetDataLayout(), DataLayoutIndexed::GetHeightIndex(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), Pooling2dDescriptor::m_DataLayout, Pooling2dDescriptor::m_PadBottom, Pooling2dDescriptor::m_PaddingMethod, Pooling2dDescriptor::m_PadLeft, Pooling2dDescriptor::m_PadRight, Pooling2dDescriptor::m_PadTop, Pooling2dDescriptor::m_PoolHeight, Pooling2dDescriptor::m_PoolType, Pooling2dDescriptor::m_PoolWidth, Pooling2dDescriptor::m_StrideX, Pooling2dDescriptor::m_StrideY, NHWC, numeric_cast(), Pooling2d(), and Encoder< IType >::Set().

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

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

◆ Pooling3d()

void Pooling3d ( Decoder< float > &  rInputDecoder,
Encoder< float > &  rOutputEncoder,
const TensorInfo inputInfo,
const TensorInfo outputInfo,
const Pooling3dDescriptor params 
)

Computes the Pooling3d operation.

Definition at line 172 of file Pooling3d.cpp.

References Decoder< IType >::DecodeTensor(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetDepthIndex(), DataLayoutIndexed::GetHeightIndex(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), Pooling3dDescriptor::m_DataLayout, Pooling3dDescriptor::m_PadBack, Pooling3dDescriptor::m_PadBottom, Pooling3dDescriptor::m_PaddingMethod, Pooling3dDescriptor::m_PadFront, Pooling3dDescriptor::m_PadLeft, Pooling3dDescriptor::m_PadRight, Pooling3dDescriptor::m_PadTop, Pooling3dDescriptor::m_PoolDepth, Pooling3dDescriptor::m_PoolHeight, Pooling3dDescriptor::m_PoolType, Pooling3dDescriptor::m_PoolWidth, Pooling3dDescriptor::m_StrideX, Pooling3dDescriptor::m_StrideY, Pooling3dDescriptor::m_StrideZ, numeric_cast(), Pooling3d(), and Encoder< IType >::Set().

Referenced by Pooling3d(), and Pooling3dLayer::Pooling3dLayer().

177 {
178  const DataLayoutIndexed dataLayout(params.m_DataLayout);
179 
180  auto channelsIndex = dataLayout.GetChannelsIndex();
181 
182  auto depthIndex = dataLayout.GetDepthIndex();
183  auto heightIndex = dataLayout.GetHeightIndex();
184  auto widthIndex = dataLayout.GetWidthIndex();
185 
186  const int batchSize = armnn::numeric_cast<int>(outputInfo.GetShape()[0]);
187  const int channels = armnn::numeric_cast<int>(outputInfo.GetShape()[channelsIndex]);
188 
189  const int depthOutput = armnn::numeric_cast<int>(outputInfo.GetShape()[depthIndex]);
190  const int heightOutput = armnn::numeric_cast<int>(outputInfo.GetShape()[heightIndex]);
191  const int widthOutput = armnn::numeric_cast<int>(outputInfo.GetShape()[widthIndex]);
192 
193  const int depthInput = armnn::numeric_cast<int>(inputInfo.GetShape()[depthIndex]);
194  const int heightInput = armnn::numeric_cast<int>(inputInfo.GetShape()[heightIndex]);
195  const int widthInput = armnn::numeric_cast<int>(inputInfo.GetShape()[widthIndex]);
196 
197  const int padLeft = armnn::numeric_cast<int>(params.m_PadLeft);
198  const int padRight = armnn::numeric_cast<int>(params.m_PadRight);
199  const int padTop = armnn::numeric_cast<int>(params.m_PadTop);
200  const int padBottom = armnn::numeric_cast<int>(params.m_PadBottom);
201  const int padFront = armnn::numeric_cast<int>(params.m_PadFront);
202  const int padBack = armnn::numeric_cast<int>(params.m_PadBack);
203 
204  const int strideX = armnn::numeric_cast<int>(params.m_StrideX);
205  const int strideY = armnn::numeric_cast<int>(params.m_StrideY);
206  const int strideZ = armnn::numeric_cast<int>(params.m_StrideZ);
207 
208  const int poolHeight = armnn::numeric_cast<int>(params.m_PoolHeight);
209  const int poolWidth = armnn::numeric_cast<int>(params.m_PoolWidth);
210  const int poolDepth = armnn::numeric_cast<int>(params.m_PoolDepth);
211 
212  float defaultInitializer = DefaultInitializer(params.m_PoolType);
213  Accumulator accumulate = GetAccumulator(params.m_PoolType);
214  Executor execute = GetExecutor(params.m_PoolType);
215 
216  // Check supported padding methods outside the loop to simplify
217  // the inner loop.
218  if (params.m_PaddingMethod != PaddingMethod::Exclude &&
219  params.m_PaddingMethod != PaddingMethod::IgnoreValue)
220  {
221  throw armnn::InvalidArgumentException("Unsupported padding type");
222  }
223 
224  const std::vector<float> decodedInputVec = rInputDecoder.DecodeTensor(inputInfo.GetShape());
225 
226  for (int n = 0; n < batchSize; n++)
227  {
228  for (int c = 0; c < channels; c++)
229  {
230  for (int zOutput = 0; zOutput < depthOutput; zOutput++)
231  {
232  // Calculate values independent of the x and y axis
233  int dstart = (zOutput * strideZ) - padFront;
234  int dend = dstart + poolDepth;
235  // Clamp the pooling region inside the valid input area (which includes the padding).
236  // This is necessary because the final pooling in a row may overlap beyond the padding.
237  dend = std::min(dend, depthInput + padBack);
238 
239  int depth = dend - dstart;
240  bool dclamped = ClampRange(dstart, dend, depthInput);
241  int depthClamped = dend - dstart;
242 
243  for (int yOutput = 0; yOutput < heightOutput; yOutput++)
244  {
245  int hstart = (yOutput * strideY) - padTop;
246  int hend = hstart + poolHeight;
247  // Clamp the pooling region inside the valid input area (which includes the padding).
248  // This is necessary because the final pooling in a row may overlap beyond the padding.
249  hend = std::min(hend, heightInput + padBottom);
250 
251  int height = hend - hstart;
252  bool hclamped = ClampRange(hstart, hend, heightInput);
253  int heightClamped = hend - hstart;
254 
255  for (int xOutput = 0; xOutput < widthOutput; xOutput++)
256  {
257  int wstart = (xOutput * strideX) - padLeft;
258  int wend = wstart + poolWidth;
259  // Clamp the pooling region inside the valid input area (which includes the padding).
260  // This is necessary because the final pooling in a row may overlap beyond the padding.
261  wend = std::min(wend, widthInput + padRight);
262 
263  int width = wend - wstart;
264  bool wclamped = ClampRange(wstart, wend, widthInput);
265  int widthClamped = wend - wstart;
266 
267  float result = defaultInitializer;
268  float poolAreaSize = armnn::numeric_cast<float>(depth * height * width);
269 
270  // Special case: when the pooling kernel is over a padding region and the padding
271  // size is larger or equal to the kernel and the kernel only covers
272  // padding and no real values, then we initialize the result as zero
273  // by convention. This is because we need to choose a value here and
274  // all values we have are padding, which we ignore.
275  if (OnPaddingOnly(dstart, dend, depthInput) ||
276  OnPaddingOnly(hstart, hend, heightInput) ||
277  OnPaddingOnly(wstart, wend, widthInput))
278  {
279  result = 0.0f;
280 
281  int outputIndex = CalculateIndex(channels, depthOutput, heightOutput, widthOutput,
282  n, c, zOutput, yOutput, xOutput, dataLayout);
283 
284  rOutputEncoder[static_cast<unsigned int>(outputIndex)];
285  rOutputEncoder.Set(result);
286 
287  continue;
288  }
289 
290  bool clamped = (dclamped | hclamped | wclamped);
291 
292  if (clamped && params.m_PaddingMethod == PaddingMethod::Exclude)
293  {
294  // When we exclude the padding, it means we calculate with a smaller
295  // kernel size, so I changed the divisor here.
296  poolAreaSize = armnn::numeric_cast<float>(depthClamped * heightClamped * widthClamped);
297  }
298 
299  for (auto zInput = dstart; zInput < dend; zInput++)
300  {
301  for (auto yInput = hstart; yInput < hend; yInput++)
302  {
303  for (auto xInput = wstart; xInput < wend; xInput++)
304  {
305 
306  int inputIndex = CalculateIndex(channels, depthInput, heightInput, widthInput,
307  n, c, zInput, yInput, xInput, dataLayout);
308 
309  accumulate(result, decodedInputVec[static_cast<unsigned int>(inputIndex)]);
310  }
311  }
312  }
313 
314  execute(result, poolAreaSize);
315 
316  int outputIndex = CalculateIndex(channels, depthOutput, heightOutput, widthOutput,
317  n, c, zOutput, yOutput, xOutput, dataLayout);
318 
319  rOutputEncoder[static_cast<unsigned int>(outputIndex)];
320  rOutputEncoder.Set(result);
321  }
322  }
323  }
324  }
325  }
326 }
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
uint32_t m_PoolWidth
Pooling width value.
uint32_t m_PoolDepth
Pooling depth value.
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, bool isDepthwise=false)=0
virtual void Set(IType right)=0
uint32_t m_PadRight
Padding right value in the width dimension.
DataLayout m_DataLayout
The data layout to be used (NCDHW, NDHWC).
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadBack
Padding back value in the depth dimension.
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).

◆ PreluImpl()

void PreluImpl ( const TensorInfo inputInfo,
const TensorInfo alphaInfo,
const TensorInfo outputInfo,
Decoder< float > &  inputData,
Decoder< float > &  alphaData,
Encoder< float > &  outputData 
)

Definition at line 13 of file PreluImpl.cpp.

References TensorInfo::GetShape(), and BroadcastLoop::Unroll().

Referenced by RefPreluWorkload::ExecuteAsync().

19 {
20  const TensorShape& inputShape = inputInfo.GetShape();
21  const TensorShape& alphaShape = alphaInfo.GetShape();
22  const TensorShape& outputShape = outputInfo.GetShape();
23 
24  // PReLU activation: f(x) = alpha * x for x < 0, f(x) = x for x >= 0
25  auto prelu = [](float x, float alpha)
26  {
27  return x < 0 ? alpha * x : x;
28  };
29 
30  BroadcastLoop(inputShape, alphaShape, outputShape).Unroll(prelu, 0, inputData, alphaData, outputData);
31 }

◆ ProfilingUpdateDescriptions()

void armnn::ProfilingUpdateDescriptions ( const std::string &  name,
const DescriptorType &  desc,
const WorkloadInfo infos,
const profiling::ProfilingGuid  guid 
)
inline

< Profiler used

Definition at line 180 of file Profiling.hpp.

References ProfilerManager::GetInstance(), and IProfiler::IsProfilingEnabled().

184 {
185  IProfiler* profiler(ProfilerManager::GetInstance().GetProfiler()); ///< Profiler used
186  if (profiler && profiler->IsProfilingEnabled())
187  {
188  profiler->AddLayerDetails(name, desc, infos, guid);
189  }
190 }

◆ Quantize() [1/2]

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

Definition at line 114 of file RefWorkloadUtils.hpp.

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

115 {
116  for (size_t i = 0; i < info.GetNumElements(); i++)
117  {
118  quant[i] = armnn::Quantize<uint8_t>(dequant[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
119  }
120 }

◆ Quantize() [2/2]

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

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

Explicit specialization of Quantize for int32_t.

Explicit specialization of Quantize for int16_t.

Explicit specialization of Quantize for uint8_t.

Explicit specialization of Quantize for int8_t.

Parameters
value- The value to quantize.
scale- The scale (must be non-zero).
offset- The offset.
Returns
- The quantized value calculated as round(value/scale)+offset.

Definition at line 30 of file TypesUtils.cpp.

References ARMNN_ASSERT.

Referenced by TEST_SUITE().

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

◆ Reduce()

void Reduce ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
Decoder< float > &  input,
Encoder< float > &  output,
const std::vector< uint32_t >  axis,
const ReduceOperation  reduceOperation 
)

Definition at line 70 of file Reduce.cpp.

References ARMNN_ASSERT, Decoder< IType >::Get(), TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), Max, Mean, Min, NextIndex(), numeric_cast(), Prod, ReducedOutputOffset(), Encoder< IType >::Set(), and Sum.

76 {
77  armnn::TensorShape inputDims = inputInfo.GetShape();
78  unsigned int inputNumDims = inputInfo.GetNumDimensions();
79  unsigned int numOutputs = outputInfo.GetNumElements();
80 
81  // Initialise temp output
82  std::vector<float> tempOut(numOutputs);
83  switch(reduceOperation)
84  {
85  case ReduceOperation::Mean:
86  case ReduceOperation::Sum:
87  std::fill(tempOut.begin(), tempOut.end(), 0.0f);
88  break;
89  case ReduceOperation::Prod:
90  std::fill(tempOut.begin(), tempOut.end(), 1.0f);
91  break;
92  case ReduceOperation::Max:
93  std::fill(tempOut.begin(), tempOut.end(), -1 * std::numeric_limits<float>::max());
94  break;
95  case ReduceOperation::Min:
96  std::fill(tempOut.begin(), tempOut.end(), std::numeric_limits<float>::max());
97  break;
98  default:
99  throw armnn::InvalidArgumentException("Unknown reduce method: " +
100  std::to_string(static_cast<int>(reduceOperation)));
101  }
102 
103  // Initialise temp index
104  std::vector<unsigned int> tempIndex(inputNumDims, 0);
105 
106  std::vector<unsigned int> resolvedAxis = axis;
107  if (resolvedAxis.empty())
108  {
109  for (unsigned int idx = 0; idx < inputNumDims; ++idx)
110  {
111  resolvedAxis.push_back(idx);
112  }
113  }
114  auto numResolvedAxis = armnn::numeric_cast<unsigned int>(resolvedAxis.size());
115 
116  // Iterates through input_data and operates over 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  auto inputValue = input.Get();
124  switch(reduceOperation)
125  {
126  case ReduceOperation::Mean:
127  case ReduceOperation::Sum:
128  tempOut[outputOffset] += inputValue;
129  break;
130  case ReduceOperation::Prod:
131  tempOut[outputOffset] *= inputValue;
132  break;
133  case ReduceOperation::Max:
134  if (inputValue > tempOut[outputOffset])
135  {
136  tempOut[outputOffset] = inputValue;
137  }
138  break;
139  case ReduceOperation::Min:
140  if (inputValue < tempOut[outputOffset])
141  {
142  tempOut[outputOffset] = inputValue;
143  }
144  break;
145  default:
146  throw armnn::InvalidArgumentException("Unknown reduce method: " +
147  std::to_string(static_cast<int>(reduceOperation)));
148  }
149  }
150 
151  // Takes average by num of elements added to get MEAN
152  size_t numElementsInAxis = 1;
153  for (unsigned int idx = 0; idx < numResolvedAxis; ++idx)
154  {
155  unsigned int current = inputDims[resolvedAxis[idx]];
156  ARMNN_ASSERT(armnn::numeric_cast<float>(current) <
157  (std::numeric_limits<float>::max() / armnn::numeric_cast<float>(numElementsInAxis)));
158  numElementsInAxis *= current;
159  }
160 
161  for (unsigned int idx = 0; idx < numOutputs; ++idx)
162  {
163  output[idx];
164  if (reduceOperation == ReduceOperation::Mean)
165  {
166  if (numElementsInAxis > 0)
167  {
168  output.Set(tempOut[idx] / armnn::numeric_cast<float>(numElementsInAxis));
169  }
170  }
171  else
172  {
173  output.Set(tempOut[idx]);
174  }
175  }
176 }
bool NextIndex(const unsigned int numDims, const armnn::TensorShape &dims, std::vector< unsigned int > &current)
Definition: Reduce.cpp:19
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: Reduce.cpp:40
virtual void Set(IType right)=0
virtual IType Get() const =0
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ 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 40 of file Reduce.cpp.

Referenced by Reduce().

45 {
46  unsigned int offset = 0;
47  for (unsigned int idx = 0; idx < numDims; ++idx)
48  {
49  bool isAxis = false;
50  if (!axis.empty())
51  {
52  for (unsigned int axisIdx = 0; axisIdx < numAxis; ++axisIdx)
53  {
54  if (idx == axis[axisIdx])
55  {
56  isAxis = true;
57  break;
58  }
59  }
60  }
61  if (!isAxis)
62  {
63  offset = offset * dims[idx] + index[idx];
64  }
65  }
66  return offset;
67 }

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

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

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

◆ ReplaceLayers()

void armnn::ReplaceLayers ( OptimizationViews optimizationViews,
LayerType baseLayer,
std::vector< IConnectableLayer *> &  layers 
)

Definition at line 392 of file ArmComputeSubgraphUtils.hpp.

References OptimizationViews::AddSubstitution().

395 {
396  std::list<IConnectableLayer*> replacementLayers(layers.begin(), layers.end());
397 
398  SubgraphView substitutionSubgraph(baseLayer);
399  SubgraphView replacementSubgraph(std::move(replacementLayers),
400  CreateIInputsFrom({replacementLayers.front()}),
401  CreateIOutputsFrom({replacementLayers.back()}));
402 
403  optimizationViews.AddSubstitution({substitutionSubgraph, replacementSubgraph});
404 }

◆ ReportError()

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

Definition at line 572 of file Network.cpp.

References ARMNN_LOG, and warning.

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

574 {
575  std::stringstream fullErrorMessage;
576  fullErrorMessage << "ERROR: " << errorMessage;
577  ARMNN_LOG(warning) << fullErrorMessage.str();
578  if (errorMessages)
579  {
580  errorMessages.value().push_back(fullErrorMessage.str());
581  }
582 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205

◆ ReportUntouchedLayers()

void armnn::ReportUntouchedLayers ( OptimizationViews optimizationViews,
std::map< LayerGuid, Layer *>  untouched 
)
inline

Definition at line 82 of file ArmComputeSubgraphUtils.hpp.

References OptimizationViews::AddUntouchedSubgraph().

Referenced by NeonBackend::OptimizeSubgraphView(), and ClBackend::OptimizeSubgraphView().

83 {
84  std::vector<Layer*> untouchedVector;
85  for (const auto& pair : untouched)
86  {
87  Layer* layer = pair.second;
88  SubgraphView subgraphView({layer},
89  CreateIInputsFrom({layer}),
90  CreateIOutputsFrom({layer}));
91  optimizationViews.AddUntouchedSubgraph(std::move(subgraphView));
92  }
93 }

◆ ReportWarning()

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

Definition at line 584 of file Network.cpp.

References ARMNN_LOG, and warning.

Referenced by ApplyBackendOptimizations(), and AttemptBackendAssignment().

586 {
587  std::stringstream fullWarningMessage;
588  fullWarningMessage << "WARNING: " << warningMessage;
589  ARMNN_LOG(warning) << fullWarningMessage.str();
590  if (warningMessages)
591  {
592  warningMessages.value().push_back(fullWarningMessage.str());
593  }
594 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:205

◆ RequiresCopy()

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

Definition at line 1257 of file Network.cpp.

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

Referenced by CalculateSlotOption().

1260 {
1261  if (src != dst)
1262  {
1263  ITensorHandleFactory* srcFactory = registry.GetFactory(src);
1264  ITensorHandleFactory* dstFactory = registry.GetFactory(dst);
1265 
1266  if (srcFactory && dstFactory &&
1267  (srcFactory->GetExportFlags() & dstFactory->GetImportFlags()) != 0)
1268  {
1269  return false;
1270  }
1271  return true;
1272  }
1273  return false;
1274 }

◆ ReshapeWeightsForAcl()

void ReshapeWeightsForAcl ( TensorInfo weightInfo,
DataLayout  dataLayout 
)

Definition at line 40 of file WorkloadUtils.cpp.

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

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

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

◆ Resize()

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

Definition at line 65 of file Resize.cpp.

References ARMNN_ASSERT, Bilinear, Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), NearestNeighbor, Resize(), and Encoder< IType >::Set().

Referenced by InferenceTestImage::GetSizeInBytes(), Resize(), ResizeLayer::ResizeLayer(), and TEST_SUITE().

73 {
74  // alignCorners and halfPixelCenters cannot both be true
75  ARMNN_ASSERT(!(alignCorners && halfPixelCenters));
76 
77  // We follow the definition of TensorFlow and AndroidNN: the top-left corner of a texel in the output
78  // image is projected into the input image to figure out the interpolants and weights. Note that this
79  // will yield different results than if projecting the centre of output texels.
80 
81  const unsigned int batchSize = inputInfo.GetShape()[0];
82  const unsigned int channelCount = inputInfo.GetShape()[dataLayout.GetChannelsIndex()];
83 
84  const unsigned int inputHeight = inputInfo.GetShape()[dataLayout.GetHeightIndex()];
85  const unsigned int inputWidth = inputInfo.GetShape()[dataLayout.GetWidthIndex()];
86  const unsigned int outputHeight = outputInfo.GetShape()[dataLayout.GetHeightIndex()];
87  const unsigned int outputWidth = outputInfo.GetShape()[dataLayout.GetWidthIndex()];
88 
89  // How much to scale pixel coordinates in the output image, to get the corresponding pixel coordinates
90  // in the input image.
91  const float scaleY = CalculateResizeScale(inputHeight, outputHeight, alignCorners);
92  const float scaleX = CalculateResizeScale(inputWidth, outputWidth, alignCorners);
93 
94  TensorShape inputShape = inputInfo.GetShape();
95  TensorShape outputShape = outputInfo.GetShape();
96 
97  for (unsigned int n = 0; n < batchSize; ++n)
98  {
99  for (unsigned int c = 0; c < channelCount; ++c)
100  {
101  for (unsigned int y = 0; y < outputHeight; ++y)
102  {
103  // Corresponding real-valued height coordinate in input image.
104  float iy = PixelScaler(y, scaleY, halfPixelCenters, resizeMethod);
105 
106  // Discrete height coordinate of top-left texel (in the 2x2 texel area used for interpolation).
107  const float fiy = (resizeMethod == armnn::ResizeMethod::NearestNeighbor && alignCorners) ?
108  roundf(iy) : floorf(iy);
109  // Pixel scaling a value with Half Pixel Centers can be negative, if so set to 0
110  const unsigned int y0 = static_cast<unsigned int>(std::max(fiy, 0.0f));
111 
112  // Interpolation weight (range [0,1]).
113  const float yw = iy - fiy;
114 
115  for (unsigned int x = 0; x < outputWidth; ++x)
116  {
117  // Real-valued and discrete width coordinates in input image.
118  float ix = PixelScaler(x, scaleX, halfPixelCenters, resizeMethod);
119 
120  // Nearest Neighbour uses rounding to align to corners
121  const float fix = resizeMethod == armnn::ResizeMethod::NearestNeighbor && alignCorners ?
122  roundf(ix) : floorf(ix);
123  // Pixel scaling a value with Half Pixel Centers can be negative, if so set to 0
124  const unsigned int x0 = static_cast<unsigned int>(std::max(fix, 0.0f));
125 
126  // Interpolation weight (range [0,1]).
127  const float xw = ix - fix;
128 
129  unsigned int x1;
130  unsigned int y1;
131  // Half Pixel Centers uses the scaling to compute a weighted parameter for nearby pixels
132  if (halfPixelCenters)
133  {
134  x1 = std::min(static_cast<unsigned int>(std::ceil(ix)), inputWidth - 1u);
135  y1 = std::min(static_cast<unsigned int>(std::ceil(iy)), inputHeight - 1u);
136  }
137  // Discrete width/height coordinates of texels below and to the right of (x0, y0).
138  else
139  {
140  x1 = std::min(x0 + 1, inputWidth - 1u);
141  y1 = std::min(y0 + 1, inputHeight - 1u);
142  }
143 
144  float interpolatedValue;
145  switch (resizeMethod)
146  {
148  {
149  in[dataLayout.GetIndex(inputShape, n, c, y0, x0)];
150  float input1 = in.Get();
151  in[dataLayout.GetIndex(inputShape, n, c, y0, x1)];
152  float input2 = in.Get();
153  in[dataLayout.GetIndex(inputShape, n, c, y1, x0)];
154  float input3 = in.Get();
155  in[dataLayout.GetIndex(inputShape, n, c, y1, x1)];
156  float input4 = in.Get();
157 
158  const float ly0 = Lerp(input1, input2, xw); // lerp along row y0.
159  const float ly1 = Lerp(input3, input4, xw); // lerp along row y1.
160  interpolatedValue = Lerp(ly0, ly1, yw);
161  break;
162  }
164  {
165  // calculate euclidean distance to the 4 neighbours
166  auto distance00 = EuclideanDistance(fix, fiy, x0, y0);
167  auto distance01 = EuclideanDistance(fix, fiy, x0, y1);
168  auto distance10 = EuclideanDistance(fix, fiy, x1, y0);
169  auto distance11 = EuclideanDistance(fix, fiy, x1, y1);
170 
171  auto minimum = std::min( { distance00, distance01, distance10, distance11 } );
172 
173  unsigned int xNearest = 0;
174  unsigned int yNearest = 0;
175 
176  if (minimum == distance00)
177  {
178  xNearest = x0;
179  yNearest = y0;
180  }
181  else if (minimum == distance01)
182  {
183  xNearest = x0;
184  yNearest = y1;
185  }
186  else if (minimum == distance10)
187  {
188  xNearest = x1;
189  yNearest = y0;
190  }
191  else if (minimum == distance11)
192  {
193  xNearest = x1;
194  yNearest = y1;
195  }
196  else
197  {
198  throw armnn::InvalidArgumentException("Resize Nearest Neighbor failure");
199  }
200 
201  in[dataLayout.GetIndex(inputShape, n, c, yNearest, xNearest)];
202  interpolatedValue = in.Get();
203  break;
204  }
205  default:
206  throw armnn::InvalidArgumentException("Unknown resize method: " +
207  std::to_string(static_cast<int>(resizeMethod)));
208  }
209  out[dataLayout.GetIndex(outputShape, n, c, y, x)];
210  out.Set(interpolatedValue);
211  }
212  }
213  }
214  }
215 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
virtual void Set(IType right)=0
unsigned int GetHeightIndex() const
virtual IType Get() const =0
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
unsigned int GetChannelsIndex() const

◆ ReturnWithError()

OptimizationResult armnn::ReturnWithError ( OptimizationResult  res,
const Layer layer,
const BackendSettings backendSettings,
Optional< std::vector< std::string > &>  errMessages 
)

Definition at line 596 of file Network.cpp.

References GetLayerTypeAsCString(), Layer::GetType(), OptimizationResult::m_Error, BackendSettings::m_PreferredBackends, and ReportError().

Referenced by AssignBackendsIConnectable(), and AttemptBackendAssignment().

600 {
601  std::stringstream failureMsg;
602  failureMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
603  << " is not supported on any preferred backend " << backendSettings.m_PreferredBackends;
604  ReportError(failureMsg.str(), errMessages);
605 
606  res.m_Error = true;
607  return res;
608 }
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > &> errorMessages)
Definition: Network.cpp:572
const char * GetLayerTypeAsCString(LayerType type)

◆ RunClFunction()

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

Definition at line 155 of file ClWorkloadUtils.hpp.

References Error, error, and WrapClError().

Referenced by ClFillWorkload::Execute(), ClPadWorkload::Execute(), ClAdditionWorkload::Execute(), ClSubtractionWorkload::Execute(), ClActivationWorkload::Execute(), ClPreluWorkload::Execute(), ClExpWorkload::Execute(), ClQuantizeWorkload::Execute(), ClRsqrtWorkload::Execute(), ClSinWorkload::Execute(), ClConvertFp16ToFp32Workload::Execute(), ClConvertFp32ToFp16Workload::Execute(), ClAbsWorkload::Execute(), ClLogWorkload::Execute(), ClLstmFloatWorkload::Execute(), ClCastWorkload::Execute(), ClNegWorkload::Execute(), ClResizeWorkload::Execute(), ClSpaceToDepthWorkload::Execute(), ClFloorFloatWorkload::Execute(), ClReshapeWorkload::Execute(), ClGatherWorkload::Execute(), ClInstanceNormalizationWorkload::Execute(), ClBatchToSpaceNdWorkload::Execute(), ClMaximumWorkload::Execute(), ClMinimumWorkload::Execute(), ClNormalizationFloatWorkload::Execute(), ClL2NormalizationFloatWorkload::Execute(), ClArgMinMaxWorkload::Execute(), ClChannelShuffleWorkload::Execute(), ClComparisonWorkload::Execute(), ClSliceWorkload::Execute(), ClDepthToSpaceWorkload::Execute(), ClDivisionWorkload::Execute(), ClMultiplicationWorkload::Execute(), ClSpaceToBatchNdWorkload::Execute(), ClStridedSliceWorkload::Execute(), ClPooling2dWorkload::Execute(), ClQuantizedLstmWorkload::Execute(), ClSoftmaxWorkload::Execute(), ClLogSoftmaxWorkload::Execute(), ClBatchNormalizationFloatWorkload::Execute(), ClDepthwiseConvolutionWorkload::Execute(), ClFullyConnectedWorkload::Execute(), ClConvolution3dWorkload::Execute(), ClTransposeConvolution2dWorkload::Execute(), ClPermuteWorkload::Execute(), ClTransposeWorkload::Execute(), and ClConvolution2dWorkload::Execute().

156 {
157  try
158  {
159  function.run();
160  }
161  catch (cl::Error& error)
162  {
163  throw WrapClError(error, location);
164  }
165 }
RuntimeException WrapClError(const cl::Error &clError, const CheckLocation &location)

◆ RuntimeLoadedNetworksReserve()

void RuntimeLoadedNetworksReserve ( armnn::RuntimeImpl runtime)

Definition at line 30 of file RuntimeTests.cpp.

Referenced by TEST_SUITE().

31 {
32  runtime->m_LoadedNetworks.reserve(1);
33 }

◆ SelectTensorHandleStrategy()

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

Definition at line 1611 of file Network.cpp.

References ARMNN_ASSERT, ARMNN_SCOPED_PROFILING_EVENT, 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 Optimize(), and TEST_SUITE().

1616 {
1617  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_SelectTensorHandleStrategy");
1618  OptimizationResult result;
1619 
1620  optGraph.ForEachLayer([&backends, &registry, &result, &errMessages, importEnabled](Layer* layer)
1621  {
1622  ARMNN_ASSERT(layer);
1623 
1624  // Lets make sure the backend is in our list of supported backends. Something went wrong during backend
1625  // assignment if this check fails
1626  ARMNN_ASSERT(backends.find(layer->GetBackendId()) != backends.end());
1627 
1628  // Check each output separately
1629  for (unsigned int slotIdx = 0; slotIdx < layer->GetNumOutputSlots(); slotIdx++)
1630  {
1631  OutputSlot& outputSlot = layer->GetOutputSlot(slotIdx);
1632 
1633  ITensorHandleFactory::FactoryId slotOption = ITensorHandleFactory::LegacyFactoryId;
1634 
1635  // Calculate the factory to use which results in the fewest copies being made.
1636  switch(layer->GetType())
1637  {
1638  case LayerType::Input:
1639  slotOption = CalculateSlotOptionForInput(backends, outputSlot, registry, importEnabled);
1640  break;
1641  case LayerType::Output:
1642  slotOption = CalculateSlotOptionForOutput(backends, outputSlot, registry);
1643  break;
1644  default:
1645  slotOption = CalculateSlotOption(backends, outputSlot, registry, importEnabled);
1646  break;
1647  }
1648  outputSlot.SetTensorHandleFactory(slotOption);
1649 
1650  // Now determine the "best" edge strategy for each connection given the slotOption.
1651  unsigned int connectionIdx = 0;
1652  for (auto&& connection : outputSlot.GetConnections())
1653  {
1654  const Layer& connectedLayer = connection->GetOwningLayer();
1655 
1656  EdgeStrategy strategy = CalculateEdgeStrategy(backends, slotOption, *layer, connectedLayer,
1657  registry, importEnabled);
1658 
1659  if (strategy == EdgeStrategy::Undefined)
1660  {
1661  result.m_Error = true;
1662  if (errMessages)
1663  {
1664  errMessages.value().emplace_back("Could not find valid strategy required for compatibility"
1665  " between backends.");
1666  }
1667  return;
1668  }
1669 
1670  outputSlot.SetEdgeStrategy(connectionIdx, strategy);
1671 
1672  connectionIdx++;
1673  }
1674  }
1675  });
1676 
1677  return result;
1678 }
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:1362
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
ITensorHandleFactory::FactoryId FactoryId
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry &registry, bool importEnabled)
Definition: Network.cpp:1372
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry &registry, bool importEnabled)
Definition: Network.cpp:1522
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry, bool importEnabled)
Definition: Network.cpp:1277

◆ SetAllLoggingSinks()

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

Definition at line 191 of file Logging.cpp.

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

192 {
193  SetLoggingSinks<LogSeverity::Trace>(standardOut, debugOut, coloured);
194  SetLoggingSinks<LogSeverity::Debug>(standardOut, debugOut, coloured);
195  SetLoggingSinks<LogSeverity::Info>(standardOut, debugOut, coloured);
196  SetLoggingSinks<LogSeverity::Warning>(standardOut, debugOut, coloured);
197  SetLoggingSinks<LogSeverity::Error>(standardOut, debugOut, coloured);
198  SetLoggingSinks<LogSeverity::Fatal>(standardOut, debugOut, coloured);
199 }

◆ SetClSliceData()

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

Definition at line 91 of file ClWorkloadUtils.hpp.

Referenced by ClSliceWorkload::ClSliceWorkload().

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

Referenced by ClStridedSliceWorkload::ClStridedSliceWorkload().

73 {
77 
78  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
79 
80  for (unsigned int i = 0; i < num_dims; i++) {
81  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_end[revertedIndex]));
85  strides.set(i, static_cast<int>(m_stride[revertedIndex]));
86  }
87 
88  return std::make_tuple(starts, ends, strides);
89 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetLogFilter()

void SetLogFilter ( LogSeverity  level)

Definition at line 73 of file Logging.cpp.

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

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

74 {
75  SimpleLogger<LogSeverity::Trace>::Get().Enable(false);
76  SimpleLogger<LogSeverity::Debug>::Get().Enable(false);
77  SimpleLogger<LogSeverity::Info>::Get().Enable(false);
78  SimpleLogger<LogSeverity::Warning>::Get().Enable(false);
79  SimpleLogger<LogSeverity::Error>::Get().Enable(false);
80  SimpleLogger<LogSeverity::Fatal>::Get().Enable(false);
81  switch (level)
82  {
83  case LogSeverity::Trace:
84  SimpleLogger<LogSeverity::Trace>::Get().Enable(true);
86  case LogSeverity::Debug:
87  SimpleLogger<LogSeverity::Debug>::Get().Enable(true);
89  case LogSeverity::Info:
90  SimpleLogger<LogSeverity::Info>::Get().Enable(true);
92  case LogSeverity::Warning:
93  SimpleLogger<LogSeverity::Warning>::Get().Enable(true);
95  case LogSeverity::Error:
96  SimpleLogger<LogSeverity::Error>::Get().Enable(true);
98  case LogSeverity::Fatal:
99  SimpleLogger<LogSeverity::Fatal>::Get().Enable(true);
100  break;
101  default:
102  ARMNN_ASSERT(false);
103  }
104 }
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:37
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ SetLoggingSinks()

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

Definition at line 167 of file Logging.cpp.

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

168 {
169  SimpleLogger<Level>::Get().RemoveAllSinks();
170 
171  if (standardOut)
172  {
173  if (coloured)
174  {
175  SimpleLogger<Level>::Get().AddSink(
176  std::make_shared<StandardOutputColourSink>(Level));
177  } else
178  {
179  SimpleLogger<Level>::Get().AddSink(
180  std::make_shared<StandardOutputSink>());
181  }
182  }
183 
184  if (debugOut)
185  {
186  SimpleLogger<Level>::Get().AddSink(
187  std::make_shared<DebugOutputSink>());
188  }
189 }

◆ SetNeonSliceData()

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

Definition at line 113 of file NeonWorkloadUtils.hpp.

References GetOutputTensorData(), and ITensorHandle::Map().

Referenced by NeonSliceWorkload::NeonSliceWorkload().

115 {
116  // This function must translate the size vector given to an end vector
117  // expected by the ACL NESlice workload
120 
121  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
122 
123  // For strided slices, we have the relationship size = (end - begin) / stride
124  // For slice, we assume stride to be a vector of all ones, yielding the formula
125  // size = (end - begin) therefore we know end = size + begin
126  for (unsigned int i = 0; i < num_dims; i++)
127  {
128  unsigned int revertedIndex = num_dims - i - 1;
129 
130  starts.set(i, static_cast<int>(m_begin[revertedIndex]));
131  ends.set(i, static_cast<int>(m_begin[revertedIndex] + m_size[revertedIndex]));
132  }
133 
134  return std::make_tuple(starts, ends);
135 }
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 91 of file NeonWorkloadUtils.hpp.

Referenced by NeonStridedSliceWorkload::NeonStridedSliceWorkload().

94 {
98 
99  unsigned int num_dims = static_cast<unsigned int>(m_begin.size());
100 
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_end[revertedIndex]));
107  strides.set(i, static_cast<int>(m_stride[revertedIndex]));
108  }
109 
110  return std::make_tuple(starts, ends, strides);
111 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ SetValueChecked()

◆ Slice()

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

Definition at line 14 of file Slice.cpp.

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

Referenced by TEST_SUITE().

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

◆ Softmax()

void Softmax ( Decoder< float > &  in,
Encoder< float > &  out,
const TensorInfo inputTensorInfo,
float  beta,
int  axis 
)

Computes the softmax function on some inputs, into outputs, with a shape given by tensorInfo.

Definition at line 17 of file Softmax.cpp.

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

Referenced by TEST_SUITE().

18 {
19  ARMNN_ASSERT_MSG(axis < static_cast<int>(inputTensorInfo.GetNumDimensions()),
20  "Required axis index greater than number of dimensions.");
21  ARMNN_ASSERT_MSG(axis >= -static_cast<int>(inputTensorInfo.GetNumDimensions()),
22  "Required axis index lower than negative of the number of dimensions");
23 
24  unsigned int uAxis = axis < 0 ?
25  inputTensorInfo.GetNumDimensions() - static_cast<unsigned int>(abs(axis))
26  : static_cast<unsigned int>(axis);
27 
28  const TensorShape& inputShape = inputTensorInfo.GetShape();
29  const unsigned int outerSize = armnnUtils::GetNumElementsBetween(inputShape, 0, uAxis);
30  const unsigned int axisSize = inputShape[uAxis];
31  const unsigned int innerSize = armnnUtils::GetNumElementsBetween(inputShape,
32  uAxis + 1,
33  inputShape.GetNumDimensions());
34 
35  for (unsigned int outer = 0; outer < outerSize; ++outer)
36  {
37  unsigned int inputBeginIdx = outer * axisSize * innerSize;
38  unsigned int inputEndIdx = inputBeginIdx + axisSize * innerSize;
39  unsigned int outputBeginIdx = outer * axisSize * innerSize;
40 
41  for (unsigned int inner = 0; inner < innerSize; ++inner, ++inputBeginIdx, ++inputEndIdx, ++outputBeginIdx)
42  {
43  // Find max
44  float maxValue = std::numeric_limits<float>::lowest();
45  for (unsigned int iter = inputBeginIdx; iter < inputEndIdx; iter += innerSize)
46  {
47  in[iter];
48  maxValue = std::max(maxValue, in.Get());
49  }
50 
51  // Compute sum
52  float sum = 0.0f;
53  for (unsigned int iter = inputBeginIdx; iter < inputEndIdx; iter += innerSize)
54  {
55  in[iter];
56  sum += std::exp((in.Get() - maxValue) * beta);
57  }
58 
59  // Compute result
60  unsigned int outputIter = outputBeginIdx;
61  out[outputIter];
62  for (unsigned int iter = inputBeginIdx; iter < inputEndIdx; iter += innerSize, outputIter += innerSize)
63  {
64  out[outputIter];
65  in[iter];
66  out.Set(std::exp((in.Get() - maxValue) * beta) / sum);
67  }
68  }
69  }
70 }
unsigned int GetNumElementsBetween(const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
virtual void Set(IType right)=0
virtual IType Get() const =0
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ SpaceToBatchNd()

void SpaceToBatchNd ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const SpaceToBatchNdDescriptor params,
Decoder< float > &  inputData,
Encoder< float > &  outputData 
)

Definition at line 34 of file SpaceToBatchNd.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), GetOffset(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), SpaceToBatchNdDescriptor::m_BlockShape, SpaceToBatchNdDescriptor::m_DataLayout, SpaceToBatchNdDescriptor::m_PadList, Encoder< IType >::Set(), and SpaceToBatchNd().

Referenced by SpaceToBatchNd(), SpaceToBatchNdLayer::SpaceToBatchNdLayer(), and TEST_SUITE().

39 {
40  DataLayoutIndexed dataLayout = params.m_DataLayout;
41 
42  const TensorShape& inputShape = inputInfo.GetShape();
43  const TensorShape& outputShape = outputInfo.GetShape();
44 
45  const unsigned int channels = inputShape[dataLayout.GetChannelsIndex()];
46 
47  const unsigned int inputBatchSize = inputShape[0];
48  const unsigned int inputHeight = inputShape[dataLayout.GetHeightIndex()];
49  const unsigned int inputWidth = inputShape[dataLayout.GetWidthIndex()];
50 
51  const unsigned int outputBatchSize = outputShape[0];
52  const unsigned int outputHeight = outputShape[dataLayout.GetHeightIndex()];
53  const unsigned int outputWidth = outputShape[dataLayout.GetWidthIndex()];
54 
55  const unsigned int blockHeight = params.m_BlockShape[0];
56  const unsigned int blockWidth = params.m_BlockShape[1];
57 
58  const unsigned int paddingTop = params.m_PadList[0].first;
59  const unsigned int paddingLeft = params.m_PadList[1].first;
60 
61  for (unsigned int outB = 0; outB < outputBatchSize; outB++)
62  {
63  unsigned int inB = outB % inputBatchSize;
64 
65  unsigned int shiftW = (outB / inputBatchSize) % blockWidth;
66  unsigned int shiftH = (outB / inputBatchSize) / blockWidth;
67 
68  for (unsigned int outH = 0; outH < outputHeight; outH++)
69  {
70  for (unsigned int outW = 0; outW < outputWidth; outW++)
71  {
72  if (outH * blockHeight + shiftH < paddingTop ||
73  outH * blockHeight + shiftH >= paddingTop + inputHeight ||
74  outW * blockWidth + shiftW < paddingLeft ||
75  outW * blockWidth + shiftW >= paddingLeft + inputWidth)
76  {
77  for (unsigned int c = 0; c < channels; c++)
78  {
79  unsigned int outOffset = GetOffset(outputShape,
80  outB,
81  outH,
82  outW,
83  c,
84  dataLayout);
85  outputData += outOffset;
86  outputData.Set(0);
87  outputData -= outOffset;
88  }
89  }
90  else
91  {
92  for (unsigned int c = 0; c < channels; c++)
93  {
94  unsigned int inOffset = GetOffset(inputShape,
95  inB,
96  (outH * blockHeight + shiftH) - paddingTop,
97  (outW * blockWidth + shiftW) - paddingLeft,
98  c,
99  dataLayout);
100 
101  unsigned int outOffset = GetOffset(outputShape,
102  outB,
103  outH,
104  outW,
105  c,
106  dataLayout);
107 
108  outputData += outOffset;
109  inputData += inOffset;
110  outputData.Set(inputData.Get());
111  inputData -= inOffset;
112  outputData -= outOffset;
113  }
114  }
115  }
116  }
117  }
118 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
virtual void Set(IType right)=0
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
unsigned int GetHeightIndex() const
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
virtual IType Get() const =0
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
std::vector< unsigned int > m_BlockShape
Block shape value.
unsigned int GetChannelsIndex() const

◆ SpaceToDepth()

void SpaceToDepth ( const TensorInfo inputInfo,
const TensorInfo outputInfo,
const SpaceToDepthDescriptor params,
Decoder< float > &  inputData,
Encoder< float > &  outputData 
)

Definition at line 36 of file SpaceToDepth.cpp.

References Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), GetOffset(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, Encoder< IType >::Set(), and SpaceToDepth().

Referenced by SpaceToDepth(), SpaceToDepthLayer::SpaceToDepthLayer(), and TEST_SUITE().

41 {
42  DataLayoutIndexed dataLayout = params.m_DataLayout;
43 
44  const TensorShape& inputShape = inputInfo.GetShape();
45  const TensorShape& outputShape = outputInfo.GetShape();
46 
47  const unsigned int inputBatchSize = inputShape[0];
48  const unsigned int inputChannels = inputShape[dataLayout.GetChannelsIndex()];
49 
50  const unsigned int outputHeight = outputShape[dataLayout.GetHeightIndex()];
51  const unsigned int outputWidth = outputShape[dataLayout.GetWidthIndex()];
52  const unsigned int outputChannels = outputShape[dataLayout.GetChannelsIndex()];
53 
54  const unsigned int blockSize = params.m_BlockSize;
55 
56  if (blockSize == 0)
57  {
59  "Input shape must be divisible by block size in all spatial dimensions: Block size is"
60  " equal to zero");
61  }
62 
63  for (unsigned int outChannelIndex = 0; outChannelIndex < outputChannels; outChannelIndex++)
64  {
65  unsigned int inChannelIndex = outChannelIndex % inputChannels;
66 
67  unsigned int shiftW = (outChannelIndex / inputChannels) % blockSize;
68  unsigned int shiftH = (outChannelIndex / inputChannels) / blockSize;
69 
70  for (unsigned int outH = 0; outH < outputHeight; outH++)
71  {
72  for (unsigned int outW = 0; outW < outputWidth; outW++)
73  {
74  for (unsigned int inBatchIndex = 0; inBatchIndex < inputBatchSize; inBatchIndex++)
75  {
76  unsigned int inOffset = GetOffset(inputShape,
77  inChannelIndex,
78  (outH * blockSize + shiftH),
79  (outW * blockSize + shiftW),
80  inBatchIndex,
81  dataLayout);
82 
83  unsigned int outOffset = GetOffset(outputShape,
84  outChannelIndex,
85  outH,
86  outW,
87  inBatchIndex,
88  dataLayout);
89 
90  outputData += outOffset;
91  inputData += inOffset;
92  outputData.Set(inputData.Get());
93  inputData -= inOffset;
94  outputData -= outOffset;
95  }
96  }
97  }
98  }
99 }
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
virtual void Set(IType right)=0
unsigned int GetHeightIndex() const
virtual IType Get() const =0
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int GetChannelsIndex() const

◆ Split()

void Split ( const SplitterQueueDescriptor data,
std::vector< ITensorHandle *>  inputs,
std::vector< ITensorHandle *>  outputs 
)

Definition at line 21 of file Splitter.cpp.

References ARMNN_ASSERT, Encoder< IType >::Get(), TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), GetTensorInfo(), SplitterQueueDescriptor::ViewOrigin::m_Origin, SplitterQueueDescriptor::m_ViewOrigins, and MaxNumOfTensorDimensions.

Referenced by RefSplitterWorkload::ExecuteAsync(), and Splitter().

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

◆ Splitter()

void armnn::Splitter ( const SplitterQueueDescriptor data,
std::vector< ITensorHandle *>  inputs,
std::vector< ITensorHandle *>  outputs 
)

Definition at line 17 of file Splitter.hpp.

References ARMNN_ASSERT, TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), GetTensorInfo(), SplitterQueueDescriptor::ViewOrigin::m_Origin, SplitterQueueDescriptor::m_ViewOrigins, MaxNumOfTensorDimensions, and Split().

Referenced by TEST_SUITE().

20 {
21  const TensorInfo& inputInfo0 = GetTensorInfo(inputs[0]);
22 
23  for (unsigned int index = 0; index < inputInfo0.GetNumElements(); ++index)
24  {
25  unsigned int indices[MaxNumOfTensorDimensions] = { 0 };
26 
27  unsigned int indexRemainder = index;
28  unsigned int dimensionStride = inputInfo0.GetNumElements();
29 
30  for (unsigned int i = 0; i<inputInfo0.GetNumDimensions(); i++)
31  {
32  dimensionStride /= inputInfo0.GetShape()[i];
33  indices[i] = indexRemainder / dimensionStride; // Use integer division to round down.
34  indexRemainder -= indices[i] * dimensionStride;
35  }
36 
37  for (unsigned int viewIdx = 0; viewIdx < data.m_ViewOrigins.size(); ++viewIdx)
38  {
39  SplitterQueueDescriptor::ViewOrigin const& view = data.m_ViewOrigins[viewIdx];
40 
41  //Split view extents are defined by the size of (the corresponding) input tensor.
42  const TensorInfo& outputInfo = GetTensorInfo(outputs[viewIdx]);
43  ARMNN_ASSERT(outputInfo.GetNumDimensions() == inputInfo0.GetNumDimensions());
44 
45  // Check all dimensions to see if this element is inside the given input view.
46  bool insideView = true;
47  for (unsigned int i = 0; i<outputInfo.GetNumDimensions(); i++)
48  {
49  if (indices[i] < view.m_Origin[i])
50  {
51  insideView = false;
52  }
53  if (indices[i] >= view.m_Origin[i] + outputInfo.GetShape()[i])
54  {
55  insideView = false;
56  }
57  }
58 
59  if (insideView)
60  {
61  unsigned int outIndex = 0;
62  unsigned int dimensionStride = 1;
63 
64  for (unsigned int i = outputInfo.GetNumDimensions(); i-- > 0;)
65  {
66  outIndex += dimensionStride * (indices[i] - view.m_Origin[i]);
67  dimensionStride *= outputInfo.GetShape()[i];
68  }
69 
70  //We are within the view, to copy input data to the output corresponding to this view.
71  DataType* outputData = GetOutputTensorData<DataType>(viewIdx, data);
72  ARMNN_ASSERT(outputData);
73 
74  const DataType* inputData = GetInputTensorData<DataType>(0, data);
75  ARMNN_ASSERT(inputData);
76 
77  outputData[outIndex] = inputData[index];
78  }
79  }
80  }
81 }
DataType
Definition: Types.hpp:35
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Definition: TensorUtils.cpp:38
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:18

◆ Stack()

void Stack ( const StackQueueDescriptor data,
std::vector< std::unique_ptr< Decoder< float >>> &  inputs,
Encoder< float > &  output,
const TensorInfo inputInfo,
const TensorInfo outputInfo 
)

Definition at line 12 of file Stack.cpp.

References TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), StackDescriptor::m_Axis, QueueDescriptor::m_Inputs, StackDescriptor::m_NumInputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and Encoder< IType >::Set().

Referenced by TEST_SUITE().

17 {
18  unsigned int outputNumDims = outputInfo.GetNumDimensions();
19  unsigned int inputNumDims = inputInfo.GetNumDimensions();
20 
21  const armnn::TensorShape& outputDims = outputInfo.GetShape();
22  const armnn::TensorShape& inputDims = inputInfo.GetShape();
23 
24  unsigned int axis = data.m_Parameters.m_Axis;
25 
26  // Can perform a simple concatenation when axis == 0
27  if (!axis)
28  {
29  unsigned int numInputs = data.m_Parameters.m_NumInputs;
30  unsigned int inputLength = inputInfo.GetNumElements();
31 
32  for (unsigned int inputIdx=0; inputIdx<numInputs; ++inputIdx)
33  {
34  for (unsigned int elmt=0; elmt<inputLength; ++elmt)
35  {
36  (*inputs[inputIdx])[elmt];
37  output[(inputIdx * inputLength) + elmt];
38  output.Set(inputs[inputIdx]->Get());
39  }
40  }
41  return;
42  }
43 
44  // Initialise output data
45  unsigned int numOutputElements = 1;
46  for (unsigned int i=0; i<outputNumDims; ++i)
47  {
48  numOutputElements *= outputDims[i];
49  }
50 
51  const unsigned int iNumTensors = static_cast<unsigned int>(data.m_Inputs.size());
52  const unsigned int iBatchSize = inputDims[0];
53  const unsigned int iChannels = (inputNumDims > 1) ? inputDims[1] : 1;
54  const unsigned int iHeight = (inputNumDims > 2) ? inputDims[2] : 1;
55  const unsigned int iWidth = (inputNumDims > 3) ? inputDims[3] : 1;
56 
57  const unsigned int oBatchSize = outputDims[1];
58  const unsigned int oChannels = (outputNumDims > 2) ? outputDims[2] : 1;
59  const unsigned int oHeight = (outputNumDims > 3) ? outputDims[3] : 1;
60  const unsigned int oWidth = (outputNumDims > 4) ? outputDims[4] : 1;
61 
62  // Array to store the input coordinates
63  // iCoordinates[0] = i, iCoordinates[1] = bi, iCoordinates[2] = ci
64  // iCoordinates[3] = hi, iCoordinates[4] = wi, iCoordinates[5] = 0
65  // iCoordinates[5] will be always zero and used for not incrementing
66  // the output when the input has less than 4 dimensions
67  std::array<unsigned int, 6> iCoordinates{ 0 };
68 
69  // Array of pointers used to map the output coordinates to the input ones, in accordance with the axis
70  // This array is initialized with &iCoordinates[5] since this will be always zero
71  std::array<unsigned int *, 5> oCoordinates = { &iCoordinates[5],
72  &iCoordinates[5],
73  &iCoordinates[5],
74  &iCoordinates[5],
75  &iCoordinates[5] };
76 
77  // Set the axis coordinate
78  oCoordinates[axis] = &iCoordinates[0];
79 
80  // Map the output coordinates, accounting for the axis
81  unsigned int dim_shift = 0;
82  for(unsigned int dim = 0; dim < inputNumDims; ++dim)
83  {
84  if(dim == axis)
85  {
86  dim_shift++;
87  }
88  oCoordinates[dim + dim_shift] = &iCoordinates[dim + 1];
89  }
90 
91  // Alias for the input coordinates
92  unsigned int &i = iCoordinates[0];
93  unsigned int &bi = iCoordinates[1];
94  unsigned int &ci = iCoordinates[2];
95  unsigned int &hi = iCoordinates[3];
96  unsigned int &wi = iCoordinates[4];
97 
98  // Alias for the output coordinates
99  unsigned int &o = *(oCoordinates[0]);
100  unsigned int &bo = *(oCoordinates[1]);
101  unsigned int &co = *(oCoordinates[2]);
102  unsigned int &ho = *(oCoordinates[3]);
103  unsigned int &wo = *(oCoordinates[4]);
104 
105  // Stack tensors
106  for(; i < iNumTensors; ++(i))
107  {
108  for(bi = 0; bi < iBatchSize; ++(bi))
109  {
110  for(ci = 0; ci < iChannels; ++(ci))
111  {
112  for(hi = 0; hi < iHeight; ++(hi))
113  {
114  for(wi = 0; wi < iWidth; ++(wi))
115  {
116  output[o * oWidth * oHeight * oChannels * oBatchSize +
117  bo * oWidth * oHeight * oChannels +
118  co * oWidth * oHeight +
119  ho * oWidth +
120  wo];
121 
122  output.Set(inputs[i]->Get());
123 
124  ++(*(inputs[i]));
125  }
126  }
127  }
128  }
129  }
130 }
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified...
Definition: Tensor.cpp:181
virtual void Set(IType right)=0

◆ StrEqual()

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

Definition at line 170 of file TypesUtils.hpp.

Referenced by ParseComputeDevice().

171 {
172  bool isEqual = true;
173  for (unsigned i = 0; isEqual && (i < N); ++i)
174  {
175  isEqual = (strA[i] == strB[i]);
176  }
177  return isEqual;
178 }

◆ StridedSlice()

void StridedSlice ( const TensorInfo inputInfo,
const StridedSliceDescriptor params,
const void *  inputData,
void *  outputData,
unsigned int  dataTypeSize 
)

Definition at line 90 of file StridedSlice.cpp.

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

Referenced by TEST_SUITE().

95 {
96  const unsigned char* input = reinterpret_cast<const unsigned char*>(inputData);
97  unsigned char* output = reinterpret_cast<unsigned char*>(outputData);
98 
99  const TensorShape inputShape = ExtendShape(inputInfo.GetShape(), 4);
100 
101  StridedSliceDescriptor paddedParams = params;
102 
103  // Pad parameters to 4 dimensions
104  PadParams(paddedParams, 4);
105 
106  const int start0 = paddedParams.GetStartForAxis(inputShape, 0);
107  const int stop0 = paddedParams.GetStopForAxis (inputShape, 0, start0);
108 
109  const int start1 = paddedParams.GetStartForAxis(inputShape, 1);
110  const int stop1 = paddedParams.GetStopForAxis (inputShape, 1, start1);
111 
112  const int start2 = paddedParams.GetStartForAxis(inputShape, 2);
113  const int stop2 = paddedParams.GetStopForAxis (inputShape, 2, start2);
114 
115  const int start3 = paddedParams.GetStartForAxis(inputShape, 3);
116  const int stop3 = paddedParams.GetStopForAxis (inputShape, 3, start3);
117 
118  const int step = armnn::numeric_cast<int>(dataTypeSize);
119 
120  for (int in0 = start0;
121  !LoopCondition(in0, stop0, paddedParams.m_Stride[0]);
122  in0 += paddedParams.m_Stride[0])
123  {
124  for (int in1 = start1;
125  !LoopCondition(in1, stop1, paddedParams.m_Stride[1]);
126  in1 += paddedParams.m_Stride[1])
127  {
128  for (int in2 = start2;
129  !LoopCondition(in2, stop2, paddedParams.m_Stride[2]);
130  in2 += paddedParams.m_Stride[2])
131  {
132  for (int in3 = start3;
133  !LoopCondition(in3, stop3, paddedParams.m_Stride[3]);
134  in3 += paddedParams.m_Stride[3])
135  {
136  int dim1 = armnn::numeric_cast<int>(inputShape[1]);
137  int dim2 = armnn::numeric_cast<int>(inputShape[2]);
138  int dim3 = armnn::numeric_cast<int>(inputShape[3]);
139 
140  int inputOffset = (((in0 * dim1 + in1) * dim2 + in2) * dim3 + in3) * step;
141  ::memcpy(output, input + inputOffset, dataTypeSize);
142  output += step;
143  }
144  }
145  }
146  }
147 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35

◆ StringToLogLevel()

LogSeverity armnn::StringToLogLevel ( std::string  level)
inline

Definition at line 36 of file Logging.hpp.

References Debug, Error, Fatal, Info, Trace, and Warning.

Referenced by DelegateOptions::SetLoggingSeverity().

37 {
38  // Transfer to lower case
39  std::transform(level.begin(), level.end(), level.begin(),
40  [](unsigned char c){ return std::tolower(c); }
41  );
42 
43  if (level == "trace")
44  {
45  return LogSeverity::Trace;
46  }
47  else if (level == "debug")
48  {
49  return LogSeverity::Debug;
50  }
51  else if (level == "info")
52  {
53  return LogSeverity::Info;
54  }
55  else if (level == "warning")
56  {
57  return LogSeverity::Warning;
58  }
59  else if (level == "error")
60  {
61  return LogSeverity::Error;
62  }
63  else if (level == "fatal")
64  {
65  return LogSeverity::Fatal;
66  }
67  else
68  {
69  throw armnn::Exception("Unknown severity level for logging: '" + level +
70  "'. Valid options: trace, debug, info, warning, error, fatal");
71  }
72 }
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:19
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46

◆ swap() [1/2]

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

Definition at line 350 of file Descriptors.cpp.

References ViewsDescriptor::swap, and swap().

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

351 {
352  using std::swap;
353  swap(first.m_NumViews, second.m_NumViews);
354  swap(first.m_NumDimensions, second.m_NumDimensions);
355  swap(first.m_ViewOrigins, second.m_ViewOrigins);
356  swap(first.m_ConcatAxis, second.m_ConcatAxis);
357 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

◆ swap() [2/2]

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

Definition at line 359 of file Descriptors.cpp.

References ViewsDescriptor::swap.

Referenced by swap().

360 {
361  using std::swap;
362  swap(first.m_Origins, second.m_Origins);
363  swap(first.m_ViewSizes, second.m_ViewSizes);
364 }
void swap(ViewsDescriptor &first, ViewsDescriptor &second)

◆ TEST_SUITE() [1/3]

armnn::TEST_SUITE ( "TestInputOutputLayerVisitor"  )

Definition at line 13 of file TestInputOutputLayerVisitor.cpp.

References NetworkImpl::AddInputLayer(), NetworkImpl::AddOutputLayer(), and IConnectableLayer::ExecuteStrategy().

14 {
15 TEST_CASE("CheckInputLayerVisitorBindingIdAndName")
16 {
17  const char* layerName = "InputLayer";
18  TestInputLayerVisitor visitor(1, layerName);
19  NetworkImpl net;
20 
21  IConnectableLayer *const layer = net.AddInputLayer(1, layerName);
22  layer->ExecuteStrategy(visitor);
23 }
24 
25 TEST_CASE("CheckInputLayerVisitorBindingIdAndNameNull")
26 {
27  TestInputLayerVisitor visitor(1);
28  NetworkImpl net;
29 
30  IConnectableLayer *const layer = net.AddInputLayer(1);
31  layer->ExecuteStrategy(visitor);
32 }
33 
34 TEST_CASE("CheckOutputLayerVisitorBindingIdAndName")
35 {
36  const char* layerName = "OutputLayer";
37  TestOutputLayerVisitor visitor(1, layerName);
38  NetworkImpl net;
39 
40  IConnectableLayer *const layer = net.AddOutputLayer(1, layerName);
41  layer->ExecuteStrategy(visitor);
42 }
43 
44 TEST_CASE("CheckOutputLayerVisitorBindingIdAndNameNull")
45 {
46  TestOutputLayerVisitor visitor(1);
47  NetworkImpl net;
48 
49  IConnectableLayer *const layer = net.AddOutputLayer(1);
50  layer->ExecuteStrategy(visitor);
51 }
52 
53 }

◆ TEST_SUITE() [2/3]

armnn::TEST_SUITE ( "MemoryManagerTests"  )

Unit test Storing, Allocating and Deallocating with a custom allocator.

Definition at line 53 of file MemoryManagerTests.cpp.

References MemoryManager::Allocate(), MemoryManager::Deallocate(), and MemoryManager::StoreMemToAllocate().

54 {
55 /// Unit test Storing, Allocating and Deallocating with a custom allocator.
56 TEST_CASE("MemoryManagerTest")
57 {
58  using namespace armnn;
59 
60  // Create mock up bufferStorageVector with 2 BufferStorage with the same TensorMemory
61  size_t numTensors = 5;
62  std::vector<std::shared_ptr<TensorMemory>> tensorMemoryPointerVector(numTensors);
63  std::vector<std::shared_ptr<TensorMemory>> tensorMemoryVector;
64  tensorMemoryVector.reserve(numTensors);
65 
66  std::vector<size_t> offsets(numTensors);
67  std::iota(std::begin(offsets), std::end(offsets), 0);
68 
69  for (uint32_t idx = 0; idx < tensorMemoryPointerVector.size(); ++idx)
70  {
71  tensorMemoryVector.emplace_back(std::make_shared<TensorMemory>(TensorMemory{offsets[idx], 0, nullptr}));
72 
73  tensorMemoryPointerVector[idx] = tensorMemoryVector[idx];
74  }
75 
76  std::vector<BufferStorage> bufferStorageVector;
77  bufferStorageVector.emplace_back(BufferStorage{tensorMemoryPointerVector, numTensors});
78  bufferStorageVector.emplace_back(BufferStorage{tensorMemoryPointerVector, numTensors});
79 
80  // Create an instance of the SampleCustomAllocator
81  std::shared_ptr<SampleCustomAllocator> customAllocator =
82  std::make_unique<SampleCustomAllocator>(SampleCustomAllocator());
83 
84  customAllocator->m_Values = {10, 11, 12, 13, 14};
85  // Check that the test was set up correctly
86  CHECK(customAllocator->m_Values.size() == numTensors);
87 
88  size_t bufferVecSize = bufferStorageVector.size();
89  // Utilise 3 functions in the MemoryManager. Check the counters and the pointer to the values are correct.
90  MemoryManager memoryManager;
91  memoryManager.StoreMemToAllocate(bufferStorageVector, customAllocator);
92 
93  memoryManager.Allocate();
94  CHECK(customAllocator->m_CounterAllocate == bufferVecSize);
95 
96  uint32_t idx = 0;
97  for (auto tensorMemory : tensorMemoryVector)
98  {
99  auto value = reinterpret_cast<uint8_t *>(tensorMemory->m_Data);
100  CHECK(customAllocator->m_Values[idx] == *value);
101  idx += 1;
102  }
103 
104  memoryManager.Deallocate();
105  CHECK(customAllocator->m_CounterFree == bufferStorageVector.size());
106 }
107 }
void Allocate()
Allocate the amount of memory indicated by , and point each to each correspondent Tensor so that the...
void Deallocate()
Deallocate memory.
Copyright (c) 2021 ARM Limited and Contributors.
void StoreMemToAllocate(std::vector< BufferStorage > bufferStorageVector, std::shared_ptr< ICustomAllocator > customAllocator, size_t typeAlignment=0)
Initialization method to store in all information needed.

◆ TEST_SUITE() [3/3]

armnn::TEST_SUITE ( "TestConstTensorLayerVisitor"  )

Definition at line 110 of file ConstTensorLayerVisitor.cpp.

References NetworkImpl::AddBatchNormalizationLayer(), NetworkImpl::AddConstantLayer(), NetworkImpl::AddConvolution2dLayer(), NetworkImpl::AddDepthwiseConvolution2dLayer(), NetworkImpl::AddFullyConnectedLayer(), NetworkImpl::AddLstmLayer(), NetworkImpl::AddQLstmLayer(), NetworkImpl::AddQuantizedLstmLayer(), IOutputSlot::Connect(), IConnectableLayer::ExecuteStrategy(), Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), LstmDescriptor::m_ActivationFunc, FullyConnectedDescriptor::m_BiasEnabled, Convolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_BiasEnabled, QuantizedLstmInputParams::m_CellBias, LstmInputParams::m_CellBias, QLstmDescriptor::m_CellClip, LstmInputParams::m_CellLayerNormWeights, LstmInputParams::m_CellToForgetWeights, LstmInputParams::m_CellToInputWeights, LstmInputParams::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, QLstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, FullyConnectedDescriptor::m_ConstantWeights, Convolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_DataLayout, BatchNormalizationDescriptor::m_Eps, QuantizedLstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetGateBias, LstmInputParams::m_ForgetLayerNormWeights, QuantizedLstmInputParams::m_InputGateBias, LstmInputParams::m_InputGateBias, LstmInputParams::m_InputLayerNormWeights, QuantizedLstmInputParams::m_InputToCellWeights, LstmInputParams::m_InputToCellWeights, QuantizedLstmInputParams::m_InputToForgetWeights, LstmInputParams::m_InputToForgetWeights, QuantizedLstmInputParams::m_InputToInputWeights, LstmInputParams::m_InputToInputWeights, QuantizedLstmInputParams::m_InputToOutputWeights, LstmInputParams::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, QuantizedLstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputGateBias, LstmInputParams::m_OutputLayerNormWeights, Convolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_PadTop, LstmDescriptor::m_PeepholeEnabled, QLstmDescriptor::m_PeepholeEnabled, LstmInputParams::m_ProjectionBias, QLstmDescriptor::m_ProjectionClip, LstmDescriptor::m_ProjectionEnabled, QLstmDescriptor::m_ProjectionEnabled, LstmInputParams::m_ProjectionWeights, QuantizedLstmInputParams::m_RecurrentToCellWeights, LstmInputParams::m_RecurrentToCellWeights, QuantizedLstmInputParams::m_RecurrentToForgetWeights, LstmInputParams::m_RecurrentToForgetWeights, QuantizedLstmInputParams::m_RecurrentToInputWeights, LstmInputParams::m_RecurrentToInputWeights, QuantizedLstmInputParams::m_RecurrentToOutputWeights, LstmInputParams::m_RecurrentToOutputWeights, Convolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, DepthwiseConvolution2dDescriptor::m_StrideY, FullyConnectedDescriptor::m_TransposeWeightMatrix, NHWC, QAsymmU8, QSymmS16, QSymmS8, and Signed32.

Referenced by TEST_SUITE().

111 {
112 TEST_CASE("CheckConvolution2dLayer")
113 {
114  Convolution2dDescriptor descriptor;
115  descriptor.m_PadLeft = 2;
116  descriptor.m_PadRight = 3;
117  descriptor.m_PadBottom = 1;
118  descriptor.m_PadTop = 5;
119  descriptor.m_StrideX = 2;
120  descriptor.m_StrideY = 3;
121  descriptor.m_DataLayout = DataLayout::NHWC;
122 
123  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
124  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
125  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
126 
127  TestConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional());
128 
129  NetworkImpl net;
130 
131  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional());
132  layer->ExecuteStrategy(visitor);
133 }
134 
135 TEST_CASE("CheckNamedConvolution2dLayer")
136 {
137  const char* layerName = "Convolution2dLayer";
138  Convolution2dDescriptor descriptor;
139  descriptor.m_PadLeft = 2;
140  descriptor.m_PadRight = 3;
141  descriptor.m_PadBottom = 1;
142  descriptor.m_PadTop = 5;
143  descriptor.m_StrideX = 2;
144  descriptor.m_StrideY = 3;
145  descriptor.m_DataLayout = DataLayout::NHWC;
146 
147  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
148  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
149  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
150 
151  TestConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional(), layerName);
152 
153  NetworkImpl net;
154 
155  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional(), layerName);
156  layer->ExecuteStrategy(visitor);
157 }
158 
159 TEST_CASE("CheckConvolution2dLayerWithBiases")
160 {
161  Convolution2dDescriptor descriptor;
162  descriptor.m_PadLeft = 2;
163  descriptor.m_PadRight = 3;
164  descriptor.m_PadBottom = 1;
165  descriptor.m_PadTop = 5;
166  descriptor.m_StrideX = 2;
167  descriptor.m_StrideY = 3;
168  descriptor.m_DataLayout = DataLayout::NHWC;
169  descriptor.m_BiasEnabled = true;
170 
171  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
172  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
173  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
174 
175  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
176  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
177  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32, 0.0f, 0, true), biasData);
178  Optional<ConstTensor> optionalBiases(biases);
179 
180  TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases);
181 
182  NetworkImpl net;
183 
184  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases);
185  layer->ExecuteStrategy(visitor);
186 }
187 
188 TEST_CASE("CheckNamedConvolution2dLayerWithBiases")
189 {
190  const char* layerName = "Convolution2dLayer";
191  Convolution2dDescriptor descriptor;
192  descriptor.m_PadLeft = 2;
193  descriptor.m_PadRight = 3;
194  descriptor.m_PadBottom = 1;
195  descriptor.m_PadTop = 5;
196  descriptor.m_StrideX = 2;
197  descriptor.m_StrideY = 3;
198  descriptor.m_DataLayout = DataLayout::NHWC;
199  descriptor.m_BiasEnabled = true;
200 
201  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
202  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
203  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
204 
205  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
206  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
207  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32, 0.0f, 0, true), biasData);
208  Optional<ConstTensor> optionalBiases(biases);
209 
210  TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName);
211 
212  NetworkImpl net;
213 
214  IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases, layerName);
215  layer->ExecuteStrategy(visitor);
216 }
217 
218 TEST_CASE("CheckDepthwiseConvolution2dLayer")
219 {
220  DepthwiseConvolution2dDescriptor descriptor;
221  descriptor.m_PadLeft = 2;
222  descriptor.m_PadRight = 3;
223  descriptor.m_PadBottom = 1;
224  descriptor.m_PadTop = 5;
225  descriptor.m_StrideX = 2;
226  descriptor.m_StrideY = 3;
227  descriptor.m_DataLayout = DataLayout::NHWC;
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, 0.0f, 0, true), data);
232 
233  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional());
234 
235  NetworkImpl net;
236 
237  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, EmptyOptional());
238  layer->ExecuteStrategy(visitor);
239 }
240 
241 TEST_CASE("CheckNamedDepthwiseConvolution2dLayer")
242 {
243  const char* layerName = "DepthwiseConvolution2dLayer";
244  DepthwiseConvolution2dDescriptor descriptor;
245  descriptor.m_PadLeft = 2;
246  descriptor.m_PadRight = 3;
247  descriptor.m_PadBottom = 1;
248  descriptor.m_PadTop = 5;
249  descriptor.m_StrideX = 2;
250  descriptor.m_StrideY = 3;
251  descriptor.m_DataLayout = DataLayout::NHWC;
252 
253  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
254  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
255  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
256 
257  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, EmptyOptional(), layerName);
258 
259  NetworkImpl net;
260 
261  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor,
262  weights,
263  EmptyOptional(),
264  layerName);
265  layer->ExecuteStrategy(visitor);
266 }
267 
268 TEST_CASE("CheckDepthwiseConvolution2dLayerWithBiases")
269 {
270  DepthwiseConvolution2dDescriptor descriptor;
271  descriptor.m_PadLeft = 2;
272  descriptor.m_PadRight = 3;
273  descriptor.m_PadBottom = 1;
274  descriptor.m_PadTop = 5;
275  descriptor.m_StrideX = 2;
276  descriptor.m_StrideY = 3;
277  descriptor.m_DataLayout = DataLayout::NHWC;
278  descriptor.m_BiasEnabled = true;
279 
280  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
281  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
282  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
283 
284  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
285  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
286  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32, 0.0f, 0, true), biasData);
287  Optional<ConstTensor> optionalBiases(biases);
288 
289  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases);
290 
291  NetworkImpl net;
292 
293  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases);
294  layer->ExecuteStrategy(visitor);
295 }
296 
297 TEST_CASE("CheckNamedDepthwiseConvolution2dLayerWithBiases")
298 {
299  const char* layerName = "DepthwiseConvolution2dLayer";
300  DepthwiseConvolution2dDescriptor descriptor;
301  descriptor.m_PadLeft = 2;
302  descriptor.m_PadRight = 3;
303  descriptor.m_PadBottom = 1;
304  descriptor.m_PadTop = 5;
305  descriptor.m_StrideX = 2;
306  descriptor.m_StrideY = 3;
307  descriptor.m_DataLayout = DataLayout::NHWC;
308  descriptor.m_BiasEnabled = true;
309 
310  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
311  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
312  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
313 
314  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
315  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
316  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32, 0.0f, 0, true), biasData);
317  Optional<ConstTensor> optionalBiases(biases);
318 
319  TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName);
320 
321  NetworkImpl net;
322 
323  IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases, layerName);
324  layer->ExecuteStrategy(visitor);
325 }
326 
327 TEST_CASE("CheckFullyConnectedLayer")
328 {
329  FullyConnectedDescriptor descriptor;
330  descriptor.m_TransposeWeightMatrix = true;
331  descriptor.m_ConstantWeights = true;
332  descriptor.m_BiasEnabled = false;
333 
334  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
335  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
336  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
337 
338  TestConstantLayerVisitor weightsVisitor(weights);
339  TestFullyConnectedLayerVistor visitor(descriptor);
340 
341  NetworkImpl net;
342 
343  IConnectableLayer* const weightsLayer = net.AddConstantLayer(weights);
344  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor);
345  weightsLayer->GetOutputSlot(0).Connect(layer->GetInputSlot(1));
346 
347  weightsLayer->ExecuteStrategy(weightsVisitor);
348  layer->ExecuteStrategy(visitor);
349 }
350 
351 TEST_CASE("CheckNamedFullyConnectedLayer")
352 {
353  const char* layerName = "FullyConnectedLayer";
354  FullyConnectedDescriptor descriptor;
355  descriptor.m_TransposeWeightMatrix = true;
356  descriptor.m_ConstantWeights = true;
357  descriptor.m_BiasEnabled = false;
358 
359  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
360  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
361  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
362 
363  TestConstantLayerVisitor weightsVisitor(weights);
364  TestFullyConnectedLayerVistor visitor(descriptor, layerName);
365 
366  NetworkImpl net;
367 
368  IConnectableLayer* const weightsLayer = net.AddConstantLayer(weights);
369  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, layerName);
370  weightsLayer->GetOutputSlot(0).Connect(layer->GetInputSlot(1));
371 
372  weightsLayer->ExecuteStrategy(weightsVisitor);
373  layer->ExecuteStrategy(visitor);
374 }
375 
376 TEST_CASE("CheckFullyConnectedLayerWithBiases")
377 {
378  FullyConnectedDescriptor descriptor;
379  descriptor.m_TransposeWeightMatrix = true;
380  descriptor.m_ConstantWeights = true;
381  descriptor.m_BiasEnabled = true;
382 
383  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
384  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
385  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
386 
387  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
388  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
389  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32, 0.0f, 0, true), biasData);
390 
391  TestConstantLayerVisitor weightsVisitor(weights);
392  TestConstantLayerVisitor biasesVisitor(biases);
393  TestFullyConnectedLayerVistor visitor(descriptor);
394 
395  NetworkImpl net;
396 
397  IConnectableLayer* const weightsLayer = net.AddConstantLayer(weights);
398  IConnectableLayer* const biasesLayer = net.AddConstantLayer(biases);
399  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor);
400  weightsLayer->GetOutputSlot(0).Connect(layer->GetInputSlot(1));
401  biasesLayer->GetOutputSlot(0).Connect(layer->GetInputSlot(2));
402 
403  weightsLayer->ExecuteStrategy(weightsVisitor);
404  biasesLayer->ExecuteStrategy(biasesVisitor);
405  layer->ExecuteStrategy(visitor);
406 }
407 
408 TEST_CASE("CheckNamedFullyConnectedLayerWithBiases")
409 {
410  const char* layerName = "FullyConnectedLayer";
411  FullyConnectedDescriptor descriptor;
412  descriptor.m_TransposeWeightMatrix = true;
413  descriptor.m_ConstantWeights = true;
414  descriptor.m_BiasEnabled = true;
415 
416  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
417  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
418  ConstTensor weights(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
419 
420  std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
421  std::vector<unsigned int> biasDimensions = {1, 1, 3, 3};
422  ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32, 0.0f, 0, true), biasData);
423 
424  TestConstantLayerVisitor weightsVisitor(weights);
425  TestConstantLayerVisitor biasesVisitor(biases);
426  TestFullyConnectedLayerVistor visitor(descriptor, layerName);
427 
428  NetworkImpl net;
429 
430  IConnectableLayer* const weightsLayer = net.AddConstantLayer(weights);
431  IConnectableLayer* const biasesLayer = net.AddConstantLayer(biases);
432  IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, layerName);
433  weightsLayer->GetOutputSlot(0).Connect(layer->GetInputSlot(1));
434  biasesLayer->GetOutputSlot(0).Connect(layer->GetInputSlot(2));
435 
436  weightsLayer->ExecuteStrategy(weightsVisitor);
437  biasesLayer->ExecuteStrategy(biasesVisitor);
438  layer->ExecuteStrategy(visitor);
439 }
440 
441 TEST_CASE("CheckBatchNormalizationLayer")
442 {
443  BatchNormalizationDescriptor descriptor;
444  descriptor.m_Eps = 0.0002f;
445  descriptor.m_DataLayout = DataLayout::NHWC;
446 
447  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
448  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
449  ConstTensor mean(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
450 
451  std::vector<float> varianceData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
452  std::vector<unsigned int> varianceDimensions = {1, 1, 3, 3};
453  ConstTensor variance(TensorInfo(4, varianceDimensions.data(), DataType::Float32, 0.0f, 0, true), varianceData);
454 
455  std::vector<float> betaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
456  std::vector<unsigned int> betaDimensions = {1, 1, 3, 3};
457  ConstTensor beta(TensorInfo(4, betaDimensions.data(), DataType::Float32, 0.0f, 0, true), betaData);
458 
459  std::vector<float> gammaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
460  std::vector<unsigned int> gammaDimensions = {1, 1, 3, 3};
461  ConstTensor gamma(TensorInfo(4, gammaDimensions.data(), DataType::Float32, 0.0f, 0, true), gammaData);
462 
463  TestBatchNormalizationLayerVisitor visitor(descriptor, mean, variance, beta, gamma);
464 
465  NetworkImpl net;
466 
467  IConnectableLayer* const layer = net.AddBatchNormalizationLayer(descriptor, mean, variance, beta, gamma);
468  layer->ExecuteStrategy(visitor);
469 }
470 
471 TEST_CASE("CheckNamedBatchNormalizationLayer")
472 {
473  const char* layerName = "BatchNormalizationLayer";
474  BatchNormalizationDescriptor descriptor;
475  descriptor.m_Eps = 0.0002f;
476  descriptor.m_DataLayout = DataLayout::NHWC;
477 
478  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
479  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
480  ConstTensor mean(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
481 
482  std::vector<float> varianceData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
483  std::vector<unsigned int> varianceDimensions = {1, 1, 3, 3};
484  ConstTensor variance(TensorInfo(4, varianceDimensions.data(), DataType::Float32, 0.0f, 0, true), varianceData);
485 
486  std::vector<float> betaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
487  std::vector<unsigned int> betaDimensions = {1, 1, 3, 3};
488  ConstTensor beta(TensorInfo(4, betaDimensions.data(), DataType::Float32, 0.0f, 0, true), betaData);
489 
490  std::vector<float> gammaData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
491  std::vector<unsigned int> gammaDimensions = {1, 1, 3, 3};
492  ConstTensor gamma(TensorInfo(4, gammaDimensions.data(), DataType::Float32, 0.0f, 0, true), gammaData);
493 
494  TestBatchNormalizationLayerVisitor visitor(descriptor, mean, variance, beta, gamma, layerName);
495 
496  NetworkImpl net;
497 
498  IConnectableLayer* const layer = net.AddBatchNormalizationLayer(
499  descriptor, mean, variance, beta, gamma, layerName);
500  layer->ExecuteStrategy(visitor);
501 }
502 
503 TEST_CASE("CheckConstLayer")
504 {
505  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
506  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
507  ConstTensor input(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
508 
509  TestConstantLayerVisitor visitor(input);
510 
511  NetworkImpl net;
512 
513  IConnectableLayer* const layer = net.AddConstantLayer(input);
514  layer->ExecuteStrategy(visitor);
515 }
516 
517 TEST_CASE("CheckNamedConstLayer")
518 {
519  const char* layerName = "ConstantLayer";
520  std::vector<float> data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
521  std::vector<unsigned int> dimensions = {1, 1, 3, 3};
522  ConstTensor input(TensorInfo(4, dimensions.data(), DataType::Float32, 0.0f, 0, true), data);
523 
524  TestConstantLayerVisitor visitor(input, layerName);
525 
526  NetworkImpl net;
527 
528  IConnectableLayer* const layer = net.AddConstantLayer(input, layerName);
529  layer->ExecuteStrategy(visitor);
530 }
531 
532 TEST_CASE("CheckLstmLayerBasic")
533 {
534  LstmDescriptor descriptor;
535  descriptor.m_ActivationFunc = 3;
536  descriptor.m_ClippingThresProj = 0.5f;
537  descriptor.m_ClippingThresCell = 0.3f;
538  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
539 
540  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
541  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
542  ConstTensor inputToForgetWeights(
543  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
544  inputToForgetWeightsData);
545 
546  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
547  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
548  ConstTensor inputToCellWeights(
549  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
550  inputToCellWeightsData);
551 
552  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
553  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
554  ConstTensor inputToOutputWeights(
555  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
556  inputToOutputWeightsData);
557 
558  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
559  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
560  ConstTensor recurrentToForgetWeights(
561  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
562  recurrentToForgetWeightsData);
563 
564  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
565  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
566  ConstTensor recurrentToCellWeights(
567  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
568  recurrentToCellWeightsData);
569 
570  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
571  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
572  ConstTensor recurrentToOutputWeights(
573  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
574  recurrentToOutputWeightsData);
575 
576  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
577  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
578  ConstTensor forgetGateBias(
579  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
580  forgetGateBiasData);
581 
582  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
583  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
584  ConstTensor cellBias(
585  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
586  cellBiasData);
587 
588  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
589  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
590  ConstTensor outputGateBias(
591  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
592  outputGateBiasData);
593 
594  LstmInputParams params;
595  params.m_InputToForgetWeights = &inputToForgetWeights;
596  params.m_InputToCellWeights = &inputToCellWeights;
597  params.m_InputToOutputWeights = &inputToOutputWeights;
598  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
599  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
600  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
601  params.m_ForgetGateBias = &forgetGateBias;
602  params.m_CellBias = &cellBias;
603  params.m_OutputGateBias = &outputGateBias;
604 
605  TestLstmLayerVisitor visitor(descriptor, params);
606 
607  NetworkImpl net;
608 
609  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
610  layer->ExecuteStrategy(visitor);
611 }
612 
613 TEST_CASE("CheckNamedLstmLayerBasic")
614 {
615  const char* layerName = "LstmLayer";
616  LstmDescriptor descriptor;
617  descriptor.m_ActivationFunc = 3;
618  descriptor.m_ClippingThresProj = 0.5f;
619  descriptor.m_ClippingThresCell = 0.3f;
620  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
621 
622  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
623  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
624  ConstTensor inputToForgetWeights(
625  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
626  inputToForgetWeightsData);
627 
628  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
629  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
630  ConstTensor inputToCellWeights(
631  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
632  inputToCellWeightsData);
633 
634  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
635  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
636  ConstTensor inputToOutputWeights(
637  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
638  inputToOutputWeightsData);
639 
640  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
641  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
642  ConstTensor recurrentToForgetWeights(
643  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
644  recurrentToForgetWeightsData);
645 
646  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
647  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
648  ConstTensor recurrentToCellWeights(
649  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
650  recurrentToCellWeightsData);
651 
652  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
653  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
654  ConstTensor recurrentToOutputWeights(
655  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
656  recurrentToOutputWeightsData);
657 
658  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
659  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
660  ConstTensor forgetGateBias(
661  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
662  forgetGateBiasData);
663 
664  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
665  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
666  ConstTensor cellBias(
667  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
668  cellBiasData);
669 
670  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
671  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
672  ConstTensor outputGateBias(
673  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
674  outputGateBiasData);
675 
676  LstmInputParams params;
677  params.m_InputToForgetWeights = &inputToForgetWeights;
678  params.m_InputToCellWeights = &inputToCellWeights;
679  params.m_InputToOutputWeights = &inputToOutputWeights;
680  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
681  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
682  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
683  params.m_ForgetGateBias = &forgetGateBias;
684  params.m_CellBias = &cellBias;
685  params.m_OutputGateBias = &outputGateBias;
686 
687  TestLstmLayerVisitor visitor(descriptor, params, layerName);
688 
689  NetworkImpl net;
690 
691  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
692  layer->ExecuteStrategy(visitor);
693 }
694 
695 TEST_CASE("CheckLstmLayerCifgDisabled")
696 {
697  LstmDescriptor descriptor;
698  descriptor.m_ActivationFunc = 3;
699  descriptor.m_ClippingThresProj = 0.5f;
700  descriptor.m_ClippingThresCell = 0.3f;
701  descriptor.m_CifgEnabled = false; // if this is true then we DON'T need to set the OptCifgParams
702 
703  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
704  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
705  ConstTensor inputToForgetWeights(
706  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
707  inputToForgetWeightsData);
708 
709  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
710  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
711  ConstTensor inputToCellWeights(
712  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
713  inputToCellWeightsData);
714 
715  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
716  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
717  ConstTensor inputToOutputWeights(
718  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
719  inputToOutputWeightsData);
720 
721  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
722  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
723  ConstTensor recurrentToForgetWeights(
724  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
725  recurrentToForgetWeightsData);
726 
727  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
728  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
729  ConstTensor recurrentToCellWeights(
730  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
731  recurrentToCellWeightsData);
732 
733  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
734  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
735  ConstTensor recurrentToOutputWeights(
736  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
737  recurrentToOutputWeightsData);
738 
739  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
740  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
741  ConstTensor forgetGateBias(
742  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
743  forgetGateBiasData);
744 
745  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
746  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
747  ConstTensor cellBias(
748  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
749  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(
754  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
755  outputGateBiasData);
756 
757  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
758  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
759  ConstTensor inputToInputWeights(
760  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
761  inputToInputWeightsData);
762 
763  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
764  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
765  ConstTensor recurrentToInputWeights(
766  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
767  recurrentToInputWeightsData);
768 
769  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
770  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
771  ConstTensor inputGateBias(
772  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
773  inputGateBiasData);
774 
775  LstmInputParams params;
776  params.m_InputToForgetWeights = &inputToForgetWeights;
777  params.m_InputToCellWeights = &inputToCellWeights;
778  params.m_InputToOutputWeights = &inputToOutputWeights;
779  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
780  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
781  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
782  params.m_ForgetGateBias = &forgetGateBias;
783  params.m_CellBias = &cellBias;
784  params.m_OutputGateBias = &outputGateBias;
785 
786  params.m_InputToInputWeights = &inputToInputWeights;
787  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
788  params.m_InputGateBias = &inputGateBias;
789 
790  TestLstmLayerVisitor visitor(descriptor, params);
791 
792  NetworkImpl net;
793 
794  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
795  layer->ExecuteStrategy(visitor);
796 }
797 
798 TEST_CASE("CheckNamedLstmLayerCifgDisabled")
799 {
800  const char* layerName = "LstmLayer";
801  LstmDescriptor descriptor;
802  descriptor.m_ActivationFunc = 3;
803  descriptor.m_ClippingThresProj = 0.5f;
804  descriptor.m_ClippingThresCell = 0.3f;
805  descriptor.m_CifgEnabled = false; // if this is true then we DON'T need to set the OptCifgParams
806 
807  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
808  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
809  ConstTensor inputToForgetWeights(
810  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
811  inputToForgetWeightsData);
812 
813  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
814  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
815  ConstTensor inputToCellWeights(
816  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
817  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, 0.0f, 0, true),
823  inputToOutputWeightsData);
824 
825  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
826  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
827  ConstTensor recurrentToForgetWeights(
828  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
829  recurrentToForgetWeightsData);
830 
831  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
832  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
833  ConstTensor recurrentToCellWeights(
834  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
835  recurrentToCellWeightsData);
836 
837  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
838  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
839  ConstTensor recurrentToOutputWeights(
840  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
841  recurrentToOutputWeightsData);
842 
843  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
844  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
845  ConstTensor forgetGateBias(
846  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
847  forgetGateBiasData);
848 
849  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
850  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
851  ConstTensor cellBias(
852  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
853  cellBiasData);
854 
855  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
856  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
857  ConstTensor outputGateBias(
858  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
859  outputGateBiasData);
860 
861  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
862  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
863  ConstTensor inputToInputWeights(
864  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
865  inputToInputWeightsData);
866 
867  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
868  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
869  ConstTensor recurrentToInputWeights(
870  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
871  recurrentToInputWeightsData);
872 
873  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
874  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
875  ConstTensor inputGateBias(
876  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
877  inputGateBiasData);
878 
879  LstmInputParams params;
880  params.m_InputToForgetWeights = &inputToForgetWeights;
881  params.m_InputToCellWeights = &inputToCellWeights;
882  params.m_InputToOutputWeights = &inputToOutputWeights;
883  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
884  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
885  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
886  params.m_ForgetGateBias = &forgetGateBias;
887  params.m_CellBias = &cellBias;
888  params.m_OutputGateBias = &outputGateBias;
889 
890  params.m_InputToInputWeights = &inputToInputWeights;
891  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
892  params.m_InputGateBias = &inputGateBias;
893 
894  TestLstmLayerVisitor visitor(descriptor, params, layerName);
895 
896  NetworkImpl net;
897 
898  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
899  layer->ExecuteStrategy(visitor);
900 }
901 
902 // TODO add one with peephole
903 TEST_CASE("CheckLstmLayerPeephole")
904 {
905  LstmDescriptor descriptor;
906  descriptor.m_ActivationFunc = 3;
907  descriptor.m_ClippingThresProj = 0.5f;
908  descriptor.m_ClippingThresCell = 0.3f;
909  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
910  descriptor.m_PeepholeEnabled = true;
911 
912  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
913  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
914  ConstTensor inputToForgetWeights(
915  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
916  inputToForgetWeightsData);
917 
918  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
919  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
920  ConstTensor inputToCellWeights(
921  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
922  inputToCellWeightsData);
923 
924  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
925  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
926  ConstTensor inputToOutputWeights(
927  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
928  inputToOutputWeightsData);
929 
930  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
931  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
932  ConstTensor recurrentToForgetWeights(
933  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
934  recurrentToForgetWeightsData);
935 
936  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
937  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
938  ConstTensor recurrentToCellWeights(
939  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
940  recurrentToCellWeightsData);
941 
942  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
943  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
944  ConstTensor recurrentToOutputWeights(
945  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
946  recurrentToOutputWeightsData);
947 
948  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
949  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
950  ConstTensor forgetGateBias(
951  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
952  forgetGateBiasData);
953 
954  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
955  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
956  ConstTensor cellBias(
957  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
958  cellBiasData);
959 
960  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
961  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
962  ConstTensor outputGateBias(
963  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
964  outputGateBiasData);
965 
966  std::vector<float> cellToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
967  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
968  ConstTensor cellToForgetWeights(
969  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
970  cellToForgetWeightsData);
971 
972  std::vector<float> cellToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
973  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
974  ConstTensor cellToOutputWeights(
975  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
976  cellToOutputWeightsData);
977 
978  LstmInputParams params;
979  params.m_InputToForgetWeights = &inputToForgetWeights;
980  params.m_InputToCellWeights = &inputToCellWeights;
981  params.m_InputToOutputWeights = &inputToOutputWeights;
982  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
983  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
984  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
985  params.m_ForgetGateBias = &forgetGateBias;
986  params.m_CellBias = &cellBias;
987  params.m_OutputGateBias = &outputGateBias;
988 
989  params.m_CellToForgetWeights = &cellToForgetWeights;
990  params.m_CellToOutputWeights = &cellToOutputWeights;
991 
992  TestLstmLayerVisitor visitor(descriptor, params);
993 
994  NetworkImpl net;
995 
996  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
997  layer->ExecuteStrategy(visitor);
998 }
999 
1000 TEST_CASE("CheckLstmLayerPeepholeCifgDisabled")
1001 {
1002  LstmDescriptor descriptor;
1003  descriptor.m_ActivationFunc = 3;
1004  descriptor.m_ClippingThresProj = 0.5f;
1005  descriptor.m_ClippingThresCell = 0.3f;
1006  descriptor.m_CifgEnabled = false;
1007  descriptor.m_PeepholeEnabled = true;
1008 
1009  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1010  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1011  ConstTensor inputToForgetWeights(
1012  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1013  inputToForgetWeightsData);
1014 
1015  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1016  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1017  ConstTensor inputToCellWeights(
1018  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1019  inputToCellWeightsData);
1020 
1021  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1022  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1023  ConstTensor inputToOutputWeights(
1024  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1025  inputToOutputWeightsData);
1026 
1027  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1028  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1029  ConstTensor recurrentToForgetWeights(
1030  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1031  recurrentToForgetWeightsData);
1032 
1033  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1034  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1035  ConstTensor recurrentToCellWeights(
1036  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1037  recurrentToCellWeightsData);
1038 
1039  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1040  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1041  ConstTensor recurrentToOutputWeights(
1042  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1043  recurrentToOutputWeightsData);
1044 
1045  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1046  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1047  ConstTensor forgetGateBias(
1048  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1049  forgetGateBiasData);
1050 
1051  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1052  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1053  ConstTensor cellBias(
1054  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1055  cellBiasData);
1056 
1057  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1058  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1059  ConstTensor outputGateBias(
1060  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1061  outputGateBiasData);
1062 
1063  std::vector<float> cellToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1064  std::vector<unsigned int> cellToInputWeightsDimensions = {1, 1, 3, 3};
1065  ConstTensor cellToInputWeights(
1066  TensorInfo(4, cellToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1067  cellToInputWeightsData);
1068 
1069  std::vector<float> cellToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1070  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1071  ConstTensor cellToForgetWeights(
1072  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1073  cellToForgetWeightsData);
1074 
1075  std::vector<float> cellToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1076  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1077  ConstTensor cellToOutputWeights(
1078  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1079  cellToOutputWeightsData);
1080 
1081  std::vector<float> inputToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1082  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1083  ConstTensor inputToInputWeights(
1084  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1085  inputToInputWeightsData);
1086 
1087  std::vector<float> recurrentToInputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1088  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1089  ConstTensor recurrentToInputWeights(
1090  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1091  recurrentToInputWeightsData);
1092 
1093  std::vector<float> inputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1094  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1095  ConstTensor inputGateBias(
1096  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1097  inputGateBiasData);
1098 
1099  LstmInputParams params;
1100  // Basic params
1101  params.m_InputToForgetWeights = &inputToForgetWeights;
1102  params.m_InputToCellWeights = &inputToCellWeights;
1103  params.m_InputToOutputWeights = &inputToOutputWeights;
1104  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1105  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1106  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1107  params.m_ForgetGateBias = &forgetGateBias;
1108  params.m_CellBias = &cellBias;
1109  params.m_OutputGateBias = &outputGateBias;
1110 
1111  // Peephole params
1112  params.m_CellToInputWeights = &cellToInputWeights;
1113  params.m_CellToForgetWeights = &cellToForgetWeights;
1114  params.m_CellToOutputWeights = &cellToOutputWeights;
1115 
1116  // Cifg params
1117  params.m_InputToInputWeights = &inputToInputWeights;
1118  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1119  params.m_InputGateBias = &inputGateBias;
1120 
1121  TestLstmLayerVisitor visitor(descriptor, params);
1122 
1123  NetworkImpl net;
1124 
1125  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
1126  layer->ExecuteStrategy(visitor);
1127 }
1128 
1129 TEST_CASE("CheckNamedLstmLayerPeephole")
1130 {
1131  const char* layerName = "LstmLayer";
1132  LstmDescriptor descriptor;
1133  descriptor.m_ActivationFunc = 3;
1134  descriptor.m_ClippingThresProj = 0.5f;
1135  descriptor.m_ClippingThresCell = 0.3f;
1136  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1137  descriptor.m_PeepholeEnabled = true;
1138 
1139  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1140  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1141  ConstTensor inputToForgetWeights(
1142  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1143  inputToForgetWeightsData);
1144 
1145  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1146  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1147  ConstTensor inputToCellWeights(
1148  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1149  inputToCellWeightsData);
1150 
1151  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1152  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1153  ConstTensor inputToOutputWeights(
1154  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1155  inputToOutputWeightsData);
1156 
1157  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1158  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1159  ConstTensor recurrentToForgetWeights(
1160  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1161  recurrentToForgetWeightsData);
1162 
1163  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1164  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1165  ConstTensor recurrentToCellWeights(
1166  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1167  recurrentToCellWeightsData);
1168 
1169  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1170  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1171  ConstTensor recurrentToOutputWeights(
1172  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1173  recurrentToOutputWeightsData);
1174 
1175  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1176  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1177  ConstTensor forgetGateBias(
1178  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1179  forgetGateBiasData);
1180 
1181  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1182  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1183  ConstTensor cellBias(
1184  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1185  cellBiasData);
1186 
1187  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1188  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1189  ConstTensor outputGateBias(
1190  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1191  outputGateBiasData);
1192 
1193  std::vector<float> cellToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1194  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1195  ConstTensor cellToForgetWeights(
1196  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1197  cellToForgetWeightsData);
1198 
1199  std::vector<float> cellToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1200  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1201  ConstTensor cellToOutputWeights(
1202  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1203  cellToOutputWeightsData);
1204 
1205  LstmInputParams params;
1206  params.m_InputToForgetWeights = &inputToForgetWeights;
1207  params.m_InputToCellWeights = &inputToCellWeights;
1208  params.m_InputToOutputWeights = &inputToOutputWeights;
1209  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1210  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1211  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1212  params.m_ForgetGateBias = &forgetGateBias;
1213  params.m_CellBias = &cellBias;
1214  params.m_OutputGateBias = &outputGateBias;
1215 
1216  params.m_CellToForgetWeights = &cellToForgetWeights;
1217  params.m_CellToOutputWeights = &cellToOutputWeights;
1218 
1219  TestLstmLayerVisitor visitor(descriptor, params, layerName);
1220 
1221  NetworkImpl net;
1222 
1223  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
1224  layer->ExecuteStrategy(visitor);
1225 }
1226 
1227 // TODO add one with projection
1228 TEST_CASE("CheckLstmLayerProjection")
1229 {
1230  LstmDescriptor descriptor;
1231  descriptor.m_ActivationFunc = 3;
1232  descriptor.m_ClippingThresProj = 0.5f;
1233  descriptor.m_ClippingThresCell = 0.3f;
1234  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1235  descriptor.m_ProjectionEnabled = true;
1236 
1237  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1238  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1239  ConstTensor inputToForgetWeights(
1240  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1241  inputToForgetWeightsData);
1242 
1243  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1244  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1245  ConstTensor inputToCellWeights(
1246  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1247  inputToCellWeightsData);
1248 
1249  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1250  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1251  ConstTensor inputToOutputWeights(
1252  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1253  inputToOutputWeightsData);
1254 
1255  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1256  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1257  ConstTensor recurrentToForgetWeights(
1258  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1259  recurrentToForgetWeightsData);
1260 
1261  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1262  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1263  ConstTensor recurrentToCellWeights(
1264  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1265  recurrentToCellWeightsData);
1266 
1267  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1268  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1269  ConstTensor recurrentToOutputWeights(
1270  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1271  recurrentToOutputWeightsData);
1272 
1273  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1274  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1275  ConstTensor forgetGateBias(
1276  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1277  forgetGateBiasData);
1278 
1279  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1280  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1281  ConstTensor cellBias(
1282  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1283  cellBiasData);
1284 
1285  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1286  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1287  ConstTensor outputGateBias(
1288  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1289  outputGateBiasData);
1290 
1291  std::vector<float> projectionBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1292  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1293  ConstTensor projectionBias(
1294  TensorInfo(4, projectionBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1295  projectionBiasData);
1296 
1297  std::vector<float> projectionWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1298  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1299  ConstTensor projectionWeights(
1300  TensorInfo(4, projectionWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1301  projectionWeightsData);
1302 
1303  LstmInputParams params;
1304  params.m_InputToForgetWeights = &inputToForgetWeights;
1305  params.m_InputToCellWeights = &inputToCellWeights;
1306  params.m_InputToOutputWeights = &inputToOutputWeights;
1307  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1308  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1309  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1310  params.m_ForgetGateBias = &forgetGateBias;
1311  params.m_CellBias = &cellBias;
1312  params.m_OutputGateBias = &outputGateBias;
1313 
1314  params.m_ProjectionWeights = &projectionWeights;
1315  params.m_ProjectionBias = &projectionBias;
1316 
1317  TestLstmLayerVisitor visitor(descriptor, params);
1318 
1319  NetworkImpl net;
1320 
1321  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params);
1322  layer->ExecuteStrategy(visitor);
1323 }
1324 
1325 TEST_CASE("CheckNamedLstmLayerProjection")
1326 {
1327  const char* layerName = "LstmLayer";
1328  LstmDescriptor descriptor;
1329  descriptor.m_ActivationFunc = 3;
1330  descriptor.m_ClippingThresProj = 0.5f;
1331  descriptor.m_ClippingThresCell = 0.3f;
1332  descriptor.m_CifgEnabled = true; // if this is true then we DON'T need to set the OptCifgParams
1333  descriptor.m_ProjectionEnabled = true;
1334 
1335  std::vector<float> inputToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1336  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1337  ConstTensor inputToForgetWeights(
1338  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1339  inputToForgetWeightsData);
1340 
1341  std::vector<float> inputToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1342  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1343  ConstTensor inputToCellWeights(
1344  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1345  inputToCellWeightsData);
1346 
1347  std::vector<float> inputToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1348  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1349  ConstTensor inputToOutputWeights(
1350  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1351  inputToOutputWeightsData);
1352 
1353  std::vector<float> recurrentToForgetWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1354  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1355  ConstTensor recurrentToForgetWeights(
1356  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1357  recurrentToForgetWeightsData);
1358 
1359  std::vector<float> recurrentToCellWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1360  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1361  ConstTensor recurrentToCellWeights(
1362  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1363  recurrentToCellWeightsData);
1364 
1365  std::vector<float> recurrentToOutputWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1366  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1367  ConstTensor recurrentToOutputWeights(
1368  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1369  recurrentToOutputWeightsData);
1370 
1371  std::vector<float> forgetGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1372  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1373  ConstTensor forgetGateBias(
1374  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1375  forgetGateBiasData);
1376 
1377  std::vector<float> cellBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1378  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1379  ConstTensor cellBias(
1380  TensorInfo(4, cellBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1381  cellBiasData);
1382 
1383  std::vector<float> outputGateBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1384  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1385  ConstTensor outputGateBias(
1386  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1387  outputGateBiasData);
1388 
1389  std::vector<float> projectionBiasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1390  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1391  ConstTensor projectionBias(
1392  TensorInfo(4, projectionBiasDimensions.data(), DataType::Float32, 0.0f, 0, true),
1393  projectionBiasData);
1394 
1395  std::vector<float> projectionWeightsData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
1396  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1397  ConstTensor projectionWeights(
1398  TensorInfo(4, projectionWeightsDimensions.data(), DataType::Float32, 0.0f, 0, true),
1399  projectionWeightsData);
1400 
1401  LstmInputParams params;
1402  params.m_InputToForgetWeights = &inputToForgetWeights;
1403  params.m_InputToCellWeights = &inputToCellWeights;
1404  params.m_InputToOutputWeights = &inputToOutputWeights;
1405  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1406  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1407  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1408  params.m_ForgetGateBias = &forgetGateBias;
1409  params.m_CellBias = &cellBias;
1410  params.m_OutputGateBias = &outputGateBias;
1411 
1412  params.m_ProjectionWeights = &projectionWeights;
1413  params.m_ProjectionBias = &projectionBias;
1414 
1415  TestLstmLayerVisitor visitor(descriptor, params, layerName);
1416 
1417  NetworkImpl net;
1418 
1419  IConnectableLayer* const layer = net.AddLstmLayer(descriptor, params, layerName);
1420  layer->ExecuteStrategy(visitor);
1421 }
1422 
1423 TEST_CASE("CheckQLstmLayerBasic")
1424 {
1425  QLstmDescriptor descriptor;
1426  descriptor.m_ProjectionClip = 0.5f;
1427  descriptor.m_CellClip = 0.3f;
1428  descriptor.m_CifgEnabled = true;
1429 
1430  // Basic params ONLY
1431  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1432  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1433  ConstTensor inputToForgetWeights(
1434  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1435  inputToForgetWeightsData);
1436 
1437  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1438  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1439  ConstTensor inputToCellWeights(
1440  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1441  inputToCellWeightsData);
1442 
1443  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1444  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1445  ConstTensor inputToOutputWeights(
1446  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1447  inputToOutputWeightsData);
1448 
1449  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1450  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1451  ConstTensor recurrentToForgetWeights(
1452  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1453  recurrentToForgetWeightsData);
1454 
1455  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1456  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1457  ConstTensor recurrentToCellWeights(
1458  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1459  recurrentToCellWeightsData);
1460 
1461  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1462  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1463  ConstTensor recurrentToOutputWeights(
1464  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1465  recurrentToOutputWeightsData);
1466 
1467  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1468  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1469  ConstTensor forgetGateBias(
1470  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1471  forgetGateBiasData);
1472 
1473  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1474  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1475  ConstTensor cellBias(
1476  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1477  cellBiasData);
1478 
1479  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1480  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1481  ConstTensor outputGateBias(
1482  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1483  outputGateBiasData);
1484 
1485  LstmInputParams params;
1486  params.m_InputToForgetWeights = &inputToForgetWeights;
1487  params.m_InputToCellWeights = &inputToCellWeights;
1488  params.m_InputToOutputWeights = &inputToOutputWeights;
1489  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1490  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1491  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1492  params.m_ForgetGateBias = &forgetGateBias;
1493  params.m_CellBias = &cellBias;
1494  params.m_OutputGateBias = &outputGateBias;
1495 
1496  TestQLstmLayerVisitor visitor(descriptor, params);
1497 
1498  NetworkImpl net;
1499 
1500  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1501  layer->ExecuteStrategy(visitor);
1502 }
1503 
1504 TEST_CASE("CheckNamedQLstmLayerBasic")
1505 {
1506  const char* layerName = "QLstmLayer";
1507  QLstmDescriptor descriptor;
1508  descriptor.m_ProjectionClip = 0.5f;
1509  descriptor.m_CellClip = 0.3f;
1510  descriptor.m_CifgEnabled = true;
1511 
1512  // Basic params ONLY
1513  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1514  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1515  ConstTensor inputToForgetWeights(
1516  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1517  inputToForgetWeightsData);
1518 
1519  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1520  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1521  ConstTensor inputToCellWeights(
1522  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1523  inputToCellWeightsData);
1524 
1525  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1526  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1527  ConstTensor inputToOutputWeights(
1528  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1529  inputToOutputWeightsData);
1530 
1531  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1532  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1533  ConstTensor recurrentToForgetWeights(
1534  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1535  recurrentToForgetWeightsData);
1536 
1537  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1538  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1539  ConstTensor recurrentToCellWeights(
1540  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1541  recurrentToCellWeightsData);
1542 
1543  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1544  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1545  ConstTensor recurrentToOutputWeights(
1546  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1547  recurrentToOutputWeightsData);
1548 
1549  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1550  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1551  ConstTensor forgetGateBias(
1552  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1553  forgetGateBiasData);
1554 
1555  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1556  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1557  ConstTensor cellBias(
1558  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1559  cellBiasData);
1560 
1561  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1562  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1563  ConstTensor outputGateBias(
1564  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1565  outputGateBiasData);
1566 
1567  LstmInputParams params;
1568  params.m_InputToForgetWeights = &inputToForgetWeights;
1569  params.m_InputToCellWeights = &inputToCellWeights;
1570  params.m_InputToOutputWeights = &inputToOutputWeights;
1571  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1572  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1573  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1574  params.m_ForgetGateBias = &forgetGateBias;
1575  params.m_CellBias = &cellBias;
1576  params.m_OutputGateBias = &outputGateBias;
1577 
1578  TestQLstmLayerVisitor visitor(descriptor, params, layerName);
1579 
1580  NetworkImpl net;
1581 
1582  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params, layerName);
1583  layer->ExecuteStrategy(visitor);
1584 }
1585 
1586 TEST_CASE("CheckQLstmLayerCifgDisabled")
1587 {
1588  QLstmDescriptor descriptor;
1589  descriptor.m_ProjectionClip = 0.5f;
1590  descriptor.m_CellClip = 0.3f;
1591  descriptor.m_CifgEnabled = false;
1592 
1593  // Basic params
1594  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1595  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1596  ConstTensor inputToForgetWeights(
1597  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1598  inputToForgetWeightsData);
1599 
1600  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1601  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1602  ConstTensor inputToCellWeights(
1603  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1604  inputToCellWeightsData);
1605 
1606  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1607  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1608  ConstTensor inputToOutputWeights(
1609  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1610  inputToOutputWeightsData);
1611 
1612  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1613  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1614  ConstTensor recurrentToForgetWeights(
1615  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1616  recurrentToForgetWeightsData);
1617 
1618  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1619  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1620  ConstTensor recurrentToCellWeights(
1621  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1622  recurrentToCellWeightsData);
1623 
1624  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1625  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1626  ConstTensor recurrentToOutputWeights(
1627  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1628  recurrentToOutputWeightsData);
1629 
1630  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1631  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1632  ConstTensor forgetGateBias(
1633  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1634  forgetGateBiasData);
1635 
1636  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1637  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1638  ConstTensor cellBias(
1639  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1640  cellBiasData);
1641 
1642  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1643  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1644  ConstTensor outputGateBias(
1645  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1646  outputGateBiasData);
1647 
1648  // CIFG disabled params
1649  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1650  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1651  ConstTensor inputToInputWeights(
1652  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1653  inputToInputWeightsData);
1654 
1655  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1656  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1657  ConstTensor recurrentToInputWeights(
1658  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1659  recurrentToInputWeightsData);
1660 
1661  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1662  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1663  ConstTensor inputGateBias(
1664  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1665  inputGateBiasData);
1666 
1667  LstmInputParams params;
1668 
1669  // Basic params
1670  params.m_InputToForgetWeights = &inputToForgetWeights;
1671  params.m_InputToCellWeights = &inputToCellWeights;
1672  params.m_InputToOutputWeights = &inputToOutputWeights;
1673  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1674  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1675  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1676  params.m_ForgetGateBias = &forgetGateBias;
1677  params.m_CellBias = &cellBias;
1678  params.m_OutputGateBias = &outputGateBias;
1679 
1680  // CIFG disabled params
1681  params.m_InputToInputWeights = &inputToInputWeights;
1682  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1683  params.m_InputGateBias = &inputGateBias;
1684 
1685  TestQLstmLayerVisitor visitor(descriptor, params);
1686 
1687  NetworkImpl net;
1688 
1689  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1690  layer->ExecuteStrategy(visitor);
1691 }
1692 
1693 TEST_CASE("CheckQLstmLayerCifgDisabledPeepholeEnabled")
1694 {
1695  QLstmDescriptor descriptor;
1696  descriptor.m_ProjectionClip = 0.5f;
1697  descriptor.m_CellClip = 0.3f;
1698  descriptor.m_CifgEnabled = false;
1699  descriptor.m_PeepholeEnabled = true;
1700 
1701  // Basic params
1702  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1703  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1704  ConstTensor inputToForgetWeights(
1705  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1706  inputToForgetWeightsData);
1707 
1708  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1709  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1710  ConstTensor inputToCellWeights(
1711  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1712  inputToCellWeightsData);
1713 
1714  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1715  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1716  ConstTensor inputToOutputWeights(
1717  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1718  inputToOutputWeightsData);
1719 
1720  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1721  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1722  ConstTensor recurrentToForgetWeights(
1723  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1724  recurrentToForgetWeightsData);
1725 
1726  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1727  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1728  ConstTensor recurrentToCellWeights(
1729  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1730  recurrentToCellWeightsData);
1731 
1732  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1733  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1734  ConstTensor recurrentToOutputWeights(
1735  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1736  recurrentToOutputWeightsData);
1737 
1738  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1739  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1740  ConstTensor forgetGateBias(
1741  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1742  forgetGateBiasData);
1743 
1744  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1745  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1746  ConstTensor cellBias(
1747  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1748  cellBiasData);
1749 
1750  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1751  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1752  ConstTensor outputGateBias(
1753  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1754  outputGateBiasData);
1755 
1756  // CIFG disabled params
1757  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1758  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
1759  ConstTensor inputToInputWeights(
1760  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1761  inputToInputWeightsData);
1762 
1763  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1764  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
1765  ConstTensor recurrentToInputWeights(
1766  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1767  recurrentToInputWeightsData);
1768 
1769  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1770  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
1771  ConstTensor inputGateBias(
1772  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1773  inputGateBiasData);
1774 
1775  // Peephole enabled, CIFG disabled params
1776  std::vector<int16_t> cellToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1777  std::vector<unsigned int> cellToInputWeightsDimensions = {1, 1, 3, 3};
1778  ConstTensor cellToInputWeights(
1779  TensorInfo(4, cellToInputWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
1780  cellToInputWeightsData);
1781 
1782  std::vector<int16_t> cellToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1783  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1784  ConstTensor cellToForgetWeights(
1785  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
1786  cellToForgetWeightsData);
1787 
1788  std::vector<int16_t> cellToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1789  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1790  ConstTensor cellToOutputWeights(
1791  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
1792  cellToOutputWeightsData);
1793 
1794  LstmInputParams params;
1795 
1796  // Basic params
1797  params.m_InputToForgetWeights = &inputToForgetWeights;
1798  params.m_InputToCellWeights = &inputToCellWeights;
1799  params.m_InputToOutputWeights = &inputToOutputWeights;
1800  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1801  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1802  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1803  params.m_ForgetGateBias = &forgetGateBias;
1804  params.m_CellBias = &cellBias;
1805  params.m_OutputGateBias = &outputGateBias;
1806 
1807  // CIFG disabled params
1808  params.m_InputToInputWeights = &inputToInputWeights;
1809  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
1810  params.m_InputGateBias = &inputGateBias;
1811 
1812  // Peephole enabled, CIFG disabled params
1813  params.m_CellToInputWeights = &cellToInputWeights;
1814  params.m_CellToForgetWeights = &cellToForgetWeights;
1815  params.m_CellToOutputWeights = &cellToOutputWeights;
1816 
1817  TestQLstmLayerVisitor visitor(descriptor, params);
1818 
1819  NetworkImpl net;
1820 
1821  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1822  layer->ExecuteStrategy(visitor);
1823 }
1824 
1825 TEST_CASE("CheckQLstmLayerCifgEnabledPeepholeEnabled")
1826 {
1827  QLstmDescriptor descriptor;
1828  descriptor.m_ProjectionClip = 0.5f;
1829  descriptor.m_CellClip = 0.3f;
1830  descriptor.m_CifgEnabled = true;
1831  descriptor.m_PeepholeEnabled = true;
1832 
1833  // Basic params
1834  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1835  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1836  ConstTensor inputToForgetWeights(
1837  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1838  inputToForgetWeightsData);
1839 
1840  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1841  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1842  ConstTensor inputToCellWeights(
1843  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1844  inputToCellWeightsData);
1845 
1846  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1847  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1848  ConstTensor inputToOutputWeights(
1849  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1850  inputToOutputWeightsData);
1851 
1852  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1853  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1854  ConstTensor recurrentToForgetWeights(
1855  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1856  recurrentToForgetWeightsData);
1857 
1858  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1859  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1860  ConstTensor recurrentToCellWeights(
1861  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1862  recurrentToCellWeightsData);
1863 
1864  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1865  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1866  ConstTensor recurrentToOutputWeights(
1867  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1868  recurrentToOutputWeightsData);
1869 
1870  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1871  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1872  ConstTensor forgetGateBias(
1873  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1874  forgetGateBiasData);
1875 
1876  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1877  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1878  ConstTensor cellBias(
1879  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1880  cellBiasData);
1881 
1882  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1883  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1884  ConstTensor outputGateBias(
1885  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1886  outputGateBiasData);
1887 
1888  // Peephole enabled and CIFG enabled params
1889  std::vector<int16_t> cellToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1890  std::vector<unsigned int> cellToForgetWeightsDimensions = {1, 1, 3, 3};
1891  ConstTensor cellToForgetWeights(
1892  TensorInfo(4, cellToForgetWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
1893  cellToForgetWeightsData);
1894 
1895  std::vector<int16_t> cellToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1896  std::vector<unsigned int> cellToOutputWeightsDimensions = {1, 1, 3, 3};
1897  ConstTensor cellToOutputWeights(
1898  TensorInfo(4, cellToOutputWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
1899  cellToOutputWeightsData);
1900 
1901  LstmInputParams params;
1902 
1903  // Basic params
1904  params.m_InputToForgetWeights = &inputToForgetWeights;
1905  params.m_InputToCellWeights = &inputToCellWeights;
1906  params.m_InputToOutputWeights = &inputToOutputWeights;
1907  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
1908  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
1909  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
1910  params.m_ForgetGateBias = &forgetGateBias;
1911  params.m_CellBias = &cellBias;
1912  params.m_OutputGateBias = &outputGateBias;
1913 
1914  // Peephole enabled and CIFG enabled params
1915  params.m_CellToForgetWeights = &cellToForgetWeights;
1916  params.m_CellToOutputWeights = &cellToOutputWeights;
1917 
1918  TestQLstmLayerVisitor visitor(descriptor, params);
1919 
1920  NetworkImpl net;
1921 
1922  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
1923  layer->ExecuteStrategy(visitor);
1924 }
1925 
1926 TEST_CASE("CheckQLstmLayerProjectionEnabled")
1927 {
1928  QLstmDescriptor descriptor;
1929  descriptor.m_ProjectionClip = 0.5f;
1930  descriptor.m_CellClip = 0.3f;
1931  descriptor.m_CifgEnabled = true;
1932  descriptor.m_ProjectionEnabled = true;
1933 
1934  // Basic params ONLY
1935  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1936  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
1937  ConstTensor inputToForgetWeights(
1938  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1939  inputToForgetWeightsData);
1940 
1941  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1942  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
1943  ConstTensor inputToCellWeights(
1944  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1945  inputToCellWeightsData);
1946 
1947  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1948  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
1949  ConstTensor inputToOutputWeights(
1950  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1951  inputToOutputWeightsData);
1952 
1953  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1954  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
1955  ConstTensor recurrentToForgetWeights(
1956  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1957  recurrentToForgetWeightsData);
1958 
1959  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1960  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
1961  ConstTensor recurrentToCellWeights(
1962  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1963  recurrentToCellWeightsData);
1964 
1965  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1966  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
1967  ConstTensor recurrentToOutputWeights(
1968  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1969  recurrentToOutputWeightsData);
1970 
1971  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1972  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
1973  ConstTensor forgetGateBias(
1974  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1975  forgetGateBiasData);
1976 
1977  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1978  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
1979  ConstTensor cellBias(
1980  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1981  cellBiasData);
1982 
1983  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1984  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
1985  ConstTensor outputGateBias(
1986  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
1987  outputGateBiasData);
1988 
1989  // Projection enabled params
1990  std::vector<uint8_t> projectionWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1991  std::vector<unsigned int> projectionWeightsDimensions = {1, 1, 3, 3};
1992  ConstTensor projectionWeights(
1993  TensorInfo(4, projectionWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
1994  projectionWeightsData);
1995 
1996  std::vector<int32_t> projectionBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1997  std::vector<unsigned int> projectionBiasDimensions = {1, 1, 3, 3};
1998  ConstTensor projectionBias(
1999  TensorInfo(4, projectionBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2000  projectionBiasData);
2001 
2002  LstmInputParams params;
2003 
2004  // Basic params
2005  params.m_InputToForgetWeights = &inputToForgetWeights;
2006  params.m_InputToCellWeights = &inputToCellWeights;
2007  params.m_InputToOutputWeights = &inputToOutputWeights;
2008  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2009  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2010  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2011  params.m_ForgetGateBias = &forgetGateBias;
2012  params.m_CellBias = &cellBias;
2013  params.m_OutputGateBias = &outputGateBias;
2014 
2015  // Projection enabled params
2016  params.m_ProjectionWeights = &projectionWeights;
2017  params.m_ProjectionBias = &projectionBias;
2018 
2019  TestQLstmLayerVisitor visitor(descriptor, params);
2020 
2021  NetworkImpl net;
2022 
2023  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
2024  layer->ExecuteStrategy(visitor);
2025 }
2026 
2027 TEST_CASE("CheckQLstmLayerCifgDisabledLayerNormEnabled")
2028 {
2029  QLstmDescriptor descriptor;
2030  descriptor.m_ProjectionClip = 0.5f;
2031  descriptor.m_CellClip = 0.3f;
2032  descriptor.m_CifgEnabled = false;
2033  descriptor.m_LayerNormEnabled = true;
2034 
2035  // Basic params
2036  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2037  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
2038  ConstTensor inputToForgetWeights(
2039  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2040  inputToForgetWeightsData);
2041 
2042  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2043  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
2044  ConstTensor inputToCellWeights(
2045  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2046  inputToCellWeightsData);
2047 
2048  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2049  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
2050  ConstTensor inputToOutputWeights(
2051  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2052  inputToOutputWeightsData);
2053 
2054  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2055  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
2056  ConstTensor recurrentToForgetWeights(
2057  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2058  recurrentToForgetWeightsData);
2059 
2060  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2061  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
2062  ConstTensor recurrentToCellWeights(
2063  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2064  recurrentToCellWeightsData);
2065 
2066  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2067  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
2068  ConstTensor recurrentToOutputWeights(
2069  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2070  recurrentToOutputWeightsData);
2071 
2072  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2073  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
2074  ConstTensor forgetGateBias(
2075  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2076  forgetGateBiasData);
2077 
2078  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2079  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
2080  ConstTensor cellBias(
2081  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2082  cellBiasData);
2083 
2084  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2085  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
2086  ConstTensor outputGateBias(
2087  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2088  outputGateBiasData);
2089 
2090  // CIFG disabled params
2091  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2092  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
2093  ConstTensor inputToInputWeights(
2094  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2095  inputToInputWeightsData);
2096 
2097  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2098  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
2099  ConstTensor recurrentToInputWeights(
2100  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2101  recurrentToInputWeightsData);
2102 
2103  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2104  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
2105  ConstTensor inputGateBias(
2106  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2107  inputGateBiasData);
2108 
2109  // Layer Norm enabled, CIFG disabled params
2110  std::vector<int16_t> inputLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2111  std::vector<unsigned int> inputLayerNormWeightsDimensions = {1, 1, 3, 3};
2112  ConstTensor inputLayerNormWeights(
2113  TensorInfo(4, inputLayerNormWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
2114  inputLayerNormWeightsData);
2115 
2116  std::vector<int16_t> forgetLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2117  std::vector<unsigned int> forgetLayerNormWeightsDimensions = {1, 1, 3, 3};
2118  ConstTensor forgetLayerNormWeights(
2119  TensorInfo(4, forgetLayerNormWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
2120  forgetLayerNormWeightsData);
2121 
2122  std::vector<int16_t> cellLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2123  std::vector<unsigned int> cellLayerNormWeightsDimensions = {1, 1, 3, 3};
2124  ConstTensor cellLayerNormWeights(
2125  TensorInfo(4, cellLayerNormWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
2126  cellLayerNormWeightsData);
2127 
2128  std::vector<int16_t> outputLayerNormWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2129  std::vector<unsigned int> outputLayerNormWeightsDimensions = {1, 1, 3, 3};
2130  ConstTensor outputLayerNormWeights(
2131  TensorInfo(4, outputLayerNormWeightsDimensions.data(), DataType::QSymmS16, 0.0f, 0, true),
2132  outputLayerNormWeightsData);
2133 
2134  LstmInputParams params;
2135 
2136  // Basic params
2137  params.m_InputToForgetWeights = &inputToForgetWeights;
2138  params.m_InputToCellWeights = &inputToCellWeights;
2139  params.m_InputToOutputWeights = &inputToOutputWeights;
2140  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2141  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2142  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2143  params.m_ForgetGateBias = &forgetGateBias;
2144  params.m_CellBias = &cellBias;
2145  params.m_OutputGateBias = &outputGateBias;
2146 
2147  // CIFG disabled params
2148  params.m_InputToInputWeights = &inputToInputWeights;
2149  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
2150  params.m_InputGateBias = &inputGateBias;
2151 
2152  // Layer Norm enabled, CIFG disabled params
2153  params.m_InputLayerNormWeights = &inputLayerNormWeights;
2154  params.m_ForgetLayerNormWeights = &forgetLayerNormWeights;
2155  params.m_CellLayerNormWeights = &cellLayerNormWeights;
2156  params.m_OutputLayerNormWeights = &outputLayerNormWeights;
2157 
2158  TestQLstmLayerVisitor visitor(descriptor, params);
2159 
2160  NetworkImpl net;
2161 
2162  IConnectableLayer* const layer = net.AddQLstmLayer(descriptor, params);
2163  layer->ExecuteStrategy(visitor);
2164 }
2165 
2166 
2167 TEST_CASE("CheckQuantizedLstmLayer")
2168 {
2169  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2170  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
2171  ConstTensor inputToInputWeights(
2172  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2173  inputToInputWeightsData);
2174 
2175  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2176  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
2177  ConstTensor inputToForgetWeights(
2178  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2179  inputToForgetWeightsData);
2180 
2181  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2182  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
2183  ConstTensor inputToCellWeights(
2184  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2185  inputToCellWeightsData);
2186 
2187  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2188  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
2189  ConstTensor inputToOutputWeights(
2190  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2191  inputToOutputWeightsData);
2192 
2193 
2194  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2195  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
2196  ConstTensor recurrentToInputWeights(
2197  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2198  recurrentToInputWeightsData);
2199 
2200  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2201  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
2202  ConstTensor recurrentToForgetWeights(
2203  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2204  recurrentToForgetWeightsData);
2205 
2206  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2207  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
2208  ConstTensor recurrentToCellWeights(
2209  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2210  recurrentToCellWeightsData);
2211 
2212  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2213  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
2214  ConstTensor recurrentToOutputWeights(
2215  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QSymmS8, 0.0f, 0, true),
2216  recurrentToOutputWeightsData);
2217 
2218 
2219  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2220  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
2221  ConstTensor inputGateBias(
2222  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2223  inputGateBiasData);
2224 
2225  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2226  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
2227  ConstTensor forgetGateBias(
2228  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2229  forgetGateBiasData);
2230 
2231  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2232  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
2233  ConstTensor cellBias(
2234  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2235  cellBiasData);
2236 
2237  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2238  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
2239  ConstTensor outputGateBias(
2240  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2241  outputGateBiasData);
2242 
2243  QuantizedLstmInputParams params;
2244 
2245  params.m_InputToInputWeights = &inputToInputWeights;
2246  params.m_InputToForgetWeights = &inputToForgetWeights;
2247  params.m_InputToCellWeights = &inputToCellWeights;
2248  params.m_InputToOutputWeights = &inputToOutputWeights;
2249 
2250  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
2251  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2252  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2253  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2254 
2255  params.m_InputGateBias = &inputGateBias;
2256  params.m_ForgetGateBias = &forgetGateBias;
2257  params.m_CellBias = &cellBias;
2258  params.m_OutputGateBias = &outputGateBias;
2259 
2260  TestQuantizedLstmLayerVisitor visitor(params);
2261 
2262  NetworkImpl net;
2263 
2264  IConnectableLayer* const layer = net.AddQuantizedLstmLayer(params);
2265  layer->ExecuteStrategy(visitor);
2266 }
2267 
2268 TEST_CASE("CheckNamedQuantizedLstmLayer")
2269 {
2270  const char* layerName = "LstmLayer";
2271  std::vector<uint8_t> inputToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2272  std::vector<unsigned int> inputToInputWeightsDimensions = {1, 1, 3, 3};
2273  ConstTensor inputToInputWeights(
2274  TensorInfo(4, inputToInputWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2275  inputToInputWeightsData);
2276 
2277  std::vector<uint8_t> inputToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2278  std::vector<unsigned int> inputToForgetWeightsDimensions = {1, 1, 3, 3};
2279  ConstTensor inputToForgetWeights(
2280  TensorInfo(4, inputToForgetWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2281  inputToForgetWeightsData);
2282 
2283  std::vector<uint8_t> inputToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2284  std::vector<unsigned int> inputToCellWeightsDimensions = {1, 1, 3, 3};
2285  ConstTensor inputToCellWeights(
2286  TensorInfo(4, inputToCellWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2287  inputToCellWeightsData);
2288 
2289  std::vector<uint8_t> inputToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2290  std::vector<unsigned int> inputToOutputWeightsDimensions = {1, 1, 3, 3};
2291  ConstTensor inputToOutputWeights(
2292  TensorInfo(4, inputToOutputWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2293  inputToOutputWeightsData);
2294 
2295 
2296  std::vector<uint8_t> recurrentToInputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2297  std::vector<unsigned int> recurrentToInputWeightsDimensions = {1, 1, 3, 3};
2298  ConstTensor recurrentToInputWeights(
2299  TensorInfo(4, recurrentToInputWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2300  recurrentToInputWeightsData);
2301 
2302  std::vector<uint8_t> recurrentToForgetWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2303  std::vector<unsigned int> recurrentToForgetWeightsDimensions = {1, 1, 3, 3};
2304  ConstTensor recurrentToForgetWeights(
2305  TensorInfo(4, recurrentToForgetWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2306  recurrentToForgetWeightsData);
2307 
2308  std::vector<uint8_t> recurrentToCellWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2309  std::vector<unsigned int> recurrentToCellWeightsDimensions = {1, 1, 3, 3};
2310  ConstTensor recurrentToCellWeights(
2311  TensorInfo(4, recurrentToCellWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2312  recurrentToCellWeightsData);
2313 
2314  std::vector<uint8_t> recurrentToOutputWeightsData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2315  std::vector<unsigned int> recurrentToOutputWeightsDimensions = {1, 1, 3, 3};
2316  ConstTensor recurrentToOutputWeights(
2317  TensorInfo(4, recurrentToOutputWeightsDimensions.data(), DataType::QAsymmU8, 0.0f, 0, true),
2318  recurrentToOutputWeightsData);
2319 
2320 
2321  std::vector<int32_t> inputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2322  std::vector<unsigned int> inputGateBiasDimensions = {1, 1, 3, 3};
2323  ConstTensor inputGateBias(
2324  TensorInfo(4, inputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2325  inputGateBiasData);
2326 
2327  std::vector<int32_t> forgetGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2328  std::vector<unsigned int> forgetGateBiasDimensions = {1, 1, 3, 3};
2329  ConstTensor forgetGateBias(
2330  TensorInfo(4, forgetGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2331  forgetGateBiasData);
2332 
2333  std::vector<int32_t> cellBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2334  std::vector<unsigned int> cellBiasDimensions = {1, 1, 3, 3};
2335  ConstTensor cellBias(
2336  TensorInfo(4, cellBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2337  cellBiasData);
2338 
2339  std::vector<int32_t> outputGateBiasData = {1, 2, 3, 4, 5, 6, 7, 8, 9};
2340  std::vector<unsigned int> outputGateBiasDimensions = {1, 1, 3, 3};
2341  ConstTensor outputGateBias(
2342  TensorInfo(4, outputGateBiasDimensions.data(), DataType::Signed32, 0.0f, 0, true),
2343  outputGateBiasData);
2344 
2345  QuantizedLstmInputParams params;
2346 
2347  params.m_InputToInputWeights = &inputToInputWeights;
2348  params.m_InputToForgetWeights = &inputToForgetWeights;
2349  params.m_InputToCellWeights = &inputToCellWeights;
2350  params.m_InputToOutputWeights = &inputToOutputWeights;
2351 
2352  params.m_RecurrentToInputWeights = &recurrentToInputWeights;
2353  params.m_RecurrentToForgetWeights = &recurrentToForgetWeights;
2354  params.m_RecurrentToCellWeights = &recurrentToCellWeights;
2355  params.m_RecurrentToOutputWeights = &recurrentToOutputWeights;
2356 
2357  params.m_InputGateBias = &inputGateBias;
2358  params.m_ForgetGateBias = &forgetGateBias;
2359  params.m_CellBias = &cellBias;
2360  params.m_OutputGateBias = &outputGateBias;
2361 
2362  TestQuantizedLstmLayerVisitor visitor(params, layerName);
2363 
2364  NetworkImpl net;
2365 
2366  IConnectableLayer* const layer = net.AddQuantizedLstmLayer(params, layerName);
2367  layer->ExecuteStrategy(visitor);
2368 }
2369 
2370 }

◆ TopKSort()

void TopKSort ( unsigned int  k,
unsigned int *  indices,
const float *  values,
unsigned int  numElement 
)

Definition at line 24 of file DetectionPostProcess.cpp.

Referenced by DetectionPostProcess(), NonMaxSuppression(), and TEST_SUITE().

25 {
26  std::partial_sort(indices, indices + k, indices + numElement,
27  [&values](unsigned int i, unsigned int j) { return values[i] > values[j]; });
28 }

◆ TransposeConvolution2dImpl()

void TransposeConvolution2dImpl ( const TransposeConvolution2dDescriptor descriptor,
const TensorShape inputShape,
Decoder< float > &  inputDecoder,
const TensorShape outputShape,
Encoder< float > &  outputEncoder,
const TensorShape weightsShape,
Decoder< float > &  weightsDecoder,
Decoder< float > *  biasesDecoder 
)

Definition at line 15 of file TransposeConvolution2d.cpp.

References Decoder< IType >::DecodeTensor(), Decoder< IType >::Get(), DataLayoutIndexed::GetChannelsIndex(), DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetIndex(), TensorShape::GetNumElements(), DataLayoutIndexed::GetWidthIndex(), TransposeConvolution2dDescriptor::m_BiasEnabled, TransposeConvolution2dDescriptor::m_DataLayout, TransposeConvolution2dDescriptor::m_PadLeft, TransposeConvolution2dDescriptor::m_PadTop, TransposeConvolution2dDescriptor::m_StrideX, TransposeConvolution2dDescriptor::m_StrideY, NHWC, and Encoder< IType >::Set().

Referenced by RefTransposeConvolution2dWorkload::ExecuteAsync().

23 {
24  if (descriptor.m_BiasEnabled && !biasesDecoder)
25  {
26  throw InvalidArgumentException("Biases enabled but no bias data provided");
27  }
28  const DataLayoutIndexed dataLayoutIndexed(descriptor.m_DataLayout);
29  const unsigned int channelsIndex = dataLayoutIndexed.GetChannelsIndex();
30  const unsigned int heightIndex = dataLayoutIndexed.GetHeightIndex();
31  const unsigned int widthIndex = dataLayoutIndexed.GetWidthIndex();
32 
33  const unsigned int numBatches = inputShape[0];
34 
35  const unsigned int inputWidth = inputShape[widthIndex];
36  const unsigned int inputHeight = inputShape[heightIndex];
37  const unsigned int inputDepth = inputShape[channelsIndex];
38 
39  const unsigned int weightsHeight = weightsShape[heightIndex];
40  const unsigned int weightsWidth = weightsShape[widthIndex];
41  const unsigned int weightsDepth = weightsShape[channelsIndex];
42 
43  const unsigned int outputHeight = outputShape[heightIndex];
44  const unsigned int outputWidth = outputShape[widthIndex];
45  const unsigned int outputDepth = outputShape[channelsIndex];
46 
47  const unsigned int paddingLeft = descriptor.m_PadLeft;
48  const unsigned int paddingTop = descriptor.m_PadTop;
49 
50  const unsigned int strideX = descriptor.m_StrideX;
51  const unsigned int strideY = descriptor.m_StrideY;
52 
53  std::vector<float> outputBuffer(outputShape.GetNumElements(), 0);
54 
55  const std::vector<float> inputVec = inputDecoder.DecodeTensor(inputShape);
56  const std::vector<float> filterVec = weightsDecoder.DecodeTensor(weightsShape);
57 
58  for (unsigned int batch = 0u; batch < numBatches; ++batch)
59  {
60  for (unsigned int yInput = 0u; yInput < inputHeight; ++yInput)
61  {
62  for (unsigned int xInput = 0u; xInput < inputWidth; ++xInput)
63  {
64  unsigned int xOutputOrigin = xInput * strideX - paddingLeft;
65  unsigned int yOutputOrigin = yInput * strideY - paddingTop;
66 
67  for (unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
68  {
69  for (unsigned int yWeights = 0u; yWeights < weightsHeight; ++yWeights)
70  {
71  for (unsigned int xWeights = 0u; xWeights < weightsWidth; ++xWeights)
72  {
73  unsigned int yOutput = yOutputOrigin + yWeights;
74  unsigned int xOutput = xOutputOrigin + xWeights;
75 
76  if (yOutput < outputHeight && xOutput< outputWidth)
77  {
78  for (unsigned int dInput = 0u; dInput < inputDepth; dInput++)
79  {
80  unsigned int inputIndex;
81  unsigned int outputIndex;
82  unsigned int weightsIndex;
83 
84  if(descriptor.m_DataLayout == armnn::DataLayout::NHWC)
85  {
86  inputIndex = batch * inputHeight * inputWidth * inputDepth +
87  yInput * inputWidth * inputDepth +
88  xInput * inputDepth +
89  dInput;
90 
91  weightsIndex = dOutput * weightsHeight * weightsWidth * weightsDepth +
92  yWeights * weightsWidth * weightsDepth +
93  xWeights * weightsDepth +
94  dInput;
95 
96  outputIndex = batch * outputHeight * outputWidth * outputDepth +
97  yOutput * outputWidth * outputDepth +
98  xOutput * outputDepth +
99  dOutput;
100  }
101  else
102  {
103  inputIndex = batch * inputDepth * inputHeight * inputWidth +
104  dInput * inputHeight * inputWidth +
105  yInput * inputWidth +
106  xInput;
107 
108  weightsIndex = dOutput * weightsDepth * weightsHeight * weightsWidth +
109  dInput * weightsHeight * weightsWidth +
110  yWeights * weightsWidth +
111  xWeights;
112 
113  outputIndex = batch * outputDepth * outputHeight * outputWidth +
114  dOutput * outputHeight * outputWidth +
115  yOutput * outputWidth +
116  xOutput;
117  }
118 
119  outputBuffer[outputIndex] += inputVec[inputIndex] * filterVec[weightsIndex];
120  }
121  }
122  }
123  }
124 
125  }
126  }
127  }
128  }
129 
130  // Apply bias (if enabled)
131  if (descriptor.m_BiasEnabled)
132  {
133  outputEncoder[0];
134  Decoder<float>& rBiasesDecoder = *biasesDecoder;
135 
136  for (unsigned int batch = 0u; batch < numBatches; ++batch)
137  {
138  for (unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
139  {
140  rBiasesDecoder[dOutput];
141  for (unsigned int yOutput = 0u; yOutput < outputHeight; ++yOutput)
142  {
143  for (unsigned int xOutput = 0u; xOutput < outputWidth; ++xOutput)
144  {
145  const unsigned int outputIndex =
146  dataLayoutIndexed.GetIndex(outputShape, batch, dOutput, yOutput, xOutput);
147  outputBuffer[outputIndex] += rBiasesDecoder.Get();
148  }
149  }
150  }
151  }
152  }
153  outputEncoder[0];
154  for (float output : outputBuffer)
155  {
156  outputEncoder.Set(output);
157  ++outputEncoder;
158  }
159 }
virtual std::vector< float > DecodeTensor(const TensorShape &tensorShape, bool isDepthwise=false)=0
virtual void Set(IType right)=0
virtual IType Get() const =0
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...

◆ TrueFunc()

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

Definition at line 54 of file LayerSupportCommon.hpp.

References IgnoreUnused().

55 {
56  IgnoreUnused(reasonIfUnsupported);
57  IgnoreUnused(params...);
58  return true;
59 }
void IgnoreUnused(Ts &&...)

◆ VerifyClContextBuffer()

bool armnn::VerifyClContextBuffer ( flatbuffers::Verifier &  verifier)
inline

Definition at line 157 of file ClContextSchema_generated.h.

References ClContextIdentifier().

158  {
159  return verifier.VerifyBuffer<armnn::ClContext>(ClContextIdentifier());
160 }
const char * ClContextIdentifier()

◆ VerifySizePrefixedClContextBuffer()

bool armnn::VerifySizePrefixedClContextBuffer ( flatbuffers::Verifier &  verifier)
inline

Definition at line 162 of file ClContextSchema_generated.h.

References ClContextIdentifier().

163  {
164  return verifier.VerifySizePrefixedBuffer<armnn::ClContext>(ClContextIdentifier());
165 }
const char * ClContextIdentifier()

◆ VerifyTensorInfoDataType()

void armnn::VerifyTensorInfoDataType ( const armnn::TensorInfo info,
armnn::DataType  dataType 
)
inline

Definition at line 337 of file TypesUtils.hpp.

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

Referenced by ParserFlatbuffersFixture::CheckTensors(), ParserFlatbuffersSerializeFixture::RunTest(), and ParserFlatbuffersFixture::RunTest().

338 {
339  if (info.GetDataType() != dataType)
340  {
341  std::stringstream ss;
342  ss << "Unexpected datatype:" << armnn::GetDataTypeName(info.GetDataType())
343  << " for tensor:" << info.GetShape()
344  << ". The type expected to be: " << armnn::GetDataTypeName(dataType);
345  throw armnn::Exception(ss.str());
346  }
347 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:202
DataType GetDataType() const
Definition: Tensor.hpp:198
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46

◆ WrapClError()

RuntimeException armnn::WrapClError ( const cl::Error clError,
const CheckLocation location 
)
inline

Definition at line 147 of file ClWorkloadUtils.hpp.

References Exception::what().

Referenced by ClWorkloadFactory::AfterWorkloadsCreated(), and RunClFunction().

148 {
149  std::stringstream message;
150  message << "CL error: " << clError.what() << ". Error code: " << clError.err();
151 
152  return RuntimeException(message.str(), location);
153 }

Variable Documentation

◆ cpuAccCapabilities

const BackendCapabilities cpuAccCapabilities("CpuAcc", { {"NonConstWeights", false}, {"AsyncExecution", false}, {"ProtectedContentAllocation", false}, {"ConstantTensorsAsInputs", false}, {"PreImportIOTensors", false}, {"ExternallyManagedMemory", true}, {"MultiAxisPacking", false}, {"SingleAxisPacking", true} })

◆ cpuRefCapabilities

const BackendCapabilities cpuRefCapabilities("CpuRef", { {"NonConstWeights", true}, {"AsyncExecution", true}, {"ProtectedContentAllocation", false}, {"ConstantTensorsAsInputs", true}, {"PreImportIOTensors", true}, {"ExternallyManagedMemory", true}, {"MultiAxisPacking", false}, {"SingleAxisPacking", true} })

◆ EXPIRE_RATE

constexpr unsigned int EXPIRE_RATE = 3U

Variable to control expire rate of priority queue.

Definition at line 24 of file Types.hpp.

Referenced by Threadpool::TerminateThreadPool().

◆ g_AggregateProfilingEventsByInference

constexpr bool g_AggregateProfilingEventsByInference = true

Definition at line 37 of file Profiling.cpp.

◆ g_ProfilingEventCountHint

constexpr std::size_t g_ProfilingEventCountHint = 1024

Definition at line 29 of file Profiling.cpp.

◆ g_WriteProfilingEventSequence

constexpr bool g_WriteProfilingEventSequence = true

Definition at line 32 of file Profiling.cpp.

◆ g_WriteReportToStdOutOnProfilerDestruction

constexpr bool g_WriteReportToStdOutOnProfilerDestruction = false

Definition at line 41 of file Profiling.cpp.

◆ gpuAccCapabilities

const BackendCapabilities gpuAccCapabilities("GpuAcc", { {"NonConstWeights", false}, {"AsyncExecution", false}, {"ProtectedContentAllocation", true}, {"ConstantTensorsAsInputs", false}, {"PreImportIOTensors", false}, {"ExternallyManagedMemory", true}, {"MultiAxisPacking", false}, {"SingleAxisPacking", true} })

◆ LOWEST_CAPTURE_PERIOD

constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u

The lowest performance data capture interval we support is 10 miliseconds.

Definition at line 21 of file Types.hpp.

Referenced by PeriodicCounterSelectionCommandHandler::operator()(), and TEST_SUITE().

◆ MaxNumOfTensorDimensions

◆ oldCpuRefCapabilities

const std::set<armnn::BackendCapability> oldCpuRefCapabilities
Initial value:
{
}
Constant weights can be accessed through the descriptors, On the other hand, non-const weights can be...

Definition at line 24 of file RefBackend.hpp.

◆ paddingRequiredLayers

const std::set<armnn::LayerType> paddingRequiredLayers
Initial value:
{
LayerType::Convolution2d,
LayerType::DepthwiseConvolution2d,
LayerType::Lstm,
LayerType::Mean,
LayerType::QuantizedLstm,
LayerType::TransposeConvolution2d
}
float Dequantize(QuantizedType value, float scale, int32_t offset)
Dequantize an 8-bit data type into a floating point data type.
Definition: TypesUtils.cpp:46
void Stack(const StackQueueDescriptor &data, std::vector< std::unique_ptr< Decoder< float >>> &inputs, Encoder< float > &output, const TensorInfo &inputInfo, const TensorInfo &outputInfo)
Definition: Stack.cpp:12
void DepthToSpace(const TensorInfo &inputInfo, const DepthToSpaceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
void ArgMinMax(Decoder< float > &in, OUT *out, const TensorInfo &inputTensorInfo, const TensorInfo &outputTensorInfo, ArgMinMaxFunction function, int axis)
Definition: ArgMinMax.cpp:16
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
void Gather(const TensorInfo &paramsInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo, Decoder< float > &params, const int32_t *indices, Encoder< float > &output, const int32_t axis)
Definition: Gather.cpp:17
QuantizedType Quantize(float value, float scale, int32_t offset)
Quantize a floating point data type into an 8-bit data type.
Definition: TypesUtils.cpp:30
void Pooling2d(Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
Computes the Pooling2d operation.
Definition: Pooling2d.cpp:142
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > *pBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.

Definition at line 16 of file NeonTensorHandleFactory.hpp.

Referenced by NeonTensorHandleFactory::GetCapabilities().

◆ tl_Profiler

thread_local IProfiler* tl_Profiler = nullptr

Definition at line 566 of file Profiling.cpp.

Referenced by ProfilerManager::GetProfiler().

◆ wordSize

constexpr size_t wordSize = sizeof(size_t) * 8