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

#include <ReduceProd.h>

Collaboration diagram for luci_interpreter::kernels::ReduceProd:

Public Member Functions

 ReduceProd (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 ReduceProd.h.

Constructor & Destructor Documentation

◆ ReduceProd()

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

Definition at line 113 of file ReduceProd.cpp.

115 : KernelWithParams<ReducerParams>({input, axes}, {output, temp_index, resolved_axes}, params)
116{
117}
const ReducerParams & params() const
Definition Kernel.h:67

References axes(), and input().

Member Function Documentation

◆ axes()

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

Definition at line 37 of file ReduceProd.h.

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

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and ReduceProd().

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 119 of file ReduceProd.cpp.

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

Implements luci_interpreter::Kernel.

Definition at line 144 of file ReduceProd.cpp.

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

References input().

◆ input()

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

Definition at line 36 of file ReduceProd.h.

36{ return _inputs[0]; }

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

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