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

#include <ReduceMax.h>

Collaboration diagram for luci_interpreter::kernels::ReduceMax:

Public Member Functions

 ReduceMax (const Tensor *input, const Tensor *axes, Tensor *output, Tensor *temp_index, Tensor *resolved_axes, 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 ReduceMax.h.

Constructor & Destructor Documentation

◆ ReduceMax()

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

Definition at line 114 of file ReduceMax.cpp.

116 : KernelWithParams<ReducerParams>({input, axes}, {output, temp_index, resolved_axes}, params)
117{
118}
const ReducerParams & params() const
Definition Kernel.h:67
const Tensor * input() const
Definition ReduceMax.h:36
const Tensor * axes() const
Definition ReduceMax.h:37

References axes(), and input().

Member Function Documentation

◆ axes()

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

Definition at line 37 of file ReduceMax.h.

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

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and ReduceMax().

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 120 of file ReduceMax.cpp.

121{
122 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
123 LUCI_INTERPRETER_CHECK(axes()->element_type() == DataType::S32);
124
125 const Shape &input_shape = input()->shape();
126 int input_num_dims = input_shape.num_dims();
127
128 const auto *axes_data = getTensorData<int32_t>(axes());
129 int num_axes = axes()->shape().num_elements();
130 LUCI_INTERPRETER_CHECK(num_axes <= 4);
131
132 // We compute shapes of outputs in configure, assuming that outputs have
133 // static shape
134 // TODO Support dynamic shape
135 Shape output_shape = getOutputShape(input_shape, axes_data, num_axes, _params.keep_dims);
137
138 auto temp_index = getOutputTensors()[1];
139 auto resolved_axes = getOutputTensors()[2];
140
141 temp_index->resize(Shape(input_num_dims));
142 resolved_axes->resize(Shape(num_axes));
143}
const std::vector< Tensor * > & getOutputTensors() const
Definition Kernel.h:40
int32_t num_elements() const
Definition Tensor.h:53
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_interpreter::Shape::num_dims(), luci_interpreter::Shape::num_elements(), output(), output_shape, luci_interpreter::Tensor::resize(), and luci_interpreter::Tensor::shape().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 145 of file ReduceMax.cpp.

146{
147 switch (input()->element_type())
148 {
149 case DataType::FLOAT32:
150 evalFloat();
151 break;
152 case DataType::BOOL:
153 evalBool();
154 break;
155 // TODO Support quantized kernels
156 default:
157 throw std::runtime_error("luci-intp ReduceMax Unsupported type.");
158 }
159}

References input().

◆ input()

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

Definition at line 36 of file ReduceMax.h.

36{ return _inputs[0]; }

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

Definition at line 38 of file ReduceMax.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: