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

Method configure

src/cpu/operators/CpuMatMul.cpp:180–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void CpuMatMul::configure(ITensorInfo *lhs,
181 ITensorInfo *rhs,
182 ITensorInfo *dst,
183 const MatMulInfo &info,
184 const CpuMatMulSettings &settings,
185 const ActivationLayerInfo &act_info)
186{
187 ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuMatMul::configure");
188 ARM_COMPUTE_ERROR_ON_NULLPTR(lhs, rhs, dst);
189 ARM_COMPUTE_LOG_PARAMS(lhs, rhs, dst, info, settings);
190 ARM_COMPUTE_ERROR_THROW_ON(CpuMatMul::validate(lhs, rhs, dst, info, settings));
191
192 _adj_lhs = info.adj_lhs();
193 _adj_rhs = info.adj_rhs();
194 _fast_math = settings.fast_math();
195
196 // 1. Create and reshape tensors
197 // ------------------------------------------------------
198 // a. Clone TensorInfo to prevent changing original tensor values during setup
199 // b. Change shape of lhs/dst to [x, y, 1, collapsed(z)] to match assembly kernel configuration
200 // c. For rhs collapse all dimensions larger than 3 to z dimension
201 TensorInfo lhs_to_use = *lhs->clone();
202 TensorInfo dst_to_use = *dst->clone();
203 TensorInfo rhs_to_use = *rhs->clone();
204
205 // Save starting shape of tensors
206 _original_lhs_shape = lhs_to_use.tensor_shape();
207 _original_dst_shape = dst_to_use.tensor_shape();
208 _original_rhs_shape = rhs_to_use.tensor_shape();
209
210 // Reshape lhs for use with assembly kernels.
211 lhs_to_use.set_tensor_shape(
212 TensorShape(_original_lhs_shape.x(), _original_lhs_shape.y(), 1, _original_lhs_shape.collapsed_from(2).z()));
213 dst_to_use.set_tensor_shape(
214 TensorShape(_original_dst_shape.x(), _original_dst_shape.y(), 1, _original_dst_shape.collapsed_from(2).z()));
215 rhs_to_use.set_tensor_shape(_original_rhs_shape.collapsed_from(2));
216
217 // 2. Configuration for transpose of lhs/rhs
218 // ------------------------------------------------------
219 // Initialise transposed TensorInfo class for aux tensors (intermediary tensors)
220 if (_adj_lhs)
221 {
222 // Setup transpose LHS
223 _transpose_kernel_lhs = std::make_unique<cpu::kernels::CpuTransposeKernel>();
224 _transpose_kernel_lhs->configure(&lhs_to_use, &_lhs_transposed);
225
226 _aux_mem[TransposeLHS] = MemoryInfo(offset_int_vec(TransposeLHS), MemoryLifetime::Temporary, lhs->total_size());
227 }
228
229 if (_adj_rhs)
230 {
231 // Setup transpose RHS
232 _transpose_kernel_rhs = std::make_unique<cpu::kernels::CpuTransposeKernel>();
233 _transpose_kernel_rhs->configure(&rhs_to_use, &_rhs_transposed);
234
235 _aux_mem[TransposeRHS] = MemoryInfo(offset_int_vec(TransposeRHS), MemoryLifetime::Temporary, rhs->total_size());
236 }
237

Callers

nothing calls this directly

Calls 15

MemoryInfoClass · 0.85
offset_int_vecFunction · 0.85
is_data_type_quantizedFunction · 0.85
adj_lhsMethod · 0.80
adj_rhsMethod · 0.80
collapsed_fromMethod · 0.80
validateFunction · 0.50
TensorShapeClass · 0.50
fast_mathMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected