Skip to content

Commit 3b09371

Browse files
authored
Merge branch 'main' into addGeluSupport
2 parents 161d196 + 2b78ce5 commit 3b09371

35 files changed

+807
-463
lines changed

.ci/scripts/tests/test_gather_benchmark_configs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def test_skip_disabled_configs(self):
5353
"mv3": [
5454
self.gather_benchmark_configs.DisabledConfig(
5555
config_name="disabled_config1",
56-
github_issue="https://github.com/org/repo/issues/123",
56+
github_issue="https://github.com/org/repo/issues/123", # @lint-ignore
5757
),
5858
self.gather_benchmark_configs.DisabledConfig(
5959
config_name="disabled_config2",
60-
github_issue="https://github.com/org/repo/issues/124",
60+
github_issue="https://github.com/org/repo/issues/124", # @lint-ignore
6161
),
6262
]
6363
},
@@ -84,7 +84,9 @@ def test_skip_disabled_configs(self):
8484
self.assertIn("enabled_config2", result)
8585

8686
def test_disabled_configs_have_github_links(self):
87-
github_issue_regex = re.compile(r"https://github\.com/.+/.+/issues/\d+")
87+
github_issue_regex = re.compile(
88+
r"https://github\.com/.+/.+/issues/\d+" # @lint-ignore
89+
)
8890

