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

[ONNX] Reduced memory consumption while running tests #23628

Merged
merged 2 commits into from
Mar 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ def _execute_pb_data(
executed_tests = executed_tests + 1
return executed_tests


def _add_model_import_test(self, model_test: ExtOnnxTestCase) -> None:
# model is loaded at runtime, note sometimes it could even
# never loaded if the test skipped
model_marker = [None] # type: List[Optional[Union[ModelProto, NodeProto]]]

def run_import(test_self: Any, device: Text) -> None:
model = ModelImportRunner._load_onnx_model(model_test.model_dir, model_test.model)
model_marker[0] = model
model_marker[0] = model_test.model_dir / model_test.model
assert import_onnx_model(model)

self._add_test("ModelImport", model_test.name, run_import, model_marker)
Expand All @@ -160,7 +161,7 @@ def _add_model_execution_test(self, model_test: ExtOnnxTestCase) -> None:

def run_execution(test_self: Any, device: Text) -> None:
model = ModelImportRunner._load_onnx_model(model_test.model_dir, model_test.model)
model_marker[0] = model
model_marker[0] = model_test.model_dir / model_test.model
prepared_model = self.backend.prepare(model, device)
assert prepared_model is not None
executed_tests = ModelImportRunner._execute_npz_data(
Expand Down
Loading