Commit 8083e267 authored by Khalique Ahmed's avatar Khalique Ahmed
Browse files

formatting

parent 48f9e6ad
......@@ -53,8 +53,21 @@ struct parse_reshape : op_parser<parse_reshape>
s.visit([&](auto v) { copy(v, std::back_inserter(dims)); });
}
return info.add_instruction(make_op("reshape", {{"dims", dims}}),
info.make_contiguous(args[0]));
std::vector<size_t> orig_dims = args[0]->get_shape().lens();
auto dims_acc = std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<int64_t>());
auto orig_dims_acc = std::accumulate(orig_dims.begin(), orig_dims.end(), 1, std::multiplies<int64_t>());
if (std::abs(dims_acc) == orig_dims_acc)
return info.add_instruction(make_op("reshape", {{"dims", dims}}),
info.make_contiguous(args[0]));
if(parser.default_dim_value * std::abs(dims_acc) == orig_dims_acc)
{
dims[0] *= parser.default_dim_value;
return info.add_instruction(make_op("reshape", {{"dims", dims}}),
info.make_contiguous(args[0]));
}
MIGRAPHX_THROW("Reshape: incorrect number of elements: " + std::to_string(dims_acc) + " versus " + std::to_string(orig_dims_acc));
}
};
......
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