Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVieriu97 committed Nov 28, 2023
1 parent 7d8c84d commit 52f995c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull_mps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
20 changes: 13 additions & 7 deletions backends/apple/mps/ci/scripts/gather_test_models_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -21,6 +20,7 @@
"macos-14": "macos-executorch",
}


def parse_args() -> Any:
from argparse import ArgumentParser

Expand All @@ -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
Expand Down Expand Up @@ -92,15 +95,17 @@ 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

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,
Expand All @@ -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()
4 changes: 1 addition & 3 deletions backends/apple/mps/test/test_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))],
)
]

Expand Down
11 changes: 8 additions & 3 deletions examples/apple/mps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 52f995c

Please sign in to comment.