12#include "lwtnn/Exceptions.hh"
19 std::vector<size_t> get_value_indices(
20 const std::vector<std::string>& order,
21 const std::vector<lwt::Input>& inputs)
23 std::map<std::string, size_t> order_indices;
24 for (
size_t i = 0;
i <
order.size();
i++) {
25 order_indices[
order.at(i)] =
i;
27 std::vector<size_t> value_indices;
28 for (
const lwt::Input& input: inputs) {
29 if (!order_indices.count(
input.name)) {
30 throw lwt::NNConfigurationException(
"Missing input " +
input.name);
32 value_indices.push_back(order_indices.at(
input.name));
45 const std::vector<Input>& inputs,
46 const std::vector<std::string>& order):
51 for (
const auto& input: inputs) {
56 m_indices = get_value_indices(order, inputs);
60 size_t input_number = 0;
62 if (
static_cast<int>(
index) >= in.rows()) {
63 throw NNEvaluationException(
64 "index " + std::to_string(
index) +
" is out of range, scalar "
65 "input only has " + std::to_string(in.rows()) +
" entries");
67 invec(input_number) = in(
index);
76 const std::vector<Input>& inputs,
77 const std::vector<std::string>& order):
82 for (
const auto& input: inputs) {
90 throw NNConfigurationException(
"need at least one input");
92 m_indices = get_value_indices(order, inputs);
95 using namespace Eigen;
96 size_t n_cols = in.cols();
100 if (
static_cast<int>(
index) >= in.rows()) {
101 throw NNEvaluationException(
102 "index " + std::to_string(
index) +
" is out of range, sequence "
103 "input only has " + std::to_string(in.rows()) +
" entries");
105 inmat.row(in_num) = in.row(
index);
Ensure that the extensions for the Vector3D are properly loaded.