message: Revive the use of constant_value workaround, since it seems that logical ops are still considerably slower on GPU. Fixes Partially addresses
diff: @@ -522,14 +522,23 @@ def _tf_range_for_stmt(
  iterate.value += delta
  def aug_test():
  + # TODO(b/159713842): Remove once constant folding works.
  + const_delta = tensor_util.constant_value(delta)
  + if const_delta is not None:
  + if const_delta >= 0:
  + main_test = iterate.value < limit
  + else:
  + main_test = iterate.value > limit
  + else:
  main_test = math_ops.logical_or(
  math_ops.logical_and(delta >= 0, iterate.value < limit),
  math_ops.logical_and(delta < 0, iterate.value > limit))
  +
  if extra_test is not None:
  - return control_flow_ops.cond(main_test, extra_test, lambda: False)
  + main_test = control_flow_ops.cond(main_test, extra_test, lambda: False)
  return main_test
  - # TODO(b/159186914): Remove.
  + # TODO(b/134181679): Remove.
  if not control_flow_util.GraphOrParentsInXlaContext(ops.get_default_graph()):
  opts['maximum_iterations'] = math_ops.cast(
  misc.get_range_len(start, limit, delta), dtypes.int32)
  