2 * Copyright (c) 2023 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 "MinMaxComputer.h"
19 #include <luci/IR/CircleNodes.h>
21 #include <unordered_map>
23 #include <gtest/gtest.h>
25 using namespace record_minmax;
27 TEST(MinMaxComputerTest, percentile)
29 auto computer = make_percentile_computer(0.0, 100.0);
34 minmax.min_vector = {1.0, 2.0, 3.0};
35 minmax.max_vector = {4.0, 5.0, 6.0};
37 std::unordered_map<const luci::CircleNode *, MinMaxVectors> min_max_map;
38 min_max_map.insert({&node, minmax});
40 computer->update_qparam(&min_max_map);
42 EXPECT_TRUE(node.quantparam() != nullptr);
45 TEST(MinMaxComputerTest, percentile_nullptr_NEG)
47 auto computer = make_percentile_computer(0.0, 100.0);
49 EXPECT_ANY_THROW(computer->update_qparam(nullptr));
52 TEST(MinMaxComputerTest, moving_avg)
54 auto computer = make_moving_avg_computer(1, 0.99);
59 minmax.min_vector = {1.0, 2.0, 3.0};
60 minmax.max_vector = {4.0, 5.0, 6.0};
62 std::unordered_map<const luci::CircleNode *, MinMaxVectors> min_max_map;
63 min_max_map.insert({&node, minmax});
65 computer->update_qparam(&min_max_map);
67 EXPECT_TRUE(node.quantparam() != nullptr);
70 TEST(MinMaxComputerTest, moving_avg_nullptr_NEG)
72 auto computer = make_moving_avg_computer(1, 0.99);
74 EXPECT_ANY_THROW(computer->update_qparam(nullptr));