Skip to content
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

Fix bug in benchmark tests with if statement #430

Merged
merged 2 commits into from
Jul 8, 2020
Merged
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
13 changes: 7 additions & 6 deletions test/benchmarks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@


@pytest.fixture(scope="session")
def onnx_adaptive_model_qa(use_gpu, num_processes):
model_name_or_path = "deepset/bert-base-cased-squad2"
onnx_model_export_path = Path("benchmarks/onnx-export")
if not (onnx_model_export_path / "model.onnx").is_file():
def onnx_adaptive_model_qa(use_gpu, num_processes, model_name_or_path="deepset/bert-base-cased-squad2"):
if (Path(model_name_or_path) / "model.onnx").is_file(): # load model directly if in ONNX format
onnx_model_path = model_name_or_path
else: # convert to ONNX format
onnx_model_path = Path("benchmarks/onnx-export")
model = AdaptiveModel.convert_from_transformers(
model_name_or_path, device="cpu", task_type="question_answering"
)
model.convert_to_onnx(onnx_model_export_path)
model.convert_to_onnx(onnx_model_path)

model = Inferencer.load(
onnx_model_export_path, task_type="question_answering", batch_size=1, num_processes=num_processes, gpu=use_gpu
onnx_model_path, task_type="question_answering", batch_size=1, num_processes=num_processes, gpu=use_gpu
)

return model