Test case for memory injection in @ref cpu::CpuGemmLowpMatrixMultiplyCore. * * Configure the operator once and inject memory at run-time in multiple executions. * * Checks performed in order: * - Both runs compute the same output */
| 209 | * - Both runs compute the same output |
| 210 | */ |
| 211 | TEST_CASE(MemoryInjection, framework::DatasetMode::ALL) |
| 212 | { |
| 213 | auto gemm = std::make_unique<cpu::CpuGemmLowpMatrixMultiplyCore>(); |
| 214 | auto a_info = TensorInfo(TensorShape(32U, 72U), 1, DataType::QASYMM8); |
| 215 | auto b_info = TensorInfo(TensorShape(17U, 32U), 1, DataType::QASYMM8); |
| 216 | auto dst_info = TensorInfo(TensorShape(17U, 72U), 1, DataType::S32); |
| 217 | a_info.set_quantization_info(QuantizationInfo(1.0f / 255, -9)); |
| 218 | b_info.set_quantization_info(QuantizationInfo(1.0f / 255, 1)); |
| 219 | const auto gemm_info = GEMMInfo{}; |
| 220 | gemm->configure(&a_info, &b_info, nullptr, &dst_info, gemm_info); |
| 221 | |
| 222 | // telhs are newly created every call of this lambda function |
| 223 | auto a = create_tensor<Tensor>(a_info); |
| 224 | auto b = create_tensor<Tensor>(b_info); |
| 225 | auto dst = create_tensor<Tensor>(dst_info); |
| 226 | a.allocator()->allocate(); |
| 227 | b.allocator()->allocate(); |
| 228 | dst.allocator()->allocate(); |
| 229 | |
| 230 | ITensorPack run_pack = {{TensorType::ACL_SRC_0, &a}, {TensorType::ACL_SRC_1, &b}, {TensorType::ACL_DST, &dst}}; |
| 231 | ITensorPack prep_pack = { |
| 232 | {TensorType::ACL_SRC_1, &b}, |
| 233 | }; |
| 234 | |
| 235 | auto mg = MemoryGroup{}; |
| 236 | auto ws = manage_workspace<Tensor>(gemm->workspace(), mg, run_pack, prep_pack); |
| 237 | |
| 238 | auto run_conv = [&]() -> Tensor |
| 239 | { |
| 240 | auto dst = create_tensor<Tensor>(dst_info); |
| 241 | dst.allocator()->allocate(); |
| 242 | run_pack.add_tensor(TensorType::ACL_DST, &dst); |
| 243 | |
| 244 | library->fill_tensor_value(Accessor(a), static_cast<uint8_t>(1)); |
| 245 | library->fill_tensor_value(Accessor(b), static_cast<uint8_t>(2)); |
| 246 | // This operator is configured once and captured by this lambda. |
| 247 | gemm->prepare(prep_pack); |
| 248 | gemm->run(run_pack); |
| 249 | return dst; |
| 250 | }; |
| 251 | auto result_0 = run_conv(); |
| 252 | auto result_1 = run_conv(); |
| 253 | for (size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 254 | { |
| 255 | ARM_COMPUTE_EXPECT(((uint8_t *)result_0.buffer())[i] == ((uint8_t *)result_1.buffer())[i], |
| 256 | framework::LogLevel::ERRORS); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /** Test case for memory injection in @ref NEGEMMLowpMatrixMultiplyCore. |
| 261 | * |
nothing calls this directly
no test coverage detected