Compute Library
 21.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  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  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, 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...
 
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...
 
void configure_tensor (Tensor *tensor)
 Configures tensor. More...
 
void execute_task (ExecutionTask &task)
 

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 72 of file Types.h.

◆ EdgeID

using EdgeID = unsigned int

Definition at line 69 of file Types.h.

◆ GraphID

using GraphID = unsigned int

Definition at line 66 of file Types.h.

◆ ITensorAccessorUPtr

using ITensorAccessorUPtr = std::unique_ptr<ITensorAccessor>

Definition at line 50 of file ITensorAccessor.h.

◆ NodeID

using NodeID = unsigned int

Definition at line 68 of file Types.h.

◆ TensorID

using TensorID = unsigned int

Definition at line 67 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 125 of file Types.h.

126 {
127  Default, /**< Default approach using internal heuristics */
128  GEMM, /**< GEMM based convolution */
129  Direct, /**< Deep direct convolution */
130  Winograd /**< Winograd based convolution */
131 };
GEMM CL kernel type.
Definition: CLTypes.h:85
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 134 of file Types.h.

135 {
136  Default, /**< Default approach using internal heuristics */
137  GEMV, /**< Generic GEMV based depthwise convolution */
138  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
139 };
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 108 of file Types.h.

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

◆ 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 142 of file Types.h.

143 {
144  Enabled, /**< Fast math enabled for Convolution layer */
145  Disabled, /**< Fast math disabled for Convolution layer */
146 };
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 201 of file Types.h.

202 {
203  Buffer, /**< Affinity at buffer level */
204  Offset /**< Affinity at offset level */
205 };

◆ NodeType

enum NodeType
strong

Supported nodes.

Enumerator
ActivationLayer 
ArgMinMaxLayer 
BatchNormalizationLayer 
BoundingBoxTransformLayer 
ChannelShuffleLayer 
ConcatenateLayer 
ConvolutionLayer 
DeconvolutionLayer 
DepthToSpaceLayer 
DepthwiseConvolutionLayer 
DequantizationLayer 
DetectionOutputLayer 
DetectionPostProcessLayer 
EltwiseLayer 
FlattenLayer 
FullyConnectedLayer 
FusedConvolutionBatchNormalizationLayer 
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 149 of file Types.h.

150 {
164  EltwiseLayer,
165  FlattenLayer,
173  PadLayer,
174  PermuteLayer,
175  PoolingLayer,
176  PReluLayer,
177  PrintLayer,
181  ReorgLayer,
182  ReshapeLayer,
183  ResizeLayer,
185  SoftmaxLayer,
186  SliceLayer,
187  SplitLayer,
188  StackLayer,
192 
193  Input,
194  Output,
195  Const,
196 
197  Dummy
198 };

◆ 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 99 of file Types.h.

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

◆ UnaryEltwiseOperation

enum UnaryEltwiseOperation
strong

Supported Unary Element-wise operations.

Enumerator
Exp 

Exp.

Definition at line 119 of file Types.h.

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

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, 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:68
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:75
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 186 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 arm_compute::graph::detail::fuse_convolution_with_batch_normalization(), arm_compute::graph::detail::fuse_depthwise_convolution_with_batch_normalization(), GroupedConvolutionMutator::mutate(), and set_tensor_accessor().

187 {
188  if(tensor != nullptr && tensor->handle() == nullptr)
189  {
190  Target target = tensor->desc().target;
191  backends::IDeviceBackend &backend = backends::BackendRegistry::get().get_backend(target);
192  std::unique_ptr<ITensorHandle> handle = backend.create_tensor(*tensor);
193  ARM_COMPUTE_ERROR_ON_MSG(!handle, "Couldn't create backend handle!");
194  tensor->set_handle(std::move(handle));
195  }
196 }
#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:85

◆ 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, 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:68
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:75
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 137 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(), ReorgLayerNode::compute_output_descriptor(), PoolingLayerNode::compute_output_descriptor(), DeconvolutionLayerNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationNode::compute_output_descriptor(), DepthwiseConvolutionLayerNode::compute_output_descriptor(), FusedDepthwiseConvolutionBatchNormalizationNode::compute_output_descriptor(), ConvolutionLayerNode::compute_output_descriptor(), ResizeLayerNode::configure_output(), arm_compute::graph::backends::detail::create_concatenate_layer(), get_dimension_size(), DepthConcatSubTensorMutator::mutate(), and set_tensor_accessor().

