Unverified Commit c0640134 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Merge branch 'develop' into cse-fix

parents 1290f3ba 97108410
...@@ -524,15 +524,7 @@ struct onnx_parser ...@@ -524,15 +524,7 @@ struct onnx_parser
if(contains(attributes, "ends")) if(contains(attributes, "ends"))
{ {
literal s = parse_value(attributes.at("ends")); op.ends = get_indices(attributes.at("ends"));
s.visit([&](auto v) { copy(v, std::back_inserter(op.ends)); });
for(size_t i = 0; i < num_dims; i++)
{
if(static_cast<size_t>(op.ends[i]) > dims[i])
{
op.ends[i] = dims[i];
}
}
} }
if(contains(attributes, "starts")) if(contains(attributes, "starts"))
{ {
...@@ -1548,6 +1540,20 @@ struct onnx_parser ...@@ -1548,6 +1540,20 @@ struct onnx_parser
return result; return result;
} }
static std::vector<int64_t> get_indices(const onnx::AttributeProto& attr)
{
std::vector<int64_t> result;
literal s = parse_value(attr);
s.visit([&](auto v) { copy(v, std::back_inserter(result)); });
// Clamp large indices to -1
std::replace_if(
result.begin(),
result.end(),
[](auto x) { return x > int64_t{std::numeric_limits<std::int32_t>::max()} / 2; },
-1);
return result;
}
template <class T> template <class T>
static literal from_repeated(shape::type_t t, const T& r) static literal from_repeated(shape::type_t t, const T& r)
{ {
......
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