Skip to content

Commit d12bf3f

Browse files
authored
Remove random selection fallback when signature def not found (#88)
* Removing random tag selector * Fix closing brace * Copyright year * Consistent punctuation. * Keep previous default behavior
1 parent 79aa290 commit d12bf3f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

mirror/tensorflow_backend_tf.cc

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright 2019-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Redistribution and use in source and binary forms, with or without
44
// modification, are permitted provided that the following conditions
@@ -990,18 +990,23 @@ TRITONTF_ModelCreateFromSavedModel(
990990
auto sig_itr =
991991
bundle->meta_graph_def.signature_def().find(SIGNATURE_DEF_KEY_TO_USE);
992992
if (sig_itr == bundle->meta_graph_def.signature_def().end()) {
993-
// If default serving signature_def key is not found, maybe it is named
994-
// something else, use one that is neither init_op key nor train_op key
995-
for (sig_itr = bundle->meta_graph_def.signature_def().begin();
996-
sig_itr != bundle->meta_graph_def.signature_def().end(); sig_itr++) {
997-
if ((sig_itr->first != INIT_OP_SIGNATURE_DEF_KEY) &&
998-
(sig_itr->first != TRAIN_OP_SIGNATURE_DEF_KEY)) {
999-
LOG(WARNING) << "unable to find serving signature '"
1000-
<< SIGNATURE_DEF_KEY_TO_USE;
1001-
LOG(WARNING) << "using signature '" << sig_itr->first << "'";
1002-
break;
993+
// If serving signature_def key is not specified and default is not found,
994+
// maybe it is named something else. Use one that is neither init_op key
995+
// nor train_op key
996+
if (strcmp(signature_def, "") == 0) {
997+
for (sig_itr = bundle->meta_graph_def.signature_def().begin();
998+
sig_itr != bundle->meta_graph_def.signature_def().end(); sig_itr++) {
999+
if ((sig_itr->first != INIT_OP_SIGNATURE_DEF_KEY) &&
1000+
(sig_itr->first != TRAIN_OP_SIGNATURE_DEF_KEY)) {
1001+
LOG(WARNING) << "unable to find serving signature '"
1002+
<< SIGNATURE_DEF_KEY_TO_USE;
1003+
LOG(WARNING) << "using signature '" << sig_itr->first << "'";
1004+
break;
1005+
}
10031006
}
10041007
}
1008+
1009+
// If serving signature_def key is not found, return error
10051010
if (sig_itr == bundle->meta_graph_def.signature_def().end()) {
10061011
return TRITONTF_ErrorNew(
10071012
"unable to load model '" + std::string(model_name) + "', expected '" +
@@ -1184,6 +1189,6 @@ TRITONTF_LoadAndRegisterLibrary(const char* path)
11841189
if (status_code != TF_OK) {
11851190
return TRITONTF_ErrorNew(status_msg);
11861191
}
1187-
1192+
11881193
return nullptr;
11891194
}

0 commit comments

Comments
 (0)