MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / update_window_if_needed

Method update_window_if_needed

src/core/AccessWindowStatic.cpp:87–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87bool AccessWindowStatic::update_window_if_needed(Window &window) const
88{
89 // If the padding is not enough and the tensor is not resizable, shrink the window to size 0
90 if (_info == nullptr || _info->is_resizable())
91 {
92 return false;
93 }
94
95 const TensorShape &shape = _info->tensor_shape();
96 const Strides &strides = _info->strides_in_bytes();
97 const size_t offset_first_element = _info->offset_first_element_in_bytes();
98
99 bool window_modified = false;
100
101 // Calculate if padding is enough
102 if (_start_y < 0)
103 {
104 const int front_pad_y_available = -static_cast<int>(offset_first_element / strides[1]);
105
106 if (_start_y < front_pad_y_available)
107 {
108 window_modified = true;
109 }
110 }
111
112 if (!window_modified)
113 {
114 if (_end_y > static_cast<int>(shape[1]))
115 {
116 const int stride_z = _info->num_dimensions() > 2 ? strides[2] : _info->total_size();
117 const int tail_pad_y_available = (stride_z / strides[1]) - shape[1];
118
119 if (static_cast<int>(shape[1]) + tail_pad_y_available < _end_y)
120 {
121 window_modified = true;
122 }
123 }
124
125 if (!window_modified)
126 {
127 const int stride_y = _info->num_dimensions() > 1 ? strides[1] : _info->total_size();
128
129 if (_start_x < 0)
130 {
131 const int front_pad_x_available =
132 -std::min<int>(static_cast<int>(offset_first_element), stride_y - shape[0] * strides[0]) /
133 static_cast<int>(strides[0]);
134
135 if (_start_x < front_pad_x_available)
136 {
137 window_modified = true;
138 }
139 }
140
141 if (!window_modified && _end_x > static_cast<int>(shape[0]))
142 {
143 const int tail_pad_x_available = (stride_y / strides[0]) - shape[0];
144

Callers

nothing calls this directly

Calls 6

DimensionClass · 0.50
is_resizableMethod · 0.45
num_dimensionsMethod · 0.45
total_sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected