| 157 | return Status{}; |
| 158 | } |
| 159 | void ClMatMulNativeKernel::configure(const ClCompileContext &compile_context, |
| 160 | ITensorInfo *lhs, |
| 161 | ITensorInfo *rhs, |
| 162 | ITensorInfo *bias, |
| 163 | ITensorInfo *dst, |
| 164 | const MatMulKernelInfo &matmul_kernel_info, |
| 165 | const ActivationLayerInfo &act_info) |
| 166 | { |
| 167 | ARM_COMPUTE_ERROR_ON_NULLPTR(lhs, rhs, dst, &compile_context, &matmul_kernel_info); |
| 168 | ARM_COMPUTE_LOG_PARAMS(lhs, rhs, bias, dst, matmul_kernel_info); |
| 169 | ARM_COMPUTE_ERROR_THROW_ON(validate(lhs, rhs, bias, dst, matmul_kernel_info)); |
| 170 | |
| 171 | // dst tensor auto initialization if not yet initialized |
| 172 | auto_init_if_empty(*dst, lhs->clone()->set_tensor_shape(misc::shape_calculator::compute_matmul_shape( |
| 173 | lhs->tensor_shape(), rhs->tensor_shape(), matmul_kernel_info))); |
| 174 | |
| 175 | const int m = dst->dimension(1); |
| 176 | const int n = dst->dimension(0); |
| 177 | const int k = matmul_kernel_info.adj_lhs ? lhs->tensor_shape().y() : lhs->tensor_shape().x(); |
| 178 | const bool adj_lhs = matmul_kernel_info.adj_lhs; |
| 179 | |
| 180 | int m0 = adj_lhs ? adjust_vec_size(matmul_kernel_info.m0, m) : std::min(matmul_kernel_info.m0, m); |
| 181 | int n0 = adjust_vec_size(matmul_kernel_info.n0, n); |
| 182 | |
| 183 | _export_rhs_to_cl_image = matmul_kernel_info.export_rhs_to_cl_image && !rhs->lock_paddings(); |
| 184 | |
| 185 | // Configure kernel window |
| 186 | Window win = calculate_max_window(*dst, Steps(n0, m0)); |
| 187 | win = win.collapse(win, Window::DimZ); |
| 188 | IClKernel::configure_internal(win); |
| 189 | |
| 190 | // Calculate partial (store instead of load) M0 and partial N0 for the partial blocks at the end of a row/column if any. This is to avoid padding. |
| 191 | const unsigned int partial_store_m0 = m % m0; |
| 192 | const unsigned int partial_store_n0 = n % n0; |
| 193 | |
| 194 | CLBuildOptions build_opts; |
| 195 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(lhs->data_type())); |
| 196 | build_opts.add_option("-DM0=" + support::cpp11::to_string(m0)); |
| 197 | build_opts.add_option("-DN0=" + support::cpp11::to_string(n0)); |
| 198 | build_opts.add_option("-DK0=" + support::cpp11::to_string(matmul_kernel_info.k0)); |
| 199 | build_opts.add_option("-DPARTIAL_STORE_M0=" + support::cpp11::to_string(partial_store_m0)); |
| 200 | build_opts.add_option("-DPARTIAL_STORE_N0=" + support::cpp11::to_string(partial_store_n0)); |
| 201 | build_opts.add_option("-DK=" + support::cpp11::to_string(k)); |
| 202 | build_opts.add_option_if(bias != nullptr, "-DBIAS"); |
| 203 | build_opts.add_option_if_else(_export_rhs_to_cl_image, "-DRHS_TENSOR_TYPE=IMAGE", "-DRHS_TENSOR_TYPE=BUFFER"); |
| 204 | |
| 205 | // Define values for activation function |
| 206 | build_opts.add_option(("-DA_VAL=" + float_to_string_with_full_precision(act_info.a()))); |
| 207 | build_opts.add_option(("-DB_VAL=" + float_to_string_with_full_precision(act_info.b()))); |
| 208 | build_opts.add_option("-DACTIVATION_TYPE=" + lower_string(string_from_activation_func(act_info.activation()))); |
| 209 | |
| 210 | std::string kernel_name("mat_mul_native"); |
| 211 | kernel_name += matmul_kernel_info.adj_lhs ? "_t" : "_nt"; |
| 212 | kernel_name += matmul_kernel_info.adj_rhs ? "_t" : "_nt"; |
| 213 | |
| 214 | // A macro guard to compile ONLY the kernel of interest |
| 215 | build_opts.add_option("-D" + upper_string(kernel_name)); |
| 216 |
nothing calls this directly
no test coverage detected