| 632 | } |
| 633 | |
| 634 | void ClFullyConnected::prepare(ITensorPack &tensors) |
| 635 | { |
| 636 | // Note : Running prepare() each run when _use_matmul is true is unnecessary unless weights conversion is needed. |
| 637 | if (!_is_prepared || _dynamic_gemm) |
| 638 | { |
| 639 | #ifdef ARM_COMPUTE_ASSERTS_ENABLED |
| 640 | ++_asrt_prepare_count; |
| 641 | ARM_COMPUTE_ERROR_ON(!_dynamic_gemm && !_use_matmul && _asrt_prepare_count > 1); |
| 642 | #endif // ARM_COMPUTE_ASSERTS_ENABLED |
| 643 | |
| 644 | auto weights = tensors.get_const_tensor(ACL_SRC_1); |
| 645 | |
| 646 | CLAuxTensorHandler reshaped_weights(offset_int_vec(TransposedWeights), _reshaped_weights, tensors, false); |
| 647 | CLAuxTensorHandler converted_weights(offset_int_vec(ConvertedWeights), _converted_weights, tensors, false); |
| 648 | |
| 649 | // Pointer to current weights |
| 650 | const ITensor *cur_weights = weights; |
| 651 | |
| 652 | // Reshape weights if needed. Disabled when matmul kernels are enabled as matmul fuses transpose. |
| 653 | if (_transpose_weights && !_use_matmul) |
| 654 | { |
| 655 | // Run reshape weights kernel and mark weights as unused |
| 656 | ITensorPack transpose_pack{{ACL_SRC, weights}, {ACL_DST, reshaped_weights.get()}}; |
| 657 | _reshape_weights->run(transpose_pack); |
| 658 | |
| 659 | cur_weights->mark_as_unused(); |
| 660 | cur_weights = reshaped_weights.get(); |
| 661 | } |
| 662 | |
| 663 | // Convert weights if needed |
| 664 | if (_run_convert_weights) |
| 665 | { |
| 666 | ITensorPack convert_pack{{ACL_SRC, cur_weights}, {ACL_DST, converted_weights.get()}}; |
| 667 | _convert_weights->run(convert_pack); |
| 668 | |
| 669 | cur_weights->mark_as_unused(); |
| 670 | cur_weights = converted_weights.get(); |
| 671 | } |
| 672 | |
| 673 | ITensorPack gemm_pack = tensors; |
| 674 | gemm_pack.add_const_tensor(ACL_SRC_1, cur_weights); |
| 675 | |
| 676 | // Prepare GEMM prepare and release unused weights |
| 677 | if (_dynamic_gemm || !_use_matmul) |
| 678 | { |
| 679 | if (!_is_quantized) |
| 680 | { |
| 681 | _mm_gemm->prepare(gemm_pack); |
| 682 | } |
| 683 | else |
| 684 | { |
| 685 | _mm_gemmlowp->prepare(gemm_pack); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | _is_prepared = true; |
| 690 | } |
| 691 | } |
nothing calls this directly
no test coverage detected