log_operator_inputs() — pytorch Function Reference
Architecture documentation for the log_operator_inputs() function in common.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 67009ec0_1e64_0f0a_7e5d_9f07d2bbbdde["log_operator_inputs()"] c9be2096_e6d7_2374_ad2e_a6e33f435ada["run()"] c9be2096_e6d7_2374_ad2e_a6e33f435ada -->|calls| 67009ec0_1e64_0f0a_7e5d_9f07d2bbbdde style 67009ec0_1e64_0f0a_7e5d_9f07d2bbbdde fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/common.py lines 4572–4607
def log_operator_inputs(model, example_inputs, model_iter_fn, name, args):
mode = "training" if args.training else "eval"
output = os.path.join(os.path.dirname(args.output), f"{name}_{mode}.txt")
# TODO - add option for coalescing inputs over multiple runs
if os.path.exists(output):
print(f"Skipping {name}, {output} already exists")
return
print(f"Running {name}")
try:
from .microbenchmarks.operator_inp_utils import OperatorInputsMode
except ImportError:
from microbenchmarks.operator_inp_utils import OperatorInputsMode
operator_mode = OperatorInputsMode()
fake_tensor_mode = FakeTensorMode()
with torch._subclasses.fake_tensor.FakeCopyMode(fake_tensor_mode):
model_fake = copy.deepcopy(model)
example_inputs_fake = copy.deepcopy(example_inputs)
try:
with fake_tensor_mode, operator_mode:
model_iter_fn(model_fake, example_inputs_fake, collect_outputs=False)
except Exception as e:
print(f"{name} failed to run with fake tensors, trying real. Exception: {e}")
operator_mode = OperatorInputsMode()
try:
with operator_mode:
model_iter_fn(model, example_inputs, collect_outputs=False)
except Exception as e2:
print(f"{name} failed to run with real. Exception: {e2}")
raise
print(f"Writing output to {output}")
operator_mode.log_to_file(output)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does log_operator_inputs() do?
log_operator_inputs() is a function in the pytorch codebase.
What calls log_operator_inputs()?
log_operator_inputs() is called by 1 function(s): run.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free