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 the checking for unexpected input name and count #92

Merged
merged 1 commit into from
Apr 28, 2023
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
24 changes: 18 additions & 6 deletions src/tensorflow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,24 @@ ValidateTRITONTFModel(

// Verify that the model configuration input and outputs match what
// is expected by the model.
// Check the name of each input first before checking the count to ensure that
// the error message returned includes the names of any unexpected extra
// inputs, instead of just a count mismatch error.
for (size_t i = 0; i < config_inputs.ArraySize(); i++) {
triton::common::TritonJson::Value io;
RETURN_IF_ERROR(config_inputs.IndexAsObject(i, &io));
RETURN_IF_ERROR(CheckAllowedModelInput(io, expected_inputs));

std::string io_name;
RETURN_IF_ERROR(io.MemberAsString("name", &io_name));
const TRITONTF_IO* input = FindIOByName(inputs, io_name);
if (input == nullptr) {
return TRITONSERVER_ErrorNew(
TRITONSERVER_ERROR_INTERNAL,
std::string("unexpected inference input '" + io_name + "'").c_str());
}
}

if (expected_inputs.size() != expected_input_cnt) {
return TRITONSERVER_ErrorNew(
TRITONSERVER_ERROR_INVALID_ARG,
Expand All @@ -330,16 +348,10 @@ ValidateTRITONTFModel(
for (size_t i = 0; i < config_inputs.ArraySize(); i++) {
triton::common::TritonJson::Value io;
RETURN_IF_ERROR(config_inputs.IndexAsObject(i, &io));
RETURN_IF_ERROR(CheckAllowedModelInput(io, expected_inputs));

std::string io_name;
RETURN_IF_ERROR(io.MemberAsString("name", &io_name));
const TRITONTF_IO* input = FindIOByName(inputs, io_name);
if (input == nullptr) {
return TRITONSERVER_ErrorNew(
TRITONSERVER_ERROR_INTERNAL,
std::string("unexpected inference input '" + io_name + "'").c_str());
}

// If a reshape is provided for the input then use that when
// validating that the TF model matches what is expected.
Expand Down