Commit 71d5ced5 authored by Rob Earhart's avatar Rob Earhart

Replace get_arguments().at(x) with get_argument(x)

This came up while debugging memory corruption in the ngraph-tf tests: plaidml_ops_replicate was holding onto
a reference to a temporary that was destroyed while the reference was still live.  Replacing that code with a
call to get_argument() eliminated the temporary and fixed the issue.  And in general, there's no reason to be
allocating temporary vectors when we're pulling out a single argument, so this change replaces the other
sequences of get_arguments().at(), too.
parent b7551a60
......@@ -53,7 +53,7 @@ ngraph::runtime::plaidml::op::Replicate::Replicate(std::shared_ptr<Node> arg,
void ngraph::runtime::plaidml::op::Replicate::validate_and_infer_types()
{
const auto& arg = get_arguments().at(0);
std::shared_ptr<Node> arg = get_argument(0);
Shape shape = arg->get_shape();
for (auto rit = m_replication_axes.begin(), sit = shape.begin();
rit != m_replication_axes.end();
......
......@@ -75,19 +75,19 @@ ngraph::runtime::plaidml::pass::LowerConvolutions::LowerConvolutions()
// op. Using target always works.
AxisVector out_axes = to_axes(target, output_transpose);
auto lhs = node->get_arguments().at(0);
auto lhs = node->get_argument(0);
auto* lhs_transpose = to_transpose(lhs);
if (lhs_transpose)
{
lhs = lhs_transpose->get_arguments().at(0);
lhs = lhs_transpose->get_argument(0);
}
AxisVector lhs_axes = to_axes(lhs, lhs_transpose);
auto rhs = node->get_arguments().at(1);
auto rhs = node->get_argument(1);
auto* rhs_transpose = to_transpose(rhs);
if (rhs_transpose)
{
rhs = rhs_transpose->get_arguments().at(0);
rhs = rhs_transpose->get_argument(0);
}
AxisVector rhs_axes = to_axes(rhs, rhs_transpose);
......
......@@ -48,7 +48,7 @@ ngraph::runtime::plaidml::pass::ReplicateCombination::ReplicateCombination()
}
replace_node(lower,
std::make_shared<plaidml::op::Replicate>(upper->get_arguments().at(0),
std::make_shared<plaidml::op::Replicate>(upper->get_argument(0),
std::move(axes)));
return true;
......
......@@ -74,7 +74,7 @@ ngraph::runtime::plaidml::pass::ReplicateElision::ReplicateElision()
if (elidable)
{
replaced_any = true;
replace_node(replicate, replicate->get_arguments().at(0));
replace_node(replicate, replicate->get_argument(0));
}
}
......
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