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

#include <Verifier.h>

Collaboration diagram for onert::ir::verifier::EdgeChecker:

Public Member Functions

bool verify (const Graph &graph) const noexcept override
 
bool verify (const train::UseDefChains &training_defuses) const noexcept
 
- Public Member Functions inherited from onert::ir::verifier::IVerifier
virtual ~IVerifier ()=default
 

Detailed Description

Definition at line 61 of file Verifier.h.

Member Function Documentation

◆ verify() [1/2]

bool onert::ir::verifier::EdgeChecker::verify ( const Graph graph) const
overridevirtualnoexcept

Implements onert::ir::verifier::IVerifier.

Definition at line 172 of file Verifier.cc.

173{
174 auto &operations = graph.operations();
175 uint32_t errors = 0;
176 operations.iterate([&](const OperationIndex &index, const IOperation &node) {
177 for (auto &&operand_index : node.getInputs() | ir::Remove::UNDEFINED)
178 {
179 try
180 {
181 auto &operand = graph.operands().at(operand_index);
182 bool operand_has_use = operand.getUses().contains(index);
183 if (!operand_has_use)
184 {
185 VERBOSE(EdgeChecker) << "[ERROR] EDGE MISMATCH : Missing USE edge - Operand "
186 << operand_index << " to Operation " << index << std::endl;
187 errors += 1;
188 }
189 }
190 catch (const std::out_of_range &e)
191 {
192 VERBOSE(EdgeChecker) << "[ERROR] OPEARAND NOT FOUND : Operation " << index
193 << " has Operand " << operand_index
194 << ", but the operand object is not present in the graph" << std::endl;
195 errors += 1;
196 }
197 }
198 for (auto &&operand_index : node.getOutputs() | ir::Remove::UNDEFINED)
199 {
200 try
201 {
202 auto &operand = graph.operands().at(operand_index);
203 if (operand.getDef() != index)
204 {
205 VERBOSE(EdgeChecker) << "[ERROR] EDGE MISMATCH : Missing DEF edge - Operand"
206 << operand_index << " to Operation " << index << std::endl;
207 errors += 1;
208 }
209 }
210 catch (const std::out_of_range &e)
211 {
212 VERBOSE(EdgeChecker) << "[ERROR] OPEARAND NOT FOUND : Operation " << index
213 << " has Operand " << operand_index
214 << ", but the operand object is not present in the graph" << std::endl;
215 errors += 1;
216 }
217 }
218 });
219
220 VERBOSE(EdgeChecker) << "Total Number of errors : " << errors << std::endl;
221
222 return errors == 0;
223}
#define VERBOSE(name, lv)
Definition Log.h:71
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References onert::ir::IOperation::getInputs(), onert::ir::IOperation::getOutputs(), onert::ir::UNDEFINED, and VERBOSE.

◆ verify() [2/2]

bool onert::ir::verifier::EdgeChecker::verify ( const train::UseDefChains training_defuses) const
noexcept

Definition at line 240 of file Verifier.cc.

241{
242 const auto operations = extractOperations(training_usedefs);
243 auto inputs_map = extractNodeInputs(training_usedefs);
244 auto outputs_map = extractNodeOutputs(training_usedefs);
245 uint32_t errors = 0;
246 for (const auto &index : operations)
247 {
248 const auto &node_inputs = inputs_map[index];
249 for (const auto &operand_index : node_inputs)
250 {
251 try
252 {
253 const auto &uses = training_usedefs.at(operand_index).getTrainingUses();
254 bool operand_has_use = (uses.find(index) != uses.end());
255 if (!operand_has_use)
256 {
257 VERBOSE(EdgeChecker) << "[ERROR] EDGE MISMATCH : Missing USE edge - Operand "
258 << operand_index << " to Operation " << index << std::endl;
259 errors += 1;
260 }
261 }
262 catch (const std::out_of_range &e)
263 {
264 VERBOSE(EdgeChecker) << "[ERROR] OPEARAND NOT FOUND : Operation " << index
265 << " has Operand " << operand_index
266 << ", but the operand object is not present in the graph" << std::endl;
267 errors += 1;
268 }
269 }
270
271 const auto &node_outputs = outputs_map[index];
272 for (const auto &operand_index : node_outputs)
273 {
274 try
275 {
276 const auto &defs = training_usedefs.at(operand_index).getTrainingDefs();
277 bool operand_has_def = (defs.find(index) != defs.end());
278 if (!operand_has_def)
279 {
280 VERBOSE(EdgeChecker) << "[ERROR] EDGE MISMATCH : Missing DEF edge - Operand"
281 << operand_index << " to Operation " << index << std::endl;
282 errors += 1;
283 }
284 }
285 catch (const std::out_of_range &e)
286 {
287 VERBOSE(EdgeChecker) << "[ERROR] OPEARAND NOT FOUND : Operation " << index
288 << " has Operand " << operand_index
289 << ", but the operand object is not present in the graph" << std::endl;
290 errors += 1;
291 }
292 }
293 }
294
295 VERBOSE(EdgeChecker) << "Total Number of errors : " << errors << std::endl;
296
297 return errors == 0;
298}

References VERBOSE.


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