Skip to content

Commit bbf612c

Browse files
committed
Update
[ghstack-poisoned]
2 parents 0bc272e + ce74f8e commit bbf612c

File tree

79 files changed

+3525
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3525
-298
lines changed

.ci/scripts/setup-openvino.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/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+
8+
set -ex
9+
10+
# shellcheck source=/dev/null
11+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
12+
13+
git clone https://github.com/openvinotoolkit/openvino.git
14+
cd openvino && git checkout releases/2025/1
15+
git submodule update --init --recursive
16+
sudo ./install_build_dependencies.sh
17+
mkdir build && cd build
18+
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
19+
make -j$(nproc)
20+
21+
cd ..
22+
cmake --install build --prefix dist
23+
24+
source dist/setupvars.sh
25+
cd ../backends/openvino
26+
pip install -r requirements.txt
27+
cd scripts
28+
./openvino_build.sh --enable_python

.ci/scripts/test_openvino.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/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+
8+
set -ex
9+
10+
# shellcheck source=/dev/null
11+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
12+
13+
source openvino/dist/setupvars.sh
14+
cd backends/openvino/tests
15+
python test_runner.py --test_type ops
16+
python test_runner.py --test_type models

.github/workflows/pull.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,3 +736,25 @@ jobs:
736736
conda activate "${CONDA_ENV}"
737737
738738
# placeholder for mediatek to add more tests
739+
740+
test-openvino-linux:
741+
name: test-openvino-linux
742+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
743+
permissions:
744+
id-token: write
745+
contents: read
746+
strategy:
747+
fail-fast: false
748+
with:
749+
runner: linux.2xlarge
750+
docker-image: executorch-ubuntu-22.04-gcc9
751+
submodules: 'true'
752+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
753+
timeout: 90
754+
script: |
755+
# The generic Linux job chooses to use base env, not the one setup by the image
756+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
757+
conda activate "${CONDA_ENV}"
758+
759+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-openvino.sh
760+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_openvino.sh

.lintrunner.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,14 @@ include_patterns = [
299299
# TODO(https://github.com/pytorch/executorch/issues/7441): Gradually start enabling all folders.
300300
# 'backends/**/*.py',
301301
'backends/arm/**/*.py',
302+
'backends/openvino/**/*.py',
302303
'build/**/*.py',
303304
'codegen/**/*.py',
304305
# 'devtools/**/*.py',
305306
'devtools/visualization/**/*.py',
306307
'docs/**/*.py',
307308
# 'examples/**/*.py',
309+
'examples/openvino/**/*.py',
308310
# 'exir/**/*.py',
309311
# 'extension/**/*.py',
310312
'kernels/**/*.py',

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2-
# Copyright 2024-2025 Arm Limited and/or its affiliates.
32
# All rights reserved.
3+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
44
#
55
# This source code is licensed under the BSD-style license found in the
66
# LICENSE file in the root directory of this source tree.
@@ -161,7 +161,7 @@ if(OPTIMIZE_SIZE)
161161
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
162162
else()
163163
# -O2: Moderate opt.
164-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
164+
set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
165165
endif()
166166

167167
option(EXECUTORCH_BUILD_ANDROID_JNI "Build Android JNI" OFF)
@@ -204,6 +204,8 @@ option(EXECUTORCH_BUILD_MPS "Build the MPS backend" OFF)
204204

205205
option(EXECUTORCH_BUILD_NEURON "Build the backends/mediatek directory" OFF)
206206

207+
option(EXECUTORCH_BUILD_OPENVINO "Build the Openvino backend" OFF)
208+
207209
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
208210

209211
option(EXECUTORCH_BUILD_QNN "Build the Qualcomm backend" OFF)
@@ -715,6 +717,10 @@ if(EXECUTORCH_BUILD_NEURON)
715717
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/mediatek)
716718
endif()
717719

720+
if(EXECUTORCH_BUILD_OPENVINO)
721+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/openvino)
722+
endif()
723+
718724
if(EXECUTORCH_BUILD_QNN)
719725
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
720726
endif()
@@ -817,6 +823,10 @@ if(EXECUTORCH_BUILD_PYBIND)
817823
list(APPEND _dep_libs mpsdelegate)
818824
endif()
819825

