Skip to content

Add required example_args argument to prepare_fx and prepare_qat_fx #916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def _load_tests():
devices.append('cuda')

for path in _list_model_paths():
# TODO: skipping quantized tests for now due to BC-breaking changes for prepare
# api, enable after PyTorch 1.13 release
if "quantized" in path:
continue
for device in devices:
_load_test(path, device)

Expand Down
8 changes: 8 additions & 0 deletions test_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_train(self, model_path, device, compiler, benchmark):
if skip_by_metadata(test="train", device=device, jit=(compiler == 'jit'), \
extra_args=[], metadata=get_metadata_from_yaml(model_path)):
raise NotImplementedError("Test skipped by its metadata.")
# TODO: skipping quantized tests for now due to BC-breaking changes for prepare
# api, enable after PyTorch 1.13 release
if "quantized" in model_path:
return
task = ModelTask(model_path)
if not task.model_details.exists:
return # Model is not supported.
Expand All @@ -67,6 +71,10 @@ def test_eval(self, model_path, device, compiler, benchmark, pytestconfig):
if skip_by_metadata(test="eval", device=device, jit=(compiler == 'jit'), \
extra_args=[], metadata=get_metadata_from_yaml(model_path)):
raise NotImplementedError("Test skipped by its metadata.")
# TODO: skipping quantized tests for now due to BC-breaking changes for prepare
# api, enable after PyTorch 1.13 release
if "quantized" in model_path:
return
task = ModelTask(model_path)
if not task.model_details.exists:
return # Model is not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, test, device, jit=False, batch_size=None, extra_args=[]):
def prep_qat_train(self):
qconfig_dict = {"": torch.quantization.get_default_qat_qconfig('fbgemm')}
self.model.train()
self.model = quantize_fx.prepare_qat_fx(self.model, qconfig_dict)
self.model = quantize_fx.prepare_qat_fx(self.model, qconfig_dict, self.example_inputs)

def train(self, niter=3):
optimizer = optim.Adam(self.model.parameters())
Expand Down
2 changes: 1 addition & 1 deletion torchbenchmark/models/resnet50_quantized_qat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, test, device, jit=False, batch_size=None, extra_args=[]):
def prep_qat_train(self):
qconfig_dict = {"": torch.quantization.get_default_qat_qconfig('fbgemm')}
self.model.train()
self.model = quantize_fx.prepare_qat_fx(self.model, qconfig_dict)
self.model = quantize_fx.prepare_qat_fx(self.model, qconfig_dict, self.example_inputs)

def get_module(self):
return self.model, self.example_inputs
Expand Down