35 : _memory_group(
std::move(memory_manager)),
39 _reduction_operation_mean(),
40 _reduction_operation_stddev(),
41 _reduction_output_mean(),
42 _reduction_output_stddev(),
86 _memory_group.
manage(&_reduction_output_mean);
93 _memory_group.
manage(&_reduction_output_stddev);
102 _global_sum = cl::Buffer(
CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(cl_ulong));
104 if(stddev !=
nullptr)
106 _global_sum_squared = cl::Buffer(
CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(cl_ulong));
109 _mean_stddev_kernel->configure(compile_context, input, mean, &_global_sum, stddev, &_global_sum_squared);
110 _fill_border_kernel->configure(compile_context, input, _mean_stddev_kernel->border_size(),
BorderMode::CONSTANT,
PixelValue(static_cast<uint8_t>(0)));
114 template <
typename T>
115 void CLMeanStdDev::run_float()
120 _reduction_operation_mean.
run();
123 _reduction_operation_stddev.
run();
124 _reduction_output_stddev.
map(
true);
127 _reduction_output_mean.
map(
true);
129 auto mean =
static_cast<T
>(0);
132 for(
unsigned int i = 0; i < _reduction_output_mean.
info()->
dimension(1); ++i)
142 auto stddev =
static_cast<T
>(0);
144 for(
unsigned int i = 0; i < _reduction_output_stddev.
info()->
dimension(1); ++i)
148 *_stddev = std::sqrt((stddev / _num_pixels) - (mean * mean));
150 _reduction_output_stddev.
unmap();
152 _reduction_output_mean.
unmap();
155 void CLMeanStdDev::run_int()
Class describing the value of a pixel for any image format.
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
static Status validate(ITensorInfo *input, float *mean, float *stddev=nullptr)
Static function to check if given info will lead to a valid configuration of CLMeanStdDev.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
static CLScheduler & get()
Access the scheduler singleton.
1 channel, 1 U8 per channel
size_t dimension(size_t index) const override
Return the size of the requested dimension.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
CLTensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
void map(bool blocking=true)
Enqueue a map operation of the allocated buffer.
uint8_t * buffer() const override
Interface to be implemented by the child class to return a pointer to CPU memory. ...
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
CLMeanStdDev(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Default Constructor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
static Status validate(const ITensorInfo *input, float *mean, cl::Buffer *global_sum, float *stddev=nullptr, cl::Buffer *global_sum_squared=nullptr)
Static function to check if given info will lead to a valid configuration of CLMeanStdDevKernel.
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_RETURN_ERROR_ON_TENSOR_NOT_2D(t)
Interface for the kernel to calculate mean and standard deviation of input image pixels.
void run() override
Run the kernels contained in the function.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op, bool keep_dims=true)
Static function to check if given info will lead to a valid configuration of CLReductionOperation.
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
void configure(ICLImage *input, float *mean, float *stddev=nullptr)
Initialise the kernel's inputs and outputs.
void allocate() override
Allocate size specified by TensorInfo of OpenCL memory.
Interface for filling the border of a kernel.
Memory group resources scope handling class.
Interface for OpenCL tensor.
int32_t offset_element_in_bytes(const Coordinates &pos) const override
The offset in bytes from the beginning of the memory allocation to access the element at position (x...
Store the tensor's metadata.
void configure(ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op, bool keep_dims=true)
Set the input and output tensors.
~CLMeanStdDev()
Default destructor.
void unmap()
Enqueue an unmap operation of the allocated and mapped buffer.
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.