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

Method validate

src/cpu/operators/CpuMatMul.cpp:98–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98Status CpuMatMul::validate(const ITensorInfo *lhs,
99 const ITensorInfo *rhs,
100 const ITensorInfo *dst,
101 const MatMulInfo &info,
102 const CpuMatMulSettings &settings,
103 const ActivationLayerInfo &act_info)
104{
105 ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuMatMul::validate");
106 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(lhs, rhs, dst);
107 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(lhs, 1, DataType::F32, DataType::F16, DataType::BFLOAT16,
108 DataType::QASYMM8, DataType::QASYMM8_SIGNED);
109 ARM_COMPUTE_RETURN_ERROR_ON_MSG(lhs->are_values_constant(), "LHS Tensor must be dynamic.");
110 ARM_COMPUTE_RETURN_ERROR_ON_MSG(rhs->are_values_constant(), "RHS Tensor must be dynamic.");
111 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(lhs);
112 ARM_COMPUTE_RETURN_ERROR_ON_CPU_BF16_UNSUPPORTED(lhs);
113
114 const auto adj_lhs = info.adj_lhs();
115 const auto adj_rhs = info.adj_rhs();
116
117 const ITensorInfo *lhs_to_use = lhs;
118 const ITensorInfo *rhs_to_use = rhs;
119 TensorInfo lhs_transposed{};
120 TensorInfo rhs_transposed{};
121
122 auto gemm_info = AsmGemmInfo();
123 gemm_info.activation_info = act_info;
124 gemm_info.fast_mode = settings.fast_math();
125 gemm_info.fixed_format = settings.fixed_format();
126
127 // Validate and then permute a/b
128 if (adj_lhs)
129 {
130 auto_init_if_empty(lhs_transposed,
131 lhs->clone()->set_tensor_shape(misc::shape_calculator::compute_transposed_shape(*lhs)));
132 ARM_COMPUTE_RETURN_ON_ERROR(cpu::kernels::CpuTransposeKernel::validate(lhs_to_use, &lhs_transposed));
133 // Assign lhs_to_use pointer to use transposed TensorInfo
134 lhs_to_use = &lhs_transposed;
135 }
136 if (adj_rhs)
137 {
138 auto_init_if_empty(rhs_transposed,
139 rhs->clone()->set_tensor_shape(misc::shape_calculator::compute_transposed_shape(*rhs)));
140 ARM_COMPUTE_RETURN_ON_ERROR(cpu::kernels::CpuTransposeKernel::validate(rhs_to_use, &rhs_transposed));
141 // Assign rhs_to_use pointer to use transposed TensorInfo
142 rhs_to_use = &rhs_transposed;
143 }
144
145 ARM_COMPUTE_RETURN_ERROR_ON_MSG(lhs_to_use->dimension(0) != rhs_to_use->dimension(1),
146 "The product AB is defined only if the number of columns in A is equal to the "
147 "number of rows in B (after transpose)");
148
149 // Iterate over dimensions to be collapsed in operator - check dimensions are equivalent between tensors
150 for (unsigned int i = 2; i < Coordinates::num_max_dimensions; i++)
151 {
152 ARM_COMPUTE_RETURN_ERROR_ON_MSG(lhs_to_use->dimension(i) != rhs_to_use->dimension(i),
153 "Broadcasting in Batch dimension is unsupported by this operator.");
154 }
155

Callers

nothing calls this directly

Calls 14

AsmGemmInfoClass · 0.85
auto_init_if_emptyFunction · 0.85
compute_transposed_shapeFunction · 0.85
is_data_type_quantizedFunction · 0.85
adj_lhsMethod · 0.80
adj_rhsMethod · 0.80
validateFunction · 0.50
are_values_constantMethod · 0.45
fast_mathMethod · 0.45
fixed_formatMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected