| 107 | // *INDENT-ON* |
| 108 | |
| 109 | TEST_CASE(Float, framework::DatasetMode::ALL) |
| 110 | { |
| 111 | const unsigned int k = 5; |
| 112 | |
| 113 | Tensor predictions = create_tensor<Tensor>(TensorShape(10, 20), DataType::F32); |
| 114 | Tensor targets = create_tensor<Tensor>(TensorShape(20), DataType::U32); |
| 115 | |
| 116 | predictions.allocator()->allocate(); |
| 117 | targets.allocator()->allocate(); |
| 118 | |
| 119 | // Fill the tensors with random pre-generated values |
| 120 | fill_tensor(Accessor(predictions), |
| 121 | std::vector<float>{ |
| 122 | 0.8147, 0.6557, 0.4387, 0.7513, 0.3517, 0.1622, 0.1067, 0.8530, 0.7803, 0.5470, 0.9058, 0.0357, |
| 123 | 0.3816, 0.2551, 0.8308, 0.7943, 0.9619, 0.6221, 0.3897, 0.2963, 0.1270, 0.8491, 0.7655, 0.5060, |
| 124 | 0.5853, 0.3112, 0.0046, 0.3510, 0.2417, 0.7447, 0.9134, 0.9340, 0.7952, 0.6991, 0.5497, 0.5285, |
| 125 | 0.7749, 0.5132, 0.4039, 0.1890, 0.6324, 0.6787, 0.1869, 0.8909, 0.9172, 0.1656, 0.8173, 0.4018, |
| 126 | 0.0965, 0.6868, 0.0975, 0.7577, 0.4898, 0.9593, 0.2858, 0.6020, 0.8687, 0.0760, 0.1320, 0.1835, |
| 127 | 0.2785, 0.7431, 0.4456, 0.5472, 0.7572, 0.2630, 0.0844, 0.2399, 0.9421, 0.3685, 0.5469, 0.3922, |
| 128 | 0.6463, 0.1386, 0.7537, 0.6541, 0.3998, 0.1233, 0.9561, 0.6256, 0.9575, 0.6555, 0.7094, 0.1493, |
| 129 | 0.3804, 0.6892, 0.2599, 0.1839, 0.5752, 0.7802, 0.9649, 0.1712, 0.7547, 0.2575, 0.5678, 0.7482, |
| 130 | 0.8001, 0.2400, 0.0598, 0.0811, 0.1576, 0.7060, 0.2760, 0.8407, 0.0759, 0.4505, 0.4314, 0.4173, |
| 131 | 0.2348, 0.9294, 0.9706, 0.0318, 0.6797, 0.2543, 0.0540, 0.0838, 0.9106, 0.0497, 0.3532, 0.7757, |
| 132 | 0.9572, 0.2769, 0.6551, 0.8143, 0.5308, 0.2290, 0.1818, 0.9027, 0.8212, 0.4868, 0.4854, 0.0462, |
| 133 | 0.1626, 0.2435, 0.7792, 0.9133, 0.2638, 0.9448, 0.0154, 0.4359, 0.8003, 0.0971, 0.1190, 0.9293, |
| 134 | 0.9340, 0.1524, 0.1455, 0.4909, 0.0430, 0.4468, 0.1419, 0.8235, 0.4984, 0.3500, 0.1299, 0.8258, |
| 135 | 0.1361, 0.4893, 0.1690, 0.3063, 0.4218, 0.6948, 0.9597, 0.1966, 0.5688, 0.5383, 0.8693, 0.3377, |
| 136 | 0.6491, 0.5085, 0.9157, 0.3171, 0.3404, 0.2511, 0.4694, 0.9961, 0.5797, 0.9001, 0.7317, 0.5108, |
| 137 | 0.7922, 0.9502, 0.5853, 0.6160, 0.0119, 0.0782, 0.5499, 0.3692, 0.6477, 0.8176, 0.9595, 0.0344, |
| 138 | 0.2238, 0.4733, 0.3371, 0.4427, 0.1450, 0.1112, 0.4509, 0.7948}); |
| 139 | |
| 140 | fill_tensor(Accessor(targets), std::vector<int>{1, 5, 7, 2, 8, 1, 2, 1, 2, 4, 3, 9, 4, 1, 9, 9, 4, 1, 2, 4}); |
| 141 | |
| 142 | // Determine the output through the CPP kernel |
| 143 | Tensor output; |
| 144 | CPPTopKV topkv; |
| 145 | topkv.configure(&predictions, &targets, &output, k); |
| 146 | |
| 147 | output.allocator()->allocate(); |
| 148 | |
| 149 | // Run the kernel |
| 150 | topkv.run(); |
| 151 | |
| 152 | // Validate against the expected values |
| 153 | SimpleTensor<uint8_t> expected_output(TensorShape(20), DataType::U8); |
| 154 | fill_tensor(expected_output, std::vector<uint8_t>{1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0}); |
| 155 | validate(Accessor(output), expected_output); |
| 156 | } |
| 157 | |
| 158 | TEST_CASE(QASYMM8, framework::DatasetMode::ALL) |
| 159 | { |
nothing calls this directly
no test coverage detected