#include "misc/tensor/Comparator.h" #include "misc/tensor/Zipper.h" #include "misc/fp32.h" namespace nnfw { namespace misc { namespace tensor { std::vector> Comparator::compare(const Shape &shape, const Reader &expected, const Reader &obtained, Observer *observer) const { std::vector> res; zip(shape, expected, obtained) << [&](const Index &index, float expected_value, float obtained_value) { if (!_compare_fn(expected_value, obtained_value)) { res.emplace_back(index, expected_value, obtained_value); } // Update max_diff_index, if necessary if (observer != nullptr) { observer->notify(index, expected_value, obtained_value); } }; return res; } } // namespace tensor } // namespace misc } // namespace nnfw