// Open interpreter session
locomotiv::Session sess(graph);
-for (uint32_t i = 0; i < graph->inputs()->size(); ++i)
+for (uint32_t i = 0; i < s.input_size(); ++i)
{
Buffer<type> buffer;
// ... building buffer ...
/// @brief Free all node annotations of the graph assigned by this Session
~Session();
+ /// @brief Get number of graph inputs held by this Session
+ uint32_t input_size() const { return _graph->inputs()->size(); }
+
/**
* @brief Set graph input at specific index by NodeData.
*
*/
void infer();
+ /// @brief Get number of graph outputs held by this Session
+ uint32_t output_size() const { return _graph->outputs()->size(); }
+
/**
* @brief Get output of graph as NodeData
*
using nncc::core::ADT::tensor::LexicalLayout;
using nncc::core::ADT::tensor::make_buffer;
+TEST(Session, graph_IO_size)
+{
+ // Make graph
+ auto g = loco::make_graph();
+
+ // inputs
+ const uint32_t inputs = 2;
+ for (uint32_t i = 0; i < inputs; ++i)
+ {
+ auto pull = g->nodes()->create<loco::Pull>();
+ g->inputs()->create()->node(pull);
+ }
+
+ // outputs
+ const uint32_t outputs = 3;
+ for (uint32_t o = 0; o < outputs; ++o)
+ {
+ auto push = g->nodes()->create<loco::Push>();
+ g->outputs()->create()->node(push);
+ }
+
+ // Make session
+ locomotiv::Session s(g.get());
+
+ ASSERT_EQ(s.input_size(), inputs);
+ ASSERT_EQ(s.output_size(), outputs);
+}
+
TEST(Session, set_input)
{
// Make graph