#include "event.h"
#include "internal/Source.h"
+#include "graph/operand/Index.h"
//
// NNAPI Implementation
// NOTE The current implemenation assumes that every input is a feature map.
// TODO Remove this assumption
- const auto operand_index = execution->plan().model().inputs().at(index);
+ neurun::graph::operand::IO::Index input_index{index};
+
+ const auto operand_index = execution->plan().model().inputs().at(input_index);
if (operands.at(operand_index).shape().rank() == 2)
{
// NOTE The current implemenation assumes that every output is a feature map.
// TODO Remove this assumption
- const auto operand_index = execution->plan().model().outputs().list().at(index);
+ neurun::graph::operand::IO::Index output_index{index};
+
+ const auto operand_index = execution->plan().model().outputs().at(output_index);
if (operands.at(operand_index).shape().rank() == 2)
{
{
auto setter = [&](::arm_compute::ITensor &tensor) { execution->source(n).push(tensor); };
- ::internal::tflite::operand::Index index{model.inputs().at(n).asInt()};
+ neurun::graph::operand::IO::Index input_index{n};
+
+ ::internal::tflite::operand::Index index{model.inputs().at(input_index).asInt()};
auto objects = plan.operands().at(index);
for (auto object : objects)
{
auto getter = [&](::arm_compute::ITensor &tensor) { execution->sink(n).pull(tensor); };
- ::internal::tflite::operand::Index index{model.outputs().at(n).asInt()};
+ neurun::graph::operand::IO::Index output_index{n};
+
+ ::internal::tflite::operand::Index index{model.outputs().at(output_index).asInt()};
auto objects = plan.operands().at(index);
for (auto object : objects)
template <typename T, typename DummyTag> class Index
{
public:
- Index(T o) : _index{o} {}
- Index(int32_t o) : _index{static_cast<T>(o)} {} // For legacy code compatibility
+ explicit Index(T o) : _index{o} {}
+ explicit Index(int32_t o) : _index{static_cast<T>(o)} {} // For legacy code compatibility
Index(const Index<T, DummyTag> &o) : _index{o._index} {}
Index<T, DummyTag> &operator=(T o)
} // namespace graph
} // namespace neurun
+namespace neurun
+{
+namespace graph
+{
+namespace operand
+{
+namespace IO
+{
+
+using Index = ::neurun::graph::Index<uint32_t, struct IndexTag>;
+
+} // namespace IO
+} // namespace operand
+} // namespace graph
+} // namespace neurun
+
#endif // __NEURUN_GRAPH_OPERAND_INDEX_H__
public:
uint32_t size() const { return static_cast<uint32_t>(_set.size()); }
- const Index &at(uint32_t set_index) const { return _set.at(set_index); }
const std::vector<Index> &list() const { return _set; }
+ const Index &at(::neurun::graph::operand::IO::Index set_index) const
+ {
+ return _set.at(set_index.asInt());
+ }
private:
std::vector<Index> _set;
operand::IndexSet set;
for (auto index : _op->param().ifm_indexes)
{
- set.append({index});
+ operand::Index ind{index};
+ set.append({ind});
}
return set;
}
{
::neurun::graph::Graph graph;
- graph.addInput({0u});
- graph.addInput({1u});
+ ::neurun::graph::operand::Index index0{0u};
+ ::neurun::graph::operand::Index index1{1u};
- graph.addOutput({10u});
- graph.addOutput({11u});
- graph.addOutput({12u});
+ graph.addInput({index0});
+ graph.addInput({index1});
+
+ ::neurun::graph::operand::Index index10{10u};
+ ::neurun::graph::operand::Index index11{11u};
+ ::neurun::graph::operand::Index index12{12u};
+
+ graph.addOutput({index10});
+ graph.addOutput({index11});
+ graph.addOutput({index12});
ASSERT_EQ(graph.inputs().size(), 2);
ASSERT_EQ(graph.outputs().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.outputs().at(io_index0), 10);
+ ASSERT_EQ(graph.outputs().at(io_index1), 11);
+ ASSERT_EQ(graph.outputs().at(io_index2), 12);
}
TEST(graph_operand_IndexSet, index_set_test)
{
- IndexSet iset{0, 1, 2, 3};
+ IndexSet iset{0, 2, 4, 8};
ASSERT_EQ(iset.size(), 4);
- iset.append(Index{4});
+ iset.append(Index{10});
ASSERT_EQ(iset.size(), 5);
- ASSERT_EQ(iset.at(0), 0);
- ASSERT_EQ(iset.at(4), 4);
+ neurun::graph::operand::IO::Index index1{1};
+ neurun::graph::operand::IO::Index index2{4};
+
+ ASSERT_EQ(iset.at(index1), 2);
+ ASSERT_EQ(iset.at(index2), 10);
}