Skip to content

Commit bd7694b

Browse files
committed
Update
[ghstack-poisoned]
2 parents 1e6caff + 7a6747f commit bd7694b

File tree

14 files changed

+263
-15
lines changed

14 files changed

+263
-15
lines changed

.ci/scripts/setup-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set -exu
1111
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212

1313
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
14+
echo "Build tool: $BUILD_TOOL, Mode: $BUILD_MODE"
1415

1516
# As Linux job is running inside a Docker container, all of its dependencies
1617
# have already been installed, so we use PyTorch build from source here instead

.ci/scripts/test_backend_linux.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
set -eux
8+
9+
SUITE=$1
10+
FLOW=$2
11+
ARTIFACT_DIR=$3
12+
13+
echo "Running backend test job for suite $SUITE, flow $FLOW."
14+
echo "Saving job artifacts to $ARTIFACT_DIR."
15+
16+
# The generic Linux job chooses to use base env, not the one setup by the image
17+
eval "$(conda shell.bash hook)"
18+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
19+
conda activate "${CONDA_ENV}"
20+
21+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
22+
source .ci/scripts/setup-vulkan-linux-deps.sh
23+
24+
# CMake options to use, in addition to the defaults.
25+
EXTRA_BUILD_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON"
26+
27+
# We need the runner to test the built library.
28+
PYTHON_EXECUTABLE=python CMAKE_ARGS="$EXTRA_BUILD_ARGS" .ci/scripts/setup-linux.sh --build-tool cmake --build-mode Release
29+
30+
python -m executorch.backends.test.suite.runner $SUITE --flow $FLOW --report "$ARTIFACT_DIR/test_results.csv"

.ci/scripts/test_backend_macos.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
set -eux
8+
9+
SUITE=$1
10+
FLOW=$2
11+
ARTIFACT_DIR=$3
12+
13+
echo "Running backend test job for suite $SUITE, flow $FLOW."
14+
echo "Saving job artifacts to $ARTIFACT_DIR."
15+
16+
${CONDA_RUN} --no-capture-output pip install awscli==1.37.21
17+
18+
bash .ci/scripts/setup-conda.sh
19+
eval "$(conda shell.bash hook)"
20+
21+
PYTHON_EXECUTABLE=python
22+
${CONDA_RUN} --no-capture-output .ci/scripts/setup-macos.sh --build-tool cmake --build-mode Release
23+
24+
${CONDA_RUN} --no-capture-output python -m executorch.backends.test.suite.runner $SUITE --flow $FLOW --report "$ARTIFACT_DIR/test_results.csv"

.ci/scripts/unittest-buck2.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ set -eux
1212
buck2 query "//backends/apple/... + //backends/example/... + \
1313
//backends/mediatek/... + //backends/transforms/... + \
1414
//backends/xnnpack/... + //configurations/... + //extension/flat_tensor: + \
15-
//kernels/aten/... + //kernels/optimized/... + //kernels/portable/... + \
16-
//kernels/quantized/... + //kernels/test/... + //runtime/... + //schema/... \
17-
+ //test/... + //util/..."
15+
//extension/llm/runner: + //kernels/aten/... + //kernels/optimized/... + \
16+
//kernels/portable/... + //kernels/quantized/... + //kernels/test/... + \
17+
//runtime/... + //schema/... + //test/... + //util/..."
1818

1919
# TODO: optimized ops are unbuildable because they now use ATen; put
2020
# them back after we can use PyTorch in OSS buck.

.github/workflows/add-unanswered-to-project.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Add Open External Contributor PRs and Issues to PyTorch Org Project 136
22

33
on:
4-
# schedule:
5-
# - cron: '0 * * * *'
64
workflow_dispatch:
7-
5+
pull_request:
6+
paths:
7+
.github/workflows/add-unanswered-to-project.yml
88
jobs:
99
add_to_project:
1010
runs-on: ubuntu-latest

.github/workflows/nightly.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,52 @@ jobs:
3636
uses: ./.github/workflows/_link_check.yml
3737
with:
3838
ref: ${{ github.sha }}
39+
40+
backend-test-linux:
41+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
flow: [vulkan, xnnpack, xnnpack_static_int8_per_channel]
46+
suite: [models, operators]
47+
with:
48+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
49+
runner: linux.4xlarge.memory
50+
docker-image: ci-image:executorch-ubuntu-22.04-clang12
51+
submodules: recursive
52+
timeout: 120
53+
upload-artifact: test-report-${{ matrix.flow }}-${{ matrix.suite }}
54+
script: |
55+
set -eux
56+
# Intentionally suppressing exit code for now.
57+
# TODO (gjcomer) Remove this when jobs are stable.
58+
EXIT_CODE=0
59+
.ci/scripts/test_backend_linux.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}" || EXIT_CODE=$?
60+
echo "Test run complete with exit code $EXIT_CODE."
61+
62+
backend-test-macos:
63+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
64+
permissions:
65+
id-token: write
66+
contents: read
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
flow: [coreml, coreml_static_int8]
71+
suite: [models, operators]
72+
with:
73+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
74+
runner: macos-m1-stable
75+
python-version: 3.12
76+
submodules: recursive
77+
timeout: 120
78+
upload-artifact: test-report-${{ matrix.flow }}-${{ matrix.suite }}
79+
script: |
80+
set -eux
81+
82+
# This is needed to get the prebuilt PyTorch wheel from S3
83+
${CONDA_RUN} --no-capture-output pip install awscli==1.37.21
84+
85+
EXIT_CODE=0
86+
.ci/scripts/test_backend_macos.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}" || EXIT_CODE=$?
87+
echo "Test run complete with exit code $EXIT_CODE."

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dist/
2020
ethos-u-scratch/
2121
executorch.egg-info
2222
pip-out/
23+
build-profiling/
2324

2425
# Any exported models and profiling outputs
2526
*.bin
@@ -60,6 +61,7 @@ xcuserdata/
6061
/share/
6162
/version.py
6263
*.csv
64+
*_etdump
6365

6466
# Android
6567
*.aar

backends/cadence/hifi/operators/op_softmax.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ Tensor& _softmax_out(
7272
if (optimized) {
7373
int* p_inp = (int*)in.const_data_ptr<float>();
7474
int* out_data = (int*)out.mutable_data_ptr<float>();
75-
7675
int num_inp_dims = in.dim();
7776
int num_out_dims = num_inp_dims;
7877

@@ -99,6 +98,37 @@ Tensor& _softmax_out(
9998

10099
outer_stride = size;
101100

101+
WORD32 ret_val = 0;
102+
103+
// Check if the input is permuted. If not, then we don't need to transpose
104+
bool is_permuted = false;
105+
for (int i = 0; i < num_inp_dims; i++) {
106+
if (p_permute_vec[i] != i) {
107+
is_permuted = true;
108+
break;
109+
}
110+
}
111+
112+
if (!is_permuted) {
113+
const float* p_inpf = in.const_data_ptr<float>();
114+
float* out_dataf = out.mutable_data_ptr<float>();
115+
116+
for (size_t outer_idx = 0; outer_idx < outer_size; ++outer_idx) {
117+
size_t outer = outer_idx * outer_stride;
118+
for (size_t inner_idx = 0; inner_idx < stride; ++inner_idx) {
119+
size_t base = outer + inner_idx;
120+
121+
float* p_in_data = (float*)&p_inpf[base];
122+
float* p_out_data = (float*)&out_dataf[base];
123+
124+
ret_val = xa_nn_vec_softmax_f32_f32(p_out_data, p_in_data, size);
125+
126+
ET_KERNEL_CHECK(ctx, ret_val == 0, Internal, out);
127+
}
128+
}
129+
return out;
130+
}
131+
102132
int* p_out =
103133
(int*)kernels::allocate_temp_memory(ctx, out.numel() * sizeof(int));
104134

@@ -109,7 +139,7 @@ Tensor& _softmax_out(
109139

110140
ET_KERNEL_CHECK(ctx, p_out1 != nullptr, MemoryAllocationFailed, out);
111141

112-
WORD32 ret_val = xa_nn_transpose_32_32(
142+
ret_val = xa_nn_transpose_32_32(
113143
p_out,
114144
p_out_shape,
115145
p_inp,
@@ -142,9 +172,7 @@ Tensor& _softmax_out(
142172
p_permute_vec,
143173
num_out_dims,
144174
num_inp_dims);
145-
146175
ET_KERNEL_CHECK(ctx, ret_val == 0, Internal, out);
147-
148176
return out;
149177
}
150178

backends/test/suite/runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Set of unsupported ops that should cause tests to be skipped
1616
UNSUPPORTED_PORTABLE_OPS = {
1717
"aten::_embedding_bag",
18+
"aten::_adaptive_avg_pool2d",
1819
"aten::median",
1920
"aten::median.dim",
2021
"aten::round.decimals",
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# Copyright 2024-25 Arm Limited and/or its affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
import argparse
9+
10+
from executorch.devtools import Inspector
11+
12+
13+
def generate_csv(etdump_path, output):
14+
"""
15+
Generate a CSV file from ETDump profiling data.
16+
17+
Args:
18+
etdump_path (str): Path to the ETDump file generated by executor_runner
19+
output (str): Path for the output CSV file
20+
"""
21+
inspector = Inspector(etdump_path)
22+
df = inspector.to_dataframe()
23+
df.to_csv(output)
24+
25+
26+
def main():
27+
"""
28+
Main function to parse command line arguments and generate profiling CSV.
29+
30+
Usage:
31+
python generate_profiling_csv.py --etdump_path="my_etdump" --output="profiling.csv"
32+
33+
Example:
34+
python generate_profiling_csv.py --etdump_path="llama3_etdump" --output="op_profiling.csv"
35+
"""
36+
parser = argparse.ArgumentParser(
37+
description="Generate profiling CSV from a model's etdump"
38+
)
39+
parser.add_argument(
40+
"--etdump_path",
41+
type=str,
42+
default="./model.etdump",
43+
help="Path to the etdump file",
44+
required=False,
45+
)
46+
47+
parser.add_argument(
48+
"--output",
49+
type=str,
50+
default="./model_profiling.csv",
51+
help="Path to the output CSV file",
52+
required=False,
53+
)
54+
55+
args = parser.parse_args()
56+
print(f"Generating CSV from {args.etdump_path}")
57+
generate_csv(args.etdump_path, args.output)
58+
print(f"Saved CSV to {args.output}")
59+
60+
61+
if __name__ == "__main__":
62+
main()

0 commit comments

Comments
 (0)