This commit implements how session get its output. Related test for this
feature added as well.
Signed-off-by: Cheongyo Bahk <ch.bahk@samsung.com>
*/
void infer();
+ /**
+ * @brief Get output of graph as NodeData
+ *
+ * @note May return nullptr, for example, when graph output not yet calculated
+ */
const NodeData *get_output(uint32_t index);
private:
}
}
+const NodeData *Session::get_output(uint32_t index)
+{
+ auto output_node = _graph->outputs()->at(index)->node();
+ return annot_data(output_node);
+}
+
} // namespace locomotiv
// Multiple run is possible
ASSERT_NO_THROW(s.infer());
- // TODO get and check output
+ auto output_data = s.get_output(0);
+ ASSERT_NE(output_data, nullptr);
+ ASSERT_EQ(output_data->dtype(), loco::DataType::FLOAT32);
+ ASSERT_EQ(*(output_data->shape()), Shape{1});
+ ASSERT_EQ(output_data->as_f32_bufptr()->at(Index{0}), 3.14f);
}
}