Skip to content

Commit

Permalink
fix: Improve error message when validating IO config (#353)
Browse files Browse the repository at this point in the history
* Fix/Improve error message when validating IO config

* fix format

* Fix the namespace

* Remove extra space
  • Loading branch information
tanmayv25 authored Jun 12, 2024
1 parent 10bcbd9 commit 8398c86
Showing 1 changed file with 15 additions and 8 deletions.
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

0 comments on commit 8398c86

Please sign in to comment.