MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / run

Method run

src/cpu/operators/CpuMatMul.cpp:288–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void CpuMatMul::run(ITensorPack &tensors)
289{
290 ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuMatMul::run");
291 // Retrieve tensors from tensor pack
292 auto lhs = tensors.get_tensor(ACL_SRC_0);
293 auto rhs = tensors.get_const_tensor(ACL_SRC_1);
294 auto dst = tensors.get_tensor(ACL_DST);
295
296 // Reshape LHS and DST to ensure compatibility with GEMM asm kernel (Batch dimensions is 4th for lhs and dst within asm)
297 // Collapse RHS (necessary to support dimensions larger than 3 in gemm assembly)
298 lhs->info()->set_tensor_shape(
299 TensorShape(_original_lhs_shape.x(), _original_lhs_shape.y(), 1,
300 _original_lhs_shape.collapsed_from(2).z())); // Collapsed 3+ dimensions into z
301 dst->info()->set_tensor_shape(
302 TensorShape(_original_dst_shape.x(), _original_dst_shape.y(), 1,
303 _original_dst_shape.collapsed_from(2).z())); // Collapsed 3+ dimensions into z
304 rhs->info()->set_tensor_shape(_original_rhs_shape.collapsed_from(2));
305
306 // Initialise object to handle stored transposed tensors in auxillary memory
307 CpuAuxTensorHandler lhs_transposed(offset_int_vec(TransposeLHS), _lhs_transposed, tensors, true);
308 CpuAuxTensorHandler rhs_transposed(offset_int_vec(TransposeRHS), _rhs_transposed, tensors, true);
309
310 // Create tensor pack for asm kernel
311 ITensorPack asm_tensors(tensors);
312
313 // Run transpose lhs if necessary
314 if (_adj_lhs)
315 {
316 ITensorPack lhs_transpose_pack = {{TensorType::ACL_SRC, lhs}, {TensorType::ACL_DST, lhs_transposed.get()}};
317 NEScheduler::get().schedule_op(_transpose_kernel_lhs.get(), Window::DimY, _transpose_kernel_lhs->window(),
318 lhs_transpose_pack);
319 asm_tensors.add_const_tensor(TensorType::ACL_SRC_0, lhs_transposed.get());
320 }
321 // Run transpose rhs if necessary
322 if (_adj_rhs)
323 {
324 ITensorPack rhs_transpose_pack = {{TensorType::ACL_SRC, rhs}, {TensorType::ACL_DST, rhs_transposed.get()}};
325 NEScheduler::get().schedule_op(_transpose_kernel_rhs.get(), Window::DimY, _transpose_kernel_rhs->window(),
326 rhs_transpose_pack);
327 asm_tensors.add_const_tensor(TensorType::ACL_SRC_1, rhs_transposed.get());
328 }
329 // Run asm kernel
330 _asm_glue->run(asm_tensors);
331
332 // Undo reshape of tensors
333 dst->info()->set_tensor_shape(_original_dst_shape);
334 lhs->info()->set_tensor_shape(_original_lhs_shape);
335 rhs->info()->set_tensor_shape(_original_rhs_shape);
336}
337
338experimental::MemoryRequirements CpuMatMul::workspace() const
339{

Callers

nothing calls this directly

Calls 12

offset_int_vecFunction · 0.85
get_const_tensorMethod · 0.80
collapsed_fromMethod · 0.80
add_const_tensorMethod · 0.80
TensorShapeClass · 0.50
get_tensorMethod · 0.45
infoMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
getMethod · 0.45
schedule_opMethod · 0.45

Tested by

no test coverage detected