2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "misc/tensor/Comparator.h"
18 #include "misc/tensor/Zipper.h"
20 #include "misc/fp32.h"
29 std::vector<Diff<float>> Comparator::compare(const Shape &shape, const Reader<float> &expected,
30 const Reader<float> &obtained,
31 Observer *observer) const
33 std::vector<Diff<float>> res;
35 zip(shape, expected, obtained) <<
36 [&](const Index &index, float expected_value, float obtained_value) {
37 if (!_compare_fn(expected_value, obtained_value))
39 res.emplace_back(index, expected_value, obtained_value);
42 // Update max_diff_index, if necessary
43 if (observer != nullptr)
45 observer->notify(index, expected_value, obtained_value);