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

Function ValidateMatrixTimesMatrix

source/val/validate_arithmetics.cpp:394–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394spv_result_t ValidateMatrixTimesMatrix(ValidationState_t& _,
395 const Instruction* inst) {
396 const spv::Op opcode = inst->opcode();
397 const uint32_t result_type = inst->type_id();
398 const uint32_t left_type_id = _.GetOperandTypeId(inst, 2);
399 const uint32_t right_type_id = _.GetOperandTypeId(inst, 3);
400
401 uint32_t res_num_rows = 0;
402 uint32_t res_num_cols = 0;
403 uint32_t res_col_type = 0;
404 uint32_t res_component_type = 0;
405 if (!_.GetMatrixTypeInfo(result_type, &res_num_rows, &res_num_cols,
406 &res_col_type, &res_component_type))
407 return _.diag(SPV_ERROR_INVALID_DATA, inst)
408 << "Expected float matrix type as Result Type: "
409 << spvOpcodeString(opcode);
410
411 uint32_t left_num_rows = 0;
412 uint32_t left_num_cols = 0;
413 uint32_t left_col_type = 0;
414 uint32_t left_component_type = 0;
415 if (!_.GetMatrixTypeInfo(left_type_id, &left_num_rows, &left_num_cols,
416 &left_col_type, &left_component_type))
417 return _.diag(SPV_ERROR_INVALID_DATA, inst)
418 << "Expected float matrix type as left operand: "
419 << spvOpcodeString(opcode);
420
421 uint32_t right_num_rows = 0;
422 uint32_t right_num_cols = 0;
423 uint32_t right_col_type = 0;
424 uint32_t right_component_type = 0;
425 if (!_.GetMatrixTypeInfo(right_type_id, &right_num_rows, &right_num_cols,
426 &right_col_type, &right_component_type))
427 return _.diag(SPV_ERROR_INVALID_DATA, inst)
428 << "Expected float matrix type as right operand: "
429 << spvOpcodeString(opcode);
430
431 if (!_.IsFloatScalarType(res_component_type))
432 return _.diag(SPV_ERROR_INVALID_DATA, inst)
433 << "Expected float matrix type as Result Type: "
434 << spvOpcodeString(opcode);
435
436 if (res_col_type != left_col_type)
437 return _.diag(SPV_ERROR_INVALID_DATA, inst)
438 << "Expected column types of Result Type and left matrix to be "
439 << "equal: " << spvOpcodeString(opcode);
440
441 if (res_component_type != right_component_type)
442 return _.diag(SPV_ERROR_INVALID_DATA, inst)
443 << "Expected component types of Result Type and right matrix to "
444 "be "
445 << "equal: " << spvOpcodeString(opcode);
446
447 if (res_num_cols != right_num_cols)
448 return _.diag(SPV_ERROR_INVALID_DATA, inst)
449 << "Expected number of columns of Result Type and right matrix "
450 "to "
451 << "be equal: " << spvOpcodeString(opcode);

Callers 1

ArithmeticsPassFunction · 0.85

Calls 7

spvOpcodeStringFunction · 0.85
GetOperandTypeIdMethod · 0.80
GetMatrixTypeInfoMethod · 0.80
diagMethod · 0.80
IsFloatScalarTypeMethod · 0.80
opcodeMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected