MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateFDot2MixAcc32

Function ValidateFDot2MixAcc32

source/val/validate_dot_product.cpp:225–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225spv_result_t ValidateFDot2MixAcc32(ValidationState_t& _,
226 const Instruction* inst) {
227 const uint32_t result_id = inst->type_id();
228 if (!_.IsFloatScalarType(result_id, 32)) {
229 return _.diag(SPV_ERROR_INVALID_DATA, inst)
230 << "Result must be a 32-bit IEEE 754 float scalar type.";
231 }
232
233 const uint32_t vec_1_id = _.GetOperandTypeId(inst, 2);
234 const uint32_t vec_2_id = _.GetOperandTypeId(inst, 3);
235
236 if (auto error = ValidateFDotMixVectors(_, inst, vec_1_id, vec_2_id, 2))
237 return error;
238
239 const uint32_t vec_1_type = _.GetComponentType(vec_1_id);
240 const uint32_t vec_2_type = _.GetComponentType(vec_2_id);
241 if (!_.IsFloatScalarType(vec_1_type, 16)) {
242 return _.diag(SPV_ERROR_INVALID_DATA, inst)
243 << "Expected 'Vector 1' to be a vector of 16-bit floats.";
244 } else if (!_.IsFloatScalarType(vec_2_type, 16)) {
245 return _.diag(SPV_ERROR_INVALID_DATA, inst)
246 << "Expected 'Vector 2' to be a vector of 16-bit floats.";
247 }
248
249 // Currently 16-bit floats are only BFloat or IEEE 754
250 const bool is_vec_1_bfloat = _.IsBfloat16ScalarType(vec_1_type);
251 const bool is_vec_2_bfloat = _.IsBfloat16ScalarType(vec_2_type);
252 if (is_vec_1_bfloat != is_vec_2_bfloat) {
253 return _.diag(SPV_ERROR_INVALID_DATA, inst)
254 << "'Vector 1' and 'Vector 2' must be the same float encoding.";
255 }
256
257 if (is_vec_1_bfloat) {
258 if (!_.HasCapability(spv::Capability::DotProductBFloat16AccVALVE)) {
259 return _.diag(SPV_ERROR_INVALID_DATA, inst)
260 << "DotProductBFloat16AccVALVE capability is required to use "
261 "BFloat16 encoded floats.";
262 }
263 } else {
264 if (!_.HasCapability(spv::Capability::DotProductFloat16AccFloat32VALVE)) {
265 return _.diag(SPV_ERROR_INVALID_DATA, inst)
266 << "DotProductFloat16AccFloat32VALVE capability is required to "
267 "use "
268 "IEEE 754 encoded 16-bit floats.";
269 }
270 }
271
272 const uint32_t accumulator_type = _.GetOperandTypeId(inst, 4);
273 if (accumulator_type != result_id) {
274 return _.diag(SPV_ERROR_INVALID_DATA, inst)
275 << "Accumulator Type must be the same as the Result Type.";
276 }
277
278 return SPV_SUCCESS;
279}
280
281spv_result_t ValidateFDot2MixAcc16(ValidationState_t& _,
282 const Instruction* inst) {

Callers 1

DotProductPassFunction · 0.85

Calls 8

ValidateFDotMixVectorsFunction · 0.85
IsFloatScalarTypeMethod · 0.80
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
IsBfloat16ScalarTypeMethod · 0.80
type_idMethod · 0.45
GetComponentTypeMethod · 0.45
HasCapabilityMethod · 0.45

Tested by

no test coverage detected