Skip to content

Commit

Permalink
Split DML test out of cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen351 committed Oct 26, 2024
1 parent 6dd4694 commit 5ba0c12
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
32 changes: 20 additions & 12 deletions onnxruntime/test/python/onnx_backend_test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def load_jsonc(basename: str):
return json.loads("\n".join(lines))


def create_backend_test(test_name=None):
def create_backend_test(devices:list[str] = None, test_name=None):

Check warning

Code scanning / lintrunner

RUFF/RUF013 Warning test

PEP 484 prohibits implicit Optional.
See https://docs.astral.sh/ruff/rules/implicit-optional
"""Creates an OrtBackendTest and adds its TestCase's to global scope so unittest will find them."""

overrides = load_jsonc("onnx_backend_test_series_overrides.jsonc")
Expand All @@ -126,36 +126,35 @@ def create_backend_test(test_name=None):
else:
filters = load_jsonc("onnx_backend_test_series_filters.jsonc")
current_failing_tests = apply_filters(filters, "current_failing_tests")

if platform.architecture()[0] == "32bit":
current_failing_tests += apply_filters(filters, "current_failing_tests_x86")

if backend.supports_device("DNNL"):
if backend.supports_device("DNNL") or "DNNL" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_DNNL")

if backend.supports_device("NNAPI"):
if backend.supports_device("NNAPI") or "NNAPI" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_NNAPI")

if backend.supports_device("OPENVINO_GPU"):
if backend.supports_device("OPENVINO_GPU") or "OPENVINO_GPU" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_OPENVINO_GPU")

if backend.supports_device("OPENVINO_CPU"):
if backend.supports_device("OPENVINO_CPU") or "OPENVINO_CPU" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_OPENVINO_CPU_FP32")
current_failing_tests += apply_filters(filters, "current_failing_tests_OPENVINO_CPU_FP16")

if backend.supports_device("OPENVINO_NPU"):
if backend.supports_device("OPENVINO_NPU") or "OPENVINO_NPU" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_OPENVINO_NPU")

if backend.supports_device("OPENVINO"):
if backend.supports_device("OPENVINO") or "OPENVINO" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_OPENVINO_opset18")

if backend.supports_device("MIGRAPHX"):
if backend.supports_device("MIGRAPHX") or "MIGRAPHX" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_MIGRAPHX")

# Skip these tests for a "pure" DML onnxruntime python wheel. We keep these tests enabled for instances where both DML and CUDA
# EPs are available (Windows GPU CI pipeline has this config) - these test will pass because CUDA has higher precedence than DML
# and the nodes are assigned to only the CUDA EP (which supports these tests)
if backend.supports_device("DML") and not backend.supports_device("GPU"):
if (backend.supports_device("DML") and not backend.supports_device("GPU")) or "DML" in devices:
current_failing_tests += apply_filters(filters, "current_failing_tests_pure_DML")

filters = (
Expand Down Expand Up @@ -196,6 +195,15 @@ def parse_args():
help="Only run tests that match this value. Matching is regex based, and '.*' is automatically appended",
)

parser.add_argument(
"--devices",
type=str,
choices=["CPU", "CUDA", "MIGRAPHX", "DNNL", "DML", "OPENVINO_GPU", "OPENVINO_CPU", "OPENVINO_NPU","OPENVINO"],
nargs="+", # allows multiple values
default=["CPU"], # default to ["CPU"] if no input is given
help="Select one or more devices CPU, CUDA, MIGRAPHX, DNNL, DML, OPENVINO_GPU, OPENVINO_CPU, OPENVINO_NPU, OPENVINO"
)

# parse just our args. python unittest has its own args and arg parsing, and that runs inside unittest.main()
parsed, unknown = parser.parse_known_args()
sys.argv = sys.argv[:1] + unknown
Expand All @@ -206,5 +214,5 @@ def parse_args():
if __name__ == "__main__":
args = parse_args()

create_backend_test(args.test_name)
unittest.main()
create_backend_test(args.devices,args.test_name)
unittest.main()

Check warning

Code scanning / lintrunner

RUFF/W292 Warning test

20 changes: 15 additions & 5 deletions tools/ci_build/github/azure-pipelines/stages/py-win-gpu-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ stages:
targetPath: $(Build.ArtifactStagingDirectory)
artifactName: win_${{ parameters.EP_NAME }}_wheel_${{ parameters.PYTHON_VERSION }}
variables:
GRADLE_OPTS: '-Dorg.gradle.daemon=false'
VSGenerator: 'Visual Studio 17 2022'
CUDA_MODULE_LOADING: 'LAZY'
- name: GRADLE_OPTS
value: '-Dorg.gradle.daemon=false'
- name: VSGenerator
value: 'Visual Studio 17 2022'
- name: CUDA_MODULE_LOADING
value: 'LAZY'
- name: ep_name_alt
value:
${{ if eq(parameters.EP_NAME, directml) }}:
'DML'
${{ else }}:
'CUDA'

steps:
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
Expand Down Expand Up @@ -190,7 +200,7 @@ stages:
TargetPath: '$(Build.ArtifactStagingDirectory)'

- task: PowerShell@2
displayName: 'Install ONNX'
displayName: 'Install Third Party Dependencies'
inputs:
filePath: '$(Build.SourcesDirectory)/tools/ci_build/github/windows/install_third_party_deps.ps1'
workingDirectory: '$(Build.BinariesDirectory)'
Expand All @@ -203,6 +213,6 @@ stages:
Copy-Item -Path $(Build.sourcesDirectory)/onnxruntime/test/python/onnx_backend_test_series.py -Destination $(Agent.TempDirectory)\ort_test_data
Copy-Item -Recurse -Path $(Build.sourcesDirectory)/onnxruntime/test/testdata -Destination $(Agent.TempDirectory)\ort_test_data
cd $(Agent.TempDirectory)\ort_test_data
python onnx_backend_test_series.py
python onnx_backend_test_series.py --devices $(ep_name_alt)
workingDirectory: '$(Build.sourcesDirectory)'
displayName: 'Run Python Tests'

0 comments on commit 5ba0c12

Please sign in to comment.