Compute Library
 21.02
CLCropResize Class Reference

Function to perform cropping and resizing. More...

#include <CLCropResize.h>

Collaboration diagram for CLCropResize:
[legend]

Public Member Functions

 CLCropResize ()
 Default constructor. More...
 
 CLCropResize (const CLCropResize &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLCropResizeoperator= (const CLCropResize &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLCropResize (CLCropResize &&)=default
 Allow instances of this class to be moved. More...
 
CLCropResizeoperator= (CLCropResize &&)=default
 Allow instances of this class to be moved. More...
 
 ~CLCropResize ()
 Default destructor. More...
 
void configure (const ICLTensor *input, ICLTensor *boxes, ICLTensor *box_ind, ICLTensor *output, Coordinates2D crop_size, InterpolationPolicy method=InterpolationPolicy::BILINEAR, float extrapolation_value=0)
 Configure kernel. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *boxes, ICLTensor *box_ind, ICLTensor *output, Coordinates2D crop_size, InterpolationPolicy method=InterpolationPolicy::BILINEAR, float extrapolation_value=0)
 Configure kernel. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, ITensorInfo *boxes, ITensorInfo *box_ind, const ITensorInfo *output, Coordinates2D crop_size, InterpolationPolicy method, float extrapolation_value)
 Static function to check if given info will lead to a valid configuration of NESlice. More...
 

Data Fields

const ICLTensor_input
 
ICLTensor_boxes
 
ICLTensor_box_ind
 
ICLTensor_output
 
size_t _num_boxes
 
InterpolationPolicy _method
 
float _extrapolation_value
 
std::vector< std::unique_ptr< CLScale > > _scale
 
std::vector< std::unique_ptr< CLCopy > > _copy
 
std::vector< std::unique_ptr< CLTensor > > _crop_results
 
std::vector< std::unique_ptr< CLTensor > > _scaled_results
 
std::vector< std::unique_ptr< IFunction > > _internal_functions
 

Detailed Description

Function to perform cropping and resizing.

Definition at line 46 of file CLCropResize.h.

Constructor & Destructor Documentation

◆ CLCropResize() [1/3]

Default constructor.

Definition at line 58 of file CLCropResize.cpp.

59  : _input(nullptr), _boxes(nullptr), _box_ind(nullptr), _output(nullptr), _num_boxes(0), _method(), _extrapolation_value(0), _scale(), _copy(), _crop_results(), _scaled_results(), _internal_functions()
60 {
61 }
std::vector< std::unique_ptr< CLTensor > > _crop_results
Definition: CLCropResize.h:131
std::vector< std::unique_ptr< CLCopy > > _copy
Definition: CLCropResize.h:130
std::vector< std::unique_ptr< IFunction > > _internal_functions
Definition: CLCropResize.h:134
std::vector< std::unique_ptr< CLTensor > > _scaled_results
Definition: CLCropResize.h:132
InterpolationPolicy _method
Definition: CLCropResize.h:126
const ICLTensor * _input
Definition: CLCropResize.h:121
std::vector< std::unique_ptr< CLScale > > _scale
Definition: CLCropResize.h:129

◆ CLCropResize() [2/3]

CLCropResize ( const CLCropResize )
delete

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

◆ CLCropResize() [3/3]

CLCropResize ( CLCropResize &&  )
default

Allow instances of this class to be moved.

◆ ~CLCropResize()

~CLCropResize ( )
default

Default destructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor boxes,
ICLTensor box_ind,
ICLTensor output,
Coordinates2D  crop_size,
InterpolationPolicy  method = InterpolationPolicy::BILINEAR,
float  extrapolation_value = 0 
)

Configure kernel.

Note
Supported tensor rank: up to 4
Box indices may be outside of the bounds, in which case extrapolation_value is used.
Start and end indices of boxes are inclusive.
Parameters
[in]inputSource tensor containing N batches of 3D images to be cropped. Data type supported: All
[in]boxesTensor containing the boxes used to crop the images. It has to be known before configuration. Data type supported: F32
[in]box_indOne dimensional tensor containing the batch index of the 3D image in input that the corresponding box in boxes will be applied to. It has to be known before configuration. Data type supported: F32
[out]outputDestination tensor containing a cropped and resized image for each box in boxes. Data type supported: F32
[in]crop_sizeThe dimensions that each cropped image will be resized to.
[in]methodThe policy to be used when resizing image. Default is bilinear.
[in]extrapolation_valueValue to be used for values outside of the image for cropping and resizing. Default is 0.

