Skip to content

Remove random selection fallback when signature def not found #88

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

Merged
merged 5 commits into from
Apr 3, 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
29 changes: 17 additions & 12 deletions mirror/tensorflow_backend_tf.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright 2019-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -990,18 +990,23 @@ TRITONTF_ModelCreateFromSavedModel(
auto sig_itr =
bundle->meta_graph_def.signature_def().find(SIGNATURE_DEF_KEY_TO_USE);
if (sig_itr == bundle->meta_graph_def.signature_def().end()) {
// If default serving signature_def key is not found, maybe it is named
// something else, use one that is neither init_op key nor train_op key
for (sig_itr = bundle->meta_graph_def.signature_def().begin();
sig_itr != bundle->meta_graph_def.signature_def().end(); sig_itr++) {
if ((sig_itr->first != INIT_OP_SIGNATURE_DEF_KEY) &&
(sig_itr->first != TRAIN_OP_SIGNATURE_DEF_KEY)) {
LOG(WARNING) << "unable to find serving signature '"
<< SIGNATURE_DEF_KEY_TO_USE;
LOG(WARNING) << "using signature '" << sig_itr->first << "'";
break;
// If serving signature_def key is not specified and default is not found,
// maybe it is named something else. Use one that is neither init_op key
// nor train_op key
if (strcmp(signature_def, "") == 0) {
for (sig_itr = bundle->meta_graph_def.signature_def().begin();
sig_itr != bundle->meta_graph_def.signature_def().end(); sig_itr++) {
if ((sig_itr->first != INIT_OP_SIGNATURE_DEF_KEY) &&
(sig_itr->first != TRAIN_OP_SIGNATURE_DEF_KEY)) {
LOG(WARNING) << "unable to find serving signature '"
<< SIGNATURE_DEF_KEY_TO_USE;
LOG(WARNING) << "using signature '" << sig_itr->first << "'";
break;
}
}
}

// If serving signature_def key is not found, return error
if (sig_itr == bundle->meta_graph_def.signature_def().end()) {
return TRITONTF_ErrorNew(
"unable to load model '" + std::string(model_name) + "', expected '" +
Expand Down Expand Up @@ -1184,6 +1189,6 @@ TRITONTF_LoadAndRegisterLibrary(const char* path)
if (status_code != TF_OK) {
return TRITONTF_ErrorNew(status_msg);
}

return nullptr;
}