ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::ir::OperationValidator Class Reference

#include <OperationValidator.h>

Collaboration diagram for onert::ir::OperationValidator:

Public Member Functions

 OperationValidator (void)=delete
 
 OperationValidator (const Graph &graph)
 
void operator() ()
 
void visit (const operation::AddN &node) override
 
void visit (const operation::ArgMinMax &node) override
 
void visit (const operation::BatchMatMul &node) override
 
void visit (const operation::BatchToSpaceND &node) override
 
void visit (const operation::BinaryArithmetic &node) override
 
void visit (const operation::Comparison &node) override
 
void visit (const operation::Concat &node) override
 
void visit (const operation::Conv2D &node) override
 
void visit (const operation::DepthToSpace &node) override
 
void visit (const operation::DepthwiseConv2D &node) override
 
void visit (const operation::DetectionPostProcess &node) override
 
void visit (const operation::ElementwiseActivation &node) override
 
void visit (const operation::ElementwiseBinary &node) override
 
void visit (const operation::ElementwiseUnary &node) override
 
void visit (const operation::EmbeddingLookup &node) override
 
void visit (const operation::ExpandDims &node) override
 
void visit (const operation::Fill &node) override
 
void visit (const operation::Gather &node) override
 
void visit (const operation::HashtableLookup &node) override
 
void visit (const operation::Pack &node) override
 
void visit (const operation::Pad &node) override
 
void visit (const operation::Rank &node) override
 
void visit (const operation::ResizeBilinear &node) override
 
void visit (const operation::Reverse &node) override
 
void visit (const operation::RoPE &node) override
 
void visit (const operation::Select &node) override
 
void visit (const operation::Shape &node) override
 
void visit (const operation::Slice &node) override
 
void visit (const operation::Softmax &node) override
 
void visit (const operation::SpaceToBatchND &node) override
 
void visit (const operation::SpaceToDepth &node) override
 
void visit (const operation::Split &node) override
 
void visit (const operation::SquaredDifference &node) override
 
void visit (const operation::StatelessRandomUniform &node) override
 
void visit (const operation::StridedSlice &node) override
 
void visit (const operation::TransposeConv &node) override
 
void visit (const operation::Unpack &node) override
 
void visit (const operation::While &node) override
 
- Public Member Functions inherited from onert::ir::OperationVisitor
virtual ~OperationVisitor ()=default
 

Detailed Description

Definition at line 38 of file OperationValidator.h.

Constructor & Destructor Documentation

◆ OperationValidator() [1/2]

onert::ir::OperationValidator::OperationValidator ( void  )
delete

◆ OperationValidator() [2/2]

onert::ir::OperationValidator::OperationValidator ( const Graph graph)

Definition at line 34 of file OperationValidator.cc.

35 : _operations{graph.operations()}, _operands{graph.operands()}
36{
37}

Member Function Documentation

◆ operator()()

void onert::ir::OperationValidator::operator() ( )

Definition at line 39 of file OperationValidator.cc.

40{
41 _operations.iterate([&](const OperationIndex &, const IOperation &node) { node.accept(*this); });
42}
void iterate(const std::function< void(const Index &, const Object &)> &fn) const
Iterate over the container with given function.
::onert::util::Index< uint32_t, OperationIndexTag > OperationIndex
Definition Index.h:32

References onert::ir::IOperation::accept(), and onert::util::ObjectManager< Index, Object >::iterate().

◆ visit() [1/38]

void onert::ir::OperationValidator::visit ( const operation::AddN node)
override

Definition at line 89 of file OperationValidator.cc.

90{
91 const auto output_index(node.getOutputs().at(0));
92
93 int size = node.getInputs().size();
94 for (int i = 0; i < size; i++)
95 {
96 const auto input_index(node.getInputs().at(i));
97 OP_REQUIRES(isValidType(input_index, {DataType::FLOAT32, DataType::INT32}));
98 OP_REQUIRES(isSameType(input_index, output_index));
99 }
100}
#define OP_REQUIRES(EXP)
int32_t size[5]
Definition Slice.cpp:35

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), OP_REQUIRES, onert::ir::OperandIndexSequence::size(), and size.

◆ visit() [2/38]

void onert::ir::OperationValidator::visit ( const operation::ArgMinMax node)
override

Definition at line 102 of file OperationValidator.cc.