138 {
139  ARM_COMPUTE_ERROR_ON_MSG(data_layout == DataLayout::UNKNOWN, "Cannot retrieve the dimension index for an unknown layout!");
140 
141  /* Return the index based on the data layout
142  * [N C H W]
143  * [3 2 1 0]
144  * [N H W C]
145  */
146  switch(data_layout_dimension)
147  {
148  case DataLayoutDimension::CHANNEL:
149  return (data_layout == DataLayout::NCHW) ? 2 : 0;
150  break;
151  case DataLayoutDimension::HEIGHT:
152  return (data_layout == DataLayout::NCHW) ? 1 : 2;
153  break;
154  case DataLayoutDimension::WIDTH:
155  return (data_layout == DataLayout::NCHW) ? 0 : 1;
156  break;
157  case DataLayoutDimension::BATCHES:
158  return 3;
159  break;
160  default:
161  break;
162  }
163  ARM_COMPUTE_ERROR("Data layout index not supported!");
164 }
Unknown CL kernel type.
Definition: CLTypes.h:81
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
const DataLayout data_layout
Definition: Im2Col.cpp:151
#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 131 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(), PriorBoxLayerNode::compute_output_descriptor(), PoolingLayerNode::compute_output_descriptor(), ReorgLayerNode::compute_output_descriptor(), DeconvolutionLayerNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationNode::compute_output_descriptor(), DepthwiseConvolutionLayerNode::compute_output_descriptor(), FusedDepthwiseConvolutionBatchNormalizationNode::compute_output_descriptor(), ConvolutionLayerNode::compute_output_descriptor(), and set_tensor_accessor().

132 {
133  ARM_COMPUTE_ERROR_ON_MSG(descriptor.layout == DataLayout::UNKNOWN, "Cannot retrieve the dimension index for an unknown layout!");
134  return descriptor.shape[get_dimension_idx(descriptor.layout, data_layout_dimension)];
135 }
Unknown CL kernel type.
Definition: CLTypes.h:81
#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:137

◆ 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 166 of file Utils.cpp.

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

Referenced by arm_compute::graph::detail::fuse_convolution_with_batch_normalization(), arm_compute::graph::detail::fuse_depthwise_convolution_with_batch_normalization(), arm_compute::graph::detail::fuse_node_with_activation(), GroupedConvolutionMutator::mutate(), and set_tensor_accessor().

167 {
168  std::vector<NodeIdxPair> driving_nodes;
169 
170  const Graph *g = node.graph();
171  ARM_COMPUTE_ERROR_ON(g == nullptr);
172 
173  for(auto &output_edge_id : node.output_edges())
174  {
175  auto output_edge = g->edge(output_edge_id);
176  if(output_edge != nullptr)
177  {
178  ARM_COMPUTE_ERROR_ON(output_edge->consumer() == nullptr);
179  driving_nodes.push_back({ output_edge->consumer_id(), output_edge->consumer_idx() });
180  }
181  }
182 
183  return driving_nodes;
184 }
#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_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, 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::FusedDepthwiseConvolutionBatchNormalizationLayer:
120  os << "FusedDepthwiseConvolutionBatchNormalizationLayer";
121  break;
122  case NodeType::GenerateProposalsLayer:
123  os << "GenerateProposalsLayer";
124  break;
125  case NodeType::L2NormalizeLayer:
126  os << "L2NormalizeLayer";
127  break;
128  case NodeType::NormalizationLayer:
129  os << "NormalizationLayer";
130  break;
131  case NodeType::NormalizePlanarYUVLayer:
132  os << "NormalizePlanarYUVLayer";
133  break;
134  case NodeType::PadLayer:
135  os << "PadLayer";
136  break;
137  case NodeType::PermuteLayer:
138  os << "PermuteLayer";
139  break;
140  case NodeType::PoolingLayer:
141  os << "PoolingLayer";
142  break;
143  case NodeType::PReluLayer:
144  os << "PReluLayer";
145  break;
146  case NodeType::PrintLayer:
147  os << "PrintLayer";
148  break;
149  case NodeType::PriorBoxLayer:
150  os << "PriorBoxLayer";
151  break;
152  case NodeType::QuantizationLayer:
153  os << "QuantizationLayer";
154  break;
155  case NodeType::ReductionOperationLayer:
156  os << "ReductionOperationLayer";
157  break;
158  case NodeType::ReorgLayer:
159  os << "ReorgLayer";
160  break;
161  case NodeType::ReshapeLayer:
162  os << "ReshapeLayer";
163  break;
164  case NodeType::ResizeLayer:
165  os << "ResizeLayer";
166  break;
167  case NodeType::ROIAlignLayer:
168  os << "ROIAlignLayer";
169  break;
170  case NodeType::SoftmaxLayer:
171  os << "SoftmaxLayer";
172  break;
173  case NodeType::SliceLayer:
174  os << "SliceLayer";
175  break;
176  case NodeType::SplitLayer:
177  os << "SplitLayer";
178  break;
179  case NodeType::StackLayer:
180  os << "StackLayer";
181  break;
182  case NodeType::StridedSliceLayer:
183  os << "StridedSliceLayer";
184  break;
185  case NodeType::UpsampleLayer:
186  os << "UpsampleLayer";
187  break;
188  case NodeType::Input:
189  os << "Input";
190  break;
191  case NodeType::Output:
192  os << "Output";
193  break;
194  case NodeType::Const:
195  os << "Const";
196  break;
197  case NodeType::Dummy:
198  os << "Dummy";
199  break;
200  default:
201  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
202  }
203 
204  return os;
205 }
#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 208 of file TypePrinter.h.

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