826+
if(EXECUTORCH_BUILD_OPENVINO)
827+
list(APPEND _dep_libs openvino_backend)
828+
endif()
829+
820830
if(EXECUTORCH_BUILD_XNNPACK)
821831
# need to explicitly specify XNNPACK and microkernels-prod
822832
# here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Platform Support:
2929
- Arm
3030
- Cadence
3131
- MediaTek
32+
- OpenVINO
3233
- Qualcomm
3334
- Vulkan
3435
- XNNPACK

backends/apple/coreml/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ runtime.cxx_python_extension(
7272
headers = glob([
7373
"runtime/inmemoryfs/**/*.hpp",
7474
]),
75-
base_module = "",
75+
base_module = "executorch.backends.apple.coreml",
7676
compiler_flags = [
7777
"-std=c++17",
7878
],

backends/arm/_passes/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from . import arm_pass_utils # noqa
88
from .annotate_channels_last_dim_order_pass import AnnotateChannelsLastDimOrder # noqa
99
from .annotate_decomposed_matmul import AnnotateDecomposedMatmulPass # noqa
10-
from .cast_int64_pass import CastInt64ToInt32Pass # noqa
10+
from .cast_int64_pass import CastInt64BuffersToInt32Pass # noqa
11+
from .cast_to_int32_pass import CastToInt32Pass # noqa
1112
from .conv1d_unsqueeze_pass import Conv1dUnsqueezePass # noqa
1213
from .convert_any_default_dim_dims_pass import ConvertAnyDefaultDimDimsPass # noqa
1314
from .convert_expand_copy_to_repeat import ConvertExpandCopyToRepeatPass # noqa

backends/arm/_passes/arm_pass_manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from executorch.backends.arm._passes import (
1111
AnnotateChannelsLastDimOrder,
1212
AnnotateDecomposedMatmulPass,
13-
CastInt64ToInt32Pass,
13+
CastInt64BuffersToInt32Pass,
14+
CastToInt32Pass,
1415
ComputeConstantOpsAOT,
1516
Conv1dUnsqueezePass,
1617
ConvertAnyDefaultDimDimsPass,
@@ -80,6 +81,8 @@ def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
8081
self.add_pass(ConvertToClampPass())
8182
self.add_pass(ConvertMinMaxPass())
8283
self.add_pass(ConvertAnyDefaultDimDimsPass())
84+
if isinstance(self.tosa_spec, Tosa_0_80) and self.tosa_spec.is_U55_subset:
85+
self.add_pass(CastToInt32Pass())
8386

8487
self.add_pass(ReplaceScalarWithTensorArgPass())
8588
self.add_pass(AnnotateDecomposedMatmulPass())
@@ -94,7 +97,7 @@ def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
9497
self.add_pass(SizeAdjustConv2DPass())
9598
self.add_pass(ConvertExpandCopyToRepeatPass())
9699
self.add_pass(UnsqueezeBeforeRepeatPass())
97-
self.add_pass(CastInt64ToInt32Pass(exported_program))
100+
self.add_pass(CastInt64BuffersToInt32Pass(exported_program))
98101
self.add_pass(KeepDimsFalseToSqueezePass())
99102
self.add_pass(Conv1dUnsqueezePass(exported_program))
100103
self.add_pass(DecomposeSelectPass())
@@ -141,7 +144,7 @@ def _tosa_080_MI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
141144
self.add_pass(SizeAdjustConv2DPass())
142145
self.add_pass(ConvertExpandCopyToRepeatPass())
143146
self.add_pass(UnsqueezeBeforeRepeatPass())
144-
self.add_pass(CastInt64ToInt32Pass(exported_program))
147+
self.add_pass(CastInt64BuffersToInt32Pass(exported_program))
145148
self.add_pass(KeepDimsFalseToSqueezePass())
146149
self.add_pass(Conv1dUnsqueezePass(exported_program))
147150
self.add_pass(DecomposeSelectPass())

backends/arm/_passes/cast_int64_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
logger.setLevel(logging.WARNING)
1616

1717

18-
class CastInt64ToInt32Pass(ExportPass):
18+
class CastInt64BuffersToInt32Pass(ExportPass):
1919
"""
2020
Cast int64 buffers to int32 if the int64 data is in int32 range.
2121
"""
2222

2323
def __init__(self, exported_program: torch.export.ExportedProgram):
24-
super(CastInt64ToInt32Pass, self).__init__()
24+
super(CastInt64BuffersToInt32Pass, self).__init__()
2525
self.exported_program = exported_program
2626

2727
def _assert_within_int32(self, tensor: torch.Tensor, node: torch.fx.Node):

0 commit comments

Comments
 (0)