Definition at line 84 of file CLCropResize.cpp.

References CLKernelLibrary::get().

86 {
87  configure(CLKernelLibrary::get().get_compile_context(), input, boxes, box_ind, output, crop_size, method, extrapolation_value);
88 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *boxes, ICLTensor *box_ind, ICLTensor *output, Coordinates2D crop_size, InterpolationPolicy method=InterpolationPolicy::BILINEAR, float extrapolation_value=0)
Configure kernel.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor boxes,
ICLTensor box_ind,
ICLTensor output,
Coordinates2D  crop_size,
InterpolationPolicy  method = InterpolationPolicy::BILINEAR,
float  extrapolation_value = 0 
)

Configure kernel.

Note
Supported tensor rank: up to 4
Box indices may be outside of the bounds, in which case extrapolation_value is used.
Start and end indices of boxes are inclusive.
Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor containing N batches of 3D images to be cropped. Data type supported: All
[in]boxesTensor containing the boxes used to crop the images. It has to be known before configuration. Data type supported: F32
[in]box_indOne dimensional tensor containing the batch index of the 3D image in input that the corresponding box in boxes will be applied to. It has to be known before configuration. Data type supported: F32
[out]outputDestination tensor containing a cropped and resized image for each box in boxes. Data type supported: F32
[in]crop_sizeThe dimensions that each cropped image will be resized to.
[in]methodThe policy to be used when resizing image. Default is bilinear.
[in]extrapolation_valueValue to be used for values outside of the image for cropping and resizing. Default is 0.

The number of rows out of bounds at the start and end of _crop_results[num_box].get().

The number of columns out of bounds at the start and end of _crop_results[num_box].get().

Definition at line 90 of file CLCropResize.cpp.

References CLCropResize::_box_ind, CLCropResize::_boxes, CLCropResize::_copy, CLCropResize::_crop_results, CLCropResize::_extrapolation_value, CLCropResize::_input, CLCropResize::_internal_functions, CLCropResize::_method, CLCropResize::_num_boxes, CLCropResize::_output, CLCropResize::_scale, CLCropResize::_scaled_results, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), arm_compute::CONSTANT, arm_compute::F32, CLScheduler::get(), ITensor::info(), arm_compute::test::validation::info, arm_compute::test::validation::input, ICLTensor::map(), arm_compute::NHWC, arm_compute::test::validation::output_shape, Window::set(), CLScheduler::sync(), ITensorInfo::tensor_shape(), arm_compute::TOP_LEFT, ICLTensor::unmap(), CLCropResize::validate(), Coordinates2D::x, and Coordinates2D::y.

92 {
93  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, boxes, box_ind);
94  ARM_COMPUTE_ERROR_THROW_ON(CLCropResize::validate(input->info(), boxes->info(), box_ind->info(), output->info(), crop_size, method, extrapolation_value));
95 
96  TensorShape output_shape = TensorShape(input->info()->tensor_shape()[0], crop_size.x, crop_size.y, boxes->info()->tensor_shape()[1]);
97  auto_init_if_empty(*output->info(), output_shape, 1, DataType::F32);
98 
99  _num_boxes = boxes->info()->tensor_shape()[1];
100  TensorShape out_shape(input->info()->tensor_shape()[0], crop_size.x, crop_size.y);
101 
102  _input = input;
103  _boxes = boxes;
104  _box_ind = box_ind;
105  _output = output;
106  _method = method;
107  _extrapolation_value = extrapolation_value;
108 
109  // For each crop box:
110  // - The initial cropped image is produced as specified by boxes[i] from the 3D image input[box_ind[i]].
111  // Possibly using a CLCrop and up to four CLFills.
112  // - A tensor is required to hold this initial cropped image.
113  // - A scale function is used to resize the cropped image to the size specified by crop_size.
114  // - A tensor is required to hold the final scaled image before it is copied into the 4D output
115  // that will hold all final cropped and scaled 3D images using CLCopy.
116 
117  // The contents of _boxes and _box_ind are required to calculate the shape
118  // of the initial cropped image and thus are required to configure the
119  // kernels used for cropping and scaling.
120  _boxes->map(CLScheduler::get().queue());
121  _box_ind->map(CLScheduler::get().queue());
122  for(unsigned int num_box = 0; num_box < _num_boxes; ++num_box)
123  {
124  auto crop_tensor = std::make_unique<CLTensor>();
125  TensorInfo crop_result_info(1, DataType::F32);
126  crop_result_info.set_data_layout(DataLayout::NHWC);
127  crop_tensor->allocator()->init(crop_result_info);
128  _crop_results.emplace_back(std::move(crop_tensor));
129 
130  auto scale_tensor = std::make_unique<CLTensor>();
131  TensorInfo scaled_result_info(out_shape, 1, DataType::F32);
132  scaled_result_info.set_data_layout(DataLayout::NHWC);
133  scale_tensor->allocator()->init(scaled_result_info);
134  _scaled_results.emplace_back(std::move(scale_tensor));
135 
136  // Size of the crop box in _boxes has to be given before the configure
137  uint32_t batch_index;
138  Coordinates start{};
139  Coordinates end{};
140  configure_crop(_input, _boxes, _box_ind, _crop_results[num_box].get(), num_box, start, end, batch_index);
141 
142  auto scale_kernel = std::make_unique<CLScale>();
143  scale_kernel->configure(compile_context, _crop_results[num_box].get(), _scaled_results[num_box].get(), ScaleKernelInfo{ _method, BorderMode::CONSTANT, PixelValue(_extrapolation_value), SamplingPolicy::TOP_LEFT });
144  _scale.emplace_back(std::move(scale_kernel));
145 
146  Window win = calculate_max_window(*_output->info());
147  win.set(3, Window::Dimension(num_box, num_box + 1, 1));
148 
149  auto copy_kernel = std::make_unique<CLCopy>();
150  copy_kernel->configure(compile_context, _scaled_results[num_box].get(), _output, &win);
151  _copy.emplace_back(std::move(copy_kernel));
152 
153  _crop_results[num_box]->allocator()->allocate();
154  _scaled_results[num_box]->allocator()->allocate();
155 
156  bool is_width_flipped = end[0] < start[0];
157  bool is_height_flipped = end[1] < start[1];
158  /** The number of rows out of bounds at the start and end of _crop_results[num_box].get(). */
159  std::array<int32_t, 2> rows_out_of_bounds{ 0 };
160  /** The number of columns out of bounds at the start and end of _crop_results[num_box].get(). */
161  std::array<int32_t, 2> cols_out_of_bounds{ 0 };
162  if(is_height_flipped)
163  {
164  rows_out_of_bounds[0] = start[1] >= static_cast<int32_t>(_input->info()->dimension(2)) ? std::min(start[1] - _input->info()->dimension(2) + 1, _crop_results[num_box].get()->info()->dimension(2)) : 0;
165  rows_out_of_bounds[1] = end[1] < 0 ? std::min(-end[1], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2))) : 0;
166  }
167  else
168  {
169  rows_out_of_bounds[0] = start[1] < 0 ? std::min(-start[1], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2))) : 0;
170  rows_out_of_bounds[1] = end[1] >= static_cast<int32_t>(_input->info()->dimension(2)) ? std::min(end[1] - _input->info()->dimension(2) + 1, _crop_results[num_box].get()->info()->dimension(2)) : 0;
171  }
172  if(is_width_flipped)
173  {
174  cols_out_of_bounds[0] = start[0] >= static_cast<int32_t>(_input->info()->dimension(1)) ? std::min(start[0] - _input->info()->dimension(1) + 1, _crop_results[num_box].get()->info()->dimension(1)) : 0;
175  cols_out_of_bounds[1] = end[0] < 0 ? std::min(-end[0], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1))) : 0;
176  }
177  else
178  {
179  cols_out_of_bounds[0] = start[0] < 0 ? std::min(-start[0], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1))) : 0;
180  cols_out_of_bounds[1] = end[0] >= static_cast<int32_t>(_input->info()->dimension(1)) ? std::min(end[0] - _input->info()->dimension(1) + 1, _crop_results[num_box].get()->info()->dimension(1)) : 0;
181  }
182 
183  Window full_window = calculate_max_window(*_crop_results[num_box].get()->info());
184 
185  // Full _crop_results[num_box].get() window:
186  // --------------------------------
187  // | Out of bounds |
188  // | rows before |
189  // |------------------------------|
190  // | Out of | In | Out of |
191  // | bounds | bounds | bounds |
192  // | cols | elements | cols |
193  // | before | copied | after |
194  // | | from input | |
195  // |------------------------------|
196  // | Out of bounds |
197  // | rows after |
198  // |------------------------------|
199  // Use a separate _crop_results[num_box].get() window for each section of the full _crop_results[num_box].get() window.
200  // Fill all _crop_results[num_box].get() rows that have no elements that are within the input bounds
201  // with the extrapolation value using memset.
202  // First for the rows before the in bounds rows.
203  if(rows_out_of_bounds[0] > 0)
204  {
205  Window slice_fill_rows_before(full_window);
206  slice_fill_rows_before.set(2, Window::Dimension(0, rows_out_of_bounds[0], 1));
207  auto kernel = std::make_unique<CLFill>();
208  kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_rows_before);
209  //_internal_functions.emplace_back(std::move(kernel));
210  _internal_functions.push_back(std::move(kernel));
211  }
212 
213  Window slice_in(full_window);
214  slice_in.set(2, Window::Dimension(rows_out_of_bounds[0], _crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1], 1));
215  slice_in.set(1, Window::Dimension(cols_out_of_bounds[0], _crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1], 1));
216 
217  int rows_in_bounds = static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2)) - rows_out_of_bounds[0] - rows_out_of_bounds[1];
218  if(rows_in_bounds > 0)
219  {
220  // Fill all elements that share a row with an in bounds element with the extrapolation value.
221  if(cols_out_of_bounds[0] > 0)
222  {
223  Window slice_fill_cols_before(slice_in);
224  slice_fill_cols_before.set(1, Window::Dimension(0, cols_out_of_bounds[0], 1));
225  auto kernel = std::make_unique<CLFill>();
226  kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_cols_before);
227  //_internal_functions.emplace_back(std::move(kernel));
228  _internal_functions.push_back(std::move(kernel));
229  }
230 
231  if(cols_out_of_bounds[1] > 0)
232  {
233  Window slice_fill_cols_after(slice_in);
234  slice_fill_cols_after.set(1, Window::Dimension(_crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1], _crop_results[num_box].get()->info()->dimension(1), 1));
235  auto kernel = std::make_unique<CLFill>();
236  kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_cols_after);
237  //_internal_functions.emplace_back(std::move(kernel));
238  _internal_functions.push_back(std::move(kernel));
239  }
240 
241  // Copy all elements within the input bounds from the input tensor.
242  int cols_in_bounds = static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1)) - cols_out_of_bounds[0] - cols_out_of_bounds[1];
243  if(cols_in_bounds > 0)
244  {
245  Coordinates2D start_in{ is_width_flipped ? start[0] - cols_out_of_bounds[0] : start[0] + cols_out_of_bounds[0],
246  is_height_flipped ? start[1] - rows_out_of_bounds[0] : start[1] + rows_out_of_bounds[0] };
247  Coordinates2D end_in{ is_width_flipped ? start_in.x - cols_in_bounds + 1 : start_in.x + cols_in_bounds - 1,
248  is_height_flipped ? start_in.y - rows_in_bounds + 1 : start_in.y + rows_in_bounds - 1 };
249  auto kernel = std::make_unique<CLCrop>();
250 
251  kernel->configure(compile_context, _input, _crop_results[num_box].get(), start_in, end_in, batch_index, extrapolation_value, &slice_in);
252  //_internal_functions.emplace_back(std::move(kernel));
253  _internal_functions.push_back(std::move(kernel));
254  }
255  }
256 
257  // Fill all rows after the in bounds elements with the extrapolation value.
258  if(rows_out_of_bounds[1] > 0)
259  {
260  Window slice_fill_rows_after(full_window);
261  slice_fill_rows_after.set(2, Window::Dimension(_crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1], _crop_results[num_box].get()->info()->dimension(2), 1));
262  auto kernel = std::make_unique<CLFill>();
263  kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_rows_after);
264  //_internal_functions.emplace_back(std::move(kernel));
265  _internal_functions.push_back(std::move(kernel));
266  }
267  }
268  _boxes->unmap(CLScheduler::get().queue());
269  _box_ind->unmap(CLScheduler::get().queue());
271 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
std::vector< std::unique_ptr< CLTensor > > _crop_results
Definition: CLCropResize.h:131
void map(cl::CommandQueue &q, bool blocking=true)
Enqueue a map operation of the allocated buffer on the given queue.
Definition: ICLTensor.cpp:35
std::vector< std::unique_ptr< CLCopy > > _copy
Definition: CLCropResize.h:130
std::vector< std::unique_ptr< IFunction > > _internal_functions
Definition: CLCropResize.h:134
static CLScheduler & get()
Access the scheduler singleton.
2D Coordinates structure
Definition: types.h:28
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
std::vector< std::unique_ptr< CLTensor > > _scaled_results
Definition: CLCropResize.h:132
InterpolationPolicy _method
Definition: CLCropResize.h:126
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue. ...
Definition: ICLTensor.cpp:40
static Status validate(const ITensorInfo *input, ITensorInfo *boxes, ITensorInfo *box_ind, const ITensorInfo *output, Coordinates2D crop_size, InterpolationPolicy method, float extrapolation_value)
Static function to check if given info will lead to a valid configuration of NESlice.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
Samples are taken at pixel top left corner.
void end(TokenStream &in, bool &valid)
Definition: MLGOParser.cpp:290
const ICLTensor * _input
Definition: CLCropResize.h:121
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
int x
The x coordinate.
Definition: types.h:30
void sync()
Blocks until all commands in the associated command queue have finished.
Definition: CLScheduler.cpp:72
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Num samples, height, width, channels.
std::vector< std::unique_ptr< CLScale > > _scale
Definition: CLCropResize.h:129
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
int y
The y coordinate.
Definition: types.h:31

◆ operator=() [1/2]

CLCropResize& operator= ( const CLCropResize )
delete

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

◆ operator=() [2/2]

CLCropResize& operator= ( CLCropResize &&  )
default

Allow instances of this class to be moved.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For Neon kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 273 of file CLCropResize.cpp.

References CLCropResize::_copy, CLCropResize::_internal_functions, CLCropResize::_output, CLCropResize::_scale, ARM_COMPUTE_ERROR_ON_MSG, CLScheduler::get(), and CLScheduler::sync().

274 {
275  ARM_COMPUTE_ERROR_ON_MSG(_output == nullptr, "Unconfigured function");
276 
277  for(unsigned int i = 0; i < _internal_functions.size(); ++i)
278  {
279  _internal_functions[i]->run();
280  }
281 
283  for(auto &kernel : _scale)
284  {
285  kernel->run();
286  }
288  for(auto &kernel : _copy)
289  {
290  kernel->run();
291  }
293 }
std::vector< std::unique_ptr< CLCopy > > _copy
Definition: CLCropResize.h:130
std::vector< std::unique_ptr< IFunction > > _internal_functions
Definition: CLCropResize.h:134
static CLScheduler & get()
Access the scheduler singleton.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
void sync()
Blocks until all commands in the associated command queue have finished.
Definition: CLScheduler.cpp:72
std::vector< std::unique_ptr< CLScale > > _scale
Definition: CLCropResize.h:129

◆ validate()

Status validate ( const ITensorInfo input,
ITensorInfo boxes,
ITensorInfo box_ind,
const ITensorInfo output,
Coordinates2D  crop_size,
InterpolationPolicy  method,
float  extrapolation_value 
)
static

Static function to check if given info will lead to a valid configuration of NESlice.

Note
Supported tensor rank: up to 4
Box indices may be outside of the bounds, in which case extrapolation_value is used.
Start and end indices of boxes are inclusive.
Parameters
[in]inputSource tensor info containing N batches of 3D images to be cropped. Data type supported: All
[in]boxesTensor info for the tensor containing the boxes used to crop the images. Data type supported: F32
[in]box_indTensor info for the one dimensional tensor containing the batch index of the 3D image in input that the corresponding box in boxes will be applied to. Data type supported: F32
[in]outputTensor info for the destination tensor containing a cropped and resized image for each box in boxes. Data type supported: F32
[in]crop_sizeThe dimensions that each cropped image will be resized to.
[in]methodThe policy to be used when resizing image. Default is bilinear.
[in]extrapolation_valueValue to be used for values outside of the image for cropping and resizing. Default is 0.
Returns
A status

Definition at line 65 of file CLCropResize.cpp.

References arm_compute::AREA, ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS, ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), ITensorInfo::dimension(), arm_compute::F32, ITensorInfo::tensor_shape(), ITensorInfo::total_size(), CLCrop::validate(), Coordinates2D::x, and Coordinates2D::y.

