Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve error message when validating IO config #353

Merged
merged 4 commits into from
Jun 12, 2024
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
23 changes: 15 additions & 8 deletions src/model_config_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,19 @@ ValidateIOShape(
Status::Code::INVALID_ARG, message_prefix + "must specify 'name'");
}

std::string message_prefix_with_name =
message_prefix + std::string("'" + io.name() + "' ");

if (io.data_type() == inference::DataType::TYPE_INVALID) {
return Status(
Status::Code::INVALID_ARG, "model output must specify 'data_type'");
Status::Code::INVALID_ARG,
message_prefix_with_name + "must specify 'data_type'");
}

if (io.dims_size() == 0) {
return Status(
Status::Code::INVALID_ARG, message_prefix + "must specify 'dims'");
Status::Code::INVALID_ARG,
message_prefix_with_name + "must specify 'dims'");
}

// If the configuration is non-batching, then no input or output
Expand All @@ -319,7 +324,7 @@ ValidateIOShape(
(max_batch_size == 0)) {
return Status(
Status::Code::INVALID_ARG,
message_prefix +
message_prefix_with_name +
"cannot have empty reshape for non-batching model as scalar "
"tensors are not supported");
}
Expand All @@ -329,7 +334,7 @@ ValidateIOShape(
if ((dim < 1) && (dim != triton::common::WILDCARD_DIM)) {
return Status(
Status::Code::INVALID_ARG,
message_prefix + "dimension must be integer >= 1, or " +
message_prefix_with_name + "dimension must be integer >= 1, or " +
std::to_string(triton::common::WILDCARD_DIM) +
" to indicate a variable-size dimension");
}
Expand All @@ -341,7 +346,8 @@ ValidateIOShape(
if ((dim < 1) && (dim != triton::common::WILDCARD_DIM)) {
return Status(
Status::Code::INVALID_ARG,
message_prefix + "reshape dimensions must be integer >= 1, or " +
message_prefix_with_name +
"reshape dimensions must be integer >= 1, or " +
std::to_string(triton::common::WILDCARD_DIM) +
" to indicate a variable-size dimension");
}
Expand All @@ -359,7 +365,7 @@ ValidateIOShape(
((reshape_size != 0) || (dims_size != 1))) {
return Status(
Status::Code::INVALID_ARG,
message_prefix + "has different size for dims and reshape");
message_prefix_with_name + "has different size for dims and reshape");
}

// shape contains variable-size dimension, in this case we compare if
Expand Down Expand Up @@ -394,15 +400,16 @@ ValidateIOShape(
if (dim_element_cnts.size() != reshape_element_cnts.size()) {
return Status(
Status::Code::INVALID_ARG,
message_prefix +
message_prefix_with_name +
"has different number of variable-size dimensions for dims "
"and reshape");
}
for (size_t idx = 0; idx < dim_element_cnts.size(); idx++) {
if (dim_element_cnts[idx] != reshape_element_cnts[idx]) {
return Status(
Status::Code::INVALID_ARG,
message_prefix + "has different size for dims and reshape");
message_prefix_with_name +
"has different size for dims and reshape");
}
}
}
Expand Down
Loading