209 {
210  switch(eltwise_op)
211  {
212  case EltwiseOperation::Add:
213  os << "Add";
214  break;
215  case EltwiseOperation::Mul:
216  os << "Mul";
217  break;
218  case EltwiseOperation::Sub:
219  os << "Sub";
220  break;
221  case EltwiseOperation::Div:
222  os << "Div";
223  break;
224  default:
225  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
226  }
227 
228  return os;
229 }
#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 232 of file TypePrinter.h.

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

233 {
234  switch(method)
235  {
236  case ConvolutionMethod::Default:
237  os << "Default";
238  break;
239  case ConvolutionMethod::Direct:
240  os << "Direct";
241  break;
243  os << "GEMM";
244  break;
245  case ConvolutionMethod::Winograd:
246  os << "Winograd";
247  break;
248  default:
249  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
250  }
251 
252  return os;
253 }
#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:85

◆ 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 256 of file TypePrinter.h.

References ARM_COMPUTE_ERROR, Disabled, and Enabled.

257 {
258  switch(hint)
259  {
260  case FastMathHint::Enabled:
261  os << "Enabled";
262  break;
263  case FastMathHint::Disabled:
264  os << "Disabled";
265  break;
266  default:
267  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
268  }
269 
270  return os;
271 }
#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 274 of file TypePrinter.h.

References ARM_COMPUTE_ERROR, Default, and Optimized3x3.

275 {
276  switch(method)
277  {
278  case DepthwiseConvolutionMethod::Default:
279  os << "DEFAULT";
280  break;
281  case DepthwiseConvolutionMethod::Optimized3x3:
282  os << "Optimized3x3";
283  break;
284  default:
285  ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
286  }
287 
288  return os;
289 }
#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_driving_nodes(), is_target_supported(), release_default_graph_context(), Tensor::set_accessor(), and setup_requested_backend_context().

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 119 of file Utils.cpp.

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

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

120 {
121  if(backends::BackendRegistry::get().contains(target))
122  {
123  const auto &backend = backends::BackendRegistry::get().find_backend(target);
124  if(backend->is_backend_supported())
125  {
126  backend->setup_backend_context(ctx);
127  }
128  }
129 }

◆ 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 73 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(), QuantizationLayerNode::forward_descriptors(), DummyNode::forward_descriptors(), ReductionLayerNode::forward_descriptors(), ROIAlignLayerNode::forward_descriptors(), DepthToSpaceLayerNode::forward_descriptors(), PadLayerNode::forward_descriptors(), PoolingLayerNode::forward_descriptors(), DetectionOutputLayerNode::forward_descriptors(), PriorBoxLayerNode::forward_descriptors(), ReorgLayerNode::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(), ConvolutionLayerNode::forward_descriptors(), UnaryEltwiseLayerNode::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().