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

Method prepare

src/cpu/operators/CpuWinogradConv2d.cpp:426–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426void CpuWinogradConv2d::prepare(ITensorPack &tensors)
427{
428 if (!_is_prepared)
429 {
430 const ITensor *weights = tensors.get_const_tensor(ACL_SRC_1);
431 ITensor *weights_aux =
432 utils::cast::polymorphic_cast<ITensor *>(tensors.get_tensor(offset_int_vec(PermutedWeights)));
433
434 CpuAuxTensorHandler permuted_weights(_weights_hwio, *weights_aux);
435 ITensorPack permute_tensors{{ACL_SRC, weights}, {ACL_DST, permuted_weights.get()}};
436 _permute_weights->run(permute_tensors);
437 const int element_size_in_bytes = permuted_weights.get()->info()->element_size();
438 // Weights were in OHWI format, before being permuted "permuted_weights" to be in HWIO format.
439 const unsigned int height_idx = 3; // H in HWIO
440 const unsigned int width_idx = 2; // W in HWIO
441 const unsigned int channel_idx = 1; // I in HWIO
442
443 const int permuted_weight_row_stride =
444 permuted_weights.get()->info()->strides_in_bytes()[height_idx] / element_size_in_bytes;
445 const int permuted_weight_col_stride =
446 permuted_weights.get()->info()->strides_in_bytes()[width_idx] / element_size_in_bytes;
447 const int permuted_weight_channel_stride =
448 permuted_weights.get()->info()->strides_in_bytes()[channel_idx] / element_size_in_bytes;
449
450 // Wrap the winograd-domain transformed weight TensorInfo in Auxiliary tensor and allocate the required memory.
451 ITensor *weights_transf =
452 utils::cast::polymorphic_cast<ITensor *>(tensors.get_tensor(offset_int_vec(TransformedWeights)));
453 ARM_COMPUTE_ERROR_ON_NULLPTR(weights_transf);
454 CpuAuxTensorHandler winograd_transformed_weights(_winograd_transformed_weights, *weights_transf);
455
456 const void *permuted_weights_ptr;
457 void *win_wght_transf_ptr;
458
459 permuted_weights_ptr = reinterpret_cast<const void *>(
460 permuted_weights.get()->buffer() + permuted_weights.get()->info()->offset_first_element_in_bytes());
461 win_wght_transf_ptr =
462 reinterpret_cast<void *>(winograd_transformed_weights.get()->buffer() +
463 winograd_transformed_weights.get()->info()->offset_first_element_in_bytes());
464
465 // Prepare Weights
466 _winograd_impl.weight_transform->execute(
467 *_conv_args, permuted_weights_ptr, permuted_weight_row_stride, permuted_weight_col_stride,
468 permuted_weight_channel_stride, win_wght_transf_ptr, _winograd_impl.winograd_spec, 0, 1 // Thread 1 of 1
469 );
470 ITensorPack gemm_pack = tensors;
471 gemm_pack.add_const_tensor(ACL_SRC_1, winograd_transformed_weights.get());
472 _gemm_function->prepare(gemm_pack);
473 _is_prepared = 1;
474 }
475}
476experimental::MemoryRequirements CpuWinogradConv2d::workspace() const
477{
478 return _aux_mem;

Callers

nothing calls this directly

Calls 11

offset_int_vecFunction · 0.85
get_const_tensorMethod · 0.80
add_const_tensorMethod · 0.80
get_tensorMethod · 0.45
getMethod · 0.45
runMethod · 0.45
element_sizeMethod · 0.45
infoMethod · 0.45
bufferMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected