| 655 | } |
| 656 | |
| 657 | void ClGemm::configure(const CLCompileContext &compile_context, |
| 658 | ITensorInfo *a, |
| 659 | ITensorInfo *b, |
| 660 | ITensorInfo *c, |
| 661 | ITensorInfo *output, |
| 662 | float alpha, |
| 663 | float beta, |
| 664 | const GEMMInfo &gemm_info) |
| 665 | { |
| 666 | ARM_COMPUTE_ERROR_ON_NULLPTR(a, b, output); |
| 667 | |
| 668 | // Perform validation step |
| 669 | ARM_COMPUTE_ERROR_THROW_ON(validate(a, b, c, output, alpha, beta, gemm_info)); |
| 670 | ARM_COMPUTE_LOG_PARAMS(a, b, c, output, alpha, beta, gemm_info); |
| 671 | |
| 672 | // Check if we need to reshape the matrix B only on the first run |
| 673 | _reshape_b_only_on_first_run = gemm_info.reshape_b_only_on_first_run(); |
| 674 | _is_prepared = gemm_info.retain_internal_weights(); |
| 675 | |
| 676 | bool reinterpret_input_as_3d = gemm_info.reinterpret_input_as_3d(); |
| 677 | const unsigned int m = reinterpret_input_as_3d ? (a->dimension(1) * a->dimension(2)) : a->dimension(1); |
| 678 | const unsigned int n = b->dimension(0); |
| 679 | const unsigned int k = a->dimension(0); |
| 680 | const unsigned int batch_size = reinterpret_input_as_3d ? a->dimension(3) : a->dimension(2); |
| 681 | |
| 682 | // Select GEMMType |
| 683 | _gemm_kernel_type = auto_select_gemm_kernel( |
| 684 | auto_heuristics::CommonQuery{CLScheduler::get().target(), a->data_type(), m, n, k, batch_size}, |
| 685 | _reshape_b_only_on_first_run, b->are_values_constant()); |
| 686 | |
| 687 | const bool fuse_add_c = (!(helpers::float_ops::is_zero(beta)) && c != nullptr); |
| 688 | |
| 689 | ITensorInfo *c_to_use = fuse_add_c ? c : nullptr; |
| 690 | |
| 691 | switch (_gemm_kernel_type) |
| 692 | { |
| 693 | case CLGEMMKernelType::NATIVE: |
| 694 | { |
| 695 | configure_native(compile_context, a, b, c_to_use, output, alpha, beta, gemm_info); |
| 696 | break; |
| 697 | } |
| 698 | case CLGEMMKernelType::RESHAPED: |
| 699 | { |
| 700 | configure_reshaped(compile_context, a, b, c_to_use, output, alpha, beta, gemm_info); |
| 701 | break; |
| 702 | } |
| 703 | case CLGEMMKernelType::RESHAPED_ONLY_RHS: |
| 704 | { |
| 705 | configure_reshaped_only_rhs(compile_context, a, b, c_to_use, output, alpha, beta, gemm_info); |
| 706 | break; |
| 707 | } |
| 708 | case CLGEMMKernelType::RESHAPED_ONLY_RHS_MMUL: |
| 709 | { |
| 710 | configure_reshaped_only_rhs_mmul(compile_context, a, b, c_to_use, output, alpha, beta, gemm_info); |
| 711 | break; |
| 712 | } |
| 713 | default: |
| 714 | { |
no test coverage detected