Commit 72a26b4f authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

Work in progress to force shapes when scalar detected in if block so we don't...

Work in progress to force shapes when scalar detected in if block so we don't fail size/shape checks with nested ifs and the like.
parent 3d229ce3
......@@ -50,12 +50,6 @@ struct if_op
}
auto out_shapes0 = mods[0]->get_output_shapes();
auto out_shapes1 = mods[1]->get_output_shapes();
if(not std::equal(
out_shapes1.begin(), out_shapes1.end(), out_shapes0.begin(), out_shapes0.end()))
{
MIGRAPHX_THROW("IF: output shapes of submodules must be the same.");
}
return {out_shapes0};
}
......
......@@ -40,13 +40,16 @@ struct parse_constant : op_parser<parse_constant>
const std::vector<instruction_ref>& /*args*/) const
{
literal v = parser.parse_value(info.attributes.at("value"));
auto dim_size = info.attributes.at("value").t().dims_size();
auto dim_param = info.attributes.at("value").t().dims();
// return empty literal
if(v.get_shape().elements() == 0)
{
return info.add_literal(literal{});
return info.add_literal(literal{dim_param.at(0)});
}
auto dim_size = info.attributes.at("value").t().dims_size();
// if dim_size is 0, it is a scalar
if(dim_size == 0)
{
......
......@@ -85,7 +85,8 @@ struct parse_if : op_parser<parse_if>
MIGRAPHX_THROW("PARSE_IF: " + info.name +
"then out incompatible output shape with else");
}
migraphx::shape s(then_out_shapes.at(0).type(), {then_out_shapes.at(0).lens().at(0), 1} , {1, 1});
migraphx::shape s(
then_out_shapes.at(0).type(), {then_out_shapes.at(0).lens().at(0), 1}, {1, 1});
then_mdl->add_outline(s);
}
else if(else_out_shapes.at(0).scalar())
......@@ -96,7 +97,8 @@ struct parse_if : op_parser<parse_if>
MIGRAPHX_THROW("PARSE_IF: " + info.name +
"else out incompatible output shape with then");
}
migraphx::shape s(else_out_shapes.at(0).type(), {else_out_shapes.at(0).lens().at(0), 1} , {1, 1});
migraphx::shape s(
else_out_shapes.at(0).type(), {else_out_shapes.at(0).lens().at(0), 1}, {1, 1});
else_mdl->add_outline(s);
}
......
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