From 4e5768769159923cd19feff3d6e5dfccb97d5b9c Mon Sep 17 00:00:00 2001 From: Ziqi Fan Date: Mon, 31 Mar 2025 15:16:14 -0700 Subject: [PATCH 1/3] refactor: return error if tensorflow related configs are found by AutoCompleteBackendFields --- src/model_config_utils.cc | 78 +++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/src/model_config_utils.cc b/src/model_config_utils.cc index a182fe397..327b1aa08 100644 --- a/src/model_config_utils.cc +++ b/src/model_config_utils.cc @@ -1072,55 +1072,43 @@ AutoCompleteBackendFields( // Trying to fill the 'backend', 'default_model_filename' field. - // TensorFlow - // For TF backend, the platform is required - if (config->platform().empty()) { - // Check 'backend', 'default_model_filename', and the actual directory - // to determine the platform - if (config->backend().empty() || - (config->backend() == kTensorFlowBackend)) { - if (config->default_model_filename() == kTensorFlowSavedModelFilename) { - config->set_platform(kTensorFlowSavedModelPlatform); - } else if ( - config->default_model_filename() == kTensorFlowGraphDefFilename) { - config->set_platform(kTensorFlowGraphDefPlatform); - } else if (config->default_model_filename().empty() && has_version) { - bool is_dir = false; - if (version_dir_content.find(kTensorFlowSavedModelFilename) != - version_dir_content.end()) { - RETURN_IF_ERROR(IsDirectory( - JoinPath({version_path, kTensorFlowSavedModelFilename}), - &is_dir)); - if (is_dir) { - config->set_platform(kTensorFlowSavedModelPlatform); - } - } - if (version_dir_content.find(kTensorFlowGraphDefFilename) != - version_dir_content.end()) { - RETURN_IF_ERROR(IsDirectory( - JoinPath({version_path, kTensorFlowGraphDefFilename}), &is_dir)); - if (!is_dir) { - config->set_platform(kTensorFlowGraphDefPlatform); - } - } + // TensorFlow is not supported since version 25.03. + // Return error if TensorFlow is found being set or TensorFlow models are + // found in the version directory. + if ((config->backend() == kTensorFlowBackend) || + (config->platform() == kTensorFlowSavedModelPlatform) || + (config->platform() == kTensorFlowGraphDefPlatform) || + (config->default_model_filename() == kTensorFlowSavedModelFilename) || + (config->default_model_filename() == kTensorFlowGraphDefFilename)) { + return Status( + Status::Code::INVALID_ARG, + "TensorFlow backend is not supported since version 25.03, please do " + "NOT set backend, platform or default_model_filename related to " + "TensorFlow."); + } else if (has_version) { + bool is_dir = false; + if (version_dir_content.find(kTensorFlowSavedModelFilename) != + version_dir_content.end()) { + RETURN_IF_ERROR(IsDirectory( + JoinPath({version_path, kTensorFlowSavedModelFilename}), &is_dir)); + if (is_dir) { + return Status( + Status::Code::INVALID_ARG, + "TensorFlow is not supported since version 25.03, however, " + + kTensorFlowSavedModelFilename + " dir is found."); } } - } - - // Fill 'backend' and 'default_model_filename' if missing - if ((config->platform() == kTensorFlowSavedModelPlatform) || - (config->platform() == kTensorFlowGraphDefPlatform)) { - if (config->backend().empty()) { - config->set_backend(kTensorFlowBackend); - } - if (config->default_model_filename().empty()) { - if (config->platform() == kTensorFlowSavedModelPlatform) { - config->set_default_model_filename(kTensorFlowSavedModelFilename); - } else { - config->set_default_model_filename(kTensorFlowGraphDefFilename); + if (version_dir_content.find(kTensorFlowGraphDefFilename) != + version_dir_content.end()) { + RETURN_IF_ERROR(IsDirectory( + JoinPath({version_path, kTensorFlowGraphDefFilename}), &is_dir)); + if (!is_dir) { + return Status( + Status::Code::INVALID_ARG, + "TensorFlow is not supported for version >= 25.03, however, " + + kTensorFlowGraphDefFilename + " file is found."); } } - return Status::Success; } // TensorRT From 0aad1dc30d0b5cf2a957de1cf31b829877e2e933 Mon Sep 17 00:00:00 2001 From: Ziqi Fan Date: Tue, 1 Apr 2025 10:18:59 -0700 Subject: [PATCH 2/3] update copyright --- src/model_config_utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model_config_utils.cc b/src/model_config_utils.cc index 327b1aa08..ce60c4a60 100644 --- a/src/model_config_utils.cc +++ b/src/model_config_utils.cc @@ -1,4 +1,4 @@ -// Copyright 2018-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// Copyright 2018-2025, 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 From b82eac37c4603cb98985e603e4af38229c2ffe4c Mon Sep 17 00:00:00 2001 From: Ziqi Fan Date: Tue, 1 Apr 2025 10:38:03 -0700 Subject: [PATCH 3/3] fix string --- src/model_config_utils.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/model_config_utils.cc b/src/model_config_utils.cc index ce60c4a60..1cb7e9cf5 100644 --- a/src/model_config_utils.cc +++ b/src/model_config_utils.cc @@ -1094,7 +1094,8 @@ AutoCompleteBackendFields( if (is_dir) { return Status( Status::Code::INVALID_ARG, - "TensorFlow is not supported since version 25.03, however, " + + std::string( + "TensorFlow is not supported since version 25.03, however, ") + kTensorFlowSavedModelFilename + " dir is found."); } } @@ -1105,7 +1106,8 @@ AutoCompleteBackendFields( if (!is_dir) { return Status( Status::Code::INVALID_ARG, - "TensorFlow is not supported for version >= 25.03, however, " + + std::string( + "TensorFlow is not supported for version >= 25.03, however, ") + kTensorFlowGraphDefFilename + " file is found."); } }