public:
ANeuralNetworksExecution(const std::shared_ptr<const neurun::codegen::Plan> &plan) : _plan{plan}
{
- _sources.resize(_plan->model().inputs().size());
- _sinks.resize(_plan->model().outputs().size());
+ _sources.resize(_plan->model().getInputs().size());
+ _sinks.resize(_plan->model().getOutputs().size());
}
public:
// TODO Remove this assumption
neurun::graph::operand::IO::Index input_index{index};
- const auto operand_index = execution->plan().model().inputs().at(input_index);
+ const auto operand_index = execution->plan().model().getInputs().at(input_index);
if (operands.at(operand_index).shape().rank() == 2)
{
// TODO Remove this assumption
neurun::graph::operand::IO::Index output_index{index};
- const auto operand_index = execution->plan().model().outputs().at(output_index);
+ const auto operand_index = execution->plan().model().getOutputs().at(output_index);
if (operands.at(operand_index).shape().rank() == 2)
{
const auto &model = plan.model();
// Set input(s)
- for (uint32_t n = 0; n < model.inputs().size(); ++n)
+ for (uint32_t n = 0; n < model.getInputs().size(); ++n)
{
auto setter = [&](::arm_compute::ITensor &tensor) { execution->source(n).push(tensor); };
neurun::graph::operand::IO::Index input_index{n};
- ::neurun::graph::operand::Index index{model.inputs().at(input_index)};
+ ::neurun::graph::operand::Index index{model.getInputs().at(input_index)};
auto objects = plan.operands().at(index);
for (auto object : objects)
}
// Get output(s)
- for (uint32_t n = 0; n < model.outputs().size(); ++n)
+ for (uint32_t n = 0; n < model.getOutputs().size(); ++n)
{
auto getter = [&](::arm_compute::ITensor &tensor) { execution->sink(n).pull(tensor); };
neurun::graph::operand::IO::Index output_index{n};
- ::neurun::graph::operand::Index index{model.outputs().at(output_index)};
+ ::neurun::graph::operand::Index index{model.getOutputs().at(output_index)};
auto objects = plan.operands().at(index);
for (auto object : objects)
return;
visited[index.asInt()] = true;
- auto outputs = node.outputs();
+ auto outputs = node.getOutputs();
for (auto output : outputs.list())
{
// TODO Fix traversing algorithm
// Every time need to search for operations that has `outgoing` as incoming from all
// operations but we can hold that info cached
graph._operations.iterate([&](const operation::Index &cand_index, NodeRef cand_node) -> void {
- auto inputs = cand_node.inputs();
+ auto inputs = cand_node.getInputs();
for (auto input : inputs.list())
{
if (output == input)
// Accessors
public:
- const operand::IndexSet &inputs() const { return _inputs; }
- const operand::IndexSet &outputs() const { return _outputs; }
+ const operand::IndexSet &getInputs() const { return _inputs; }
+ const operand::IndexSet &getOutputs() const { return _outputs; }
const operand::Set &operands() const { return _operands; }
operand::Set &operands() { return _operands; } // TODO Remove this non-const accessor
const operation::Set &operations() const { return _operations; }
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
_op->param().ifm_index = indexes.at(index).asInt();
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override { return {_op->param().ifm_index}; }
- virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getInputs() const override { return {_op->param().ifm_index}; }
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().ofm_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-operand::IndexSet Node::inputs() const
+operand::IndexSet Node::getInputs() const
{
operand::IndexSet set;
for (auto index : _op->param().ifm_indexes)
return set;
}
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
std::vector<int32_t> inds;
for (auto index : indexes.list())
_op->param().ifm_indexes = inds;
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override;
- virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getInputs() const override;
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().ofm_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
_op->param().ifm_index = indexes.at(index).asInt();
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override
+ virtual operand::IndexSet getInputs() const override
{
return {_op->param().ifm_index, _op->param().ker_index, _op->param().bias_index};
}
- virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().ofm_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
_op->param().input_index = indexes.at(index).asInt();
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override
+ virtual operand::IndexSet getInputs() const override
{
return {_op->param().input_index, _op->param().weight_index, _op->param().bias_index};
}
- virtual operand::IndexSet outputs() const override { return {_op->param().output_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().output_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
_op->param().ifm_index = indexes.at(index).asInt();
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override { return {_op->param().ifm_index}; }
- virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getInputs() const override { return {_op->param().ifm_index}; }
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().ofm_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-operand::IndexSet Node::inputs() const
+operand::IndexSet Node::getInputs() const
{
operand::IndexSet set;
for (auto index : _op->param().ifm_indexes)
return set;
}
-operand::IndexSet Node::outputs() const
+operand::IndexSet Node::getOutputs() const
{
operand::IndexSet set;
for (auto index : _op->param().ofm_indexes)
return set;
}
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
std::vector<int32_t> inds;
for (auto index : indexes.list())
_op->param().ifm_indexes = inds;
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
std::vector<int32_t> inds;
for (auto index : indexes.list())
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override;
- virtual operand::IndexSet outputs() const override;
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getInputs() const override;
+ virtual operand::IndexSet getOutputs() const override;
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
virtual void accept(NodeVisitor &&) const = 0;
public:
- virtual operand::IndexSet inputs() const = 0;
- virtual operand::IndexSet outputs() const = 0;
+ virtual operand::IndexSet getInputs() const = 0;
+ virtual operand::IndexSet getOutputs() const = 0;
// It's for only input/output tensors but const data.
- virtual void inputs(const operand::IndexSet &indexes) = 0;
- virtual void outputs(const operand::IndexSet &indexes) = 0;
+ virtual void setInputs(const operand::IndexSet &indexes) = 0;
+ virtual void setOutputs(const operand::IndexSet &indexes) = 0;
virtual const ::internal::tflite::op::Node *op() const = 0;
public:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
_op->param().input_index = indexes.at(index).asInt();
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override
+ virtual operand::IndexSet getInputs() const override
{
return {_op->param().input_index, _op->param().shape_index};
}
- virtual operand::IndexSet outputs() const override { return {_op->param().output_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().output_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-void Node::inputs(const operand::IndexSet &indexes)
+void Node::setInputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
_op->param().input_index = indexes.at(index).asInt();
}
-void Node::outputs(const operand::IndexSet &indexes)
+void Node::setOutputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
virtual void accept(NodeVisitor &&) const override;
public:
- virtual operand::IndexSet inputs() const override { return {_op->param().input_index}; }
- virtual operand::IndexSet outputs() const override { return {_op->param().output_index}; }
- virtual void inputs(const operand::IndexSet &indexes) override;
- virtual void outputs(const operand::IndexSet &indexes) override;
+ virtual operand::IndexSet getInputs() const override { return {_op->param().input_index}; }
+ virtual operand::IndexSet getOutputs() const override { return {_op->param().output_index}; }
+ virtual void setInputs(const operand::IndexSet &indexes) override;
+ virtual void setOutputs(const operand::IndexSet &indexes) override;
virtual const ::internal::tflite::op::Node *op() const override { return _op.get(); }
private:
visited[index.value()] = true;
on_stack[index.value()] = true;
- auto outputs = node.outputs();
+ auto outputs = node.getOutputs();
for (auto output : outputs.list())
{
// TODO Fix traversing algorithm
// Every time need to search for operations that has `outgoing` as incoming from all
// operations but we can hold that info cached
operations.iterate([&](const operation::Index &cand_index, const operation::Node &cand_node) {
- auto inputs = cand_node.inputs();
+ auto inputs = cand_node.getInputs();
for (auto input : inputs.list())
{
if (output == input)
graph.addOutput({index11});
graph.addOutput({index12});
- ASSERT_EQ(graph.inputs().size(), 2);
- ASSERT_EQ(graph.outputs().size(), 3);
+ ASSERT_EQ(graph.getInputs().size(), 2);
+ ASSERT_EQ(graph.getOutputs().size(), 3);
::neurun::graph::operand::IO::Index io_index0{0};
::neurun::graph::operand::IO::Index io_index1{1};
::neurun::graph::operand::IO::Index io_index2{2};
- ASSERT_EQ(graph.inputs().at(io_index0), 0);
- ASSERT_EQ(graph.inputs().at(io_index1), 1);
+ ASSERT_EQ(graph.getInputs().at(io_index0), 0);
+ ASSERT_EQ(graph.getInputs().at(io_index1), 1);
- ASSERT_EQ(graph.outputs().at(io_index0), 10);
- ASSERT_EQ(graph.outputs().at(io_index1), 11);
- ASSERT_EQ(graph.outputs().at(io_index2), 12);
+ ASSERT_EQ(graph.getOutputs().at(io_index0), 10);
+ ASSERT_EQ(graph.getOutputs().at(io_index1), 11);
+ ASSERT_EQ(graph.getOutputs().at(io_index2), 12);
}
virtual void accept(neurun::graph::operation::NodeVisitor &&) const override {}
public:
- virtual neurun::graph::operand::IndexSet inputs() const { return {1, 2, 3, 4}; }
- virtual neurun::graph::operand::IndexSet outputs() const { return {1, 2, 3}; }
- virtual void inputs(const neurun::graph::operand::IndexSet &indexes) override {}
- virtual void outputs(const neurun::graph::operand::IndexSet &indexes) override {}
+ virtual neurun::graph::operand::IndexSet getInputs() const { return {1, 2, 3, 4}; }
+ virtual neurun::graph::operand::IndexSet getOutputs() const { return {1, 2, 3}; }
+ virtual void setInputs(const neurun::graph::operand::IndexSet &indexes) override {}
+ virtual void setOutputs(const neurun::graph::operand::IndexSet &indexes) override {}
virtual const ::internal::tflite::op::Node *op() const { return nullptr; }
};
Set set;
set.append(std::unique_ptr<Node>(new TestNode()));
Index idx{0u};
- ASSERT_EQ(set.at(idx).inputs().size(), 4);
- ASSERT_EQ(set.at(idx).outputs().size(), 3);
+ ASSERT_EQ(set.at(idx).getInputs().size(), 4);
+ ASSERT_EQ(set.at(idx).getOutputs().size(), 3);
}
auto conv = nnfw::make_unique<GraphNode>(
nnfw::make_unique<Node>(Param(7, params.data(), 1, &outoperand)));
- ASSERT_EQ(conv->inputs().at(Index{0}).asInt(), params[0]);
- conv->inputs({8});
- ASSERT_NE(conv->inputs().at(Index{0}).asInt(), params[0]);
- ASSERT_EQ(conv->inputs().at(Index{0}).asInt(), 8);
+ ASSERT_EQ(conv->getInputs().at(Index{0}).asInt(), params[0]);
+ conv->setInputs({8});
+ ASSERT_NE(conv->getInputs().at(Index{0}).asInt(), params[0]);
+ ASSERT_EQ(conv->getInputs().at(Index{0}).asInt(), 8);
}
TEST(graph_operation_setIO, operation_setIO_concat)
auto concat = nnfw::make_unique<GraphNode>(
nnfw::make_unique<Node>(Param(7, params.data(), 1, &outoperand)));
- ASSERT_EQ(concat->inputs().size(), 6);
- ASSERT_EQ(concat->inputs().at(Index{0}).asInt(), params[0]);
+ ASSERT_EQ(concat->getInputs().size(), 6);
+ ASSERT_EQ(concat->getInputs().at(Index{0}).asInt(), params[0]);
- concat->inputs({80, 6, 9, 11});
- ASSERT_EQ(concat->inputs().size(), 4);
- ASSERT_NE(concat->inputs().at(Index{0}).asInt(), params[0]);
- ASSERT_EQ(concat->inputs().at(Index{0}).asInt(), 80);
- ASSERT_EQ(concat->inputs().at(Index{2}).asInt(), 9);
- ASSERT_THROW(concat->inputs().at(Index{5}), std::out_of_range);
+ concat->setInputs({80, 6, 9, 11});
+ ASSERT_EQ(concat->getInputs().size(), 4);
+ ASSERT_NE(concat->getInputs().at(Index{0}).asInt(), params[0]);
+ ASSERT_EQ(concat->getInputs().at(Index{0}).asInt(), 80);
+ ASSERT_EQ(concat->getInputs().at(Index{2}).asInt(), 9);
+ ASSERT_THROW(concat->getInputs().at(Index{5}), std::out_of_range);
}
virtual void accept(neurun::graph::operation::NodeVisitor &&) const override {}
public:
- virtual neurun::graph::operand::IndexSet inputs() const override { return {_input}; }
- virtual neurun::graph::operand::IndexSet outputs() const override { return {_output}; }
- virtual void inputs(const neurun::graph::operand::IndexSet &indexes) override {}
- virtual void outputs(const neurun::graph::operand::IndexSet &indexes) override {}
+ virtual neurun::graph::operand::IndexSet getInputs() const override { return {_input}; }
+ virtual neurun::graph::operand::IndexSet getOutputs() const override { return {_output}; }
+ virtual void setInputs(const neurun::graph::operand::IndexSet &indexes) override {}
+ virtual void setOutputs(const neurun::graph::operand::IndexSet &indexes) override {}
virtual const ::internal::tflite::op::Node *op() const override { return nullptr; }
private: