Compute Library
 21.08
CaffePreproccessor Class Reference

Caffe preproccessor. More...

#include <GraphUtils.h>

Collaboration diagram for CaffePreproccessor:
[legend]

Public Member Functions

 CaffePreproccessor (std::array< float, 3 > mean=std::array< float, 3 > { { 0, 0, 0 } }, bool bgr=true, float scale=1.f)
 Default Constructor. More...
 
void preprocess (ITensor &tensor) override
 Preprocess the given tensor. More...
 
- Public Member Functions inherited from IPreprocessor
virtual ~IPreprocessor ()=default
 Default destructor. More...
 

Detailed Description

Caffe preproccessor.

Definition at line 60 of file GraphUtils.h.

Constructor & Destructor Documentation

◆ CaffePreproccessor()

CaffePreproccessor ( std::array< float, 3 >  mean = std::array<float, 3> { { 0, 0, 0 } },
bool  bgr = true,
float  scale = 1.f 
)

Default Constructor.

Parameters
[in]meanMean array in RGB ordering
[in]bgrBoolean specifying if the preprocessing should assume BGR format
[in]scaleScale value

Definition at line 101 of file GraphUtils.cpp.

References arm_compute::swap().

102  : _mean(mean), _bgr(bgr), _scale(scale)
103 {
104  if(_bgr)
105  {
106  std::swap(_mean[0], _mean[2]);
107  }
108 }
void swap(Window &lhs, Window &rhs)
Definition: Window.inl:304

Member Function Documentation

◆ preprocess()

void preprocess ( ITensor tensor)
overridevirtual

Preprocess the given tensor.

Parameters
[in]tensorTensor to preprocess.

Implements IPreprocessor.

Definition at line 110 of file GraphUtils.cpp.

References ARM_COMPUTE_ERROR, arm_compute::CHANNEL, ITensorInfo::data_layout(), ITensorInfo::data_type(), arm_compute::execute_window_loop(), arm_compute::F16, arm_compute::F32, arm_compute::get_data_layout_dimension_index(), ITensor::info(), ITensor::ptr_to_element(), ITensorInfo::tensor_shape(), and Window::use_tensor_dimensions().

111 {
112  if(tensor.info()->data_type() == DataType::F32)
113  {
114  preprocess_typed<float>(tensor);
115  }
116  else if(tensor.info()->data_type() == DataType::F16)
117  {
118  preprocess_typed<half>(tensor);
119  }
120  else
121  {
122  ARM_COMPUTE_ERROR("NOT SUPPORTED!");
123  }
124 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 F32 per channel
1 channel, 1 F16 per channel

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