in source/neuropod/internal/config_utils.cc [81:117]
std::vector<Dimension> get_dims_from_json(const Json::Value &json_shape)
{
// Make sure that the shape is an array
if (json_shape.isArray())
{
// The dims to return
std::vector<Dimension> out;
for (const auto &item : json_shape)
{
// Get the number and do some validation
// Each item in the array must be either null or a positive integer
if (item.isInt() && item.asInt64() > 0)
{
out.emplace_back(item.asInt64());
}
else if (item.isNull())
{
// A dim of size -1 means we won't check the size of that dim
out.emplace_back(-1);
}
else if (item.isString())
{
// It is a symbol
out.emplace_back(item.asString());
}
else
{
throw_neuropod_config_error(
"All items in 'shape' must be either null, a string, or a positive integer.");
}
}
return out;
}
throw_neuropod_config_error("'shape' must be an array. Please check your config file");
}