Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions tmva/sofie/test/test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@ runModel(std::string outputTypeName, std::string const &modelName, std::string s
outputTypeName = "std::tuple<std::vector<float>, std::vector<int64_t>>";
}

// Helper: map C++ type -> string used in interpreter
auto type_name = []<typename T>() {
if constexpr (std::is_same_v<T, int>)
return "int";
else if constexpr (std::is_same_v<T, std::vector<float>>)
return "std::vector<float>";
else if constexpr (std::is_same_v<T, std::vector<int>>)
return "std::vector<float>";
else if constexpr (std::is_same_v<T, std::vector<int64_t>>)
return "std::vector<int64_t>";
else if constexpr (std::is_same_v<T, std::vector<uint8_t>>)
return "std::vector<uint8_t>";
else
static_assert(!sizeof(T), "Input type not supported");
};

std::stringstream cmd;

if (sessionArgs.empty()) {
Expand All @@ -104,15 +88,34 @@ runModel(std::string outputTypeName, std::string const &modelName, std::string s
}

// Emit all inputs to s.infer(...)
bool first = true;
(
[&] {
if (!first)
cmd << ", ";
first = false;
cmd << toInterpreter(inputs, type_name.template operator()<Ts>(), true);
}(),
...);
if constexpr (sizeof...(Ts) > 0) {

// Helper: map C++ type -> string used in interpreter
auto type_name = []<typename T>() {
if constexpr (std::is_same_v<T, int>)
return "int";
else if constexpr (std::is_same_v<T, std::vector<float>>)
return "std::vector<float>";
else if constexpr (std::is_same_v<T, std::vector<int>>)
return "std::vector<float>";
else if constexpr (std::is_same_v<T, std::vector<int64_t>>)
return "std::vector<int64_t>";
else if constexpr (std::is_same_v<T, std::vector<uint8_t>>)
return "std::vector<uint8_t>";
else
static_assert(!sizeof(T), "Input type not supported");
};

bool first = true;
(
[&] {
if (!first)
cmd << ", ";
first = false;
cmd << toInterpreter(inputs, type_name.template operator()<Ts>(), true);
}(),
...);
}

cmd << R"();
std::swap(output, *)"
Expand Down
Loading