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

Function ValidateMatrixTimesVector

source/val/validate_arithmetics.cpp:348–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348spv_result_t ValidateMatrixTimesVector(ValidationState_t& _,
349 const Instruction* inst) {
350 const spv::Op opcode = inst->opcode();
351 const uint32_t result_type = inst->type_id();
352 const uint32_t matrix_type_id = _.GetOperandTypeId(inst, 2);
353 const uint32_t vector_type_id = _.GetOperandTypeId(inst, 3);
354
355 if (!_.IsFloatVectorType(result_type))
356 return _.diag(SPV_ERROR_INVALID_DATA, inst)
357 << "Expected float vector type as Result Type: "
358 << spvOpcodeString(opcode);
359
360 uint32_t matrix_num_rows = 0;
361 uint32_t matrix_num_cols = 0;
362 uint32_t matrix_col_type = 0;
363 uint32_t matrix_component_type = 0;
364 if (!_.GetMatrixTypeInfo(matrix_type_id, &matrix_num_rows, &matrix_num_cols,
365 &matrix_col_type, &matrix_component_type))
366 return _.diag(SPV_ERROR_INVALID_DATA, inst)
367 << "Expected float matrix type as left operand: "
368 << spvOpcodeString(opcode);
369
370 if (result_type != matrix_col_type)
371 return _.diag(SPV_ERROR_INVALID_DATA, inst)
372 << "Expected column type of the matrix to be equal to Result "
373 "Type: "
374 << spvOpcodeString(opcode);
375
376 if (!vector_type_id || !_.IsFloatVectorType(vector_type_id))
377 return _.diag(SPV_ERROR_INVALID_DATA, inst)
378 << "Expected float vector type as right operand: "
379 << spvOpcodeString(opcode);
380
381 if (matrix_component_type != _.GetComponentType(vector_type_id))
382 return _.diag(SPV_ERROR_INVALID_DATA, inst)
383 << "Expected component types of the operands to be equal: "
384 << spvOpcodeString(opcode);
385
386 if (matrix_num_cols != _.GetDimension(vector_type_id))
387 return _.diag(SPV_ERROR_INVALID_DATA, inst)
388 << "Expected number of columns of the matrix to be equal to the "
389 << "vector size: " << spvOpcodeString(opcode);
390
391 return SPV_SUCCESS;
392}
393
394spv_result_t ValidateMatrixTimesMatrix(ValidationState_t& _,
395 const Instruction* inst) {

Callers 1

ArithmeticsPassFunction · 0.85

Calls 9

spvOpcodeStringFunction · 0.85
GetOperandTypeIdMethod · 0.80
IsFloatVectorTypeMethod · 0.80
diagMethod · 0.80
GetMatrixTypeInfoMethod · 0.80
GetDimensionMethod · 0.80
opcodeMethod · 0.45
type_idMethod · 0.45
GetComponentTypeMethod · 0.45

Tested by

no test coverage detected