Reputation: 366
I am writing a Spir-V parser, which will be capable of iterating through the bytecode and change the Result Type id of float variables. Actually I want to convert fp32 variables to fp16.
I wrote this code so far.
static void find_float_constants_and_replace_to_16(std::vector<uint32_t> &bytecode) { auto i = find_first_occurrence_of_opcode(std::cbegin(bytecode) + 5, std::cend(bytecode), spv::OpConstant); uint32_t type_id_f16 = find_or_create_16_bit_float_type(bytecode);
while (i != std::cend(bytecode)) {
auto length = std::get<0>(unpack_instruction_length_and_opcode(*i));
if (length == 4) {
// here should be the instruction which unpack the result type id and then pack it
}
i = find_first_occurrence_of_opcode(i + length, std::cend(bytecode), spv::OpConstant);
}
}
In the find_or_create_16_bit_float_type
method I get the result type id of the created float16 type, but I don't know how can I unpack and pack the result type id
of the found opconstants. There is a comment in the above code indicating the place of the instruction I am looking for.
Any help is appreciated!
Upvotes: 0
Views: 47