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

Function ValidateVectorTimesMatrix

source/val/validate_arithmetics.cpp:297–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297spv_result_t ValidateVectorTimesMatrix(ValidationState_t& _,
298 const Instruction* inst) {
299 const spv::Op opcode = inst->opcode();
300 const uint32_t result_type = inst->type_id();
301 const uint32_t vector_type_id = _.GetOperandTypeId(inst, 2);
302 const uint32_t matrix_type_id = _.GetOperandTypeId(inst, 3);
303
304 if (!_.IsFloatVectorType(result_type))
305 return _.diag(SPV_ERROR_INVALID_DATA, inst)
306 << "Expected float vector type as Result Type: "
307 << spvOpcodeString(opcode);
308
309 const uint32_t res_component_type = _.GetComponentType(result_type);
310
311 if (!vector_type_id || !_.IsFloatVectorType(vector_type_id))
312 return _.diag(SPV_ERROR_INVALID_DATA, inst)
313 << "Expected float vector type as left operand: "
314 << spvOpcodeString(opcode);
315
316 if (res_component_type != _.GetComponentType(vector_type_id))
317 return _.diag(SPV_ERROR_INVALID_DATA, inst)
318 << "Expected component types of Result Type and vector to be "
319 << "equal: " << spvOpcodeString(opcode);
320
321 uint32_t matrix_num_rows = 0;
322 uint32_t matrix_num_cols = 0;
323 uint32_t matrix_col_type = 0;
324 uint32_t matrix_component_type = 0;
325 if (!_.GetMatrixTypeInfo(matrix_type_id, &matrix_num_rows, &matrix_num_cols,
326 &matrix_col_type, &matrix_component_type))
327 return _.diag(SPV_ERROR_INVALID_DATA, inst)
328 << "Expected float matrix type as right operand: "
329 << spvOpcodeString(opcode);
330
331 if (res_component_type != matrix_component_type)
332 return _.diag(SPV_ERROR_INVALID_DATA, inst)
333 << "Expected component types of Result Type and matrix to be "
334 << "equal: " << spvOpcodeString(opcode);
335
336 if (matrix_num_cols != _.GetDimension(result_type))
337 return _.diag(SPV_ERROR_INVALID_DATA, inst)
338 << "Expected number of columns of the matrix to be equal to "
339 << "Result Type vector size: " << spvOpcodeString(opcode);
340
341 if (matrix_num_rows != _.GetDimension(vector_type_id))
342 return _.diag(SPV_ERROR_INVALID_DATA, inst)
343 << "Expected number of rows of the matrix to be equal to the "
344 << "vector operand size: " << spvOpcodeString(opcode);
345 return SPV_SUCCESS;
346}
347
348spv_result_t ValidateMatrixTimesVector(ValidationState_t& _,
349 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