30 #include "tests/datasets/ShapeDatasets.h" 35 #include "tests/validation/fixtures/PermuteFixture.h" 45 template <
typename U,
typename T>
46 inline void fill_tensor(U &&tensor,
const std::vector<T> &v)
48 std::memcpy(tensor.data(), v.data(),
sizeof(T) * v.size());
78 const Status status =
CPPTopKV::validate(&prediction_info.clone()->set_is_resizable(
false),&targets_info.clone()->set_is_resizable(
false), &output_info.clone()->set_is_resizable(
false), k);
86 const unsigned int k = 5;
92 targets.allocator()->allocate();
97 0.8147, 0.6557, 0.4387, 0.7513, 0.3517, 0.1622, 0.1067, 0.8530, 0.7803, 0.5470,
98 0.9058, 0.0357, 0.3816, 0.2551, 0.8308, 0.7943, 0.9619, 0.6221, 0.3897, 0.2963,
99 0.1270, 0.8491, 0.7655, 0.5060, 0.5853, 0.3112, 0.0046, 0.3510, 0.2417, 0.7447,
100 0.9134, 0.9340, 0.7952, 0.6991, 0.5497, 0.5285, 0.7749, 0.5132, 0.4039, 0.1890,
101 0.6324, 0.6787, 0.1869, 0.8909, 0.9172, 0.1656, 0.8173, 0.4018, 0.0965, 0.6868,
102 0.0975, 0.7577, 0.4898, 0.9593, 0.2858, 0.6020, 0.8687, 0.0760, 0.1320, 0.1835,
103 0.2785, 0.7431, 0.4456, 0.5472, 0.7572, 0.2630, 0.0844, 0.2399, 0.9421, 0.3685,
104 0.5469, 0.3922, 0.6463, 0.1386, 0.7537, 0.6541, 0.3998, 0.1233, 0.9561, 0.6256,
105 0.9575, 0.6555, 0.7094, 0.1493, 0.3804, 0.6892, 0.2599, 0.1839, 0.5752, 0.7802,
106 0.9649, 0.1712, 0.7547, 0.2575, 0.5678, 0.7482, 0.8001, 0.2400, 0.0598, 0.0811,
107 0.1576, 0.7060, 0.2760, 0.8407, 0.0759, 0.4505, 0.4314, 0.4173, 0.2348, 0.9294,
108 0.9706, 0.0318, 0.6797, 0.2543, 0.0540, 0.0838, 0.9106, 0.0497, 0.3532, 0.7757,
109 0.9572, 0.2769, 0.6551, 0.8143, 0.5308, 0.2290, 0.1818, 0.9027, 0.8212, 0.4868,
110 0.4854, 0.0462, 0.1626, 0.2435, 0.7792, 0.9133, 0.2638, 0.9448, 0.0154, 0.4359,
111 0.8003, 0.0971, 0.1190, 0.9293, 0.9340, 0.1524, 0.1455, 0.4909, 0.0430, 0.4468,
112 0.1419, 0.8235, 0.4984, 0.3500, 0.1299, 0.8258, 0.1361, 0.4893, 0.1690, 0.3063,
113 0.4218, 0.6948, 0.9597, 0.1966, 0.5688, 0.5383, 0.8693, 0.3377, 0.6491, 0.5085,
114 0.9157, 0.3171, 0.3404, 0.2511, 0.4694, 0.9961, 0.5797, 0.9001, 0.7317, 0.5108,
115 0.7922, 0.9502, 0.5853, 0.6160, 0.0119, 0.0782, 0.5499, 0.3692, 0.6477, 0.8176,
116 0.9595, 0.0344, 0.2238, 0.4733, 0.3371, 0.4427, 0.1450, 0.1112, 0.4509, 0.7948
119 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 });
124 topkv.
configure(&predictions, &targets, &output, k);
126 output.allocator()->allocate();
133 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 });
139 const unsigned int k = 5;
145 targets.allocator()->allocate();
150 133, 235, 69, 118, 140, 179, 189, 203, 137, 157,
151 242, 1, 196, 170, 166, 25, 102, 244, 24, 254,
152 164, 119, 49, 198, 140, 135, 175, 84, 29, 136,
153 246, 109, 74, 90, 185, 136, 181, 172, 35, 123,
154 62, 118, 24, 170, 134, 221, 114, 113, 174, 206,
155 174, 198, 148, 107, 255, 125, 6, 214, 127, 59,
156 75, 83, 175, 216, 56, 101, 85, 197, 49, 128,
157 172, 201, 140, 214, 28, 172, 109, 43, 127, 231,
158 178, 121, 109, 66, 29, 190, 70, 221, 38, 148,
159 18, 10, 165, 158, 17, 134, 51, 254, 15, 217,
160 66, 46, 166, 150, 104, 90, 211, 132, 218, 190,
161 58, 185, 174, 139, 115, 39, 111, 227, 144, 151,
162 171, 122, 163, 223, 94, 151, 228, 151, 238, 64,
163 217, 40, 242, 68, 196, 68, 101, 40, 179, 171,
164 89, 88, 54, 82, 161, 12, 197, 52, 150, 22,
165 200, 156, 182, 31, 198, 194, 102, 105, 209, 161,
166 173, 50, 61, 241, 239, 63, 207, 192, 226, 170,
167 2, 190, 31, 166, 250, 114, 194, 212, 254, 187,
168 155, 63, 156, 123, 50, 177, 97, 203, 1, 229,
169 100, 235, 116, 164, 36, 92, 56, 82, 222, 252
172 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 });
177 topkv.
configure(&predictions, &targets, &output, k);
179 output.allocator()->allocate();
186 fill_tensor(expected_output, std::vector<uint8_t> { 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0 });
192 const unsigned int k = 5;
198 targets.allocator()->allocate();
203 123, -34, 69, 118, 20, -45, 99, -98, 127, 117,
204 -99, 1, -128, 90, 60, 25, 102, 76, 24, -110,
205 99, 119, 49, 43, -40, 60, 43, 84, 29, 67,
206 33, 109, 74, 90, 90, 44, 98, 90, 35, 123,
207 62, 118, 24, -32, 34, 21, 114, 113, 124, 20,
208 74, 98, 48, 107, 127, 125, 6, -98, 127, 59,
209 75, 83, 75, -118, 56, 101, 85, 97, 49, 127,
210 72, -20, 40, 14, 28, -30, 109, 43, 127, -31,
211 78, 121, 109, 66, 29, 90, 70, 21, 38, 48,
212 18, 10, 115, 124, 17, 123, 51, 54, 15, 17,
213 66, 46, -66, 125, 104, 90, 123, 113, -54, -126,
214 58, -85, 74, 39, 115, 39, 111, -27, 44, 51,
215 71, 122, -34, -123, 94, 113, 125, 111, 38, 64,
216 -17, 40, 42, 68, 96, 68, 101, 40, 79, 71,
217 89, 88, 54, 82, 127, 12, 112, 52, 125, 22,
218 -128, 56, 82, 31, 98, 94, 102, 105, 127, 123,
219 112, 50, 61, 41, 39, 63, -77, 92, 26, 70,
220 2, 90, 31, 99, -34, 114, 112, 126, 127, 87,
221 125, 63, 56, 123, 50, -77, 97, -93, 1, 29,
222 100, -35, 116, 64, 36, 92, 56, 82, -22, -118
225 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 });
230 topkv.
configure(&predictions, &targets, &output, k);
232 output.allocator()->allocate();
239 fill_tensor(expected_output, std::vector<int8_t> { 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0 });
1 channel, 1 U8 per channel
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
SimpleTensor< uint8_t > expected_output(output_shape, DataType::QASYMM8, 1, qasymm)
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Quantization information.
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
Accessor implementation for Tensor objects.
DatasetMode
Possible dataset modes.
fill_tensor(input_to_input_weights, std::vector< uint8_t >{ 122, 130, 124, 134, 120, 122, 134, 134 })
1 channel, 1 U32 per channel
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
void configure(const ITensor *predictions, const ITensor *targets, ITensor *output, const unsigned int k)
Set the input and output of the kernel.
quantized, asymmetric fixed-point 8-bit number unsigned
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
Basic implementation of the tensor interface.
TEST_SUITE(U8_to_S8) FIXTURE_DATA_TEST_CASE(RunSmall
validate(CLAccessor(output_state), expected_output)
Store the tensor's metadata.
void run() override final
Run the kernels contained in the function.
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
quantized, asymmetric fixed-point 8-bit number signed
Basic function to run CPPTopKVKernel.
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
static Status validate(const ITensorInfo *predictions, const ITensorInfo *targets, ITensorInfo *output, const unsigned int k)
Static function to check if given info will lead to a valid configuration of CPPTopKVKernel.