Home / Function/ randomize_input() — pytorch Function Reference

randomize_input() — pytorch Function Reference

Architecture documentation for the randomize_input() function in common.py from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  d0c96460_b5ec_95d1_765a_084b5860c03d["randomize_input()"]
  f5d4c5a3_21f5_4ed1_f582_7d73c454a4d7["latency_experiment()"]
  f5d4c5a3_21f5_4ed1_f582_7d73c454a4d7 -->|calls| d0c96460_b5ec_95d1_765a_084b5860c03d
  04a3a4a6_8db3_854d_a893_02c9542bf9dd["speedup_experiment()"]
  04a3a4a6_8db3_854d_a893_02c9542bf9dd -->|calls| d0c96460_b5ec_95d1_765a_084b5860c03d
  ce8fd365_4112_b289_9c73_7345d5e35203["RuntimeError()"]
  d0c96460_b5ec_95d1_765a_084b5860c03d -->|calls| ce8fd365_4112_b289_9c73_7345d5e35203
  style d0c96460_b5ec_95d1_765a_084b5860c03d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmarks/dynamo/common.py lines 866–887

def randomize_input(inputs):
    if isinstance(inputs, (list, tuple)):
        return type(inputs)([randomize_input(x) for x in inputs])
    elif isinstance(inputs, torch.Tensor):
        if inputs.dtype in (torch.float32, torch.float64):
            torch._dynamo.utils.counters["randomize_input"]["times"] += 1
            return torch.randn_like(inputs)
        elif inputs.dtype == torch.int64:
            # Note: we can not simply tune integer tensors as follows
            #   `return torch.randint_like(inputs, high=inputs.max().item())`
            # This may break some invariants between tensors.
            # E.g. in embedding lookup case, one tensor is the length
            # and another is an indices tensor.
            return inputs
        else:
            raise RuntimeError(
                f"randomize_input need support tensor of type {inputs.dtype}"
            )
    else:
        raise RuntimeError(
            f"randomize_input can not handle input of type {type(inputs)}"
        )

Subdomains

Frequently Asked Questions

What does randomize_input() do?
randomize_input() is a function in the pytorch codebase.
What does randomize_input() call?
randomize_input() calls 1 function(s): RuntimeError.
What calls randomize_input()?
randomize_input() is called by 2 function(s): latency_experiment, speedup_experiment.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free