23.11
|
Go to the documentation of this file.
39 validate_config(
const ITensorInfo *
input,
const Coordinates &reduction_axis,
bool keep_dims,
const ITensorInfo *output)
49 const unsigned int reduction_ops = reduction_axis.num_dimensions();
50 const int input_dims =
input->num_dimensions();
51 Coordinates axis_local = reduction_axis;
53 for (
unsigned int i = 0; i < axis_local.num_dimensions(); ++i)
60 if (output->tensor_shape().total_size() != 0)
63 TensorShape out_shape =
input->tensor_shape();
66 std::sort(axis_local.begin(), axis_local.begin() + reduction_ops);
67 for (
unsigned int i = 0; i < reduction_ops; ++i)
71 if (output->total_size() > 0 && keep_dims)
77 out_shape.set(axis_local[i], 1);
82 const unsigned int remove_index = axis_local[i] - i;
84 out_shape.remove_dimension(remove_index,
false);
87 const TensorInfo out_info =
input->clone()->set_tensor_shape(out_shape);
97 : _memory_group(std::move(memory_manager)),
111 return validate_config(
input, reduction_axis, keep_dims, output);
126 _reduction_kernels.resize(_reduction_ops);
127 _reduced_outs.resize(_reduction_ops - (keep_dims ? 1 : 0));
128 _keep_dims = keep_dims;
139 for (
int i = 0; i < _reduction_ops; ++i)
143 out_shape.
set(axis_local[i], 1);
144 auto in = (i == 0) ? tmp_input : (&_reduced_outs[i - 1]);
146 if (i == _reduction_ops - 1 && keep_dims)
155 _memory_group.
manage(&_reduced_outs[i]);
161 for (
int i = 0; i < _reduction_ops - (keep_dims ? 1 : 0); ++i)
163 _reduced_outs[i].allocator()->allocate();
171 std::sort(axis_local.
begin(), axis_local.
begin() + _reduction_ops);
172 for (
int i = 0; i < _reduction_ops; ++i)
177 _reshape.
configure(&_reduced_outs[_reduction_ops - 1], tmp_output);
184 for (
auto &kernel : _reduction_kernels)
void run() override
Run the kernels contained in the function.
static Status validate(const ITensorInfo *input, const Coordinates &reduction_axis, bool keep_dims, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEReduceMean.
virtual size_t num_channels() const =0
The number of channels for each tensor element.
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
NEReduceMean(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Constructor.
void run() override
Run the kernels contained in the function.
Interface for CPU tensor.
void configure(ITensor *input, const Coordinates &reduction_axis, bool keep_dims, ITensor *output)
Configure kernel.
TensorShape calculate_reduce_mean_shape(ITensorInfo *input, const Coordinates &reduction_axis, bool keep_dims)
Calculate the output tensor shape for the reduce mean operation.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
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...
~NEReduceMean()
Default destructor.
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
std::array< T, num_max_dimensions >::iterator begin()
Returns a read/write iterator that points to the first element in the dimension array.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
Store the tensor's metadata.
Memory group resources scope handling class.
Copyright (c) 2017-2023 Arm Limited.
void remove_dimension(size_t n, bool apply_dim_correction=true)
Accessor to remove the dimension n from the tensor shape.
@ F16
16-bit floating-point number
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
@ F32
32-bit floating-point number
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void configure(const ITensor *input, ITensor *output)
Initialise the kernel's inputs and outputs.
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
Coordinates & convert_negative_axis(Coordinates &coords, int max_value)
Convert negative coordinates to positive in the range [0, num_dims_input].
#define ARM_COMPUTE_LOG_PARAMS(...)
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)