Commit 789afa39 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

fix cppcheck errors

parent 5a0c8ca7
......@@ -88,32 +88,35 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
}
}
if(inputs != converted_inputs)
// no change for the input, return directly
if (inputs == converted_inputs)
{
auto op = ins->get_operator();
auto ins_shape = compute_shape(op, converted_inputs);
if(ins_shape.type() != orig_type)
return;
}
auto op = ins->get_operator();
auto ins_shape = compute_shape(op, converted_inputs);
if(ins_shape.type() != orig_type)
{
// insert another convert instruction to convert it back
if(ins == std::prev(prog.end()))
{
// insert another convert instruction to convert it back
if(ins == std::prev(prog.end()))
{
prog.add_instruction(op::convert{orig_type}, ins);
}
else
prog.add_instruction(op::convert{orig_type}, ins);
}
else
{
// check the dead code case to avoid assert
bool output_empty = ins->outputs().empty();
auto ins_orig_type =
prog.insert_instruction(std::next(ins), op::convert{orig_type}, ins);
if(!output_empty)
{
// check the dead code case to avoid assert
bool output_empty = ins->outputs().empty();
auto ins_orig_type =
prog.insert_instruction(std::next(ins), op::convert{orig_type}, ins);
if(!output_empty)
{
prog.replace_instruction(ins, ins_orig_type);
}
prog.replace_instruction(ins, ins_orig_type);
}
}
prog.replace_instruction(ins, op, converted_inputs);
}
prog.replace_instruction(ins, op, converted_inputs);
}
}
......
......@@ -17,7 +17,7 @@ struct hip_convert : unary_device<hip_convert, device::convert>
op::convert op;
hip_convert(const op::convert& oper) : op(oper) {}
hip_convert(const op::convert&& oper) : op(std::move(oper)) {}
hip_convert(const op::convert&& oper) : op(oper) {}
shape compute_shape(std::vector<shape> inputs) const
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment