ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 48 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 168 of file Verifier.cc.

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

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

References VERBOSE.


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