| 259 | } |
| 260 | |
| 261 | spv_result_t ValidateFConvert(ValidationState_t& _, const Instruction* inst, |
| 262 | uint32_t operand_index = 2) { |
| 263 | const spv::Op opcode = inst->opcode(); |
| 264 | const uint32_t result_type = inst->type_id(); |
| 265 | if (!_.IsFloatScalarType(result_type) && !_.IsFloatVectorType(result_type) && |
| 266 | !_.IsFloatCooperativeMatrixType(result_type) && |
| 267 | !_.IsFloatCooperativeVectorNVType(result_type)) |
| 268 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 269 | << "Expected float scalar or vector type as Result Type: " |
| 270 | << spvOpcodeString(opcode); |
| 271 | |
| 272 | const uint32_t input_type = _.GetOperandTypeId(inst, operand_index); |
| 273 | if (!input_type || |
| 274 | (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) && |
| 275 | !_.IsFloatCooperativeMatrixType(input_type) && |
| 276 | !_.IsFloatCooperativeVectorNVType(input_type))) |
| 277 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 278 | << "Expected input to be float scalar or vector: " |
| 279 | << spvOpcodeString(opcode); |
| 280 | |
| 281 | if (_.IsCooperativeVectorNVType(result_type) || |
| 282 | _.IsCooperativeVectorNVType(input_type)) { |
| 283 | spv_result_t ret = |
| 284 | _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); |
| 285 | if (ret != SPV_SUCCESS) return ret; |
| 286 | } else if (_.IsCooperativeMatrixType(result_type) || |
| 287 | _.IsCooperativeMatrixType(input_type)) { |
| 288 | spv_result_t ret = |
| 289 | _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); |
| 290 | if (ret != SPV_SUCCESS) return ret; |
| 291 | } else { |
| 292 | if (_.GetDimension(result_type) != _.GetDimension(input_type)) |
| 293 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 294 | << "Expected input to have the same dimension as Result Type: " |
| 295 | << spvOpcodeString(opcode); |
| 296 | } |
| 297 | |
| 298 | // Scalar type |
| 299 | const uint32_t resScalarType = _.GetComponentType(result_type); |
| 300 | const uint32_t inputScalartype = _.GetComponentType(input_type); |
| 301 | if (resScalarType == inputScalartype) { |
| 302 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 303 | << "Expected component type of Value to be different from " |
| 304 | "component type of Result Type: " |
| 305 | << spvOpcodeString(opcode); |
| 306 | } |
| 307 | return SPV_SUCCESS; |
| 308 | } |
| 309 | |
| 310 | spv_result_t ValidateQuantizeToF16(ValidationState_t& _, |
| 311 | const Instruction* inst, |
no test coverage detected