Home / Function/ benchmark_single_shape_for_backend() — pytorch Function Reference

benchmark_single_shape_for_backend() — pytorch Function Reference

Architecture documentation for the benchmark_single_shape_for_backend() function in utils.py from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  3d4e92c5_a13f_fad7_1514_52cd7fc93a06["benchmark_single_shape_for_backend()"]
  38cd02c9_bda5_f921_f4c9_f7772e1a880b["benchmark_single_shape()"]
  38cd02c9_bda5_f921_f4c9_f7772e1a880b -->|calls| 3d4e92c5_a13f_fad7_1514_52cd7fc93a06
  d4938e53_a1f5_c58c_a1e1_efc656eb80f1["clone_inputs()"]
  3d4e92c5_a13f_fad7_1514_52cd7fc93a06 -->|calls| d4938e53_a1f5_c58c_a1e1_efc656eb80f1
  f0f1f380_c551_5bfd_3a89_2f91a2eabca0["get_memory_bytes()"]
  3d4e92c5_a13f_fad7_1514_52cd7fc93a06 -->|calls| f0f1f380_c551_5bfd_3a89_2f91a2eabca0
  52d0e3c4_92e4_8027_cd0e_d942bee8cfc8["benchmark_kernel_in_milliseconds()"]
  3d4e92c5_a13f_fad7_1514_52cd7fc93a06 -->|calls| 52d0e3c4_92e4_8027_cd0e_d942bee8cfc8
  style 3d4e92c5_a13f_fad7_1514_52cd7fc93a06 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmarks/dynamo/genai_layers/utils.py lines 150–168

    def benchmark_single_shape_for_backend(
        self, backend, args, kwargs, setting, fn=None
    ) -> bool:
        if fn is None:
            fn = getattr(self, backend)
        args_ref, kwargs_ref = self.clone_inputs(args, kwargs)
        try:
            avg_time = benchmark_kernel_in_milliseconds(fn(args_ref, kwargs_ref))
        except Exception as e:
            print(
                f"Failed to run {backend} backend on {self.name} kernel for {setting} due to {e}"
            )
            self.available_backends.remove(backend)  # noqa: B909
            return False
        mem_bytes = self.get_memory_bytes(args_ref, kwargs_ref)
        perf = Performance(setting, avg_time, mem_bytes)
        print(f"{self.name} kernel on {backend} backend. {perf}")
        self.profiling_results[backend].append(perf)
        return True

Subdomains

Frequently Asked Questions

What does benchmark_single_shape_for_backend() do?
benchmark_single_shape_for_backend() is a function in the pytorch codebase.
What does benchmark_single_shape_for_backend() call?
benchmark_single_shape_for_backend() calls 3 function(s): benchmark_kernel_in_milliseconds, clone_inputs, get_memory_bytes.
What calls benchmark_single_shape_for_backend()?
benchmark_single_shape_for_backend() is called by 1 function(s): benchmark_single_shape.

Analyze Your Own Codebase

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

Try Supermodel Free