Referenced by CLCropResize::configure(), and arm_compute::test::validation::DATA_TEST_CASE().

67 {
68  ARM_COMPUTE_RETURN_ERROR_ON(crop_size.x <= 0 || crop_size.y <= 0);
70  ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[0] != 4);
71  ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[1] != box_ind->tensor_shape()[0]);
72  TensorInfo temp_info;
73  ARM_COMPUTE_RETURN_ON_ERROR(CLCrop::validate(input->clone().get(), &temp_info, { 0, 0 }, { 1, 1 }, input->dimension(3) - 1, extrapolation_value));
74  if(output->total_size() > 0)
75  {
78  TensorShape out_shape(input->tensor_shape()[0], crop_size.x, crop_size.y, boxes->tensor_shape()[1]);
79  ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), out_shape);
80  }
81  return Status{};
82 }
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
Definition: Validate.h:494
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
1 channel, 1 F32 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
Definition: Validate.h:288
int x
The x coordinate.
Definition: types.h:30
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
static Status validate(const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value=0, Window *output_window=nullptr)
Static function to check if given info will lead to a valid configuration of CLStridedSliceKernel.
Definition: CLCrop.cpp:70
int y
The y coordinate.
Definition: types.h:31
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(t,...)
Definition: Validate.h:694

Field Documentation

◆ _box_ind

ICLTensor* _box_ind

Definition at line 123 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _boxes

ICLTensor* _boxes

Definition at line 122 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _copy

std::vector<std::unique_ptr<CLCopy> > _copy

Definition at line 130 of file CLCropResize.h.

Referenced by CLCropResize::configure(), and CLCropResize::run().

◆ _crop_results

std::vector<std::unique_ptr<CLTensor> > _crop_results

Definition at line 131 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _extrapolation_value

float _extrapolation_value

Definition at line 127 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _input

const ICLTensor* _input

Definition at line 121 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _internal_functions

std::vector<std::unique_ptr<IFunction> > _internal_functions

Definition at line 134 of file CLCropResize.h.

Referenced by CLCropResize::configure(), and CLCropResize::run().

◆ _method

Definition at line 126 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _num_boxes

size_t _num_boxes

Definition at line 125 of file CLCropResize.h.

Referenced by CLCropResize::configure().

◆ _output

ICLTensor* _output

Definition at line 124 of file CLCropResize.h.

Referenced by CLCropResize::configure(), and CLCropResize::run().

◆ _scale

std::vector<std::unique_ptr<CLScale> > _scale

Definition at line 129 of file CLCropResize.h.

Referenced by CLCropResize::configure(), and CLCropResize::run().

◆ _scaled_results

std::vector<std::unique_ptr<CLTensor> > _scaled_results

Definition at line 132 of file CLCropResize.h.

Referenced by CLCropResize::configure().


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