ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci_interpreter::kernels::Mean Class Reference

#include <Mean.h>

Collaboration diagram for luci_interpreter::kernels::Mean:

Public Member Functions

 Mean (const Tensor *input, const Tensor *axes, Tensor *output, Tensor *temp_index, Tensor *resolved_axes, Tensor *temp_sum, const ReducerParams &params)
 
const Tensorinput () const
 
const Tensoraxes () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< ReducerParams >
const ReducerParamsparams () const
 
- Public Member Functions inherited from luci_interpreter::Kernel
virtual ~Kernel ()=default
 
const std::vector< const Tensor * > & getInputTensors () const
 
const std::vector< Tensor * > & getOutputTensors () const
 

Additional Inherited Members

- Protected Member Functions inherited from luci_interpreter::KernelWithParams< ReducerParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const ReducerParams &params)
 
- Protected Member Functions inherited from luci_interpreter::Kernel
 Kernel (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
 
- Protected Attributes inherited from luci_interpreter::KernelWithParams< ReducerParams >
const ReducerParams _params
 
- Protected Attributes inherited from luci_interpreter::Kernel
const std::vector< const Tensor * > _inputs
 
const std::vector< Tensor * > _outputs
 

Detailed Description

Definition at line 30 of file Mean.h.

Constructor & Destructor Documentation

◆ Mean()

luci_interpreter::kernels::Mean::Mean ( const Tensor input,
const Tensor axes,
Tensor output,
Tensor temp_index,
Tensor resolved_axes,
Tensor temp_sum,
const ReducerParams params 
)

Definition at line 127 of file Mean.cpp.

129 : KernelWithParams<ReducerParams>({input, axes}, {output, temp_index, resolved_axes, temp_sum},
130 params)
131{
132}
const ReducerParams & params() const
Definition Kernel.h:67
const Tensor * axes() const
Definition Mean.h:37
Tensor * output() const
Definition Mean.h:38
const Tensor * input() const
Definition Mean.h:36
T must_cast(loco::Node *node)

References axes(), and input().

Member Function Documentation

◆ axes()

const Tensor * luci_interpreter::kernels::Mean::axes ( ) const
inline

Definition at line 37 of file Mean.h.

37{ return _inputs[1]; }
const std::vector< const Tensor * > _inputs
Definition Kernel.h:52

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and Mean().

◆ configure()

void luci_interpreter::kernels::Mean::configure ( )
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 134 of file Mean.cpp.

135{
136 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
137 LUCI_INTERPRETER_CHECK(axes()->element_type() == DataType::S32);
138 if (input()->element_type() == DataType::S16)
139 {
140 LUCI_INTERPRETER_CHECK(input()->zero_point() == 0 && output()->zero_point() == 0);
141 }
142
143 const Shape &input_shape = input()->shape();
145
146 const auto *axes_data = getTensorData<int32_t>(axes());
147 int num_axes = axes()->shape().num_elements();
148 assert(num_axes <= 4);
149
152
153 tflite::MeanParams params{};
154 resolveAxes(axes_data, num_axes, &params);
155
156 auto temp_index = getOutputTensors()[1];
158 auto temp_sum = getOutputTensors()[3];
159
161 resolved_axes->resize(Shape(num_axes));
162 temp_sum->resize(output()->shape());
163}
const std::vector< Tensor * > & getOutputTensors() const
Definition Kernel.h:40
int32_t num_elements() const
Definition Tensor.h:53
int num_dims() const
Definition Tensor.h:39
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
const Shape & shape() const
Definition Tensor.h:107
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
const luci_interpreter::RuntimeShape output_shape
Definition Shape.h:28

References luci_interpreter::KernelWithParams< ReducerParams >::_params, axes(), luci_interpreter::Kernel::getOutputTensors(), input(), luci_interpreter::ReducerParams::keep_dims, LUCI_INTERPRETER_CHECK, luci::must_cast(), luci_interpreter::Shape::num_dims(), luci_interpreter::Shape::num_elements(), output(), output_shape, luci_interpreter::KernelWithParams< ReducerParams >::params(), luci_interpreter::Tensor::resize(), and luci_interpreter::Tensor::shape().

◆ execute()

void luci_interpreter::kernels::Mean::execute ( ) const
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 165 of file Mean.cpp.

166{
167 switch (input()->element_type())
168 {
169 case DataType::FLOAT32:
170 evalFloat();
171 break;
172 case DataType::U8:
173 evalQuantized();
174 break;
175 case DataType::S16:
176 evalQuantizedS16();
177 break;
178 default:
179 throw std::runtime_error("luci-intp Mean Unsupported type.");
180 }
181}

References input().

◆ input()

const Tensor * luci_interpreter::kernels::Mean::input ( ) const
inline

Definition at line 36 of file Mean.h.

36{ return _inputs[0]; }

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), execute(), and Mean().

◆ output()

Tensor * luci_interpreter::kernels::Mean::output ( ) const
inline

Definition at line 38 of file Mean.h.

38{ return _outputs[0]; }
const std::vector< Tensor * > _outputs
Definition Kernel.h:53

References luci_interpreter::Kernel::_outputs.

Referenced by configure().


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