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

#include <Fill.h>

Collaboration diagram for luci_interpreter::kernels::Fill:

Public Member Functions

 Fill (const Tensor *dims, const Tensor *value, Tensor *output)
 
const Tensordims () const
 
const Tensorvalue () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- 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::Kernel
 Kernel (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
 
- Protected Attributes inherited from luci_interpreter::Kernel
const std::vector< const Tensor * > _inputs
 
const std::vector< Tensor * > _outputs
 

Detailed Description

Definition at line 28 of file Fill.h.

Constructor & Destructor Documentation

◆ Fill()

luci_interpreter::kernels::Fill::Fill ( const Tensor dims,
const Tensor value,
Tensor output 
)

Definition at line 26 of file Fill.cpp.

27 : Kernel({dims, value}, {output})
28{
29}
Kernel(std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
Definition Kernel.h:31
Tensor * output() const
Definition Fill.h:35
const Tensor * dims() const
Definition Fill.h:33
const Tensor * value() const
Definition Fill.h:34

References dims(), and value().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 48 of file Fill.cpp.

49{
50 const auto dims_shape = dims()->shape();
51 const auto value_shape = value()->shape();
52
53 // Make sure the 1st input tensor is 1-D
54 LUCI_INTERPRETER_CHECK(dims_shape.num_dims() == 1);
55
56 // Make sure the 1st input tensor is int32 or int64
57 LUCI_INTERPRETER_CHECK(dims()->element_type() == DataType::S32 or
58 dims()->element_type() == DataType::S64);
59
60 // Make sure the 2nd input tensor is a scalar
61 LUCI_INTERPRETER_CHECK(value_shape.num_dims() == 0)
62
63 // Check zero point and scale for S16 and S8
64 if (value()->element_type() == loco::DataType::S16 or
65 value()->element_type() == loco::DataType::S8)
66 {
68 LUCI_INTERPRETER_CHECK(value()->zero_point() == output()->zero_point());
69
70 if (value()->element_type() == loco::DataType::S16)
71 LUCI_INTERPRETER_CHECK(value()->zero_point() == 0);
72 }
73 // Resize output
74 switch (dims()->element_type())
75 {
76 case DataType::S32:
77 configureShape<int32_t>();
78 break;
79 case DataType::S64:
80 configureShape<int64_t>();
81 break;
82 default:
83 throw std::runtime_error("luci-intp Fill(1) Unsupported type.");
84 }
85}
const Shape & shape() const
Definition Tensor.h:107
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
DataType
"scalar" value type
Definition DataType.h:27

References dims(), LUCI_INTERPRETER_CHECK, output(), luci_interpreter::Tensor::shape(), and value().

◆ dims()

const Tensor * luci_interpreter::kernels::Fill::dims ( ) const
inline

Definition at line 33 of file Fill.h.

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

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and Fill().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 87 of file Fill.cpp.

88{
89 switch (output()->element_type())
90 {
91 case DataType::S8:
92 tflite::reference_ops::Fill(getTensorShape(value()), getTensorData<int8_t>(value()),
93 getTensorShape(output()), getTensorData<int8_t>(output()));
94 break;
95 case DataType::S16:
96 tflite::reference_ops::Fill(getTensorShape(value()), getTensorData<int16_t>(value()),
97 getTensorShape(output()), getTensorData<int16_t>(output()));
98 break;
99 case DataType::S32:
100 tflite::reference_ops::Fill(getTensorShape(value()), getTensorData<int32_t>(value()),
101 getTensorShape(output()), getTensorData<int32_t>(output()));
102 break;
103 case DataType::S64:
104 tflite::reference_ops::Fill(getTensorShape(value()), getTensorData<int64_t>(value()),
105 getTensorShape(output()), getTensorData<int64_t>(output()));
106 break;
107 case DataType::FLOAT32:
108 tflite::reference_ops::Fill(getTensorShape(value()), getTensorData<float>(value()),
109 getTensorShape(output()), getTensorData<float>(output()));
110 break;
111 default:
112 throw std::runtime_error("luci-intp Fill(2) Unsupported type.");
113 }
114}
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194

References luci_interpreter::kernels::getTensorShape(), output(), and value().

◆ output()

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

Definition at line 35 of file Fill.h.

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

References luci_interpreter::Kernel::_outputs.

Referenced by configure(), and execute().

◆ value()

const Tensor * luci_interpreter::kernels::Fill::value ( ) const
inline

Definition at line 34 of file Fill.h.

34{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

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


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