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

Function ValidateDot

source/val/validate_arithmetics.cpp:198–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198spv_result_t ValidateDot(ValidationState_t& _, const Instruction* inst) {
199 const spv::Op opcode = inst->opcode();
200 const uint32_t result_type = inst->type_id();
201 if (!_.IsFloatScalarType(result_type))
202 return _.diag(SPV_ERROR_INVALID_DATA, inst)
203 << "Expected float scalar type as Result Type: "
204 << spvOpcodeString(opcode);
205
206 if (_.IsBfloat16ScalarType(result_type)) {
207 if (!_.HasCapability(spv::Capability::BFloat16DotProductKHR)) {
208 return _.diag(SPV_ERROR_INVALID_DATA, inst)
209 << "OpDot Result Type <id> " << _.getIdName(result_type)
210 << "requires BFloat16DotProductKHR be declared.";
211 }
212 }
213
214 uint32_t first_vector_num_components = 0;
215
216 for (size_t operand_index = 2; operand_index < inst->operands().size();
217 ++operand_index) {
218 const uint32_t type_id = _.GetOperandTypeId(inst, operand_index);
219
220 if (!type_id || !_.IsFloatVectorType(type_id))
221 return _.diag(SPV_ERROR_INVALID_DATA, inst)
222 << "Expected float vector as operand: " << spvOpcodeString(opcode)
223 << " operand index " << operand_index;
224
225 const uint32_t component_type = _.GetComponentType(type_id);
226 if (component_type != result_type)
227 return _.diag(SPV_ERROR_INVALID_DATA, inst)
228 << "Expected component type to be equal to Result Type: "
229 << spvOpcodeString(opcode) << " operand index " << operand_index;
230
231 const uint32_t num_components = _.GetDimension(type_id);
232 if (operand_index == 2) {
233 first_vector_num_components = num_components;
234 } else if (num_components != first_vector_num_components) {
235 return _.diag(SPV_ERROR_INVALID_DATA, inst)
236 << "Expected operands to have the same number of components: "
237 << spvOpcodeString(opcode);
238 }
239 }
240 return SPV_SUCCESS;
241}
242
243spv_result_t ValidateVectorTimesScalar(ValidationState_t& _,
244 const Instruction* inst) {

Callers 1

ArithmeticsPassFunction · 0.85

Calls 14

spvOpcodeStringFunction · 0.85
IsFloatScalarTypeMethod · 0.80
diagMethod · 0.80
IsBfloat16ScalarTypeMethod · 0.80
getIdNameMethod · 0.80
operandsMethod · 0.80
GetOperandTypeIdMethod · 0.80
IsFloatVectorTypeMethod · 0.80
GetDimensionMethod · 0.80
opcodeMethod · 0.45
type_idMethod · 0.45
HasCapabilityMethod · 0.45

Tested by

no test coverage detected