| 384 | } |
| 385 | |
| 386 | void CLFFTConvolutionLayer::prepare() |
| 387 | { |
| 388 | if (!_is_prepared) |
| 389 | { |
| 390 | // Permute bias to NCHW |
| 391 | if (_original_bias != nullptr) |
| 392 | { |
| 393 | _permuted_bias.allocator()->allocate(); |
| 394 | _permute_bias_func.run(); |
| 395 | _original_bias->mark_as_unused(); |
| 396 | } |
| 397 | |
| 398 | const ICLTensor *cur_weights = _original_weights; |
| 399 | // Permute weights |
| 400 | if (_needs_permute) |
| 401 | { |
| 402 | ARM_COMPUTE_ERROR_ON(!cur_weights->is_used()); |
| 403 | |
| 404 | _permuted_weights.allocator()->allocate(); |
| 405 | _permute_weights_func.run(); |
| 406 | cur_weights->mark_as_unused(); |
| 407 | cur_weights = &_permuted_weights; |
| 408 | } |
| 409 | |
| 410 | // Flip weights |
| 411 | _flipped_weights.allocator()->allocate(); |
| 412 | _flip_weights_func.run(); |
| 413 | cur_weights->mark_as_unused(); |
| 414 | |
| 415 | // Pad weights |
| 416 | _padded_weights.allocator()->allocate(); |
| 417 | _pad_weights_func.run(); |
| 418 | _flipped_weights.mark_as_unused(); |
| 419 | CLScheduler::get().queue().finish(); |
| 420 | _flipped_weights.allocator()->free(); |
| 421 | |
| 422 | // Transform weights to frequency domain |
| 423 | _transformed_weights.allocator()->allocate(); |
| 424 | _transform_weights_func->run(); |
| 425 | _padded_weights.mark_as_unused(); |
| 426 | CLScheduler::get().queue().finish(); |
| 427 | // Delete object and release internal memory |
| 428 | _transform_weights_func.reset(); |
| 429 | _padded_weights.allocator()->free(); |
| 430 | |
| 431 | _is_prepared = true; |
| 432 | } |
| 433 | } |
| 434 | } // namespace arm_compute |