Compute Library
 22.08
arm_compute::graph Namespace Reference

Namespaces

 backends
 
 descriptors
 
 detail
 
 frontend
 

Data Structures

class  ActivationLayerNode
 Activation Layer node. More...
 
class  ArgMinMaxLayerNode
 Arg Min/Max Layer node. More...
 
class  BatchNormalizationLayerNode
 Batch Normalization Layer node. More...
 
class  BoundingBoxTransformLayerNode
 Bounding Box Transform Layer node. More...
 
class  ChannelShuffleLayerNode
 Channel Shuffle Layer node. More...
 
class  ConcatenateLayerNode
 Concatenation Layer node. More...
 
class  ConstNode
 Const node. More...
 
class  ConvolutionLayerNode
 Convolution Layer node. More...
 
class  ConvPostOpInfo
 Convolution post operator info. More...
 
class  ConvPostOpInfoActivation
 
class  ConvPostOpInfoEltwiseAdd
 
class  DataLayerVisitor
 Graph printer visitor. More...
 
class  DeconvolutionLayerNode
 Deconvolution Layer node. More...
 
class  DefaultNodeVisitor
 Default visitor implementation. More...
 
class  DepthConcatSubTensorMutator
 Mutation pass to optimize depth concatenation operations by using sub-tensors. More...
 
class  DepthToSpaceLayerNode
 DepthToSpace Layer node. More...
 
class  DepthwiseConvolutionLayerNode
 Depthwise Convolution Layer node. More...
 
class  DequantizationLayerNode
 Dequantize Layer node. More...
 
class  DetectionOutputLayerNode
 DetectionOutput Layer node. More...
 
class  DetectionPostProcessLayerNode
 DetectionPostProcess Layer node. More...
 
class  DotGraphPrinter
 Graph printer interface. More...
 
class  DotGraphVisitor
 Graph printer visitor. More...
 
class  DummyNode
 Dummy Layer node. More...
 
class  Edge
 Graph Edge. More...
 
class  EltwiseLayerNode
 Eltwise Layer node. More...
 
struct  ExecutionTask
 Execution task. More...
 
struct  ExecutionWorkload
 Execution workload. More...
 
class  FlattenLayerNode
 Flatten Layer node. More...
 
class  FullyConnectedLayerNode
 Fully Connected Layer node. More...
 
class  FusedConvolutionBatchNormalizationNode
 Batch Normalization node. More...
 
class  FusedConvolutionBatchNormalizationWithPostOpsNode
 Batch Normalization node. More...
 
class  FusedConvolutionWithPostOpNode
 Convolution node. More...
 
class  FusedDepthwiseConvolutionBatchNormalizationNode
 Fused Depthwise Convolution Batch Normalization node. More...
 
class  GenerateProposalsLayerNode
 Generate Proposals Layer node. More...
 
class  Graph
 Graph class. More...
 
class  GraphBuilder
 Graph builder class. More...
 
struct  GraphConfig
 Graph configuration structure Device target types. More...
 
class  GraphContext
 Graph context. More...
 
class  GraphManager
 Graph manager class. More...
 
class  GroupedConvolutionMutator
 Mutation pass to implement/optimize grouped convolutions. More...
 
class  IGraphMutator
 Graph mutator interface. More...
 
class  IGraphPrinter
 Graph printer interface. More...
 
class  INode
 Node interface. More...
 
class  INodeVisitor
 Node visitor interface. More...
 
class  InPlaceOperationMutator
 Mutation pass to optimize operations that can be performed in-place. More...
 
class  InputNode
 Input Layer node. More...
 
class  ITensorAccessor
 Tensor accessor interface. More...
 
class  ITensorHandle
 Tensor handle interface object. More...
 
class  L2NormalizeLayerNode
 L2Normalize Layer node. More...
 
struct  MemoryManagerContext
 Contains structs required for memory management. More...
 
class  NodeExecutionMethodMutator
 Mutation pass to fall-back to default execution method. More...
 
class  NodeFusionMutator
 Mutation pass to fuss nodes. More...
 
struct  NodeIdxPair
 NodeID-index struct. More...
 
struct  NodeParams
 Common node parameters. More...
 
class  NormalizationLayerNode
 Normalization Layer node. More...
 
class  NormalizePlanarYUVLayerNode
 Batch Normalization Layer node. More...
 
class  OutputNode
 Output Layer node. More...
 
class  PadLayerNode
 Pad Layer node. More...
 
class  PassManager
 Pass manager. More...
 
class  PermuteLayerNode
 Permute Layer node. More...
 
class  PoolingLayerNode
 Pooling Layer node. More...
 
class  PReluLayerNode
 PRelu Layer node. More...
 
class  PrintLayerNode
 Print Layer node. More...
 
class  PriorBoxLayerNode
 PriorBox Layer node. More...
 
class  QuantizationLayerNode
 Quantization Layer node. More...
 
class  ReductionLayerNode
 Reduction Operation node. More...
 
class  ReorgLayerNode
 Reorg Layer node. More...
 
class  ReshapeLayerNode
 Reshape Layer node. More...
 
class  ResizeLayerNode
 Resize Layer node. More...
 
class  ROIAlignLayerNode
 ROI Align node. More...
 
class  SliceLayerNode
 Slice Layer node. More...
 
class  SoftmaxLayerNode
 Softmax Layer node. More...
 
class  SplitLayerNode
 Split Layer node. More...
 
class  SplitLayerSubTensorMutator
 Mutation pass to optimize split operations by using sub-tensors. More...
 
class  StackLayerNode
 Stack Layer node. More...
 
class  StridedSliceLayerNode
 Slice Layer node. More...
 
class  SyntheticDataTypeMutator
 Mutation pass to create synthetic graphs of a given data type. More...
 
class  TaskExecutor
 Task executor. More...
 
class  Tensor
 Tensor object. More...
 
struct  TensorDescriptor
 Tensor metadata class. More...
 
class  UnaryEltwiseLayerNode
 Unary Eltwise Layer node. More...
 
struct  WeightsManagerContext
 Contains structs required for weights management. More...
 

Typedefs

using ITensorAccessorUPtr = std::unique_ptr< ITensorAccessor >
 
using GraphID = unsigned int
 
using TensorID = unsigned int
 
using NodeID = unsigned int
 
using EdgeID = unsigned int
 
using Activation = arm_compute::ActivationLayerInfo::ActivationFunction
 Constant TensorID specifying an equivalent of null tensor. More...
 

Enumerations

enum  Target { UNSPECIFIED, NEON, CL, CLVK }
 
enum  EltwiseOperation {
  Add, Sub, Mul, Max,
  Div, Min
}
 Supported Element-wise operations. More...
 
enum  UnaryEltwiseOperation { Exp }
 Supported Unary Element-wise operations. More...
 
enum  ConvolutionMethod { Default, GEMM, Direct, Winograd }
 Supported Convolution layer methods. More...
 
enum  DepthwiseConvolutionMethod { Default, GEMV, Optimized3x3 }
 Supported Depthwise Convolution layer methods. More...
 
enum  FastMathHint { Enabled, Disabled }
 Enable or disable fast math for Convolution layer. More...
 
