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

Function ValidateGraphConstant

source/val/validate_graph.cpp:113–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113spv_result_t ValidateGraphConstant(ValidationState_t& _,
114 const Instruction* inst) {
115 // Check Result Type
116 if (!_.IsTensorType(inst->type_id())) {
117 return _.diag(SPV_ERROR_INVALID_DATA, inst)
118 << spvOpcodeString(inst->opcode())
119 << " must have a Result Type that is a tensor type.";
120 }
121
122 // Check the instruction is not preceded by another OpGraphConstantARM with
123 // the same ID
124 const uint32_t cst_id = inst->word(3);
125 size_t inst_num = inst->LineNum() - 1;
126 while (--inst_num) {
127 auto prev_inst = &_.ordered_instructions()[inst_num];
128 if (prev_inst->opcode() == spv::Op::OpGraphConstantARM) {
129 const uint32_t prev_cst_id = prev_inst->word(3);
130 if (prev_cst_id == cst_id) {
131 return _.diag(SPV_ERROR_INVALID_DATA, inst)
132 << "No two OpGraphConstantARM instructions may have the same "
133 "GraphConstantID";
134 }
135 }
136 }
137 return SPV_SUCCESS;
138}
139
140spv_result_t ValidateGraphEntryPoint(ValidationState_t& _,
141 const Instruction* inst) {

Callers 1

GraphPassFunction · 0.85

Calls 7

spvOpcodeStringFunction · 0.85
IsTensorTypeMethod · 0.80
diagMethod · 0.80
wordMethod · 0.80
LineNumMethod · 0.80
type_idMethod · 0.45
opcodeMethod · 0.45

Tested by

no test coverage detected