From 52f995c0ce45448dbb8b98ff8e2220bf64fd8872 Mon Sep 17 00:00:00 2001 From: Denis Vieriu Date: Tue, 28 Nov 2023 13:56:47 -0800 Subject: [PATCH] Fix lint --- .github/workflows/pull_mps.yml | 8 ++++---- .../mps/ci/scripts/gather_test_models_mps.py | 20 ++++++++++++------- backends/apple/mps/test/test_mps.py | 4 +--- examples/apple/mps/CMakeLists.txt | 11 +++++++--- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull_mps.yml b/.github/workflows/pull_mps.yml index 90a8782d43..e282930d09 100644 --- a/.github/workflows/pull_mps.yml +++ b/.github/workflows/pull_mps.yml @@ -35,8 +35,8 @@ jobs: install_pip_dependencies install_executorch PYTHONPATH="${PWD}" python -m backends.apple.mps.ci.scripts.gather_test_models_mps - # test-mps-models-macos: - # name: test-mps-models-macos + # test-mps-models: + # name: test-mps-models # runs-on: macos-executorch # needs: gather-models-mps # strategy: @@ -59,8 +59,8 @@ jobs: # # Build and test ExecuTorch # PYTHON_EXECUTABLE=python bash backends/apple/mps/ci/scripts/test-mps.sh "${MODEL_NAME}" "${BUILD_TOOL}" # popd - test-mps-macos: - name: test-mps-macos + test-mps: + name: test-mps runs-on: macos-executorch needs: gather-models-mps strategy: diff --git a/backends/apple/mps/ci/scripts/gather_test_models_mps.py b/backends/apple/mps/ci/scripts/gather_test_models_mps.py index 9c317e13cb..e7cbca8438 100644 --- a/backends/apple/mps/ci/scripts/gather_test_models_mps.py +++ b/backends/apple/mps/ci/scripts/gather_test_models_mps.py @@ -5,13 +5,12 @@ import json import os +import unittest from typing import Any from examples.models import MODEL_NAME_TO_MODEL -from examples.xnnpack import MODEL_NAME_TO_OPTIONS -import unittest -MPS_TEST_SUITE_PATH = 'backends/apple/mps/test' +MPS_TEST_SUITE_PATH = "backends/apple/mps/test" MPS_SUITE = unittest.defaultTestLoader.discover(MPS_TEST_SUITE_PATH) BUILD_TOOLS = { @@ -21,6 +20,7 @@ "macos-14": "macos-executorch", } + def parse_args() -> Any: from argparse import ArgumentParser @@ -47,18 +47,21 @@ def set_output(name: str, val: Any) -> None: else: print(f"::set-output name={name}::{val}") + def gather_mps_test_list(suite, mps_test_list): - if hasattr(suite, '__iter__'): + if hasattr(suite, "__iter__"): for x in suite: - gather_mps_test_list(x, mps_test_list) + gather_mps_test_list(x, mps_test_list) else: mps_test_list.append(suite) + def gather_mps_tests(suite): mps_test_list = [] gather_mps_test_list(suite, mps_test_list) return mps_test_list + def export_models_for_ci() -> None: """ This gathers all the example models that we want to test on GitHub OSS CI @@ -92,7 +95,7 @@ def export_models_for_ci() -> None: start_path = ".".join([MPS_TEST_SUITE_PATH.replace("/", "."), "test_mps"]) for testcase in mps_test_list: if "test_mps" not in str(testcase.__class__): - continue + continue for build_tool in BUILD_TOOLS.keys(): if target_os not in BUILD_TOOLS[build_tool]: continue @@ -100,7 +103,9 @@ def export_models_for_ci() -> None: print(f"method: {testcase._testMethodName}") print(f"{testcase.__class__}") print(f"{testcase.__class__.__name__}") - cmd = ".".join([start_path, testcase.__class__.__name__, testcase._testMethodName]) + cmd = ".".join( + [start_path, testcase.__class__.__name__, testcase._testMethodName] + ) record = { "build-tool": build_tool, "model": cmd, @@ -111,5 +116,6 @@ def export_models_for_ci() -> None: set_output("mps_models", json.dumps(mps_models)) + if __name__ == "__main__": export_models_for_ci() diff --git a/backends/apple/mps/test/test_mps.py b/backends/apple/mps/test/test_mps.py index 6e6bc065fa..43a69eb3ef 100644 --- a/backends/apple/mps/test/test_mps.py +++ b/backends/apple/mps/test/test_mps.py @@ -133,9 +133,7 @@ def forward(self, *args): method_test_suites = [ MethodTestSuite( method_name="forward", - test_cases=[ - MethodTestCase(inputs=m_inputs, expected_outputs=m(*m_inputs)) - ], + test_cases=[MethodTestCase(inputs=m_inputs, expected_outputs=m(*m_inputs))], ) ] diff --git a/examples/apple/mps/CMakeLists.txt b/examples/apple/mps/CMakeLists.txt index 6643178b5e..7a29d26688 100644 --- a/examples/apple/mps/CMakeLists.txt +++ b/examples/apple/mps/CMakeLists.txt @@ -52,7 +52,8 @@ add_custom_command( OUTPUT ${_bundled_program_schema__outputs} COMMAND ${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o - "${_program_schema__include_dir}/executorch/sdk/bundled_program/schema" ${_bundled_program_schema__srcs} + "${_program_schema__include_dir}/executorch/sdk/bundled_program/schema" + ${_bundled_program_schema__srcs} WORKING_DIRECTORY ${EXECUTORCH_ROOT} DEPENDS ${FLATC_EXECUTABLE} ${_bundled_program_schema__srcs} COMMENT "Generating bundled_program headers" @@ -68,8 +69,12 @@ set(mps_executor_runner_libs "-framework Foundation" "-weak_framework MetalPerformanceShaders" "-weak_framework MetalPerformanceShadersGraph" "-weak_framework Metal") -list(TRANSFORM _mps_executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/") -add_executable(mps_executor_runner ${_mps_executor_runner__srcs} ${_bundled_program_schema__outputs}) +list( + TRANSFORM _mps_executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/") +add_executable( + mps_executor_runner + ${_mps_executor_runner__srcs} + ${_bundled_program_schema__outputs}) target_include_directories( mps_executor_runner INTERFACE ${CMAKE_BINARY_DIR}/schema/include/ ${EXECUTORCH_ROOT}/third-party/flatbuffers/include)