Skip to content

Commit

Permalink
Benchmark to save sample inputs to disk before running (#114163)
Browse files Browse the repository at this point in the history
Summary:
Such that even if failures occur during model run, the sample inputs
are accessible for later investigation.

X-link: pytorch/pytorch#114163
Approved by: https://github.com/thiagocrepaldi
ghstack dependencies: #113780

Reviewed By: DanilBaibak

Differential Revision: D51528081

fbshipit-source-id: 80731ad3c25e362309aa663ee38f098d5a4463c4
  • Loading branch information
BowenBao authored and facebook-github-bot committed Nov 23, 2023
1 parent ef244f0 commit ec23124
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions userbenchmark/dynamo/dynamobench/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,15 @@ def save_tensor_data(cls, numpy_tensor, output_path):
f.write(proto_tensor.SerializeToString())

def run_and_serialize_inputs_outputs(self, pt_inputs):
onnx_inputs = self.adapt_pt_inputs_to_onnx(pt_inputs)
onnx_outputs = self.run_with_onnx_inputs(onnx_inputs)

test_data_dir = self.model_dir / "test_data_set_0"
test_data_dir.mkdir(parents=True, exist_ok=True)

onnx_inputs = self.adapt_pt_inputs_to_onnx(pt_inputs)
for i, onnx_input in enumerate(onnx_inputs.values()):
self.save_tensor_data(onnx_input, str(test_data_dir / f"input_{i}.pb"))

onnx_outputs = self.run_with_onnx_inputs(onnx_inputs)

for i, onnx_output in enumerate(onnx_outputs):
self.save_tensor_data(onnx_output, str(test_data_dir / f"output_{i}.pb"))

Expand Down

0 comments on commit ec23124

Please sign in to comment.