Skip to content

Commit e7da0cd

Browse files
authored
Merge pull request pytorch#18 from cavusmustafa/input_validate_fix
Fix for input path bug in validation
2 parents 6c96e78 + 8959283 commit e7da0cd

File tree

9 files changed

+21
-35
lines changed

9 files changed

+21
-35
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ 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" ON)
207+
option(EXECUTORCH_BUILD_OPENVINO "Build the Openvino backend" OFF)
208208

209209
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
210210

backends/openvino/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,13 @@ executorch
4747

4848
Before you begin, ensure you have openvino installed and configured on your system:
4949

50-
## TODO: Update with the openvino commit/Release tag once the changes in OpenVINO are merged
5150
## TODO: Add instructions for support with OpenVINO release package
5251

5352
```bash
54-
git clone -b executorch_ov_backend https://github.com/ynimmaga/openvino
55-
cd openvino
53+
git clone https://github.com/openvinotoolkit/openvino.git
54+
cd openvino && git checkout 20ad7cb
5655
git submodule update --init --recursive
57-
mkdir build
58-
cd build
56+
mkdir build && cd build
5957
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
6058
make -j<N>
6159

backends/openvino/partitioner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import Callable, final, List, Optional, Tuple
88

99
import torch
10-
import torch.fx as fx
1110
from executorch.backends.openvino.preprocess import OpenvinoBackend
1211
from executorch.exir.backend.backend_details import CompileSpec
1312
from executorch.exir.backend.partitioner import (

backends/openvino/preprocess.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
# except in compliance with the License. See the license file in the root
55
# directory of this source tree for more details.
66

7-
import contextlib
8-
import struct
7+
from typing import final, List
98

10-
from typing import cast, final, List
11-
12-
import torch
139
from executorch.exir.backend.backend_details import (
1410
BackendDetails,
1511
ExportedProgram,
@@ -36,17 +32,12 @@ def preprocess(
3632
Returns:
3733
PreprocessResult: The result of preprocessing, including the compiled model bytes.
3834
"""
39-
name_to_node_mappings = {node.name: node for node in edge_program.graph.nodes}
4035
input_names = edge_program.graph_signature.user_inputs
41-
output_names = edge_program.graph_signature.user_outputs
4236
args = []
4337
for node in edge_program.graph.nodes:
4438
if node.target in input_names:
4539
args.append(node.meta["val"])
4640

47-
input_shapes = []
48-
output_shapes = []
49-
5041
compile_options = {}
5142
for spec in module_compile_spec:
5243
compile_options[spec.key] = spec.value.decode()

backends/openvino/tests/ops/base_openvino_op_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import torch
1010
from executorch.backends.openvino.partitioner import OpenvinoPartitioner
1111
from executorch.backends.openvino.preprocess import OpenvinoBackend
12-
from executorch.exir import EdgeProgramManager, to_edge
12+
from executorch.exir import EdgeProgramManager, to_edge_transform_and_lower
1313
from executorch.exir.backend.backend_details import CompileSpec
1414
from torch.export import export, ExportedProgram
1515

@@ -33,13 +33,14 @@ def execute_layer_test(
3333
# Export to aten dialect using torch.export
3434
aten_dialect: ExportedProgram = export(module, sample_inputs)
3535

36-
# Convert to edge dialect
37-
edge_program: EdgeProgramManager = to_edge(aten_dialect)
38-
to_be_lowered_module = edge_program.exported_program()
39-
40-
# Lower the module to the backend with a custom partitioner
36+
# Convert to edge dialect and lower the module to the backend with a custom partitioner
4137
compile_spec = [CompileSpec("device", self.device.encode())]
42-
lowered_module = edge_program.to_backend(OpenvinoPartitioner(compile_spec))
38+
lowered_module: EdgeProgramManager = to_edge_transform_and_lower(
39+
aten_dialect,
40+
partitioner=[
41+
OpenvinoPartitioner(compile_spec),
42+
],
43+
)
4344

4445
# Apply backend-specific passes
4546
exec_prog = lowered_module.to_executorch(

backends/openvino/tests/ops/test_pooling.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ def forward(self, x):
7878
def test_pooling2d(self):
7979
for params in d2_params:
8080
with self.subTest(params=params):
81-
bias_shape = None
82-
if "bias_shape" in params:
83-
bias_shape = params["bias_shape"]
8481
module = self.create_model(
8582
op_type="MaxPool2D",
8683
kernel_size=params["kernel_size"],

docs/source/build-run-openvino.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,13 @@ executorch
6868

6969
Before you begin, ensure you have openvino installed and configured on your system:
7070

71-
#### TODO: Update with the openvino commit/Release tag once the changes in OpenVINO are merged
7271
#### TODO: Add instructions for support with OpenVINO release package
7372

7473
```bash
75-
git clone -b executorch_ov_backend https://github.com/ynimmaga/openvino
76-
cd openvino
74+
git clone https://github.com/openvinotoolkit/openvino.git
75+
cd openvino && git checkout 20ad7cb
7776
git submodule update --init --recursive
78-
mkdir build
79-
cd build
77+
mkdir build && cd build
8078
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
8179
make -j<N>
8280

examples/openvino/aot/aot_openvino_compiler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import numpy as np
1818
import timm
1919
import torch
20-
import torchvision.datasets as datasets
2120
import torchvision.models as torchvision_models
2221
from executorch.backends.openvino import OpenVINOQuantizer
2322
from executorch.backends.openvino.partitioner import OpenvinoPartitioner
@@ -30,6 +29,7 @@
3029
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
3130
from torch.export import export
3231
from torch.export.exported_program import ExportedProgram
32+
from torchvision import datasets
3333
from transformers import AutoModel
3434

3535

@@ -119,10 +119,11 @@ def dump_inputs(calibration_dataset, dest_path):
119119
for idx, data in enumerate(calibration_dataset):
120120
feature, target = data
121121
targets.extend(target)
122-
file_name = f"{dest_path}/input_{idx}_0.raw"
122+
file_name = f"input_{idx}_0.raw"
123+
file_path = f"{dest_path}/{file_name}"
123124
if not isinstance(feature, torch.Tensor):
124125
feature = torch.tensor(feature)
125-
feature.detach().numpy().tofile(file_name)
126+
feature.detach().numpy().tofile(file_path)
126127
input_files.append(file_name)
127128

128129
return input_files, targets

examples/openvino/openvino_build_example.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ main() {
2424
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
2525
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
2626
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
27+
-DEXECUTORCH_ENABLE_LOGGING=ON \
2728
-B"${build_dir}"
2829

2930

0 commit comments

Comments
 (0)