Compute Library
 22.05
AccessWindowAutoPadding Class Reference

Dummy access window. More...

#include <AccessWindowAutoPadding.h>

Collaboration diagram for AccessWindowAutoPadding:
[legend]

Public Member Functions

 AccessWindowAutoPadding (ITensorInfo *info)
 Default constructor. More...
 
 AccessWindowAutoPadding (const AccessWindowAutoPadding &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
AccessWindowAutoPaddingoperator= (const AccessWindowAutoPadding &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 AccessWindowAutoPadding (AccessWindowAutoPadding &&)=default
 Allow instances of this class to be move constructed. More...
 
AccessWindowAutoPaddingoperator= (AccessWindowAutoPadding &&)=default
 Allow instances of this class to be moved. More...
 
 ~AccessWindowAutoPadding ()=default
 Default destructor. More...
 
void set_valid_region ()
 Set the valid region to match the entire tensor. More...
 
ValidRegion compute_valid_region () const
 Return a valid region that spans across the entire tensor. More...
 
bool update_window_if_needed (Window &window) const override
 Shrink the window if padding is not large enough. More...
 
bool update_padding_if_needed (const Window &window) override
 Increase the padding to be large enough for the window. More...
 
ValidRegion compute_valid_region (const Window &window, ValidRegion input_valid_region, bool border_undefined, BorderSize border_size) const override
 Compute the valid region based on access pattern and valid region of the inputs. More...
 
- Public Member Functions inherited from IAccessWindow
virtual ~IAccessWindow ()=default
 Default virtual destructor. More...
 

Detailed Description

Dummy access window.

This implementation always uses the auto padding of the tensor info and never updates the window. The valid region is always set to cover the entire tensor.

Note
This access window is only used during the migration to the new padding system. It will be removed once all kernels have been ported.

Definition at line 47 of file AccessWindowAutoPadding.h.

Constructor & Destructor Documentation

◆ AccessWindowAutoPadding() [1/3]

Default constructor.

Parameters
[in,out]infoTensor info of the accessed kernel.

Definition at line 31 of file AccessWindowAutoPadding.cpp.

32  : _info(info)
33 {
34 }

◆ AccessWindowAutoPadding() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ AccessWindowAutoPadding() [3/3]

Allow instances of this class to be move constructed.

◆ ~AccessWindowAutoPadding()

Default destructor.

Member Function Documentation

◆ compute_valid_region() [1/2]

ValidRegion compute_valid_region ( ) const

Return a valid region that spans across the entire tensor.

Returns
a valid region.

Definition at line 46 of file AccessWindowAutoPadding.cpp.

References ITensorInfo::tensor_shape().

Referenced by AccessWindowAutoPadding::compute_valid_region(), and AccessWindowAutoPadding::set_valid_region().

47 {
48  if(_info == nullptr)
49  {
50  return ValidRegion{};
51  }
52 
53  return ValidRegion{ Coordinates(), _info->tensor_shape() };
54 }
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Coordinates of an item.
Definition: Coordinates.h:37
Container for valid region of a window.
Definition: Types.h:184

◆ compute_valid_region() [2/2]

ValidRegion compute_valid_region ( const Window window,
ValidRegion  input_valid_region,
bool  border_undefined,
BorderSize  border_size 
) const
overridevirtual

Compute the valid region based on access pattern and valid region of the inputs.

Note
This method assumes that there is no border.
Parameters
[in]windowExecution window of the kernel.
[in]input_valid_regionCombined valid region of all inputs.
[in]border_undefinedUndefined borders are excluded from the valid region.
[in]border_sizeSize of the border around the XY-plane of the tensor.
Returns
a valid region.

Implements IAccessWindow.

Definition at line 36 of file AccessWindowAutoPadding.cpp.

References ARM_COMPUTE_UNUSED, and AccessWindowAutoPadding::compute_valid_region().

37 {
38  ARM_COMPUTE_UNUSED(window);
39  ARM_COMPUTE_UNUSED(input_valid_region);
40  ARM_COMPUTE_UNUSED(border_undefined);
41  ARM_COMPUTE_UNUSED(border_size);
42 
43  return compute_valid_region();
44 }
ValidRegion compute_valid_region() const
Return a valid region that spans across the entire tensor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ operator=() [1/2]

AccessWindowAutoPadding& operator= ( const AccessWindowAutoPadding )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

AccessWindowAutoPadding& operator= ( AccessWindowAutoPadding &&  )
default

Allow instances of this class to be moved.

◆ set_valid_region()

void set_valid_region ( )

Set the valid region to match the entire tensor.

Definition at line 56 of file AccessWindowAutoPadding.cpp.

References AccessWindowAutoPadding::compute_valid_region(), and ITensorInfo::set_valid_region().

57 {
58  if(_info == nullptr)
59  {
60  return;
61  }
62 
64 }
ValidRegion compute_valid_region() const
Return a valid region that spans across the entire tensor.
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.

◆ update_padding_if_needed()

bool update_padding_if_needed ( const Window window)
overridevirtual

Increase the padding to be large enough for the window.

Parameters
[in]windowWindow used by the kernel.
Returns
True if the padding has been changed.

Implements IAccessWindow.

Definition at line 73 of file AccessWindowAutoPadding.cpp.

References ARM_COMPUTE_UNUSED, ITensorInfo::auto_padding(), and ITensorInfo::is_resizable().

74 {
75  ARM_COMPUTE_UNUSED(window);
76 
77  // Only update the padding if the tensor allows it
78  if(_info == nullptr || !_info->is_resizable())
79  {
80  return false;
81  }
82 
83  // Update strides in tensor info
84  return _info->auto_padding();
85 }
virtual bool is_resizable() const =0
Flag indicating whether the size of the tensor can be changed.
virtual bool auto_padding()=0
Update the offset to the first element and the strides to automatically computed values.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ update_window_if_needed()

bool update_window_if_needed ( Window window) const
overridevirtual

Shrink the window if padding is not large enough.

Parameters
[in]windowWindow used by the kernel.
Returns
True if the window has been changed.

Implements IAccessWindow.

Definition at line 66 of file AccessWindowAutoPadding.cpp.

References ARM_COMPUTE_UNUSED.

67 {
68  ARM_COMPUTE_UNUSED(window);
69 
70  return false;
71 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

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