| 784 | } |
| 785 | |
| 786 | void ClGemm::run(ITensorPack &tensors) |
| 787 | { |
| 788 | const ITensor *lhs = tensors.get_const_tensor(ACL_SRC_0); |
| 789 | const ITensor *rhs = tensors.get_const_tensor(ACL_SRC_1); |
| 790 | ITensor *dst = tensors.get_tensor(ACL_DST); |
| 791 | |
| 792 | ARM_COMPUTE_ERROR_ON_NULLPTR(lhs, dst); |
| 793 | |
| 794 | CLAuxTensorHandler lhs_reshaped(offset_int_vec(LhsReshape), _tmp_a, tensors, true); |
| 795 | CLAuxTensorHandler rhs_reshaped(offset_int_vec(RhsReshape), _tmp_b, tensors, true); |
| 796 | |
| 797 | // Prepare the consts if needed |
| 798 | prepare(tensors); |
| 799 | |
| 800 | // Run matrix multiply kernel |
| 801 | switch (_gemm_kernel_type) |
| 802 | { |
| 803 | case CLGEMMKernelType::NATIVE: |
| 804 | { |
| 805 | CLScheduler::get().enqueue_op(*_mm_native_kernel, tensors, true); |
| 806 | break; |
| 807 | } |
| 808 | case CLGEMMKernelType::RESHAPED: |
| 809 | { |
| 810 | // Run interleave kernel |
| 811 | ITensorPack reshape_lhs_pack{{ACL_SRC, lhs}, {ACL_DST, lhs_reshaped.get()}}; |
| 812 | CLScheduler::get().enqueue_op(*_reshape_lhs_kernel, reshape_lhs_pack, false); |
| 813 | |
| 814 | if (!_reshape_b_only_on_first_run) |
| 815 | { |
| 816 | // Run transpose kernel |
| 817 | ITensorPack reshape_rhs_pack{{ACL_SRC, rhs}, {ACL_DST, rhs_reshaped.get()}}; |
| 818 | CLScheduler::get().enqueue_op(*_reshape_rhs_kernel, reshape_rhs_pack, false); |
| 819 | } |
| 820 | // Copy original tensor pack and overwrite lhs and rhs with reshaped counterparts |
| 821 | ITensorPack gemm_reshaped_pack(tensors); |
| 822 | gemm_reshaped_pack.add_const_tensor(ACL_SRC_0, lhs_reshaped.get()); |
| 823 | gemm_reshaped_pack.add_const_tensor(ACL_SRC_1, rhs_reshaped.get()); |
| 824 | |
| 825 | if (_gemm_kernel_type == CLGEMMKernelType::RESHAPED) |
| 826 | { |
| 827 | CLScheduler::get().enqueue_op(*_mm_reshaped_kernel, gemm_reshaped_pack, true); |
| 828 | } |
| 829 | break; |
| 830 | } |
| 831 | case CLGEMMKernelType::RESHAPED_ONLY_RHS: |
| 832 | { |
| 833 | if (!_reshape_b_only_on_first_run) |
| 834 | { |
| 835 | // Run transpose kernel |
| 836 | ITensorPack reshape_rhs_pack{{ACL_SRC, rhs}, {ACL_DST, rhs_reshaped.get()}}; |
| 837 | CLScheduler::get().enqueue_op(*_reshape_rhs_kernel, reshape_rhs_pack, false); |
| 838 | } |
| 839 | // In case of RESHAPED_ONLY_RHS, we need to check the padding requirement |
| 840 | // Check if the lhs or dst tensors have padding |
| 841 | const unsigned int cross_plane_pad_lhs = lhs->info()->padding().top + lhs->info()->padding().bottom; |
| 842 | const unsigned int cross_plane_pad_dst = dst->info()->padding().top + dst->info()->padding().bottom; |
| 843 | bool has_pad_y = (cross_plane_pad_lhs != 0) || (cross_plane_pad_dst != 0); |
nothing calls this directly
no test coverage detected