103{
104 const auto input_index(node.getInputs().at(operation::ArgMinMax::Input::INPUT));
105 const auto axis_index(node.getInputs().at(operation::ArgMinMax::Input::AXIS));
106 const auto output_index(node.getOutputs().at(0));
107 const auto output_type = node.param().output_type;
108
109 OP_REQUIRES(isValidType(input_index, {DataType::FLOAT32, DataType::INT32, DataType::UINT8,
110 DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
111 OP_REQUIRES(isValidType(axis_index, {DataType::INT32, DataType::INT64}));
112 OP_REQUIRES(isValidType(output_index, {DataType::INT32, DataType::INT64}));
113 OP_REQUIRES(isValidType(output_index, output_type));
114}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::ArgMinMax::AXIS, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::ArgMinMax::INPUT, OP_REQUIRES, onert::ir::operation::ArgMinMax::Param::output_type, and onert::ir::operation::ArgMinMax::param().

◆ visit() [3/38]

void onert::ir::OperationValidator::visit ( const operation::BatchMatMul node)
override

Definition at line 116 of file OperationValidator.cc.

117{
118 const auto lhs_index(node.getInputs().at(operation::BatchMatMul::Input::LHS));
119 const auto rhs_index(node.getInputs().at(operation::BatchMatMul::Input::RHS));
120 const auto output_index(node.getOutputs().at(0));
121
122 // Constant lhs and rhs is not implemented yet
123 OP_REQUIRES(!isConstant(lhs_index) && !isConstant(rhs_index));
124
125 // Allow hybrid quantization (lhs: float / rhs: qint8 / out: float)
126 OP_REQUIRES(isValidType(
127 lhs_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
128 OP_REQUIRES(isSameType(lhs_index, rhs_index) ||
129 ((operandType(lhs_index) == DataType::FLOAT32) &&
130 (operandType(rhs_index) == DataType::QUANT_INT8_ASYMM)));
131 OP_REQUIRES(isSameType(lhs_index, output_index));
132}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::BatchMatMul::LHS, OP_REQUIRES, and onert::ir::operation::BatchMatMul::RHS.

◆ visit() [4/38]

void onert::ir::OperationValidator::visit ( const operation::BatchToSpaceND node)
override

Definition at line 134 of file OperationValidator.cc.

135{
136 const auto input_index{node.getInputs().at(operation::BatchToSpaceND::Input::INPUT)};
137 const auto output_index{node.getOutputs().at(0)};
138
139 OP_REQUIRES(isSameType(input_index, output_index));
140}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::BatchToSpaceND::INPUT, and OP_REQUIRES.

◆ visit() [5/38]

void onert::ir::OperationValidator::visit ( const operation::BinaryArithmetic node)
override

Definition at line 142 of file OperationValidator.cc.

143{
144 const auto output_index{node.getOutputs().at(0)};
145 const auto lhs_index{node.getInputs().at(operation::BinaryArithmetic::Input::LHS)};
146 const auto rhs_index{node.getInputs().at(operation::BinaryArithmetic::Input::RHS)};
147
148 OP_REQUIRES(isSameType(lhs_index, rhs_index));
149 OP_REQUIRES(isSameType(lhs_index, output_index));
150}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::BinaryArithmetic::LHS, OP_REQUIRES, and onert::ir::operation::BinaryArithmetic::RHS.

◆ visit() [6/38]

void onert::ir::OperationValidator::visit ( const operation::Comparison node)
override

Definition at line 152 of file OperationValidator.cc.

153{
154 const auto output_index{node.getOutputs().at(0)};
155
156 const auto lhs_index{node.getInputs().at(operation::Comparison::Input::INPUT0)};
157 const auto rhs_index{node.getInputs().at(operation::Comparison::Input::INPUT1)};
158
159 OP_REQUIRES(isSameType(lhs_index, rhs_index));
160 OP_REQUIRES(isValidType(output_index, DataType::BOOL8));
161}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::Comparison::INPUT0, onert::ir::operation::Comparison::INPUT1, and OP_REQUIRES.

◆ visit() [7/38]

void onert::ir::OperationValidator::visit ( const operation::Concat node)
override

Definition at line 163 of file OperationValidator.cc.

164{
165 const auto output_index{node.getOutputs().at(0)};
166
167 for (auto &&input_index : node.getInputs())
168 {
169 OP_REQUIRES(isSameType(input_index, output_index));
170
171 // Int8 quantization requires same scale and zero point
172 if (isValidType(output_index, DataType::QUANT_INT8_ASYMM))
173 {
174 OP_REQUIRES(isSameQuantParam(input_index, output_index));
175 }
176 }
177}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), and OP_REQUIRES.

◆ visit() [8/38]

void onert::ir::OperationValidator::visit ( const operation::Conv2D node)
override

Definition at line 179 of file OperationValidator.cc.

180{
181 const auto input_index{node.getInputs().at(operation::Conv2D::Input::INPUT)};
182 const auto kernel_index{node.getInputs().at(operation::Conv2D::Input::KERNEL)};
183 const auto output_index{node.getOutputs().at(0)};
184
185 uint32_t stride_horizontal = node.param().stride.horizontal;
186 uint32_t stride_vertical = node.param().stride.vertical;
187 uint32_t dilation_width = node.param().dilation.width_factor;
188 uint32_t dilation_height = node.param().dilation.height_factor;
189
190 OP_REQUIRES((stride_horizontal > 0) && (stride_vertical > 0));
191 OP_REQUIRES((dilation_width > 0) && (dilation_height > 0));
192 OP_REQUIRES(isSameType(input_index, output_index));
193
194 if (isConstant(kernel_index) && operandType(kernel_index) == DataType::QUANT_INT8_ASYMM)
195 {
196 for (const auto zeropoint : _operands.at(kernel_index).typeInfo().zero_points())
197 OP_REQUIRES(zeropoint == 0);
198 }
199}

References onert::util::ObjectManager< Index, Object >::at(), onert::ir::OperandIndexSequence::at(), onert::ir::operation::Conv2D::Param::dilation, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::Dilation::height_factor, onert::ir::Stride::horizontal, onert::ir::operation::Conv2D::INPUT, onert::ir::operation::Conv2D::KERNEL, OP_REQUIRES, onert::ir::operation::Conv2D::param(), onert::ir::operation::Conv2D::Param::stride, onert::ir::Stride::vertical, and onert::ir::Dilation::width_factor.

◆ visit() [9/38]

void onert::ir::OperationValidator::visit ( const operation::DepthToSpace node)
override

Definition at line 201 of file OperationValidator.cc.

202{
203 const auto input_index{node.getInputs().at(operation::DepthToSpace::Input::INPUT)};
204 const auto output_index{node.getOutputs().at(0)};
205
206 int32_t block_size = node.param().block_size;
207
208 OP_REQUIRES(isValidType(input_index, {DataType::FLOAT32, DataType::INT32, DataType::INT64,
209 DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
210 OP_REQUIRES(isSameType(input_index, output_index));
211
212 OP_REQUIRES(block_size > 0);
213}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::DepthToSpace::Param::block_size, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::DepthToSpace::INPUT, OP_REQUIRES, and onert::ir::operation::DepthToSpace::param().

◆ visit() [10/38]

void onert::ir::OperationValidator::visit ( const operation::DepthwiseConv2D node)
override

Definition at line 223 of file OperationValidator.cc.

224{
225 const auto input_index{node.getInputs().at(operation::DepthwiseConv2D::Input::INPUT)};
226 const auto kernel_index{node.getInputs().at(operation::DepthwiseConv2D::Input::KERNEL)};
227 const auto output_index{node.getOutputs().at(0)};
228
229 uint32_t stride_horizontal = node.param().stride.horizontal;
230 uint32_t stride_vertical = node.param().stride.vertical;
231 uint32_t dilation_width = node.param().dilation.width_factor;
232 uint32_t dilation_height = node.param().dilation.height_factor;
233
234 OP_REQUIRES((stride_horizontal > 0) && (stride_vertical > 0));
235 OP_REQUIRES((dilation_width > 0) && (dilation_height > 0));
236 OP_REQUIRES(isSameType(input_index, output_index));
237
238 if (isConstant(kernel_index) && operandType(kernel_index) == DataType::QUANT_INT8_ASYMM)
239 {
240 for (const auto zeropoint : _operands.at(kernel_index).typeInfo().zero_points())
241 OP_REQUIRES(zeropoint == 0);
242 }
243}

References onert::util::ObjectManager< Index, Object >::at(), onert::ir::OperandIndexSequence::at(), onert::ir::operation::DepthwiseConv2D::Param::dilation, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::Dilation::height_factor, onert::ir::Stride::horizontal, onert::ir::operation::DepthwiseConv2D::INPUT, onert::ir::operation::DepthwiseConv2D::KERNEL, OP_REQUIRES, onert::ir::operation::DepthwiseConv2D::param(), onert::ir::operation::DepthwiseConv2D::Param::stride, onert::ir::Stride::vertical, and onert::ir::Dilation::width_factor.

◆ visit() [11/38]

void onert::ir::OperationValidator::visit ( const operation::DetectionPostProcess node)
override

Definition at line 215 of file OperationValidator.cc.

216{
217 const auto &param = node.param();
218
219 // FIXME: number of classes should be 1 for now.
220 OP_REQUIRES(param.num_classes == 1);
221}

References OP_REQUIRES, and onert::ir::operation::DetectionPostProcess::param().

◆ visit() [12/38]

void onert::ir::OperationValidator::visit ( const operation::ElementwiseActivation node)
override

Definition at line 245 of file OperationValidator.cc.

246{
247 const auto output_index{node.getOutputs().at(0)};
248 const auto input_index{node.getInputs().at(0)};
249
250 // Check if I/O types match
251 OP_REQUIRES(isSameType(output_index, input_index));
252
253 switch (node.param().op_type)
254 {
256 OP_REQUIRES(isValidType(input_index, DataType::FLOAT32));
257 break;
260 isValidType(input_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM,
261 DataType::QUANT_INT8_ASYMM, DataType::QUANT_INT16_ASYMM}));
262 break;
265 isValidType(input_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM,
266 DataType::QUANT_INT8_ASYMM, DataType::QUANT_INT16_ASYMM}));
267 break;
269 OP_REQUIRES(isValidType(
270 input_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
271 break;
274 isValidType(input_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM,
275 DataType::QUANT_INT8_ASYMM, DataType::QUANT_INT16_ASYMM}));
276 break;
277 }
278}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::ElementwiseActivation::ELU, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::ElementwiseActivation::LEAKY_RELU, onert::ir::operation::ElementwiseActivation::LOGISTIC, OP_REQUIRES, onert::ir::operation::ElementwiseActivation::Param::op_type, onert::ir::operation::ElementwiseActivation::param(), onert::ir::operation::ElementwiseActivation::RELU, and onert::ir::operation::ElementwiseActivation::TANH.

◆ visit() [13/38]

void onert::ir::OperationValidator::visit ( const operation::ElementwiseBinary node)
override

◆ visit() [14/38]

void onert::ir::OperationValidator::visit ( const operation::ElementwiseUnary node)
override

Definition at line 297 of file OperationValidator.cc.

298{
299 const auto output_index{node.getOutputs().at(0)};
300 const auto input_index{node.getInputs().at(operation::ElementwiseUnary::Input::INPUT)};
301
302 // Check if I/O types match
303 if (node.param().op_type == operation::ElementwiseUnary::Type::DEQUANTIZE)
304 {
305 // NNAPI allow QUANT_INT8_SYMM type input
306 OP_REQUIRES(isValidType(input_index, {DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_SYMM,
307 DataType::QUANT_INT8_ASYMM}));
308 OP_REQUIRES(isValidType(output_index, DataType::FLOAT32));
309 }
310 else if (node.param().op_type == operation::ElementwiseUnary::Type::QUANTIZE)
311 {
312 OP_REQUIRES(isValidType(
313 input_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
315 isValidType(output_index, {DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
316 }
317 else if (node.param().op_type == operation::ElementwiseUnary::Type::FLOOR)
318 {
319 OP_REQUIRES(isValidType(input_index, DataType::FLOAT32));
320 OP_REQUIRES(isSameType(output_index, input_index));
321 }
322 else if (node.param().op_type != operation::ElementwiseUnary::Type::CAST)
323 {
324 OP_REQUIRES(isSameType(output_index, input_index));
325 }
326}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::ElementwiseUnary::CAST, onert::ir::operation::ElementwiseUnary::DEQUANTIZE, onert::ir::operation::ElementwiseUnary::FLOOR, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::ElementwiseUnary::INPUT, OP_REQUIRES, onert::ir::operation::ElementwiseUnary::Param::op_type, onert::ir::operation::ElementwiseUnary::param(), and onert::ir::operation::ElementwiseUnary::QUANTIZE.

◆ visit() [15/38]

void onert::ir::OperationValidator::visit ( const operation::EmbeddingLookup node)
override

Definition at line 328 of file OperationValidator.cc.

329{
330 const auto lookups_index{node.getInputs().at(operation::EmbeddingLookup::Input::LOOKUPS)};
331 const auto values_index{node.getInputs().at(operation::EmbeddingLookup::Input::VALUES)};
332 const auto output_index{node.getOutputs().at(0)};
333
334 OP_REQUIRES(isValidType(lookups_index, DataType::INT32));
335
336 // TFLite: Allow hybrid type - value table & output
337 // NNAPI: Require same value table and output type
339 isSameType(values_index, output_index) ||
340 (isValidType(output_index, DataType::FLOAT32) &&
341 (isValidType(values_index, {DataType::QUANT_INT8_ASYMM, DataType::QUANT_INT8_SYMM}))));
342}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::EmbeddingLookup::LOOKUPS, OP_REQUIRES, and onert::ir::operation::EmbeddingLookup::VALUES.

◆ visit() [16/38]

void onert::ir::OperationValidator::visit ( const operation::ExpandDims node)
override

Definition at line 344 of file OperationValidator.cc.

345{
346 const auto output_index{node.getOutputs().at(0)};
347 const auto input_index{node.getInputs().at(operation::ExpandDims::Input::INPUT)};
348 const auto axis_index{node.getInputs().at(operation::ExpandDims::Input::AXIS)};
349
350 OP_REQUIRES(isSameType(output_index, input_index));
351 OP_REQUIRES(isValidType(axis_index, {DataType::INT32, DataType::INT64}));
352}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::ExpandDims::AXIS, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::ExpandDims::INPUT, and OP_REQUIRES.

◆ visit() [17/38]

void onert::ir::OperationValidator::visit ( const operation::Fill node)
override

Definition at line 354 of file OperationValidator.cc.

355{
356 const auto output_index{node.getOutputs().at(0)};
357 const auto input_index{node.getInputs().at(operation::Fill::Input::SHAPE)};
358 const auto value_index{node.getInputs().at(operation::Fill::Input::VALUE)};
359
360 OP_REQUIRES(isSameType(output_index, value_index));
361 OP_REQUIRES(isValidType(input_index, {DataType::INT32, DataType::INT64}));
362 OP_REQUIRES(isValidType(output_index,
363 {DataType::FLOAT32, DataType::INT32, DataType::INT64, DataType::BOOL8}));
364}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), OP_REQUIRES, onert::ir::operation::Fill::SHAPE, and onert::ir::operation::Fill::VALUE.

◆ visit() [18/38]

void onert::ir::OperationValidator::visit ( const operation::Gather node)
override

Definition at line 366 of file OperationValidator.cc.

367{
368 const auto output_index{node.getOutputs().at(0)};
369 const auto input_index{node.getInputs().at(operation::Gather::INPUT)};
370 const auto indices_index{node.getInputs().at(operation::Gather::INDICES)};
371
372 const auto input_type = operandType(input_index);
373 if (input_type == DataType::QUANT_GGML_Q4_0 || input_type == DataType::QUANT_GGML_Q8_0)
374 OP_REQUIRES(isValidType(output_index, {DataType::FLOAT32}));
375 else
376 OP_REQUIRES(isSameType(output_index, input_index));
377
378 OP_REQUIRES(isValidType(indices_index, {DataType::INT32, DataType::INT64}));
379}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::Gather::INDICES, onert::ir::operation::Gather::INPUT, and OP_REQUIRES.

◆ visit() [19/38]

void onert::ir::OperationValidator::visit ( const operation::HashtableLookup node)
override

Definition at line 381 of file OperationValidator.cc.

382{
383 const auto hits_index{node.getOutputs().at(operation::HashtableLookup::Output::HITS)};
384 const auto lookups_index{node.getInputs().at(operation::HashtableLookup::Input::LOOKUPS)};
385 const auto keys_index{node.getInputs().at(operation::HashtableLookup::Input::KEYS)};
386
387 OP_REQUIRES(isValidType(lookups_index, DataType::INT32));
388 OP_REQUIRES(isValidType(keys_index, DataType::INT32));
389 OP_REQUIRES(isValidType(hits_index, DataType::QUANT_UINT8_ASYMM));
390}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::HashtableLookup::HITS, onert::ir::operation::HashtableLookup::KEYS, onert::ir::operation::HashtableLookup::LOOKUPS, and OP_REQUIRES.

◆ visit() [20/38]

void onert::ir::OperationValidator::visit ( const operation::Pack node)
override

Definition at line 392 of file OperationValidator.cc.

393{
394 const auto num{node.param().num};
395
396 OP_REQUIRES(num == static_cast<int32_t>(node.getInputs().size()));
397}

References onert::ir::Operation::getInputs(), onert::ir::operation::Pack::Param::num, OP_REQUIRES, onert::ir::operation::Pack::param(), and onert::ir::OperandIndexSequence::size().

◆ visit() [21/38]

void onert::ir::OperationValidator::visit ( const operation::Pad node)
override

Definition at line 399 of file OperationValidator.cc.

400{
401 const auto output_index{node.getOutputs().at(0)};
402 const auto input_index{node.getInputs().at(operation::Pad::Input::INPUT)};
403 const auto pad_index{node.getInputs().at(operation::Pad::Input::PAD)};
404 bool isQuantType =
405 isValidType(output_index, {DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM});
406 bool isPadV2 = node.getInputs().size() == 3 ? true : false;
407
408 OP_REQUIRES(isValidType(pad_index, DataType::INT32));
409 OP_REQUIRES(isSameType(input_index, output_index));
410
411 if (isQuantType)
412 OP_REQUIRES(isSameQuantParam(input_index, output_index));
413
414 if (isPadV2)
415 {
416 const auto value_index{node.getInputs().at(operation::Pad::Input::VALUE)};
417 const bool cond_same = isSameType(input_index, value_index);
418 const bool cond_same_quant = (!isQuantType || isSameQuantParam(input_index, value_index));
419 const auto input_t = operandType(input_index);
420 const auto value_t = operandType(value_index);
421 // NNAPI accepts this case. scale and zeroPoint are assumed to be the same as in input0.
422 const bool cond_quant8 =
423 ((input_t == DataType::QUANT_UINT8_ASYMM || input_t == DataType::QUANT_INT8_ASYMM) &&
424 value_t == DataType::INT32);
425 OP_REQUIRES((cond_same && cond_same_quant) || cond_quant8);
426 }
427}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::Pad::INPUT, OP_REQUIRES, onert::ir::operation::Pad::PAD, onert::ir::OperandIndexSequence::size(), and onert::ir::operation::Pad::VALUE.

◆ visit() [22/38]

void onert::ir::OperationValidator::visit ( const operation::Rank node)
override

Definition at line 429 of file OperationValidator.cc.

430{
431 const auto output_index{node.getOutputs().at(0)};
432
433 OP_REQUIRES(isValidType(output_index, DataType::INT32));
434}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getOutputs(), and OP_REQUIRES.

◆ visit() [23/38]

void onert::ir::OperationValidator::visit ( const operation::ResizeBilinear node)
override

Definition at line 436 of file OperationValidator.cc.

437{
438 auto align_corners = node.param().align_corners;
439 auto half_pixel_centers = node.param().half_pixel_centers;
440
441 OP_REQUIRES(!align_corners || !half_pixel_centers);
442}

References onert::ir::operation::ResizeBilinear::Param::align_corners, onert::ir::operation::ResizeBilinear::Param::half_pixel_centers, OP_REQUIRES, and onert::ir::operation::ResizeBilinear::param().

◆ visit() [24/38]

void onert::ir::OperationValidator::visit ( const operation::Reverse node)
override

Definition at line 444 of file OperationValidator.cc.

445{
446 const auto output_index{node.getOutputs().at(0)};
447 const auto input_index{node.getInputs().at(operation::Reverse::Input::INPUT)};
448 const auto axis_index{node.getInputs().at(operation::Reverse::Input::AXIS)};
449
450 OP_REQUIRES(isValidType(axis_index, DataType::INT32));
451 OP_REQUIRES(isSameType(output_index, input_index));
452}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::Reverse::AXIS, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::Reverse::INPUT, and OP_REQUIRES.

◆ visit() [25/38]

void onert::ir::OperationValidator::visit ( const operation::RoPE node)
override

Definition at line 454 of file OperationValidator.cc.

455{
456 const auto input_index{node.getInputs().at(operation::RoPE::Input::INPUT)};
457 const auto sin_index{node.getInputs().at(operation::RoPE::Input::SIN_TABLE)};
458 const auto cos_index{node.getInputs().at(operation::RoPE::Input::COS_TABLE)};
459 const auto output_index{node.getOutputs().at(operation::RoPE::Output::OUTPUT)};
460
461 OP_REQUIRES(isValidType(input_index, DataType::FLOAT32));
462 OP_REQUIRES(isValidType(sin_index, DataType::FLOAT32));
463 OP_REQUIRES(isValidType(cos_index, DataType::FLOAT32));
464 OP_REQUIRES(isSameType(input_index, output_index));
465}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::RoPE::COS_TABLE, onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::RoPE::INPUT, OP_REQUIRES, onert::ir::operation::RoPE::OUTPUT, and onert::ir::operation::RoPE::SIN_TABLE.

◆ visit() [26/38]

void onert::ir::OperationValidator::visit ( const operation::Select node)
override

Definition at line 467 of file OperationValidator.cc.

468{
469 const auto condition_index{node.getInputs().at(operation::Select::Input::CONDITION)};
470 const auto input_true_index{node.getInputs().at(operation::Select::Input::INPUT_TRUE)};
471 const auto input_false_index{node.getInputs().at(operation::Select::Input::INPUT_FALSE)};
472
473 OP_REQUIRES(isValidType(condition_index, DataType::BOOL8));
474 OP_REQUIRES(isSameType(input_true_index, input_false_index));
475}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::Select::CONDITION, onert::ir::Operation::getInputs(), onert::ir::operation::Select::INPUT_FALSE, onert::ir::operation::Select::INPUT_TRUE, and OP_REQUIRES.

◆ visit() [27/38]

void onert::ir::OperationValidator::visit ( const operation::Shape node)
override

Definition at line 477 of file OperationValidator.cc.

478{
479 const auto output_index{node.getOutputs().at(0)};
480
481 OP_REQUIRES(isValidType(output_index, {DataType::UINT32, DataType::INT32, DataType::INT64}));
482}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getOutputs(), and OP_REQUIRES.

◆ visit() [28/38]

void onert::ir::OperationValidator::visit ( const operation::Slice node)
override

Definition at line 484 of file OperationValidator.cc.

485{
486 const auto begins_index{node.getInputs().at(operation::Slice::BEGINS)};
487 const auto sizes_index{node.getInputs().at(operation::Slice::SIZES)};
488
489 OP_REQUIRES(isValidType(begins_index, {DataType::INT32, DataType::INT64}));
490 OP_REQUIRES(isSameType(begins_index, sizes_index));
491}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::Slice::BEGINS, onert::ir::Operation::getInputs(), OP_REQUIRES, and onert::ir::operation::Slice::SIZES.

◆ visit() [29/38]

void onert::ir::OperationValidator::visit ( const operation::Softmax node)
override

Definition at line 493 of file OperationValidator.cc.

494{
495 const auto output_index{node.getOutputs().at(0)};
496 const auto input_index{node.getInputs().at(operation::Softmax::INPUT)};
497
498 OP_REQUIRES(isSameType(input_index, output_index));
499 OP_REQUIRES(isValidType(
500 output_index, {DataType::FLOAT32, DataType::QUANT_UINT8_ASYMM, DataType::QUANT_INT8_ASYMM}));
501}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::Softmax::INPUT, and OP_REQUIRES.

◆ visit() [30/38]

void onert::ir::OperationValidator::visit ( const operation::SpaceToBatchND node)
override

Definition at line 503 of file OperationValidator.cc.

504{
505 const auto block_size_index{node.getInputs().at(operation::SpaceToBatchND::Input::BLOCK_SIZE)};
506 const auto paddings_index{node.getInputs().at(operation::SpaceToBatchND::Input::PADDINGS)};
507
508 // Non-constant block_size and padding is not implemented yet
509 OP_REQUIRES(isConstant(block_size_index));
510 OP_REQUIRES(isConstant(paddings_index));
511}

References onert::ir::OperandIndexSequence::at(), onert::ir::operation::SpaceToBatchND::BLOCK_SIZE, onert::ir::Operation::getInputs(), OP_REQUIRES, and onert::ir::operation::SpaceToBatchND::PADDINGS.

◆ visit() [31/38]

void onert::ir::OperationValidator::visit ( const operation::SpaceToDepth node)
override

Definition at line 513 of file OperationValidator.cc.

514{
515 const auto block_size = node.param().block_size;
516 OP_REQUIRES(block_size >= 1);
517}

References onert::ir::operation::SpaceToDepth::Param::block_size, OP_REQUIRES, and onert::ir::operation::SpaceToDepth::param().

◆ visit() [32/38]

void onert::ir::OperationValidator::visit ( const operation::Split node)
override

Definition at line 519 of file OperationValidator.cc.

520{
521 const auto num_splits = node.param().num_splits;
522
523 OP_REQUIRES(num_splits > 0 && num_splits <= 0xFFFF);
524 OP_REQUIRES(node.getOutputs().size() == static_cast<uint32_t>(num_splits));
525}

References onert::ir::Operation::getOutputs(), onert::ir::operation::Split::Param::num_splits, OP_REQUIRES, onert::ir::operation::Split::param(), and onert::ir::OperandIndexSequence::size().

◆ visit() [33/38]

void onert::ir::OperationValidator::visit ( const operation::SquaredDifference node)
override

Definition at line 527 of file OperationValidator.cc.

528{
529 const auto output_index{node.getOutputs().at(0)};
530 const auto lhs_index{node.getInputs().at(operation::SquaredDifference::Input::LHS)};
531 const auto rhs_index{node.getInputs().at(operation::SquaredDifference::Input::RHS)};
532
533 OP_REQUIRES(isSameType(output_index, lhs_index));
534 OP_REQUIRES(isSameType(lhs_index, rhs_index));
535}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::SquaredDifference::LHS, OP_REQUIRES, and onert::ir::operation::SquaredDifference::RHS.

◆ visit() [34/38]

void onert::ir::OperationValidator::visit ( const operation::StatelessRandomUniform node)
override

Definition at line 537 of file OperationValidator.cc.

538{
539 const auto output_index{node.getOutputs().at(0)};
540 const auto shape_index{node.getInputs().at(operation::StatelessRandomUniform::Input::SHAPE)};
541 const auto seed_index{node.getInputs().at(operation::StatelessRandomUniform::Input::SEED)};
542
543 OP_REQUIRES(isValidType(output_index, DataType::FLOAT32));
544 OP_REQUIRES(isValidType(shape_index, DataType::INT32));
545 OP_REQUIRES(isValidType(seed_index, DataType::INT32));
546}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), OP_REQUIRES, onert::ir::operation::StatelessRandomUniform::SEED, and onert::ir::operation::StatelessRandomUniform::SHAPE.

◆ visit() [35/38]

void onert::ir::OperationValidator::visit ( const operation::StridedSlice node)
override

Definition at line 548 of file OperationValidator.cc.

549{
550 const auto output_index{node.getOutputs().at(0)};
551 const auto input_index{node.getInputs().at(operation::StridedSlice::Input::INPUT)};
552
553 OP_REQUIRES(isSameType(output_index, input_index));
554}

References onert::ir::OperandIndexSequence::at(), onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::operation::StridedSlice::INPUT, and OP_REQUIRES.

◆ visit() [36/38]

void onert::ir::OperationValidator::visit ( const operation::TransposeConv node)
override

◆ visit() [37/38]

void onert::ir::OperationValidator::visit ( const operation::Unpack node)
override

Definition at line 562 of file OperationValidator.cc.

563{
564 const auto num{node.param().num};
565 OP_REQUIRES(num == static_cast<int32_t>(node.getOutputs().size()));
566}

References onert::ir::Operation::getOutputs(), onert::ir::operation::Unpack::Param::num, OP_REQUIRES, onert::ir::operation::Unpack::param(), and onert::ir::OperandIndexSequence::size().

◆ visit() [38/38]

void onert::ir::OperationValidator::visit ( const operation::While node)
override

Definition at line 568 of file OperationValidator.cc.

569{
570 OP_REQUIRES(node.getInputs().size() == node.getOutputs().size());
571}

References onert::ir::Operation::getInputs(), onert::ir::Operation::getOutputs(), OP_REQUIRES, and onert::ir::OperandIndexSequence::size().


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