| 1009 | } |
| 1010 | |
| 1011 | void 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, |
nothing calls this directly
no test coverage detected