1 // 2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #include <catch.hpp> 7 #include <map> 8 #include "Decoder.hpp" 9 10 11 TEST_CASE("Test KWS decoder") 12 { 13 // Actual output probability: [0.0, 0.06, 0.02, 0.03, 0.0, 0.0, 0.05, 0.0, 0.83, 0.0, 0.1, 0.0] 14 // int8 quantised Model output [1, 4, 2, 3, 1, 1, 3, 1, 43, 1, 6, 1] 15 // Reconstructed dequantised probability [0.0, 0.06, 0.02, 0.04, 0.0, 0.0, 0.04, 0.0, 0.84, 0.0, 0.1, 0.0] 16 17 int quantisationOffset = 1; 18 float quantisationScale = 0.02; 19 20 std::vector<int8_t> modelOutput = {1, 4, 2, 3, 1, 1, 3, 1, 43, 1, 6, 1}; 21 22 kws::Decoder decoder(quantisationOffset,quantisationScale); 23 24 std::pair<int,float> result = decoder.decodeOutput(modelOutput); 25 26 27 CHECK(result == std::pair<int,float>(8,0.84)); 28 } 29