enum  NodeType {
  ActivationLayer, ArgMinMaxLayer, BatchNormalizationLayer, BoundingBoxTransformLayer,
  ChannelShuffleLayer, ConcatenateLayer, ConvolutionLayer, DeconvolutionLayer,
  DepthToSpaceLayer, DepthwiseConvolutionLayer, DequantizationLayer, DetectionOutputLayer,
  DetectionPostProcessLayer, EltwiseLayer, FlattenLayer, FullyConnectedLayer,
  FusedConvolutionBatchNormalizationLayer, FusedConvolutionWithPostOp, FusedConvolutionBatchNormalizationLayerWithPostOpsLayer, FusedDepthwiseConvolutionBatchNormalizationLayer,
  GenerateProposalsLayer, L2NormalizeLayer, NormalizationLayer, NormalizePlanarYUVLayer,
  PadLayer, PermuteLayer, PoolingLayer, PReluLayer,
  PrintLayer, PriorBoxLayer, QuantizationLayer, ReductionOperationLayer,
  ReorgLayer, ReshapeLayer, ResizeLayer, ROIAlignLayer,
  SoftmaxLayer, SliceLayer, SplitLayer, StackLayer,
  StridedSliceLayer, UpsampleLayer, UnaryEltwiseLayer, Input,
  Output, Const, Dummy
}
 Supported nodes. More...
 
enum  MemoryManagerAffinity { Buffer, Offset }
 Backend Memory Manager affinity. More...
 

Functions

std::vector< NodeIDbfs (Graph &g)
 Breadth first search traversal. More...
 
std::vector< NodeIDdfs (Graph &g)
 Depth first search traversal. More...
 
Target target_from_name (const std::string &name)
 Converts a string to a strong types enumeration Target. More...
 
inline ::std::istream & operator>> (::std::istream &stream, Target &target)
 Input Stream operator for Target. More...
 
ConvolutionMethod Convolution_method_from_name (const std::string &name)
 Converts a string to a strong types enumeration ConvolutionMethod. More...
 
inline ::std::istream & operator>> (::std::istream &stream, ConvolutionMethod &target)
 Input Stream operator for ConvolutionMethod. More...
 
DepthwiseConvolutionMethod depthwise_convolution_method_from_name (const std::string &name)
 Converts a string to a strong types enumeration DepthwiseConvolutionMethod. More...
 
inline ::std::istream & operator>> (::std::istream &stream, DepthwiseConvolutionMethod &target)
 Input Stream operator for DepthwiseConvolutionMethod. More...
 
inline ::std::ostream & operator<< (::std::ostream &os, const Target &target)
 Formatted output of the Target. More...
 
inline ::std::ostream & operator<< (::std::ostream &os, const NodeType &node_type)
 
inline ::std::ostream & operator<< (::std::ostream &os, const EltwiseOperation &eltwise_op)
 Formatted output of the EltwiseOperation type. More...
 
inline ::std::ostream & operator<< (::std::ostream &os, const ConvolutionMethod &method)
 Formatted output of the ConvolutionMethod type. More...
 
inline ::std::ostream & operator<< (::std::ostream &os, const FastMathHint &hint)
 Formatted output of the FastMathHint type. More...
 
inline ::std::ostream & operator<< (::std::ostream &os, const DepthwiseConvolutionMethod &method)
 Formatted output of the DepthwiseConvolutionMethod type. More...
 
bool is_utility_node (INode *node)
 
TensorDescriptor get_tensor_descriptor (const Graph &g, TensorID tid)
 Returns the tensor descriptor of a given tensor. More...
 
Status set_tensor_accessor (Tensor *tensor, std::unique_ptr< ITensorAccessor > accessor)
 Sets an accessor on a given tensor. More...
 
bool is_target_supported (Target target)
 Checks if a specific target is supported. More...
 
Target get_default_target ()
 Returns default target for execution. More...
 
void force_target_to_graph (Graph &g, Target target)
 Forces a single target to all graph constructs. More...
 
PassManager create_default_pass_manager (Target target, const GraphConfig &cfg)
 Creates a default PassManager. More...
 
void setup_requested_backend_context (GraphContext &ctx, Target target)
 Setups requested backend context if it exists, is supported and hasn't been initialized already. More...
 
void release_default_graph_context (GraphContext &ctx)
 Default releases the graph context if not done manually. More...
 
void sync_backends ()
 Synchronize kernels execution on the backends. More...
 
size_t get_dimension_size (const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension)
 Get size of a tensor's given dimension depending on its layout. More...
 
