check_accuracy() — pytorch Function Reference
Architecture documentation for the check_accuracy() function in kernels.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD cf57d9a8_fc49_42e9_c1eb_53ac4b8190b5["check_accuracy()"] d4938e53_a1f5_c58c_a1e1_efc656eb80f1["clone_inputs()"] cf57d9a8_fc49_42e9_c1eb_53ac4b8190b5 -->|calls| d4938e53_a1f5_c58c_a1e1_efc656eb80f1 bf14c1d3_0a90_a5c6_58ff_3e6211ae65ce["check_accuracy()"] cf57d9a8_fc49_42e9_c1eb_53ac4b8190b5 -->|calls| bf14c1d3_0a90_a5c6_58ff_3e6211ae65ce style cf57d9a8_fc49_42e9_c1eb_53ac4b8190b5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/genai_layers/kernels.py lines 97–118
def check_accuracy(self, args, kwargs) -> None:
res = {}
for backend in self.available_backends:
args_ref, kwargs_ref = self.clone_inputs(args, kwargs)
res[backend] = getattr(self, backend)(args_ref, kwargs_ref)()
gold = res["eager"]
for backend in self.available_backends:
if backend == "eager":
continue
if backend == "quack":
# quack's cross_entropy only returns float32 loss output.
# Need to convert it to the same dtype as gold for comparison.
res[backend] = res[backend].to(gold.dtype)
try:
torch.testing.assert_close(res[backend], gold)
print(
f"Accuracy check \033[92m✓ succeed\033[0m for {backend} backend on {self.name} kernel"
)
except Exception as e:
print(
f"Accuracy check \033[91m✗ failed\033[0m for {backend} backend on {self.name} kernel. Error {e}"
)
Domain
Subdomains
Source
Frequently Asked Questions
What does check_accuracy() do?
check_accuracy() is a function in the pytorch codebase.
What does check_accuracy() call?
check_accuracy() calls 2 function(s): check_accuracy, clone_inputs.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free