Commit 1bdd55e8 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

clang format.

parent eb1e4353
...@@ -659,9 +659,7 @@ struct gather ...@@ -659,9 +659,7 @@ struct gather
// max dimension in axis // max dimension in axis
std::size_t max_dim = args[0].get_shape().lens()[axis]; std::size_t max_dim = args[0].get_shape().lens()[axis];
std::vector<std::size_t> vec_indices(args[1].get_shape().lens().size()); std::vector<std::size_t> vec_indices(args[1].get_shape().lens().size());
args[1].visit([&](auto indices) { args[1].visit([&](auto indices) { vec_indices.assign(indices.begin(), indices.end()); });
vec_indices.assign(indices.begin(), indices.end());
});
std::size_t idx = vec_indices.at(out_idx[axis]); std::size_t idx = vec_indices.at(out_idx[axis]);
if(idx >= max_dim) if(idx >= max_dim)
{ {
......
...@@ -556,7 +556,6 @@ struct onnx_parser ...@@ -556,7 +556,6 @@ struct onnx_parser
return prog.add_literal(migraphx::literal{s, vec_shape}); return prog.add_literal(migraphx::literal{s, vec_shape});
} }
// Use a literal instruction to replace the constantFill operator. In RNN, input shape // Use a literal instruction to replace the constantFill operator. In RNN, input shape
// and value are fixed, so no need to do the actual computation for the constantFill // and value are fixed, so no need to do the actual computation for the constantFill
// operator // operator
...@@ -584,26 +583,28 @@ struct onnx_parser ...@@ -584,26 +583,28 @@ struct onnx_parser
value = parse_value(attributes.at("value")).at<float>(); value = parse_value(attributes.at("value")).at<float>();
} }
if (contains(attributes, "extra_shape")) { if(contains(attributes, "extra_shape"))
{
MIGRAPHX_THROW("ConstantFill, cannot handle extra shape attribute"); MIGRAPHX_THROW("ConstantFill, cannot handle extra shape attribute");
} }
if(input_as_shape == 1) if(input_as_shape == 1)
{ {
if (args.size() != 1) if(args.size() != 1)
{ {
MIGRAPHX_THROW("ConstantFill, need an input argument as output shape"); MIGRAPHX_THROW("ConstantFill, need an input argument as output shape");
} }
if (contains(attributes, "shape")) { if(contains(attributes, "shape"))
MIGRAPHX_THROW("ConstantFill, cannot set the shape argument and pass in an input at the same time"); {
MIGRAPHX_THROW("ConstantFill, cannot set the shape argument and pass in an input "
"at the same time");
} }
migraphx::argument in = args[0]->eval(); migraphx::argument in = args[0]->eval();
if(in.empty()) if(in.empty())
{ {
MIGRAPHX_THROW( MIGRAPHX_THROW("ConstantFill, cannot handle dynamic shape as input");
"ConstantFill, cannot handle dynamic shape as input");
} }
std::vector<std::size_t> dims; std::vector<std::size_t> dims;
...@@ -614,13 +615,14 @@ struct onnx_parser ...@@ -614,13 +615,14 @@ struct onnx_parser
} }
else if(input_as_shape == 0) else if(input_as_shape == 0)
{ {
if (!contains(attributes, "shape")) { if(!contains(attributes, "shape"))
{
MIGRAPHX_THROW("ConstantFill, attribute output shape is needed"); MIGRAPHX_THROW("ConstantFill, attribute output shape is needed");
} }
literal ls = parse_value(attributes.at("shape")); literal ls = parse_value(attributes.at("shape"));
std::vector<std::size_t> dims(ls.get_shape().elements()); std::vector<std::size_t> dims(ls.get_shape().elements());
ls.visit([&] (auto s) { dims.assign(s.begin(), s.end()); } ); ls.visit([&](auto s) { dims.assign(s.begin(), s.end()); });
migraphx::shape s{type, dims}; migraphx::shape s{type, dims};
std::vector<float> values(s.elements(), value); std::vector<float> values(s.elements(), value);
return prog.add_literal(migraphx::literal(s, values)); return prog.add_literal(migraphx::literal(s, values));
......
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