Commit fe11d758 authored by Brian Pickrell's avatar Brian Pickrell
Browse files

added special case for Upsample-7 in Resize parser but it breaks resize_downsample_c_test

parent a24048bd
......@@ -214,7 +214,7 @@ struct parse_resize : op_parser<parse_resize>
[](const shape::dynamic_dimension& dd) { return dd.is_fixed(); });
if(not mostly_fixed)
MIGRAPHX_THROW("PARSE_" + opd.op_name +
MIGRAPHX_THROW("PARSE_" + opd.onnx_name +
": dynamic shape inputs other than batch size are not supported");
// Get static dimension set and
......@@ -279,7 +279,7 @@ struct parse_resize : op_parser<parse_resize>
}
instruction_ref parse(const op_desc& opd,
const onnx_parser& /*parser*/,
const onnx_parser& parser,
onnx_parser::node_info info,
std::vector<instruction_ref> args) const
{
......@@ -296,14 +296,14 @@ struct parse_resize : op_parser<parse_resize>
if(contains(info.attributes, "exclude_outside") and
info.attributes.at("exclude_outside").i() == 1)
{
MIGRAPHX_THROW("PARSE_" + opd.op_name + ": exclude_outside 1 is not supported!");
MIGRAPHX_THROW("PARSE_" + opd.onnx_name + ": exclude_outside 1 is not supported!");
}
// input data shape info. Convert static lens to dynamic to simplify referencing them later
auto in_s = args[0]->get_shape().to_dynamic();
if(args[0]->get_shape().dynamic() and in_s.ndim() < 2)
MIGRAPHX_THROW(
"PARSE_" + opd.op_name +
"PARSE_" + opd.onnx_name +
": requires 2 or more dimensions input, where first dimension is batch #");
std::vector<migraphx::shape::dynamic_dimension> in_dims = in_s.dyn_dims();
......@@ -314,11 +314,12 @@ struct parse_resize : op_parser<parse_resize>
std::vector<double> vec_scale;
// Look at inputs and infer either output size or scale, depending on input type
// The input ROI is not currently suported
for(const auto& arg : args)
{
if(arg != args[0] and arg->get_shape().dynamic())
{
MIGRAPHX_THROW("PARSE_" + opd.op_name +
MIGRAPHX_THROW("PARSE_" + opd.onnx_name +
": no dynamic input shapes allowed except the first one");
}
......@@ -337,13 +338,13 @@ struct parse_resize : op_parser<parse_resize>
{
auto arg_out_s = arg->eval();
check_arg_empty(arg_out_s,
"PARSE_" + opd.op_name + ": dynamic output size is not supported!");
"PARSE_" + opd.onnx_name + ": dynamic output size is not supported!");
out_lens.clear();
arg_out_s.visit([&](auto ol) { out_lens.assign(ol.begin(), ol.end()); });
if(out_lens.size() != in_s.ndim())
{
MIGRAPHX_THROW("PARSE_" + opd.op_name +
MIGRAPHX_THROW("PARSE_" + opd.onnx_name +
": specified output rank does not match input rank");
}
......@@ -361,16 +362,35 @@ struct parse_resize : op_parser<parse_resize>
{
// scale input
auto arg_scale = arg->eval();
check_arg_empty(arg_scale,
"PARSE_" + opd.op_name + ": dynamic input scale is not supported!");
arg_scale.visit([&](auto v) { vec_scale.assign(v.begin(), v.end()); });
if(in_dims.size() != vec_scale.size())
// Special-case for the deprecated Upsample-7 operation: scales is an attribute
// rather than an input. Upsample-9 uses scales as an input
if(opd.onnx_name == "Upsample" and arg_scale.empty())
{
MIGRAPHX_THROW("PARSE_" + opd.op_name +
": specified scale rank does not match input rank");
if(contains(info.attributes, "scales"))
{
// vec_scale = info.attributes.at("scales").vector<float>();
literal scales = parser.parse_value(info.attributes.at("scales"));
scales.visit([&](auto s) { vec_scale.assign(s.begin(), s.end()); });
}
else
MIGRAPHX_THROW("PARSE_" + opd.onnx_name +
": scales attribute missing");
}
else
{
check_arg_empty(arg_scale,
"PARSE_" + opd.onnx_name + ": dynamic input scale is not supported!");
arg_scale.visit([&](auto v) { vec_scale.assign(v.begin(), v.end()); });
if(in_dims.size() != vec_scale.size())
{
MIGRAPHX_THROW("PARSE_" + opd.onnx_name +
": specified scale rank does not match input rank");
}
}
std::transform(in_dims.begin(),
in_dims.end(),
vec_scale.begin(),
......@@ -383,7 +403,7 @@ struct parse_resize : op_parser<parse_resize>
}
}
if(out_lens.size() == 0)
MIGRAPHX_THROW("PARSE_" + opd.op_name + ": no input was given for scale or output size");
MIGRAPHX_THROW("PARSE_" + opd.onnx_name + ": no input was given for scale or output size");
// Dynamic batch: Only args[0] can have a dynamic shape, only the 0'th
// dimension--batch size--can be non-fixed, and the only resize mode allowed is "nearest"
......
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