message: [tf-signal] Avoid conditionals in window functions if the window length is known statically.
diff: @@ -23,6 +23,7 @@ import numpy as np
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  +from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  @@ -105,6 +106,9 @@ def _raised_cosine_window(name, default_name, window_length, periodic,
  window_length = ops.convert_to_tensor(window_length, dtype=dtypes.int32,
  name='window_length')
  window_length.shape.assert_has_rank(0)
  + window_length_const = tensor_util.constant_value(window_length)
  + if window_length_const == 1:
  + return array_ops.ones([1], dtype=dtype)
  periodic = math_ops.cast(
  ops.convert_to_tensor(periodic, dtype=dtypes.bool, name='periodic'),
  dtypes.int32)
  @@ -115,6 +119,8 @@ def _raised_cosine_window(name, default_name, window_length, periodic,
  count = math_ops.cast(math_ops.range(window_length), dtype)
  cos_arg = constant_op.constant(2 * np.pi, dtype=dtype) * count / n
  + if window_length_const is not None:
  + return math_ops.cast(a - b * math_ops.cos(cos_arg), dtype=dtype)
  return control_flow_ops.cond(
  math_ops.equal(window_length, 1),
  lambda: array_ops.ones([1], dtype=dtype),
  