def _skip_single_var(self, var, delta):
   resource_variable_ops.variable_accessed(var)
   # TODO(wangpeng): Cache the cast algorithm instead of casting everytime.
   return gen_stateful_random_ops.rng_read_and_skip(
       var.handle,
       alg=math_ops.cast(self.algorithm, dtypes.int32),
       delta=math_ops.cast(delta, dtypes.uint64))
示例#2
0
  def skip(self, delta):
    """Advance the counter of a counter-based RNG.

    Args:
      delta: the amount of advancement. The state of the RNG after
        `skip(n)` will be the same as that after `normal([n])`
        (or any other distribution). The actual increment added to the
        counter is an unspecified implementation detail.
    """
    if compat.forward_compatible(2020, 10, 25):
      return gen_stateful_random_ops.rng_read_and_skip(
          self.state.handle,
          alg=math_ops.cast(self.algorithm, dtypes.int32),
          delta=math_ops.cast(delta, dtypes.uint64))
    gen_stateful_random_ops.rng_skip(
        self.state.handle, math_ops.cast(self.algorithm, dtypes.int64),
        math_ops.cast(delta, dtypes.int64))