12 #include "lwtnn/lightweight_network_config.hh"
17 std::string formatSet(
const std::set<std::string>&
s) {
19 for (
const std::string&
var:
s) {
21 if (
var != *
s.rbegin())
out.append(
", ");
34 std::string first_match;
35 for (
const auto&
node: graph_cfg.inputs) {
36 for (
const auto&
var:
node.variables) {
37 const std::string&
name =
var.name;
41 for (
const auto&
var:
node.variables) {
42 k.fatjet.insert(
var.name);
44 }
else if (std::regex_match(
node.
name, subjet_match)) {
45 std::set<std::string> subjet_set;
46 for (
const auto&
var:
node.variables) {
47 subjet_set.insert(
var.name);
49 if (
k.n_subjets == 0) {
50 k.subjet = std::move(subjet_set);
52 }
else if (
k.subjet != subjet_set) {
53 std::string
error =
"mismatch in subjet keys: we expect the same"
54 " variables to be read from each subjet. ";
55 error.append(
"first subjet (" + first_match +
") "
56 + formatSet(
k.subjet) +
", match "
58 +
", (" +
node.
name +
") " + formatSet(subjet_set));
59 throw std::runtime_error(
error);
63 throw std::runtime_error(
"no way to match '" +
node.
name +
"'");