Compute Library
 22.08
IClKernelComponent Class Referenceabstract

#include <Common.h>

Data Structures

struct  TagVal
 

Public Types

using Link = SharedVarLink
 
using Tag = std::string
 
using TagLUT = std::unordered_map< Tag, TagVal >
 

Public Member Functions

 IClKernelComponent (ClKernelBlueprint *blueprint)
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (IClKernelComponent)
 
virtual ~IClKernelComponent ()=default
 
virtual ComponentType get_component_type () const =0
 
virtual std::vector< Linkget_links () const =0
 
virtual std::string name () const =0
 
ComponentID id () const
 
void set_id (ComponentID id)
 
virtual std::set< std::string > get_headers_list () const
 
virtual std::string get_additional_macros () const
 
virtual std::string get_component_code () const
 
virtual Window get_window () const
 
virtual TagLUT get_tag_lut (const SharedVarTable &vtable) const =0
 Get the tag look-up table used to instantiate the component code. More...
 
virtual void allocate_shared_vars (SharedVarTable &vtable) const =0
 Allocate all shared variables used by the component in the vtable. More...
 
virtual std::string get_dst_addr_calculation () const
 
virtual std::string generate_config_id () const
 Generate config id of the component. More...
 
virtual CLBuildOptions generate_build_options () const
 

Static Public Member Functions

static std::string replace_tags (const std::string &code_template, const TagLUT &tags)
 

Detailed Description

Definition at line 256 of file Common.h.

Member Typedef Documentation

◆ Link

Definition at line 259 of file Common.h.

◆ Tag

using Tag = std::string

Definition at line 260 of file Common.h.

◆ TagLUT

using TagLUT = std::unordered_map<Tag, TagVal>

Definition at line 292 of file Common.h.

Constructor & Destructor Documentation

◆ IClKernelComponent()

IClKernelComponent ( ClKernelBlueprint blueprint)
inline

Definition at line 294 of file Common.h.

References ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE, and name.

Referenced by ClDirectConvolutionKernelComponent::ClDirectConvolutionKernelComponent().

295  : _blueprint(blueprint)
296  {
297  }

◆ ~IClKernelComponent()

virtual ~IClKernelComponent ( )
virtualdefault

Member Function Documentation

◆ allocate_shared_vars()

virtual void allocate_shared_vars ( SharedVarTable vtable) const
pure virtual

Allocate all shared variables used by the component in the vtable.

Parameters
vtable

Implemented in ClStoreIndirectWidthSelectKernelComponent, ClElementwiseKernelComponent, ClFloorKernelComponent, ClDirectConvolutionKernelComponent, and ClStoreBlockBoundaryAwareKernelComponent.

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( IClKernelComponent  )

◆ generate_build_options()

virtual CLBuildOptions generate_build_options ( ) const
inlinevirtual

◆ generate_config_id()

virtual std::string generate_config_id ( ) const
inlinevirtual

Generate config id of the component.

Returns
std::string

Reimplemented in ClElementwiseKernelComponent, and ClFloorKernelComponent.

Definition at line 397 of file Common.h.

398  {
399  return "";
400  }

◆ get_additional_macros()

virtual std::string get_additional_macros ( ) const
inlinevirtual

Reimplemented in ClDirectConvolutionKernelComponent.

Definition at line 360 of file Common.h.

361  {
362  return "";
363  }

◆ get_component_code()

virtual std::string get_component_code ( ) const
inlinevirtual

◆ get_component_type()

◆ get_dst_addr_calculation()

virtual std::string get_dst_addr_calculation ( ) const
inlinevirtual

Definition at line 388 of file Common.h.

389  {
390  return "";
391  }

◆ get_headers_list()

virtual std::set<std::string> get_headers_list ( ) const
inlinevirtual

Reimplemented in ClElementwiseKernelComponent, ClFloorKernelComponent, and ClDirectConvolutionKernelComponent.

Definition at line 355 of file Common.h.

356  {
357  return std::set<std::string> {};
358  }

◆ get_links()

◆ get_tag_lut()

virtual TagLUT get_tag_lut ( const SharedVarTable vtable) const
pure virtual

Get the tag look-up table used to instantiate the component code.

Parameters
vtable
Returns
TagLUT

Implemented in ClStoreIndirectWidthSelectKernelComponent, ClElementwiseKernelComponent, ClFloorKernelComponent, ClDirectConvolutionKernelComponent, and ClStoreBlockBoundaryAwareKernelComponent.

◆ get_window()

virtual Window get_window ( ) const
inlinevirtual

Reimplemented in ClElementwiseKernelComponent, ClFloorKernelComponent, and ClDirectConvolutionKernelComponent.

Definition at line 370 of file Common.h.

371  {
372  return Window{};
373  }

◆ id()

◆ name()

◆ replace_tags()

static std::string replace_tags ( const std::string &  code_template,
const TagLUT tags 
)
inlinestatic

Definition at line 307 of file Common.h.

References ARM_COMPUTE_ERROR_ON_MSG.

Referenced by ClKernelBlueprint::Implementation::build_code().

308  {
309  std::string replaced_code = "";
310  bool scanning_pattern = false;
311  std::string pattern_found = "";
312  for(size_t i = 0; i < code_template.size() - 1; ++i)
313  {
314  if(!scanning_pattern)
315  {
316  if(code_template[i] == '{' && code_template[i + 1] == '{')
317  {
318  i += 1;
319  scanning_pattern = true;
320  pattern_found = "";
321  }
322  else
323  {
324  replaced_code += code_template[i];
325  }
326  }
327  else
328  {
329  if(code_template[i] == '}' && code_template[i + 1] == '}')
330  {
331  i += 1;
332  scanning_pattern = false;
333  std::string err = "Pattern " + pattern_found + " not found in tags";
334  ARM_COMPUTE_ERROR_ON_MSG(tags.find(pattern_found) == tags.end(), err.c_str());
335  replaced_code += tags.find(pattern_found)->second.value;
336  }
337  else
338  {
339  pattern_found += code_template[i];
340  }
341  }
342  }
343 
344  return replaced_code;
345  }
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456

◆ set_id()

void set_id ( ComponentID  id)
inline

Definition at line 350 of file Common.h.

351  {
352  _id = id;
353  }

The documentation for this class was generated from the following file: