Skip to content

[ExecuTorch][XNNPACK] Rename linear weight partitioning flag for clarity #8928

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

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
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
120 changes: 63 additions & 57 deletions .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,63 +96,6 @@ jobs:

PYTHONPATH="${PWD}" python .ci/scripts/gather_benchmark_configs.py $ARGS

prepare-test-specs:
runs-on: linux.2xlarge
needs: set-parameters
strategy:
matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }}
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Prepare the spec
id: prepare
shell: bash
env:
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
working-directory: extension/benchmark/android/benchmark
run: |
set -eux

# The model will be exported in the next step to this S3 path
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"
# We could write a script to properly use jinja here, but there is only one variable,
# so let's just sed it
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2

BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
# later by the upload script
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' android-llm-device-farm-test-spec.yml.j2

cp android-llm-device-farm-test-spec.yml.j2 android-llm-device-farm-test-spec.yml
# Just print the test spec for debugging
cat android-llm-device-farm-test-spec.yml

# Save the benchmark configs so that we can use it later in the dashboard
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT

- name: Upload the spec
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}
retention-days: 1
if-no-files-found: error
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml

- name: Update the benchmark configs
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
retention-days: 1
if-no-files-found: error
path: extension/benchmark/android/benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json

export-models:
name: export-models
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
Expand Down Expand Up @@ -335,6 +278,69 @@ jobs:
fi
echo "::endgroup::"

prepare-test-specs:
runs-on: linux.2xlarge
needs:
- set-parameters
- export-models
strategy:
matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }}
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Prepare the spec
id: prepare
shell: bash
env:
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
working-directory: extension/benchmark/android/benchmark
run: |
set -eux

# The model will be exported in the next step to this S3 path
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"

# Check if the model artifact exists, fail this step skip generating test-spec.
curl -s --head -f ${MODEL_PATH}

# We could write a script to properly use jinja here, but there is only one variable,
# so let's just sed it
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2

BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
# later by the upload script
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' android-llm-device-farm-test-spec.yml.j2

cp android-llm-device-farm-test-spec.yml.j2 android-llm-device-farm-test-spec.yml
# Just print the test spec for debugging
cat android-llm-device-farm-test-spec.yml

# Save the benchmark configs so that we can use it later in the dashboard
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT

- name: Upload the spec
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}
retention-days: 1
if-no-files-found: error
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml

- name: Update the benchmark configs
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
retention-days: 1
if-no-files-found: error
path: extension/benchmark/android/benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json

build-benchmark-app:
name: build-benchmark-app
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
Expand Down
119 changes: 62 additions & 57 deletions .github/workflows/apple-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,63 +98,6 @@ jobs:

echo "benchmark_configs is: ${{ steps.set-parameters.outputs.benchmark_configs }}"

prepare-test-specs:
runs-on: linux.2xlarge
needs: set-parameters
strategy:
matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }}
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Prepare the spec
id: prepare
shell: bash
env:
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
working-directory: extension/benchmark/apple/Benchmark
run: |
set -eux

# The model will be exported in the next step to this S3 path
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"
# We could write a script to properly use jinja here, but there is only one variable,
# so let's just sed it
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' default-ios-device-farm-appium-test-spec.yml.j2

BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
# later by the upload script
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' default-ios-device-farm-appium-test-spec.yml.j2

cp default-ios-device-farm-appium-test-spec.yml.j2 default-ios-device-farm-appium-test-spec.yml
# Just print the test spec for debugging
cat default-ios-device-farm-appium-test-spec.yml

# Save the benchmark configs so that we can use it later in the dashboard
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT

- name: Upload the spec
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}
retention-days: 1
if-no-files-found: error
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml

- name: Update the benchmark configs
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
retention-days: 1
if-no-files-found: error
path: extension/benchmark/apple/Benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json

export-models:
name: export-models
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
Expand Down Expand Up @@ -344,6 +287,68 @@ jobs:
fi
echo "::endgroup::"

prepare-test-specs:
runs-on: linux.2xlarge
needs:
- set-parameters
- export-models
strategy:
matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }}
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Prepare the spec
id: prepare
shell: bash
env:
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
working-directory: extension/benchmark/apple/Benchmark
run: |
set -eux

# The model will be exported in the next step to this S3 path
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"
# Check if the model artifact exists, fail this step skip generating test-spec.
curl -s --head -f ${MODEL_PATH}
# We could write a script to properly use jinja here, but there is only one variable,
# so let's just sed it
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' default-ios-device-farm-appium-test-spec.yml.j2

BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
# later by the upload script
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' default-ios-device-farm-appium-test-spec.yml.j2

cp default-ios-device-farm-appium-test-spec.yml.j2 default-ios-device-farm-appium-test-spec.yml
# Just print the test spec for debugging
cat default-ios-device-farm-appium-test-spec.yml

# Save the benchmark configs so that we can use it later in the dashboard
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT

- name: Upload the spec
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}
retention-days: 1
if-no-files-found: error
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml

- name: Update the benchmark configs
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
retention-days: 1
if-no-files-found: error
path: extension/benchmark/apple/Benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json


build-benchmark-app:
name: build-benchmark-app
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,15 @@ cmake_dependent_option(
"NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF
)

if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
endif()

if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
endif()

if(EXECUTORCH_BUILD_EXTENSION_MODULE)
Expand Down
18 changes: 8 additions & 10 deletions backends/apple/coreml/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ runtime.python_library(
"@EXECUTORCH_CLIENTS",
],
deps = [
"fbsource//third-party/pypi/coremltools:coremltools",
":executorchcoreml",
"//executorch/exir/backend:backend_details",
"//executorch/exir/backend:compile_spec_schema",
"fbsource//third-party/pypi/coremltools:coremltools",
],
)

Expand All @@ -30,13 +30,13 @@ runtime.python_library(
"@EXECUTORCH_CLIENTS",
],
deps = [
"fbsource//third-party/pypi/coremltools:coremltools",
":backend",
"//caffe2:torch",
"//executorch/exir:lib",
"//executorch/exir/backend:compile_spec_schema",
"//executorch/exir/backend:partitioner",
"//executorch/exir/backend:utils",
"fbsource//third-party/pypi/coremltools:coremltools",
],
)

Expand Down Expand Up @@ -64,25 +64,23 @@ runtime.cxx_python_extension(
headers = glob([
"runtime/inmemoryfs/**/*.hpp",
]),
base_module = "",
compiler_flags = [
"-std=c++17",
],
preprocessor_flags = [
"-Iexecutorch/backends/apple/coreml/runtime/util",
],
types = [
"executorchcoreml.pyi",
],
compiler_flags = [
"-std=c++17",
],
base_module = "",
visibility = [
"//executorch/examples/apple/coreml/...",
"@EXECUTORCH_CLIENTS",
],
external_deps = [
"pybind11",
],
deps = [
"fbsource//third-party/nlohmann-json:nlohmann-json",
"fbsource//third-party/pybind11:pybind11",
],
)

Expand All @@ -92,10 +90,10 @@ runtime.python_test(
"test/*.py",
]),
deps = [
"fbsource//third-party/pypi/pytest:pytest",
":partitioner",
":quantizer",
"//caffe2:torch",
"//pytorch/vision:torchvision",
"fbsource//third-party/pypi/pytest:pytest",
],
)
5 changes: 4 additions & 1 deletion backends/arm/tosa_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def __init__(self, argument: Any) -> None:
if isinstance(argument, (int, float)):
self.__process_number(argument)
return
if isinstance(argument, torch.dtype):
# Dtype is parsed from fake tensor
return

RuntimeError(
raise RuntimeError(
f"Unhandled node input argument: {argument}, of type {type(argument)}"
)
Loading
Loading