Home / Function/ benchmark() — pytorch Function Reference

benchmark() — pytorch Function Reference

Architecture documentation for the benchmark() function in kernels.py from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  02c5a438_2afc_6211_922d_df8faf0ed669["benchmark()"]
  5c0b54aa_ac77_fbf9_e176_6951222c00c4["get_shapes()"]
  02c5a438_2afc_6211_922d_df8faf0ed669 -->|calls| 5c0b54aa_ac77_fbf9_e176_6951222c00c4
  38cd02c9_bda5_f921_f4c9_f7772e1a880b["benchmark_single_shape()"]
  02c5a438_2afc_6211_922d_df8faf0ed669 -->|calls| 38cd02c9_bda5_f921_f4c9_f7772e1a880b
  style 02c5a438_2afc_6211_922d_df8faf0ed669 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmarks/dynamo/genai_layers/kernels.py lines 199–210

    def benchmark(self):
        for M, N in self.get_shapes():
            print(f"Tensor dimensions: [{M}, {N}]")
            torch_dtype = cutlass_torch.dtype(cutlass.BFloat16)
            x = 0.1 * torch.randn(
                M, N, device="cuda", dtype=torch_dtype, requires_grad=True
            )
            target = torch.randint(0, N, (M,), device="cuda", dtype=torch.int64)
            dloss = torch.randn(M, device="cuda", dtype=torch.float32)
            self.benchmark_single_shape(
                (x, target, dloss), setting=f"shape: [{M}, {N}]"
            )

Subdomains

Frequently Asked Questions

What does benchmark() do?
benchmark() is a function in the pytorch codebase.
What does benchmark() call?
benchmark() calls 2 function(s): benchmark_single_shape, get_shapes.

Analyze Your Own Codebase

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

Try Supermodel Free