Don't allow skipping deepcopy (#102973)

We might mutate it afterwards!  This could lead to hard to understand
bugs.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/102973
Approved by: https://github.com/albanD
This commit is contained in:
Edward Z. Yang
2023-06-05 08:08:22 -07:00
committed by PyTorch MergeBot
parent 7112880cc1
commit cca7b38564

View File

@ -1263,10 +1263,7 @@ class BenchmarkRunner:
continue # bad benchmark implementation
def deepcopy_model(self, model):
try:
return copy.deepcopy(model)
except TypeError:
return model
return copy.deepcopy(model)
def validate_model(self, model, example_inputs):
"""