8991
for (
9092
model_name,

.ci/scripts/unittest-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
2020
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
2121
source .ci/scripts/setup-vulkan-linux-deps.sh
2222

23+
# We need the runner to test the built library.
2324
PYTHON_EXECUTABLE=python \
24-
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2526
.ci/scripts/setup-linux.sh "$@"
2627

2728
.ci/scripts/unittest-linux-cmake.sh

.ci/scripts/unittest-macos.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export PATH="${TMP_DIR}:$PATH"
2020
trap 'rm -rfv ${TMP_DIR}' EXIT
2121

2222
# Setup MacOS dependencies as there is no Docker support on MacOS atm
23+
# We need the runner to test the built library.
2324
PYTHON_EXECUTABLE=python \
24-
CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2526
${CONDA_RUN} --no-capture-output \
2627
.ci/scripts/setup-macos.sh "$@"
2728

.ci/scripts/wheel/envvar_base.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@
1111
# Ensure that CMAKE_ARGS is defined before referencing it. Defaults to empty
1212
# if not defined.
1313
export CMAKE_ARGS="${CMAKE_ARGS:-}"
14-
15-
# Link the XNNPACK backend into the pybindings runtime so that users can execute
16-
# ExecuTorch programs that delegate to it.
17-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_XNNPACK=ON"

.ci/scripts/wheel/envvar_macos.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@
99
# any variables so that subprocesses will see them.
1010

1111
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"
12-
13-
# When building for macOS, link additional backends into the pybindings runtime.
14-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_COREML=ON"
15-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_MPS=ON"

.github/scripts/label_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def get_last_page_num_from_header(header: Any) -> int:
5151
# rel="next", <https://api.github.com/repositories/65600975/labels?per_page=100&page=3>; rel="last"
5252
link_info = header["link"]
5353
# Docs does not specify that it should be present for projects with just few labels
54-
# And https://github.com/malfet/deleteme/actions/runs/7334565243/job/19971396887 it's not the case
5554
if link_info is None:
5655
return 1
5756
prefix = "&page="

.github/scripts/test_extract_benchmark_results.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
2929
"name": "Syslog",
3030
"type": "DEVICE_LOG",
3131
"extension": "syslog",
32-
"url": "https://job_arn_1_device_log",
33-
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog",
32+
"url": "https://job_arn_1_device_log", # @lint-ignore
33+
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog", # @lint-ignore
3434
"app_type": app_type,
3535
"job_name": "job_arn_1_name",
3636
"os": "14",
@@ -55,8 +55,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
5555
"name": "Customer Artifacts",
5656
"type": "CUSTOMER_ARTIFACT",
5757
"extension": "zip",
58-
"url": "https://job_arn_1_customer_artifact",
59-
"s3_url": "https://job_arn_1_customer_artifact1",
58+
"url": "https://job_arn_1_customer_artifact", # @lint-ignore
59+
"s3_url": "https://job_arn_1_customer_artifact1", # @lint-ignore
6060
"app_type": app_type,
6161
"job_name": "job_arn_1_device_name",
6262
"os": "14",
@@ -68,8 +68,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
6868
"name": "Syslog",
6969
"type": "DEVICE_LOG",
7070
"extension": "syslog",
71-
"url": "https://job_arn_1_device_log",
72-
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog",
71+
"url": "https://job_arn_1_device_log", # @lint-ignore
72+
"s3_url": "https://job_arn_1/test-workflow1/1/syslog.syslog", # @lint-ignore
7373
"app_type": app_type,
7474
"job_name": "job_arn_2_name",
7575
"os": "14",
@@ -94,8 +94,8 @@ def get_mock_happy_flow_content(app_type: str = "IOS_APP"):
9494
"name": "Customer Artifacts",
9595
"type": "CUSTOMER_ARTIFACT",
9696
"extension": "zip",
97-
"url": "https://job_arn_1_customer_artifact",
98-
"s3_url": "https://job_arn_1_customer_artifact1",
97+
"url": "https://job_arn_1_customer_artifact", # @lint-ignore
98+
"s3_url": "https://job_arn_1_customer_artifact1", # @lint-ignore
9999
"app_type": app_type,
100100
"job_name": "job_arn_2_name",
101101
"os": "14",

.github/scripts/trymerge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ def check_for_sev(org: str, project: str, skip_mandatory_checks: bool) -> None:
19641964
response = cast(
19651965
Dict[str, Any],
19661966
gh_fetch_json_list(
1967-
"https://api.github.com/search/issues",
1967+
"https://api.github.com/search/issues", # @lint-ignore
19681968
params={"q": f'repo:{org}/{project} is:open is:issue label:"ci: sev"'},
19691969
),
19701970
)

CMakePresets.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
2-
"version": 10,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 31,
6-
"patch": 0
7-
},
8-
"$comment": "On-device AI across mobile, embedded and edge for PyTorch.",
2+
"version": 6,
93
"configurePresets": [
104
{
115
"name": "common",

backends/cadence/aot/tests/test_fusion_ops_passes.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -248,32 +248,28 @@ def forward(self, x):
248248
)
249249

250250
def test_force_quant_dequant_fusion(self):
251-
class M(torch.nn.Module):
252-
def __init__(self):
253-
super().__init__()
254-
255-
def forward(self, x):
256-
x = torch.ops.quantized_decomposed.quantize_per_tensor(
257-
x, 1.2, 3, 0, 127, torch.int8
258-
)
259-
x = torch.permute(x, [2, 0, 1, 3])
260-
x = torch.ops.quantized_decomposed.dequantize_per_tensor(
261-
x, 4.5, 6, 0, 127, torch.int8
262-
)
263-
return x
264-
265-
inputs = torch.randn(2, 12, 1, 6)
266-
model = M()
267-
graph_module = export_to_edge(model, (inputs,)).exported_program().graph_module
268-
269-
graph_module = FuseQuantDequantToRequantizePass(
251+
builder = GraphBuilder()
252+
x = builder.placeholder("x", torch.randn(2, 12, 1, 6, dtype=torch.float32))
253+
quant = builder.call_operator(
254+
op=exir_ops.edge.quantized_decomposed.quantize_per_tensor.default,
255+
args=(x, 1.2, 3, 0, 127, torch.int8),
256+
)
257+
permute = builder.call_operator(
258+
op=exir_ops.edge.aten.permute_copy.default, args=(quant, [2, 0, 1, 3])
259+
)
260+
dequant = builder.call_operator(
261+
op=exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default,
262+
args=(permute, 4.5, 6, 0, 127, torch.int8),
263+
)
264+
builder.output(dequant)
265+
original_graph = builder.get_graph_module()
266+
converted_graph = FuseQuantDequantToRequantizePass(
270267
force_quant_dequant_fusion=True
271-
)(graph_module).graph_module
268+
)(original_graph).graph_module
272269
self.check_op_counts(
273-
graph_module,
270+
converted_graph,
274271
expected_op_counts={
275-
# Verify that no dequant/quant pair was replaced with requantize.
276-
# quantize -> permute -> dequantize should not be replaced with requantize.
272+
# Verify that dequant/quant pair was replaced with requantize.
277273
exir_ops.edge.quantized_decomposed.quantize_per_tensor.default: 0,
278274
exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default: 0,
279275
exir_ops.edge.cadence.requantize.default: 1,

backends/openvino/scripts/openvino_build.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,11 @@ main() {
4848
# Set parameters to configure the project with CMake
4949
# Note: Add any additional configuration options you need here
5050
export CMAKE_ARGS="-DEXECUTORCH_BUILD_OPENVINO=ON \
51-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
52-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
53-
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
54-
-DEXECUTORCH_ENABLE_LOGGING=ON \
55-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
56-
-DEXECUTORCH_BUILD_PYBIND=ON"
51+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON"
5752
export CMAKE_BUILD_ARGS="--target openvino_backend"
5853

5954
# Build the package
60-
pip install . --no-build-isolation
55+
./install_executorch.sh
6156

6257
else
6358
echo "Error: Argument is not valid: $build_type"

backends/vulkan/runtime/graph/ComputeGraph.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,11 @@ void ComputeGraph::prepare() {
644644
if (config_.enable_querypool) {
645645
context_->initialize_querypool();
646646
}
647+
648+
for (SharedObject& shared_object : shared_objects_) {
649+
shared_object.allocate(this);
650+
shared_object.bind_users(this);
651+
}
647652
}
648653

649654
void ComputeGraph::encode_prepack() {
@@ -668,11 +673,6 @@ void ComputeGraph::encode_execute() {
668673

669674
context_->cmd_reset_querypool();
670675

671-
for (SharedObject& shared_object : shared_objects_) {
672-
shared_object.allocate(this);
673-
shared_object.bind_users(this);
674-
}
675-
676676
for (std::unique_ptr<ExecuteNode>& node : execute_nodes_) {
677677
node->encode(this);
678678
}

backends/vulkan/runtime/graph/ComputeGraph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <executorch/backends/vulkan/runtime/graph/containers/Value.h>
2222

2323
#include <executorch/backends/vulkan/runtime/graph/ops/DispatchNode.h>
24+
#include <executorch/backends/vulkan/runtime/graph/ops/DynamicDispatchNode.h>
2425
#include <executorch/backends/vulkan/runtime/graph/ops/ExecuteNode.h>
2526
#include <executorch/backends/vulkan/runtime/graph/ops/PrepackNode.h>
2627

backends/vulkan/runtime/graph/ops/DispatchNode.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ComputeGraph;
2222
/*
2323
* Represents a single shader execution op in a ML model.
2424
*/
25-
class DispatchNode final : public ExecuteNode {
25+
class DispatchNode : public ExecuteNode {
2626
friend class ComputeGraph;
2727

2828
public:
@@ -43,9 +43,9 @@ class DispatchNode final : public ExecuteNode {
4343
void encode(ComputeGraph* graph) override;
4444

4545
protected:
46-
const vkapi::ShaderInfo shader_;
47-
const utils::uvec3 global_workgroup_size_;
48-
const utils::WorkgroupSize local_workgroup_size_;
46+
vkapi::ShaderInfo shader_;
47+
utils::uvec3 global_workgroup_size_;
48+
utils::WorkgroupSize local_workgroup_size_;
4949
const vkapi::ParamsBindList params_;
5050
const vkapi::SpecVarList spec_vars_;
5151
const std::vector<PushConstantDataInfo> push_constants_;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
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+
9+
#include <executorch/backends/vulkan/runtime/graph/ops/DynamicDispatchNode.h>
10+
11+
#include <executorch/backends/vulkan/runtime/graph/ComputeGraph.h>
12+
13+
namespace vkcompute {
14+
15+
DynamicDispatchNode::DynamicDispatchNode(
16+
ComputeGraph& graph,
17+
const PickShaderFn& pick_shader_fn,
18+
const PickGlobalFn& pick_global_wg_fn,
19+
const PickLocalFn& pick_local_wg_fn,
20+
const std::vector<ArgGroup>& args,
21+
const vkapi::ParamsBindList& params,
22+
const std::vector<PushConstantDataInfo>& push_constants,
23+
const vkapi::SpecVarList& spec_vars,
24+
const std::vector<ValueRef>& resize_args,
25+
const ResizeFunction& resize_fn)
26+
: DispatchNode(
27+
graph,
28+
pick_shader_fn(&graph, args, resize_args),
29+
pick_global_wg_fn(&graph, args, resize_args),
30+
pick_local_wg_fn(&graph, args, resize_args),
31+
args,
32+
params,
33+
push_constants,
34+
spec_vars,
35+
resize_args,
36+
resize_fn),
37+
pick_shader_fn_(pick_shader_fn),
38+
pick_global_wg_fn_(pick_global_wg_fn),
39+
pick_local_wg_fn_(pick_local_wg_fn) {}
40+
41+
void DynamicDispatchNode::encode(ComputeGraph* graph) {
42+
shader_ = pick_shader_fn_(graph, args_, resize_args_);
43+
global_workgroup_size_ = pick_global_wg_fn_(graph, args_, resize_args_);
44+
local_workgroup_size_ =
45+
utils::WorkgroupSize(pick_local_wg_fn_(graph, args_, resize_args_));
46+
DispatchNode::encode(graph);
47+
}
48+
49+
} // namespace vkcompute
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
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+
9+
#pragma once
10+
11+
#include <executorch/backends/vulkan/runtime/api/api.h>
12+
13+
#include <executorch/backends/vulkan/runtime/graph/containers/PushConstantData.h>
14+
#include <executorch/backends/vulkan/runtime/graph/containers/Value.h>
15+
16+
#include <executorch/backends/vulkan/runtime/graph/ops/DispatchNode.h>
17+
18+
namespace vkcompute {
19+
20+
class ComputeGraph;
21+
22+
/*
23+
* Represents a single shader execution op in a ML model.
24+
*/
25+
class DynamicDispatchNode final : public DispatchNode {
26+
friend class ComputeGraph;
27+
28+
public:
29+
using PickShaderFn = const std::function<vkapi::ShaderInfo(
30+
ComputeGraph*,
31+
const std::vector<ArgGroup>&,
32+
const std::vector<ValueRef>&)>;
33+
using PickGlobalFn = const std::function<utils::uvec3(
34+
ComputeGraph*,
35+
const std::vector<ArgGroup>&,
36+
const std::vector<ValueRef>&)>;
37+
using PickLocalFn = const std::function<utils::uvec3(
38+
ComputeGraph*,
39+
const std::vector<ArgGroup>&,
40+
const std::vector<ValueRef>&)>;
41+
42+
explicit DynamicDispatchNode(
43+
ComputeGraph& graph,
44+
const PickShaderFn& pick_shader_fn,
45+
const PickGlobalFn& pick_global_wg_fn,
46+
const PickLocalFn& pick_local_wg_fn,
47+
const std::vector<ArgGroup>& args,
48+
const vkapi::ParamsBindList& params,
49+
const std::vector<PushConstantDataInfo>& push_constants,
50+
const vkapi::SpecVarList& spec_vars,
51+
const std::vector<ValueRef>& resize_args,
52+
const ResizeFunction& resize_fn = nullptr);
53+
54+
~DynamicDispatchNode() override = default;
55+
56+
void encode(ComputeGraph* graph) override;
57+
58+
protected:
59+
const PickShaderFn pick_shader_fn_;
60+
const PickGlobalFn pick_global_wg_fn_;
61+
const PickLocalFn pick_local_wg_fn_;
62+
63+
public:
64+
operator bool() const {
65+
return shader_;
66+
}
67+
};
68+
69+
} // namespace vkcompute

0 commit comments

Comments
 (0)