| 223 | } |
| 224 | |
| 225 | spv_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 | |
| 281 | spv_result_t ValidateFDot2MixAcc16(ValidationState_t& _, |
| 282 | const Instruction* inst) { |
no test coverage detected