Test case for memory injection in @ref cpu::CpuWinogradConv2d. * * Configure the operator once and inject memory at run-time in multiple executions. * * Checks performed in order: * - Both runs compute the same output */
| 341 | * - Both runs compute the same output |
| 342 | */ |
| 343 | TEST_CASE(MemoryInjection, framework::DatasetMode::ALL) |
| 344 | { |
| 345 | auto winograd = std::make_unique<cpu::CpuWinogradConv2d>(); |
| 346 | const auto src_info = TensorInfo(TensorShape(8U, 8U, 32U), 1, DataType::F32); |
| 347 | const auto w_info = TensorInfo(TensorShape(1U), 1, DataType::F32); |
| 348 | const auto b_info = TensorInfo(TensorShape(1U, 3U, 32U, 1U), 1, DataType::F32); |
| 349 | auto dst_info = TensorInfo(TensorShape(8U, 6U, 1U), 1, DataType::F32); |
| 350 | const PadStrideInfo pad_info{}; |
| 351 | |
| 352 | winograd->configure(&src_info, &b_info, &w_info, &dst_info, pad_info); |
| 353 | |
| 354 | // telhs are newly created every call of this lambda function |
| 355 | auto a = create_tensor<Tensor>(src_info); |
| 356 | auto b = create_tensor<Tensor>(b_info); |
| 357 | auto c = create_tensor<Tensor>(w_info); |
| 358 | a.allocator()->allocate(); |
| 359 | b.allocator()->allocate(); |
| 360 | c.allocator()->allocate(); |
| 361 | |
| 362 | ITensorPack run_pack{{TensorType::ACL_SRC_0, &a}, {TensorType::ACL_SRC_1, &b}, {TensorType::ACL_SRC_2, &c}}; |
| 363 | ITensorPack prep_pack{{TensorType::ACL_SRC_1, &b}, {TensorType::ACL_SRC_2, &c}}; |
| 364 | |
| 365 | auto mg = MemoryGroup{}; |
| 366 | auto ws = manage_workspace<Tensor>(winograd->workspace(), mg, run_pack, prep_pack); |
| 367 | auto run_conv = [&]() -> Tensor |
| 368 | { |
| 369 | auto dst = create_tensor<Tensor>(dst_info); |
| 370 | dst.allocator()->allocate(); |
| 371 | |
| 372 | run_pack.add_tensor(TensorType::ACL_DST, &dst); |
| 373 | library->fill_tensor_value(Accessor(a), 1.f); |
| 374 | library->fill_tensor_value(Accessor(b), 2.f); |
| 375 | library->fill_tensor_value(Accessor(c), 3.f); |
| 376 | |
| 377 | // This operator is configured once and captured by this lambda. |
| 378 | winograd->prepare(prep_pack); |
| 379 | winograd->run(run_pack); |
| 380 | return dst; |
| 381 | }; |
| 382 | |
| 383 | auto result_0 = run_conv(); |
| 384 | auto result_1 = run_conv(); |
| 385 | |
| 386 | for (size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 387 | { |
| 388 | ARM_COMPUTE_EXPECT(reinterpret_cast<float *>(result_0.buffer())[i] == |
| 389 | reinterpret_cast<float *>(result_1.buffer())[i], |
| 390 | framework::LogLevel::ERRORS); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /** Test case for memory injection in @ref NEWinogradConvolutionLayer. |
| 395 | * |
nothing calls this directly
no test coverage detected