From a05bb5559f80ef1401bada468414e30161845713 Mon Sep 17 00:00:00 2001 From: Ongun Kanat Date: Fri, 28 Aug 2020 04:12:06 +0200 Subject: [PATCH] Use a ternary if for checking main_op is None Fixes a minor bug in saved_model which raises an exception since evaluating ops as booleans are forbidden in TF 2.x Fixes #38041 --- tensorflow/python/saved_model/builder_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/saved_model/builder_impl.py b/tensorflow/python/saved_model/builder_impl.py index 46b1fb57de2..51e3f55924d 100644 --- a/tensorflow/python/saved_model/builder_impl.py +++ b/tensorflow/python/saved_model/builder_impl.py @@ -534,7 +534,7 @@ class SavedModelBuilder(_SavedModelBuilder): # legacy_init_op is deprecated, and going away in TF 2.0. # Re-mapping to main_op, as treatment is identical regardless. - main_op = main_op or legacy_init_op + main_op = main_op if main_op is not None else legacy_init_op # Add assets and ops self._add_collections(assets_collection, main_op, None)