Created
February 16, 2024 01:55
-
-
Save maxwillzq/5f9ada3da9bc5c281fcaa6c3e568ab28 to your computer and use it in GitHub Desktop.
jaxonnxruntime test_backend.py for score_board
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""ONNX backend test initialization.""" | |
# copy from: https://github.com/onnx/backend-scoreboard/blob/master/test/test_backend.py | |
# Cmd: pytest test_backend.py -k 'not _cuda' --tb=short | |
import importlib | |
import os | |
import unittest | |
import onnx.backend.test | |
def import_backend(onnx_backend_module): | |
"""Import ONNX backend module. | |
:param onnx_backend_module: ONNX backend module to import. | |
:type onnx_backend_module: str | |
:raises ValueError: Not a valid ONNX backend. | |
:return: The ONNX backend module. | |
:rtype: class 'module' | |
""" | |
backend = importlib.import_module(onnx_backend_module) | |
if not hasattr(backend, "run_model") and not hasattr(backend, "run"): | |
raise ValueError("%s is not a valid ONNX backend", onnx_backend_module) | |
return backend | |
# Import custom backend | |
backend = import_backend(os.getenv('ONNX_BACKEND_MODULE')) | |
# Set backend device name to be used | |
backend.backend_name = "CPU" | |
# This is a pytest variable to load extra plugins | |
# Enable the ONNX compatibility report | |
pytest_plugins = "onnx.backend.test.report" | |
# Import all test cases at global scope to make them visible to python.unittest | |
backend_test = onnx.backend.test.BackendTest(backend, __name__) | |
globals().update(backend_test.enable_report().test_cases) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At 02/15/2014:
The final test result is: == 595 failed, 722 passed, 1317 deselected, 408 warnings in 67.48s (0:01:07) ===