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

Method prepare

src/cpu/operators/CpuGemmConv2d.cpp:1011–1101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1009}
1010
1011void CpuGemmConv2d::prepare(ITensorPack &tensors)
1012{
1013 if (!_is_prepared)
1014 {
1015 auto weights = tensors.get_const_tensor(TensorType::ACL_SRC_1);
1016 // Determine which weights reshape path to take
1017 // Note that this decision can only occur at prepare instead of configure because it relies on the presence of
1018 // any holes in the weight tensor, which may change after configure (e.g. from extending padding)
1019 if (_run_wt)
1020 {
1021 _wt_method = get_wt_method(*(weights->info()));
1022 switch (_wt_method)
1023 {
1024 case (WeightTransformMethod::FusedReshapeAndTranspose):
1025 {
1026 ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL("Perform weight transformation: FusedReshapeAndTranspose");
1027 _weights_reshape_and_transpose_kernel = std::make_unique<kernels::CpuWeightsReshapeKernel>();
1028 _weights_reshape_and_transpose_kernel->configure(weights->info(), nullptr, &_weights_reshaped);
1029 break;
1030 }
1031 case (WeightTransformMethod::ReshapeThenTranspose):
1032 {
1033 ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL("Perform weight transformation: ReshapeThenTranspose");
1034 _weights_reshape = std::make_unique<CpuReshape>();
1035 _weights_reshape->configure(weights->info(), &_weights_reshaped);
1036 break;
1037 }
1038 case (WeightTransformMethod::ReinterpretThenTranspose):
1039 {
1040 ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL("Perform weight transformation: ReinterpretThenTranspose");
1041 // Nothing to configure
1042 break;
1043 }
1044 default:
1045 {
1046 ARM_COMPUTE_ERROR("Unsupported weight transform method");
1047 }
1048 }
1049 }
1050 else
1051 {
1052 ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL("No weight transformation is performed");
1053 }
1054 ITensorPack gemm_pack = tensors;
1055 // Allocate reshaped weights if required
1056 CpuAuxTensorHandler reinterpreted_wei(
1057 _weights_reshaped,
1058 *weights); // Re-interpreted weights. Only tensor shape is changed. No allocation
1059 CpuAuxTensorHandler reshaped_wei(offset_int_vec(WeightsReshaped), _weights_reshaped, tensors);
1060 // Run weights reshape if required
1061 if (_run_wt)
1062 {
1063 switch (_wt_method)
1064 {
1065 case (WeightTransformMethod::FusedReshapeAndTranspose):
1066 {
1067 ITensorPack pack = {{TensorType::ACL_SRC, weights}, {TensorType::ACL_DST, reshaped_wei.get()}};
1068 NEScheduler::get().schedule_op(_weights_reshape_and_transpose_kernel.get(), Window::DimW,

Callers

nothing calls this directly

Calls 10

offset_int_vecFunction · 0.85
get_const_tensorMethod · 0.80
mark_as_unusedMethod · 0.80
add_const_tensorMethod · 0.80
infoMethod · 0.45
configureMethod · 0.45
getMethod · 0.45
schedule_opMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected