Skip to content

Commit

Permalink
tensorflow: replace try-except with if-else
Browse files Browse the repository at this point in the history
  • Loading branch information
ymjiang committed Jun 29, 2019
1 parent 0138c6a commit d299643
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions byteps/tensorflow/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def _push_pull(tensor, scope='', name=None):
if name is None and not _executing_eagerly():
name = 'BytePSPushPull_%s' % _normalize_name(tensor.name)
if scope == '' and not _executing_eagerly():
try:
scope = tf.get_default_graph().get_name_scope()
except:
if 'v1' in dir(tf.compat):
scope = tf.compat.v1.get_default_graph().get_name_scope()
else:
scope = tf.get_default_graph().get_name_scope()
if scope != '':
scope += '/'
full_name = scope + name
Expand Down Expand Up @@ -118,10 +118,10 @@ def broadcast(tensor, root_rank, scope='', name=None, is_variable=True):
if name is None and not _executing_eagerly():
name = 'BytePSBroadcast_%s' % _normalize_name(tensor.name)
if scope == '' and not _executing_eagerly():
try:
scope = tf.get_default_graph().get_name_scope()
except:
if 'v1' in dir(tf.compat):
scope = tf.compat.v1.get_default_graph().get_name_scope()
else:
scope = tf.get_default_graph().get_name_scope()
if scope != '':
scope += '/'
full_name = scope + name
Expand Down

0 comments on commit d299643

Please sign in to comment.