size_t get_dimension_idx (DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
 Get index of a tensor's given dimension depending on its layout. More...
 
std::vector< NodeIdxPairget_driving_nodes (const INode &node)
 Get the list of driving nodes of a given node. More...
 
std::vector< NodeIdxPairget_driver_nodes (const INode &node)
 Get the list of driver nodes of a given node. More...
 
void configure_tensor (Tensor *tensor)
 Configures tensor. More...
 
void execute_task (ExecutionTask &task)
 
bool is_padding_in_height_or_width (const DataLayout &layout, const PaddingList &padding_list)
 Check if padding is in height and/or width dimensions. More...
 

Variables

constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max()
 Constant NodeID specifying an equivalent of null node. More...
 
constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max()
 Constant EdgeID specifying an equivalent of null edge. More...
 
constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max()
 

Typedef Documentation

◆ Activation

Constant TensorID specifying an equivalent of null tensor.

Definition at line 73 of file Types.h.

◆ EdgeID

using EdgeID = unsigned int

Definition at line 70 of file Types.h.

◆ GraphID

using GraphID = unsigned int

Definition at line 67 of file Types.h.

◆ ITensorAccessorUPtr

using ITensorAccessorUPtr = std::unique_ptr<ITensorAccessor>

Definition at line 58 of file ITensorAccessor.h.

◆ NodeID

using NodeID = unsigned int

Definition at line 69 of file Types.h.

◆ TensorID

using TensorID = unsigned int

Definition at line 68 of file Types.h.

Enumeration Type Documentation

◆ ConvolutionMethod

enum ConvolutionMethod
strong

Supported Convolution layer methods.

Enumerator
Default 

Default approach using internal heuristics.

GEMM 

GEMM based convolution.

Direct 

Deep direct convolution.

Winograd 

Winograd based convolution.

Definition at line 126 of file Types.h.

127 {
128  Default, /**< Default approach using internal heuristics */
129  GEMM, /**< GEMM based convolution */
130  Direct, /**< Deep direct convolution */
131  Winograd /**< Winograd based convolution */
132 };
GEMM CL kernel type.
Definition: CLTypes.h:86
Default approach using internal heuristics.

◆ DepthwiseConvolutionMethod

Supported Depthwise Convolution layer methods.

Enumerator
Default 

Default approach using internal heuristics.

GEMV 

Generic GEMV based depthwise convolution.

Optimized3x3 

Optimized 3x3 direct depthwise convolution.

Definition at line 135 of file Types.h.

136 {
137  Default, /**< Default approach using internal heuristics */
138  GEMV, /**< Generic GEMV based depthwise convolution */
139  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
140 };
Generic GEMV based depthwise convolution.
Default approach using internal heuristics.
Optimized 3x3 direct depthwise convolution.

◆ EltwiseOperation

enum EltwiseOperation
strong

Supported Element-wise operations.

Enumerator
Add 

Arithmetic addition.

Sub 

Arithmetic subtraction.

Mul 

Arithmetic multiplication.

Max 

Arithmetic maximum.

Div 

Arithmetic division.

Min 

Arithmetic minimum.

Definition at line 109 of file Types.h.

110 {
111  Add, /**< Arithmetic addition */
112  Sub, /**< Arithmetic subtraction */
113  Mul, /**< Arithmetic multiplication */
114  Max, /**< Arithmetic maximum */
115  Div, /**< Arithmetic division */
116  Min, /**< Arithmetic minimum */
117 };

◆ FastMathHint

enum FastMathHint
strong

Enable or disable fast math for Convolution layer.

Enumerator
Enabled 

Fast math enabled for Convolution layer.

Disabled 

Fast math disabled for Convolution layer.

Definition at line 143 of file Types.h.

144 {
145  Enabled, /**< Fast math enabled for Convolution layer */
146  Disabled, /**< Fast math disabled for Convolution layer */
147 };
Fast math enabled for Convolution layer.
Fast math disabled for Convolution layer.

◆ MemoryManagerAffinity

enum MemoryManagerAffinity
strong

Backend Memory Manager affinity.

Enumerator
Buffer 

Affinity at buffer level.

Offset 

Affinity at offset level.

Definition at line 253 of file Types.h.

254 {
255  Buffer, /**< Affinity at buffer level */
256  Offset /**< Affinity at offset level */
257 };

◆ NodeType

enum NodeType
strong

Supported nodes.

Enumerator
ActivationLayer 
ArgMinMaxLayer 
BatchNormalizationLayer 
BoundingBoxTransformLayer 
ChannelShuffleLayer 
ConcatenateLayer 
ConvolutionLayer 
DeconvolutionLayer 
DepthToSpaceLayer 
DepthwiseConvolutionLayer 
DequantizationLayer 
DetectionOutputLayer 
DetectionPostProcessLayer 
EltwiseLayer 
FlattenLayer 
FullyConnectedLayer 
FusedConvolutionBatchNormalizationLayer 
FusedConvolutionWithPostOp 
FusedConvolutionBatchNormalizationLayerWithPostOpsLayer 
FusedDepthwiseConvolutionBatchNormalizationLayer 
GenerateProposalsLayer 
L2NormalizeLayer 
NormalizationLayer 
NormalizePlanarYUVLayer 
PadLayer 
PermuteLayer 
PoolingLayer 
PReluLayer 
PrintLayer 
PriorBoxLayer 
QuantizationLayer 
ReductionOperationLayer 
ReorgLayer 
ReshapeLayer 
ResizeLayer 
ROIAlignLayer 
SoftmaxLayer 
SliceLayer 
SplitLayer 
StackLayer 
StridedSliceLayer 
UpsampleLayer 
UnaryEltwiseLayer 
Input 
Output 
Const 
Dummy 

Definition at line 199 of file Types.h.

200 {
214  EltwiseLayer,
215  FlattenLayer,
225  PadLayer,
226  PermuteLayer,
227  PoolingLayer,
228  PReluLayer,
229  PrintLayer,
233  ReorgLayer,
234  ReshapeLayer,
235  ResizeLayer,
237  SoftmaxLayer,
238  SliceLayer,
239  SplitLayer,
240  StackLayer,
244 
245  Input,
246  Output,
247  Const,
248 
249  Dummy
250 };

◆ Target

enum Target
strong
Enumerator
UNSPECIFIED 

Unspecified Target.

NEON 

Arm® Neon™ capable target device.

CL 

OpenCL capable target device.

CLVK 

CLVK capable target device.

Definition at line 100 of file Types.h.

101 {
102  UNSPECIFIED, /**< Unspecified Target */
103  NEON, /**< Arm® Neon™ capable target device */
104  CL, /**< OpenCL capable target device */
105  CLVK, /**< CLVK capable target device */
106 };
CLVK capable target device.

◆ UnaryEltwiseOperation

enum UnaryEltwiseOperation
strong

Supported Unary Element-wise operations.

Enumerator
Exp 

Exp.

Definition at line 120 of file Types.h.

121 {
122  Exp /**< Exp */
123 };

Function Documentation

◆ bfs()

std::vector< NodeID > bfs ( Graph g)

Breadth first search traversal.

Parameters
gGraph to traverse
Returns
A vector with the node id traversal order

Definition at line 72 of file TopologicalSort.cpp.

References arm_compute::graph::detail::all_inputs_are_visited(), ARM_COMPUTE_ERROR_ON, Const, Edge::consumer(), Edge::consumer_id(), Graph::edge(), EmptyNodeID, Input, arm_compute::test::validation::input, arm_compute::test::validation::n, Graph::node(), Graph::nodes(), and INode::output_edges().

Referenced by arm_compute::cpu::add_qasymm8_neon(), arm_compute::cpu::add_qasymm8_signed_neon(), arm_compute::cpu::add_qsymm16_neon(), arm_compute::cpu::elementwise_comp_quantized_signed(), arm_compute::cpu::elementwise_op_quantized(), arm_compute::cpu::elementwise_op_quantized_signed(), arm_compute::cpu::sub_qasymm8_neon(), arm_compute::cpu::sub_qasymm8_signed_neon(), and arm_compute::cpu::sub_qsymm16_neon().

73 {
74  std::vector<NodeID> bfs_order_vector;
75 
76  // Created visited vector
77  std::vector<bool> visited(g.nodes().size(), false);
78 
79  // Create BFS queue
80  std::list<NodeID> queue;
81 
82  // Push inputs and mark as visited
83  for(auto &input : g.nodes(NodeType::Input))
84  {
85  if(input != EmptyNodeID)
86  {
87  visited[input] = true;
88  queue.push_back(input);
89  }
90  }
91 
92  // Push const nodes and mark as visited
93  for(auto &const_node : g.nodes(NodeType::Const))
94  {
95  if(const_node != EmptyNodeID)
96  {
97  visited[const_node] = true;
98  queue.push_back(const_node);
99  }
100  }
101 
102  // Iterate over vector and edges
103  while(!queue.empty())
104  {
105  // Dequeue a node from queue and process
106  NodeID n = queue.front();
107  bfs_order_vector.push_back(n);
108  queue.pop_front();
109 
110  const INode *node = g.node(n);
111  ARM_COMPUTE_ERROR_ON(node == nullptr);
112  for(const auto &eid : node->output_edges())
113  {
114  const Edge *e = g.edge(eid);
115  ARM_COMPUTE_ERROR_ON(e == nullptr);
116  if(!visited[e->consumer_id()] && detail::all_inputs_are_visited(e->consumer(), visited))
117  {
118  visited[e->consumer_id()] = true;
119  queue.push_back(e->consumer_id());
120  }
121  }
122  }
123 
124  return bfs_order_vector;
125 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
bool all_inputs_are_visited(const INode *node, const std::vector< bool > &visited)
Checks if all the input dependencies of a node have been visited.

◆ configure_tensor()

void configure_tensor ( Tensor tensor)

Configures tensor.

Parameters
[in,out]tensorTensor to configure

Definition at line 217 of file Utils.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, IDeviceBackend::create_tensor(), Tensor::desc(), BackendRegistry::get(), BackendRegistry::get_backend(), Tensor::handle(), Tensor::set_handle(), and TensorDescriptor::target.

Referenced by GroupedConvolutionMutator::mutate(), set_tensor_accessor(), and arm_compute::graph::detail::transfer_driving_nodes_and_remove_old_node().

218 {
219  if(tensor != nullptr && tensor->handle() == nullptr)
220  {
221  Target target = tensor->desc().target;
222  backends::IDeviceBackend &backend = backends::BackendRegistry::get().get_backend(target);
223  std::unique_ptr<ITensorHandle> handle = backend.create_tensor(*tensor);
224  ARM_COMPUTE_ERROR_ON_MSG(!handle, "Couldn't create backend handle!");
225  tensor->set_handle(std::move(handle));
226  }
227 }
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
Target
< Target enum
Definition: Acl.hpp:293

◆ Convolution_method_from_name()

ConvolutionMethod Convolution_method_from_name ( const std::string &  name)

Converts a string to a strong types enumeration ConvolutionMethod.

Parameters
[in]nameString to convert
Returns
Converted Target enumeration

Definition at line 80 of file TypeLoader.cpp.

References Default, Direct, GEMM, arm_compute::utility::tolower(), and Winograd.

Referenced by operator>>().

81 {
82  static const std::map<std::string, ConvolutionMethod> methods =
83  {
84  { "default", ConvolutionMethod::Default },
85  { "direct", ConvolutionMethod::Direct },
86  { "gemm", ConvolutionMethod::GEMM },
87  { "winograd", ConvolutionMethod::Winograd },
88  };
89 
90 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
91  try
92  {
93 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
94  return methods.at(arm_compute::utility::tolower(name));
95 
96 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
97  }
98  catch(const std::out_of_range &)
99  {
100  throw std::invalid_argument(name);
101  }
102 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
103 }
std::string tolower(std::string string)
Convert string to lower case.
Definition: Utility.h:205
const char * name
GEMM CL kernel type.
Definition: CLTypes.h:86

◆ create_default_pass_manager()

PassManager create_default_pass_manager ( Target  target,
const GraphConfig cfg 
)

Creates a default PassManager.

Parameters
[in]targetTarget to create the pass manager for
[in]cfgGraph configuration meta-data
Returns
A PassManager with default mutating passes

Definition at line 73 of file Utils.cpp.

References PassManager::append(), ARM_COMPUTE_ERROR, ARM_COMPUTE_UNUSED, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, GraphConfig::synthetic_type, and GraphConfig::use_synthetic_type.

Referenced by Stream::finalize(), and set_tensor_accessor().

74 {
75  ARM_COMPUTE_UNUSED(target);
76  PassManager pm;
77 
78  // Passes that mutate graph IR
79  if(cfg.use_synthetic_type)
80  {
81  switch(cfg.synthetic_type)
82  {
83  case DataType::QASYMM8:
84  case DataType::QASYMM8_SIGNED:
85  {
86  pm.append(std::make_unique<SyntheticDataTypeMutator>(cfg.synthetic_type));
87  break;
88  }
89  default:
90  {
91  ARM_COMPUTE_ERROR("Unsupported DataType for SyntheticDataTypeMutator");
92  break;
93  }
94  }
95  }
96  pm.append(std::make_unique<NodeFusionMutator>());
97  pm.append(std::make_unique<GroupedConvolutionMutator>());
98  pm.append(std::make_unique<InPlaceOperationMutator>());
99 
100  // Passes that mutate backend information
101  pm.append(std::make_unique<DepthConcatSubTensorMutator>());
102  pm.append(std::make_unique<SplitLayerSubTensorMutator>());
103  pm.append(std::make_unique<NodeExecutionMethodMutator>());
104 
105  return pm;
106 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ depthwise_convolution_method_from_name()

DepthwiseConvolutionMethod depthwise_convolution_method_from_name ( const std::string &  name)

Converts a string to a strong types enumeration DepthwiseConvolutionMethod.

Parameters
[in]nameString to convert
Returns
Converted Target enumeration

Definition at line 105 of file TypeLoader.cpp.

References Default, Optimized3x3, and arm_compute::utility::tolower().

Referenced by operator>>().

106 {
107  static const std::map<std::string, DepthwiseConvolutionMethod> methods =
108  {
109  { "default", DepthwiseConvolutionMethod::Default },
110  { "optimized3x3", DepthwiseConvolutionMethod::Optimized3x3 },
111  };
112 
113 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
114  try
115  {
116 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
117  return methods.at(arm_compute::utility::tolower(name));
118 
119 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
120  }
121  catch(const std::out_of_range &)
122  {
123  throw std::invalid_argument(name);
124  }
125 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
126 }
std::string tolower(std::string string)
Convert string to lower case.
Definition: Utility.h:205
const char * name

◆ dfs()

std::vector< NodeID > dfs ( Graph g)

Depth first search traversal.

Parameters
gGraph to traverse
Returns
A vector with the node id traversal order

Definition at line 127 of file TopologicalSort.cpp.

References arm_compute::graph::detail::all_inputs_are_visited(), ARM_COMPUTE_ERROR_ON, Const, Edge::consumer(), Edge::consumer_id(), Graph::edge(), EmptyNodeID, Input, arm_compute::test::validation::input, arm_compute::test::validation::n, Graph::node(), Graph::nodes(), INode::output_edges(), and arm_compute::utils::iterable::reverse_iterate().

Referenced by GraphManager::finalize_graph(), SplitLayerSubTensorMutator::mutate(), and DepthConcatSubTensorMutator::mutate().

128 {
129  std::vector<NodeID> dfs_order_vector;
130 
131  // Created visited vector
132  std::vector<bool> visited(g.nodes().size(), false);
133 
134  // Create DFS stack
135  std::stack<NodeID> stack;
136 
137  // Push inputs and mark as visited
138  for(auto &input : g.nodes(NodeType::Input))
139  {
140  if(input != EmptyNodeID)
141  {
142  visited[input] = true;
143  stack.push(input);
144  }
145  }
146 
147  // Push const nodes and mark as visited
148  for(auto &const_node : g.nodes(NodeType::Const))
149  {
150  if(const_node != EmptyNodeID)
151  {
152  visited[const_node] = true;
153  stack.push(const_node);
154  }
155  }
156 
157  // Iterate over vector and edges
158  while(!stack.empty())
159  {
160  // Pop a node from stack and process
161  NodeID n = stack.top();
162  dfs_order_vector.push_back(n);
163  stack.pop();
164 
165  // Mark node as visited
166  if(!visited[n])
167  {
168  visited[n] = true;
169  }
170 
171  const INode *node = g.node(n);
172  ARM_COMPUTE_ERROR_ON(node == nullptr);
173  // Reverse iterate to push branches from right to left and pop on the opposite order
174  for(const auto &eid : arm_compute::utils::iterable::reverse_iterate(node->output_edges()))
175  {
176  const Edge *e = g.edge(eid);
177  ARM_COMPUTE_ERROR_ON(e == nullptr);
178  if(!visited[e->consumer_id()] && detail::all_inputs_are_visited(e->consumer(), visited))
179  {
180  stack.push(e->consumer_id());
181  }
182  }
183  }
184 
185  return dfs_order_vector;
186 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
reverse_iterable< T > reverse_iterate(T &val)
Creates a reverse iterable for a given type.
Definition: Iterable.h:101
bool all_inputs_are_visited(const INode *node, const std::vector< bool > &visited)
Checks if all the input dependencies of a node have been visited.

◆ execute_task()

void execute_task ( ExecutionTask task)

Definition at line 41 of file Workload.cpp.

References arm_compute::test::validation::input, ExecutionTask::node, ITensor::print(), PrintLayer, ExecutionTask::task, and INode::type().

Referenced by ExecutionTask::prepare().

42 {
43  if(task.task)
44  {
45  task.task->run();
46  }
47 #ifdef ARM_COMPUTE_ASSERTS_ENABLED
48  else if(task.node->type() == NodeType::PrintLayer)
49  {
50  auto print_node = utils::cast::polymorphic_downcast<PrintLayerNode *>(task.node);
51  auto input_handle = print_node->input(0)->handle();
52  auto transform = print_node->transform();
53 
54  input_handle->map(true);
55  ITensor *input = transform ? transform(&input_handle->tensor()) : &input_handle->tensor();
56  input->print(print_node->stream(), print_node->format_info());
57  input_handle->unmap();
58  }
59 #endif // ARM_COMPUTE_ASSERTS_ENABLED
60 }

◆ force_target_to_graph()

void force_target_to_graph ( Graph g,
Target  target 
)

Forces a single target to all graph constructs.

Parameters
[in]gGraph to force target on
[in]targetTarget to force

Definition at line 52 of file Utils.cpp.

References Graph::nodes(), and Graph::tensors().

Referenced by GraphManager::finalize_graph(), and set_tensor_accessor().

53 {
54  auto &nodes = g.nodes();
55  for(auto &node : nodes)
56  {
57  if(node)
58  {
59  node->set_assigned_target(target);
60  }
61  }
62 
63  auto &tensors = g.tensors();
64  for(auto &tensor : tensors)
65  {
66  if(tensor)
67  {
68  tensor->desc().target = target;
69  }
70  }
71 }

◆ get_default_target()

Target get_default_target ( )

Returns default target for execution.

Note
If an OpenCL backend exists then OpenCL is returned, else if the CPU backend exists returns Target::NEON as target. If no backends are registered an error is raised.
Returns
Default target

Definition at line 39 of file Utils.cpp.

References ARM_COMPUTE_ERROR, CL, is_target_supported(), and NEON.

Referenced by GraphManager::finalize_graph(), and set_tensor_accessor().

40 {
41  if(is_target_supported(Target::NEON))
42  {
43  return Target::NEON;
44  }
45  if(is_target_supported(Target::CL))
46  {
47  return Target::CL;
48  }
49  ARM_COMPUTE_ERROR("No backend exists!");
50 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
bool is_target_supported(Target target)
Checks if a specific target is supported.
Definition: Utils.cpp:34

◆ get_dimension_idx()

size_t get_dimension_idx ( DataLayout  data_layout,
const DataLayoutDimension  data_layout_dimension 
)

Get index of a tensor's given dimension depending on its layout.

Parameters
[in]data_layoutData layout of the tensor
[in]data_layout_dimensionTensor data layout dimension
Returns
Idx of given dimension

Definition at line 148 of file Utils.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_MSG, arm_compute::BATCHES, arm_compute::CHANNEL, arm_compute::HEIGHT, arm_compute::NCHW, arm_compute::UNKNOWN, and arm_compute::WIDTH.

Referenced by GraphBuilder::add_convolution_node(), GraphBuilder::add_deconvolution_node(), GraphBuilder::add_depthwise_convolution_node(), GraphBuilder::add_scale_layer(), ConcatenateLayerNode::compute_output_descriptor(), PoolingLayerNode::compute_output_descriptor(), ReorgLayerNode::compute_output_descriptor(), DeconvolutionLayerNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationWithPostOpsNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationNode::compute_output_descriptor(), FusedDepthwiseConvolutionBatchNormalizationNode::compute_output_descriptor(), DepthwiseConvolutionLayerNode::compute_output_descriptor(), ConvolutionLayerNode::compute_output_descriptor(), FusedConvolutionWithPostOpNode::compute_output_descriptor(), ResizeLayerNode::configure_output(), arm_compute::graph::backends::detail::create_concatenate_layer(), arm_compute::graph::detail::fuse_pad_with_convolution(), get_dimension_size(), is_padding_in_height_or_width(), DepthConcatSubTensorMutator::mutate(), and set_tensor_accessor().

149 {
150  ARM_COMPUTE_ERROR_ON_MSG(data_layout == DataLayout::UNKNOWN, "Cannot retrieve the dimension index for an unknown layout!");
151 
152  /* Return the index based on the data layout
153  * [N C H W]
154  * [3 2 1 0]
155  * [N H W C]
156  */
157  switch(data_layout_dimension)
158  {
159  case DataLayoutDimension::CHANNEL:
160  return (data_layout == DataLayout::NCHW) ? 2 : 0;
161  break;
162  case DataLayoutDimension::HEIGHT:
163  return (data_layout == DataLayout::NCHW) ? 1 : 2;
164  break;
165  case DataLayoutDimension::WIDTH:
166  return (data_layout == DataLayout::NCHW) ? 0 : 1;
167  break;
168  case DataLayoutDimension::BATCHES:
169  return 3;
170  break;
171  default:
172  break;
173  }
174  ARM_COMPUTE_ERROR("Data layout index not supported!");
175 }
Unknown CL kernel type.
Definition: CLTypes.h:82
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456

◆ get_dimension_size()

size_t get_dimension_size ( const TensorDescriptor descriptor,
const DataLayoutDimension  data_layout_dimension 
)

Get size of a tensor's given dimension depending on its layout.

Parameters
[in]descriptorDescriptor
[in]data_layout_dimensionTensor data layout dimension
Returns
Size of requested dimension

Definition at line 142 of file Utils.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, get_dimension_idx(), TensorDescriptor::layout, TensorDescriptor::shape, and arm_compute::UNKNOWN.

Referenced by GraphBuilder::add_batch_normalization_node(), GraphBuilder::add_convolution_node(), GraphBuilder::add_deconvolution_node(), GraphBuilder::add_depthwise_convolution_node(), GraphBuilder::add_normalize_planar_yuv_node(), ReorgLayerNode::compute_output_descriptor(), PriorBoxLayerNode::compute_output_descriptor(), PoolingLayerNode::compute_output_descriptor(), DeconvolutionLayerNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationWithPostOpsNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationNode::compute_output_descriptor(), FusedDepthwiseConvolutionBatchNormalizationNode::compute_output_descriptor(), DepthwiseConvolutionLayerNode::compute_output_descriptor(), ConvolutionLayerNode::compute_output_descriptor(), FusedConvolutionWithPostOpNode::compute_output_descriptor(), and set_tensor_accessor().

143 {
144  ARM_COMPUTE_ERROR_ON_MSG(descriptor.layout == DataLayout::UNKNOWN, "Cannot retrieve the dimension index for an unknown layout!");
145  return descriptor.shape[get_dimension_idx(descriptor.layout, data_layout_dimension)];
146 }
Unknown CL kernel type.
Definition: CLTypes.h:82
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ get_driver_nodes()

std::vector< NodeIdxPair > get_driver_nodes ( const INode node)

Get the list of driver nodes of a given node.

Parameters
[in]nodeNode to find the driver node of
Returns
A list with the driver node of a given node

Definition at line 197 of file Utils.cpp.

References ARM_COMPUTE_ERROR_ON, Graph::edge(), INode::graph(), and INode::input_edges().

Referenced by arm_compute::graph::detail::fuse_pad_with_convolution(), and set_tensor_accessor().

198 {
199  std::vector<NodeIdxPair> driver_nodes;
200 
201  const Graph *g = node.graph();
202  ARM_COMPUTE_ERROR_ON(g == nullptr);
203 
204  for(auto &input_edge_id : node.input_edges())
205  {
206  auto input_edge = g->edge(input_edge_id);
207  if(input_edge != nullptr)
208  {
209  ARM_COMPUTE_ERROR_ON(input_edge->producer() == nullptr);
210  driver_nodes.push_back({ input_edge->producer_id(), input_edge->producer_idx() });
211  }
212  }
213 
214  return driver_nodes;
215 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ get_driving_nodes()

std::vector< NodeIdxPair > get_driving_nodes ( const INode node)

Get the list of driving nodes of a given node.

Parameters
[in]nodeNode to find the driving node of
Returns
A list with the driving node of a given node

Definition at line 177 of file Utils.cpp.

References ARM_COMPUTE_ERROR_ON, Graph::edge(), INode::graph(), and INode::output_edges().

Referenced by GroupedConvolutionMutator::mutate(), set_tensor_accessor(), and arm_compute::graph::detail::transfer_driving_nodes_and_remove_old_node().

178 {
179  std::vector<NodeIdxPair> driving_nodes;
180 
181  const Graph *g = node.graph();
182  ARM_COMPUTE_ERROR_ON(g == nullptr);
183 
184  for(auto &output_edge_id : node.output_edges())
185  {
186  auto output_edge = g->edge(output_edge_id);
187  if(output_edge != nullptr)
188  {
189  ARM_COMPUTE_ERROR_ON(output_edge->consumer() == nullptr);
190  driving_nodes.push_back({ output_edge->consumer_id(), output_edge->consumer_idx() });
191  }
192  }
193 
194  return driving_nodes;
195 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ get_tensor_descriptor()

TensorDescriptor arm_compute::graph::get_tensor_descriptor ( const Graph g,
TensorID  tid 
)
inline

Returns the tensor descriptor of a given tensor.

Parameters
[in]gGraph that the tensor belongs to
[in]tidTensor ID
Returns
Tensor descriptor if tensor was found else empty descriptor

Definition at line 50 of file Utils.h.

References Tensor::desc(), and Graph::tensor().

Referenced by GraphBuilder::add_batch_normalization_node(), GraphBuilder::add_convolution_node(), GraphBuilder::add_deconvolution_node(), GraphBuilder::add_depthwise_convolution_node(), GraphBuilder::add_detection_post_process_node(), GraphBuilder::add_fully_connected_layer(), GraphBuilder::add_normalize_planar_yuv_node(), GraphBuilder::add_scale_layer(), and GraphBuilder::add_yolo_node().

51 {
52  const Tensor *tensor = g.tensor(tid);
53  return (tensor != nullptr) ? tensor->desc() : TensorDescriptor();
54 }

◆ is_padding_in_height_or_width()

bool is_padding_in_height_or_width ( const DataLayout layout,
const PaddingList padding_list 
)

Check if padding is in height and/or width dimensions.

Parameters
[in]layoutData layout of the tensor
[in]padding_listList of padding pairs

Definition at line 30 of file MutatorUtils.cpp.

References get_dimension_idx(), arm_compute::HEIGHT, arm_compute::NCHW, arm_compute::NHWC, and arm_compute::WIDTH.

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and arm_compute::graph::detail::fuse_pad_with_convolution().

31 {
32  if(layout == DataLayout::NCHW || layout == DataLayout::NHWC)
33  {
34  const unsigned int height_index = get_dimension_idx(layout, DataLayoutDimension::HEIGHT);
35  const unsigned int width_index = get_dimension_idx(layout, DataLayoutDimension::WIDTH);
36 
37  for(unsigned int i = 0; i < padding_list.size(); ++i)
38  {
39  if(i != height_index && i != width_index && padding_list[i] != PaddingInfo(0, 0))
40  {
41  // if the index is not either height or width, don't fuse
42  return false;
43  }
44  }
45 
46  return true;
47  }
48 
49  return false;
50 }
std::pair< uint32_t, uint32_t > PaddingInfo
Padding information as a pair of unsigned int start/end.
Definition: Types.h:450
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor&#39;s given dimension depending on its layout.
Definition: Utils.cpp:148

◆ is_target_supported()

bool is_target_supported ( Target  target)

Checks if a specific target is supported.

Parameters
[in]targetTarget to check
Returns
True if target is support else false

Definition at line 34 of file Utils.cpp.

References BackendRegistry::contains(), BackendRegistry::find_backend(), BackendRegistry::get(), and IDeviceBackend::is_backend_supported().

Referenced by GraphManager::finalize_graph(), get_default_target(), DepthConcatSubTensorMutator::mutate(), SplitLayerSubTensorMutator::mutate(), and set_tensor_accessor().

35 {
36  return backends::BackendRegistry::get().contains(target) && backends::BackendRegistry::get().find_backend(target)->is_backend_supported();
37 }

◆ is_utility_node()

bool arm_compute::graph::is_utility_node ( INode node)
inline

Definition at line 37 of file Utils.h.

References PrintLayer, and INode::type().

Referenced by arm_compute::graph::detail::configure_all_nodes().

38 {
39  std::set<NodeType> utility_node_types = { NodeType::PrintLayer };
40  return utility_node_types.find(node->type()) != utility_node_types.end();
41 }

◆ operator<<() [1/6]

inline ::std::ostream& arm_compute::graph::operator<< ( ::std::ostream &  os,
const Target target 
)

Formatted output of the Target.

Definition at line 38 of file TypePrinter.h.

References ARM_COMPUTE_ERROR, CL, CLVK, NEON, and UNSPECIFIED.

39 {
40  switch(target)
41  {
42  case Target::UNSPECIFIED:
43  os << "UNSPECIFIED";
44  break;
45  case Target::NEON:
46  os << "Neon";
47  break;
48  case Target::CL:
49  os << "CL";
50  break;
51  case Target::CLVK:
52  os << "CLVK";
53  break;
54  default:
55  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
56  }
57 
58  return os;
59 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ operator<<() [2/6]

inline ::std::ostream& arm_compute::graph::operator<< ( ::std::ostream &  os,
const NodeType node_type 
)

Definition at line 61 of file TypePrinter.h.

References ActivationLayer, ArgMinMaxLayer, ARM_COMPUTE_ERROR, BatchNormalizationLayer, BoundingBoxTransformLayer, ChannelShuffleLayer, ConcatenateLayer, Const, ConvolutionLayer, DeconvolutionLayer, DepthToSpaceLayer, DepthwiseConvolutionLayer, DequantizationLayer, DetectionOutputLayer, DetectionPostProcessLayer, Dummy, EltwiseLayer, FlattenLayer, FullyConnectedLayer, FusedConvolutionBatchNormalizationLayer, FusedConvolutionBatchNormalizationLayerWithPostOpsLayer, FusedConvolutionWithPostOp, FusedDepthwiseConvolutionBatchNormalizationLayer, GenerateProposalsLayer, Input, L2NormalizeLayer, NormalizationLayer, NormalizePlanarYUVLayer, Output, PadLayer, PermuteLayer, PoolingLayer, PReluLayer, PrintLayer, PriorBoxLayer, QuantizationLayer, ReductionOperationLayer, ReorgLayer, ReshapeLayer, ResizeLayer, ROIAlignLayer, SliceLayer, SoftmaxLayer, SplitLayer, StackLayer, StridedSliceLayer, UnaryEltwiseLayer, and UpsampleLayer.

62 {
63  switch(node_type)
64  {
65  case NodeType::ActivationLayer:
66  os << "ActivationLayer";
67  break;
68  case NodeType::ArgMinMaxLayer:
69  os << "ArgMinMaxLayer";
70  break;
71  case NodeType::BatchNormalizationLayer:
72  os << "BatchNormalizationLayer";
73  break;
74  case NodeType::BoundingBoxTransformLayer:
75  os << "BoundingBoxTransformLayer";
76  break;
77  case NodeType::ChannelShuffleLayer:
78  os << "ChannelShuffleLayer";
79  break;
80  case NodeType::ConcatenateLayer:
81  os << "ConcatenateLayer";
82  break;
83  case NodeType::ConvolutionLayer:
84  os << "ConvolutionLayer";
85  break;
86  case NodeType::DeconvolutionLayer:
87  os << "DeconvolutionLayer";
88  break;
89  case NodeType::DepthToSpaceLayer:
90  os << "DepthToSpaceLayer";
91  break;
92  case NodeType::DequantizationLayer:
93  os << "DequantizationLayer";
94  break;
95  case NodeType::DetectionOutputLayer:
96  os << "DetectionOutputLayer";
97  break;
98  case NodeType::DetectionPostProcessLayer:
99  os << "DetectionPostProcessLayer";
100  break;
101  case NodeType::DepthwiseConvolutionLayer:
102  os << "DepthwiseConvolutionLayer";
103  break;
104  case NodeType::EltwiseLayer:
105  os << "EltwiseLayer";
106  break;
107  case NodeType::UnaryEltwiseLayer:
108  os << "UnaryEltwiseLayer";
109  break;
110  case NodeType::FlattenLayer:
111  os << "FlattenLayer";
112  break;
113  case NodeType::FullyConnectedLayer:
114  os << "FullyConnectedLayer";
115  break;
116  case NodeType::FusedConvolutionBatchNormalizationLayer:
117  os << "FusedConvolutionBatchNormalizationLayer";
118  break;
119  case NodeType::FusedConvolutionBatchNormalizationLayerWithPostOpsLayer:
120  os << "FusedConvolutionBatchNormalizationLayerWithPostOpsLayer";
121  break;
122  case NodeType::FusedConvolutionWithPostOp:
123  os << "FusedConvolutionWithPostOp";
124  break;
125  case NodeType::FusedDepthwiseConvolutionBatchNormalizationLayer:
126  os << "FusedDepthwiseConvolutionBatchNormalizationLayer";
127  break;
128  case NodeType::GenerateProposalsLayer:
129  os << "GenerateProposalsLayer";
130  break;
131  case NodeType::L2NormalizeLayer:
132  os << "L2NormalizeLayer";
133  break;
134  case NodeType::NormalizationLayer:
135  os << "NormalizationLayer";
136  break;
137  case NodeType::NormalizePlanarYUVLayer:
138  os << "NormalizePlanarYUVLayer";
139  break;
140  case NodeType::PadLayer:
141  os << "PadLayer";
142  break;
143  case NodeType::PermuteLayer:
144  os << "PermuteLayer";
145  break;
146  case NodeType::PoolingLayer:
147  os << "PoolingLayer";
148  break;
149  case NodeType::PReluLayer:
150  os << "PReluLayer";
151  break;
152  case NodeType::PrintLayer:
153  os << "PrintLayer";
154  break;
155  case NodeType::PriorBoxLayer:
156  os << "PriorBoxLayer";
157  break;
158  case NodeType::QuantizationLayer:
159  os << "QuantizationLayer";
160  break;
161  case NodeType::ReductionOperationLayer:
162  os << "ReductionOperationLayer";
163  break;
164  case NodeType::ReorgLayer:
165  os << "ReorgLayer";
166  break;
167  case NodeType::ReshapeLayer:
168  os << "ReshapeLayer";
169  break;
170  case NodeType::ResizeLayer:
171  os << "ResizeLayer";
172  break;
173  case NodeType::ROIAlignLayer:
174  os << "ROIAlignLayer";
175  break;
176  case NodeType::SoftmaxLayer:
177  os << "SoftmaxLayer";
178  break;
179  case NodeType::SliceLayer:
180  os << "SliceLayer";
181  break;
182  case NodeType::SplitLayer:
183  os << "SplitLayer";
184  break;
185  case NodeType::StackLayer:
186  os << "StackLayer";
187  break;
188  case NodeType::StridedSliceLayer:
189  os << "StridedSliceLayer";
190  break;
191  case NodeType::UpsampleLayer:
192  os << "UpsampleLayer";
193  break;
194  case NodeType::Input:
195  os << "Input";
196  break;
197  case NodeType::Output:
198  os << "Output";
199  break;
200  case NodeType::Const:
201  os << "Const";
202  break;
203  case NodeType::Dummy:
204  os << "Dummy";
205  break;
206  default:
207  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
208  }
209 
210  return os;
211 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ operator<<() [3/6]

inline ::std::ostream& arm_compute::graph::operator<< ( ::std::ostream &  os,
const EltwiseOperation eltwise_op 
)

Formatted output of the EltwiseOperation type.

Definition at line 214 of file TypePrinter.h.

References Add, ARM_COMPUTE_ERROR, Div, Mul, and Sub.

215 {
216  switch(eltwise_op)
217  {
218  case EltwiseOperation::Add:
219  os << "Add";
220  break;
221  case EltwiseOperation::Mul:
222  os << "Mul";
223  break;
224  case EltwiseOperation::Sub:
225  os << "Sub";
226  break;
227  case EltwiseOperation::Div:
228  os << "Div";
229  break;
230  default:
231  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
232  }
233 
234  return os;
235 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ operator<<() [4/6]

inline ::std::ostream& arm_compute::graph::operator<< ( ::std::ostream &  os,
const ConvolutionMethod method 
)

Formatted output of the ConvolutionMethod type.

Definition at line 238 of file TypePrinter.h.

References ARM_COMPUTE_ERROR, Default, Direct, GEMM, and Winograd.

239 {
240  switch(method)
241  {
242  case ConvolutionMethod::Default:
243  os << "Default";
244  break;
245  case ConvolutionMethod::Direct:
246  os << "Direct";
247  break;
249  os << "GEMM";
250  break;
251  case ConvolutionMethod::Winograd:
252  os << "Winograd";
253  break;
254  default:
255  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
256  }
257 
258  return os;
259 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
GEMM CL kernel type.
Definition: CLTypes.h:86

◆ operator<<() [5/6]

inline ::std::ostream& arm_compute::graph::operator<< ( ::std::ostream &  os,
const FastMathHint hint 
)

Formatted output of the FastMathHint type.

Definition at line 262 of file TypePrinter.h.

References ARM_COMPUTE_ERROR, Disabled, and Enabled.

263 {
264  switch(hint)
265  {
266  case FastMathHint::Enabled:
267  os << "Enabled";
268  break;
269  case FastMathHint::Disabled:
270  os << "Disabled";
271  break;
272  default:
273  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
274  }
275 
276  return os;
277 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ operator<<() [6/6]

inline ::std::ostream& arm_compute::graph::operator<< ( ::std::ostream &  os,
const DepthwiseConvolutionMethod method 
)

Formatted output of the DepthwiseConvolutionMethod type.

Definition at line 280 of file TypePrinter.h.

References ARM_COMPUTE_ERROR, Default, and Optimized3x3.

281 {
282  switch(method)
283  {
284  case DepthwiseConvolutionMethod::Default:
285  os << "DEFAULT";
286  break;
287  case DepthwiseConvolutionMethod::Optimized3x3:
288  os << "Optimized3x3";
289  break;
290  default:
291  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
292  }
293 
294  return os;
295 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ operator>>() [1/3]

inline ::std::istream& arm_compute::graph::operator>> ( ::std::istream &  stream,
Target target 
)

Input Stream operator for Target.

Parameters
[in]streamStream to parse
[out]targetOutput target
Returns
Updated stream

Definition at line 73 of file TypeLoader.h.

References Convolution_method_from_name(), and target_from_name().

74 {
75  std::string value;
76  stream >> value;
77  target = target_from_name(value);
78  return stream;
79 }
Target target_from_name(const std::string &name)
Converts a string to a strong types enumeration Target.
Definition: TypeLoader.cpp:56

◆ operator>>() [2/3]

inline ::std::istream& arm_compute::graph::operator>> ( ::std::istream &  stream,
ConvolutionMethod target 
)

Input Stream operator for ConvolutionMethod.

Parameters
[in]streamStream to parse
[out]targetOutput target
Returns
Updated stream

Definition at line 96 of file TypeLoader.h.

References Convolution_method_from_name(), and depthwise_convolution_method_from_name().

97 {
98  std::string value;
99  stream >> value;
100  target = Convolution_method_from_name(value);
101  return stream;
102 }
ConvolutionMethod Convolution_method_from_name(const std::string &name)
Converts a string to a strong types enumeration ConvolutionMethod.
Definition: TypeLoader.cpp:80

◆ operator>>() [3/3]

inline ::std::istream& arm_compute::graph::operator>> ( ::std::istream &  stream,
DepthwiseConvolutionMethod target 
)

Input Stream operator for DepthwiseConvolutionMethod.

Parameters
[in]streamStream to parse
[out]targetOutput target
Returns
Updated stream

Definition at line 119 of file TypeLoader.h.

References depthwise_convolution_method_from_name().

120 {
121  std::string value;
122  stream >> value;
124  return stream;
125 }
DepthwiseConvolutionMethod depthwise_convolution_method_from_name(const std::string &name)
Converts a string to a strong types enumeration DepthwiseConvolutionMethod.
Definition: TypeLoader.cpp:105

◆ release_default_graph_context()

void release_default_graph_context ( GraphContext ctx)

Default releases the graph context if not done manually.

Parameters
[in,out]ctxGraph Context

Definition at line 108 of file Utils.cpp.

References BackendRegistry::get().

Referenced by set_tensor_accessor(), and GraphContext::~GraphContext().

109 {
110  for(const auto &backend : backends::BackendRegistry::get().backends())
111  {
112  if(backend.second->is_backend_supported())
113  {
114  backend.second->release_backend_context(ctx);
115  }
116  }
117 }

◆ set_tensor_accessor()

Status arm_compute::graph::set_tensor_accessor ( Tensor tensor,
std::unique_ptr< ITensorAccessor accessor 
)
inline

Sets an accessor on a given tensor.

Parameters
[in]tensorTensor to set the accessor to
[in]accessorAccessor to set
Returns
True if accessor was set else false

Definition at line 62 of file Utils.h.

References ARM_COMPUTE_RETURN_ERROR_ON, configure_tensor(), create_default_pass_manager(), arm_compute::test::validation::data_layout, force_target_to_graph(), get_default_target(), get_dimension_idx(), get_dimension_size(), get_driver_nodes(), get_driving_nodes(), is_target_supported(), release_default_graph_context(), Tensor::set_accessor(), setup_requested_backend_context(), and sync_backends().

63 {
64  ARM_COMPUTE_RETURN_ERROR_ON(tensor == nullptr);
65  tensor->set_accessor(std::move(accessor));
66 
67  return Status{};
68 }
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296

◆ setup_requested_backend_context()

void setup_requested_backend_context ( GraphContext ctx,
Target  target 
)

Setups requested backend context if it exists, is supported and hasn't been initialized already.

Parameters
[in,out]ctxGraph Context.
[in]targetTarget to setup the backend for.

Definition at line 130 of file Utils.cpp.

References BackendRegistry::find_backend(), BackendRegistry::get(), and IDeviceBackend::setup_backend_context().

Referenced by GraphManager::finalize_graph(), and set_tensor_accessor().

131 {
132  if(backends::BackendRegistry::get().contains(target))
133  {
134  const auto &backend = backends::BackendRegistry::get().find_backend(target);
135  if(backend->is_backend_supported())
136  {
137  backend->setup_backend_context(ctx);
138  }
139  }
140 }

◆ sync_backends()

void sync_backends ( )

Synchronize kernels execution on the backends.

On GPU, this results in a blocking call waiting for all kernels to be completed.

Definition at line 119 of file Utils.cpp.

References BackendRegistry::get().

Referenced by arm_compute::graph::detail::call_all_output_node_accessors(), and set_tensor_accessor().

120 {
121  for(const auto &backend : backends::BackendRegistry::get().backends())
122  {
123  if(backend.second->backend_allocator())
124  {
125  backend.second->sync();
126  }
127  }
128 }

◆ target_from_name()

Target target_from_name ( const std::string &  name)

Converts a string to a strong types enumeration Target.

Parameters
[in]nameString to convert
Returns
Converted Target enumeration

Definition at line 56 of file TypeLoader.cpp.

References CL, CLVK, NEON, and arm_compute::utility::tolower().

Referenced by arm_compute::operator>>(), and operator>>().

57 {
58  static const std::map<std::string, Target> targets =
59  {
60  { "neon", Target::NEON },
61  { "cl", Target::CL },
62  { "clvk", Target::CLVK },
63  };
64 
65 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
66  try
67  {
68 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
69  return targets.at(arm_compute::utility::tolower(name));
70 
71 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
72  }
73  catch(const std::out_of_range &)
74  {
75  throw std::invalid_argument(name);
76  }
77 #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
78 }
std::string tolower(std::string string)
Convert string to lower case.
Definition: Utility.h:205
const char * name

Variable Documentation

◆ EmptyEdgeID

◆ EmptyNodeID

◆ NullTensorID

constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max()

Constant NodeID specifying an equivalent of null node.

Definition at line 74 of file Types.h.

Referenced by Graph::add_connection(), ArgMinMaxLayerNode::ArgMinMaxLayerNode(), BatchNormalizationLayerNode::BatchNormalizationLayerNode(), BoundingBoxTransformLayerNode::BoundingBoxTransformLayerNode(), ChannelShuffleLayerNode::ChannelShuffleLayerNode(), ConcatenateLayerNode::ConcatenateLayerNode(), ConstNode::ConstNode(), DeconvolutionLayerNode::DeconvolutionLayerNode(), DepthToSpaceLayerNode::DepthToSpaceLayerNode(), DequantizationLayerNode::DequantizationLayerNode(), DummyNode::DummyNode(), EltwiseLayerNode::EltwiseLayerNode(), FlattenLayerNode::FlattenLayerNode(), FlattenLayerNode::forward_descriptors(), NormalizePlanarYUVLayerNode::forward_descriptors(), PReluLayerNode::forward_descriptors(), ReshapeLayerNode::forward_descriptors(), ConstNode::forward_descriptors(), InputNode::forward_descriptors(), DequantizationLayerNode::forward_descriptors(), SoftmaxLayerNode::forward_descriptors(), NormalizationLayerNode::forward_descriptors(), DetectionPostProcessLayerNode::forward_descriptors(), ChannelShuffleLayerNode::forward_descriptors(), GenerateProposalsLayerNode::forward_descriptors(), BoundingBoxTransformLayerNode::forward_descriptors(), ResizeLayerNode::forward_descriptors(), PermuteLayerNode::forward_descriptors(), ActivationLayerNode::forward_descriptors(), DummyNode::forward_descriptors(), QuantizationLayerNode::forward_descriptors(), ROIAlignLayerNode::forward_descriptors(), DepthToSpaceLayerNode::forward_descriptors(), PadLayerNode::forward_descriptors(), ReductionLayerNode::forward_descriptors(), ReorgLayerNode::forward_descriptors(), DetectionOutputLayerNode::forward_descriptors(), PoolingLayerNode::forward_descriptors(), PriorBoxLayerNode::forward_descriptors(), StackLayerNode::forward_descriptors(), BatchNormalizationLayerNode::forward_descriptors(), DeconvolutionLayerNode::forward_descriptors(), ArgMinMaxLayerNode::forward_descriptors(), SliceLayerNode::forward_descriptors(), PrintLayerNode::forward_descriptors(), L2NormalizeLayerNode::forward_descriptors(), SplitLayerNode::forward_descriptors(), ConcatenateLayerNode::forward_descriptors(), EltwiseLayerNode::forward_descriptors(), StridedSliceLayerNode::forward_descriptors(), FullyConnectedLayerNode::forward_descriptors(), DepthwiseConvolutionLayerNode::forward_descriptors(), FusedConvolutionBatchNormalizationWithPostOpsNode::forward_descriptors(), ConvolutionLayerNode::forward_descriptors(), UnaryEltwiseLayerNode::forward_descriptors(), FusedConvolutionWithPostOpNode::forward_descriptors(), FusedDepthwiseConvolutionBatchNormalizationNode::forward_descriptors(), FusedConvolutionBatchNormalizationNode::forward_descriptors(), IStream::forward_tail(), INode::input_id(), InputNode::InputNode(), L2NormalizeLayerNode::L2NormalizeLayerNode(), NormalizePlanarYUVLayerNode::NormalizePlanarYUVLayerNode(), PadLayerNode::PadLayerNode(), PermuteLayerNode::PermuteLayerNode(), PReluLayerNode::PReluLayerNode(), PrintLayerNode::PrintLayerNode(), QuantizationLayerNode::QuantizationLayerNode(), ReductionLayerNode::ReductionLayerNode(), ReorgLayerNode::ReorgLayerNode(), ReshapeLayerNode::ReshapeLayerNode(), ResizeLayerNode::ResizeLayerNode(), ROIAlignLayerNode::ROIAlignLayerNode(), INode::set_output_tensor(), SliceLayerNode::SliceLayerNode(), SoftmaxLayerNode::SoftmaxLayerNode(), SplitLayerNode::SplitLayerNode(), StackLayerNode::StackLayerNode(), Edge::tensor_id(), and UnaryEltwiseLayerNode::UnaryEltwiseLayerNode().