Skip to content

Commit 6bb3801

Browse files
authored
Merge branch 'main' into phi4-export
2 parents b687fd9 + 17cbef5 commit 6bb3801

35 files changed

+1126
-372
lines changed

.ci/docker/requirements-ci.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ parameterized==0.9.0
1717

1818
# Doc build requirements, same as https://github.com/pytorch/pytorch/blob/main/.ci/docker/requirements-docs.txt
1919
sphinx==5.3.0
20+
sphinx-reredirects==0.1.4
2021
sphinx-gallery==0.14.0
2122
breathe==4.34.0
2223
exhale==0.2.3

.github/workflows/_android.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
script: |
2323
set -eux
2424
25+
# Use sccache for NDK compiler as well
26+
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
27+
export CMAKE_C_COMPILER_LAUNCHER=sccache
28+
2529
# The generic Linux job chooses to use base env, not the one setup by the image
2630
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2731
conda activate "${CONDA_ENV}"

.github/workflows/android-perf.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ jobs:
353353
script: |
354354
set -eux
355355
356+
# Use sccache for NDK compiler as well
357+
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
358+
export CMAKE_C_COMPILER_LAUNCHER=sccache
359+
356360
# The generic Linux job chooses to use base env, not the one setup by the image
357361
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
358362
conda activate "${CONDA_ENV}"
@@ -392,7 +396,7 @@ jobs:
392396
fail-fast: false
393397
with:
394398
# Due to scheduling a job may be pushed beyond the default 60m threshold
395-
timeout: 120
399+
timeout: 240
396400
device-type: android
397401
runner: linux.2xlarge
398402
test-infra-ref: ''

.github/workflows/android-release-artifacts.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ jobs:
6060
script: |
6161
set -eux
6262
63+
# Use sccache for NDK compiler as well
64+
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
65+
export CMAKE_C_COMPILER_LAUNCHER=sccache
66+
6367
# The generic Linux job chooses to use base env, not the one setup by the image
6468
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
6569
conda activate "${CONDA_ENV}"

backends/arm/test/ops/test_sigmoid.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
from typing import Tuple
1111

12+
import pytest
13+
1214
import torch
13-
from executorch.backends.arm.test import common
15+
from executorch.backends.arm.test import common, conftest
1416
from executorch.backends.arm.test.tester.arm_tester import ArmTester
1517
from executorch.exir.backend.compile_spec_schema import CompileSpec
1618
from parameterized import parameterized
@@ -63,7 +65,7 @@ def forward(self, x, y):
6365
def _test_sigmoid_tosa_MI_pipeline(
6466
self, module: torch.nn.Module, test_data: Tuple[torch.tensor]
6567
):
66-
(
68+
tester = (
6769
ArmTester(
6870
module,
6971
example_inputs=test_data,
@@ -77,11 +79,13 @@ def _test_sigmoid_tosa_MI_pipeline(
7779
.check_not(["executorch_exir_dialects_edge__ops_aten_sigmoid_default"])
7880
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
7981
.to_executorch()
80-
.run_method_and_compare_outputs(inputs=test_data)
8182
)
8283

84+
if conftest.is_option_enabled("tosa_ref_model"):
85+
tester.run_method_and_compare_outputs(inputs=test_data)
86+
8387
def _test_sigmoid_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tuple):
84-
(
88+
tester = (
8589
ArmTester(
8690
module,
8791
example_inputs=test_data,
@@ -96,9 +100,11 @@ def _test_sigmoid_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tup
96100
.check_not(["executorch_exir_dialects_edge__ops_aten_sigmoid_default"])
97101
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
98102
.to_executorch()
99-
.run_method_and_compare_outputs(inputs=test_data)
100103
)
101104

105+
if conftest.is_option_enabled("tosa_ref_model"):
106+
tester.run_method_and_compare_outputs(inputs=test_data)
107+
102108
def _test_sigmoid_tosa_ethos_BI_pipeline(
103109
self,
104110
compile_spec: list[CompileSpec],
@@ -137,6 +143,7 @@ def _test_sigmoid_tosa_u85_BI_pipeline(
137143
)
138144

139145
@parameterized.expand(test_data_suite)
146+
@pytest.mark.tosa_ref_model
140147
def test_sigmoid_tosa_MI(
141148
self,
142149
test_name: str,
@@ -145,26 +152,33 @@ def test_sigmoid_tosa_MI(
145152
self._test_sigmoid_tosa_MI_pipeline(self.Sigmoid(), (test_data,))
146153

147154
@parameterized.expand(test_data_suite)
155+
@pytest.mark.tosa_ref_model
148156
def test_sigmoid_tosa_BI(self, test_name: str, test_data: torch.Tensor):
149157
self._test_sigmoid_tosa_BI_pipeline(self.Sigmoid(), (test_data,))
150158

159+
@pytest.mark.tosa_ref_model
151160
def test_add_sigmoid_tosa_MI(self):
152161
self._test_sigmoid_tosa_MI_pipeline(self.AddSigmoid(), (test_data_suite[0][1],))
153162

163+
@pytest.mark.tosa_ref_model
154164
def test_add_sigmoid_tosa_BI(self):
155165
self._test_sigmoid_tosa_BI_pipeline(self.AddSigmoid(), (test_data_suite[5][1],))
156166

167+
@pytest.mark.tosa_ref_model
157168
def test_sigmoid_add_tosa_MI(self):
158169
self._test_sigmoid_tosa_MI_pipeline(self.SigmoidAdd(), (test_data_suite[0][1],))
159170

171+
@pytest.mark.tosa_ref_model
160172
def test_sigmoid_add_tosa_BI(self):
161173
self._test_sigmoid_tosa_BI_pipeline(self.SigmoidAdd(), (test_data_suite[0][1],))
162174

175+
@pytest.mark.tosa_ref_model
163176
def test_sigmoid_add_sigmoid_tosa_MI(self):
164177
self._test_sigmoid_tosa_MI_pipeline(
165178
self.SigmoidAddSigmoid(), (test_data_suite[4][1], test_data_suite[3][1])
166179
)
167180

181+
@pytest.mark.tosa_ref_model
168182
def test_sigmoid_add_sigmoid_tosa_BI(self):
169183
self._test_sigmoid_tosa_BI_pipeline(
170184
self.SigmoidAddSigmoid(), (test_data_suite[4][1], test_data_suite[3][1])

backends/arm/test/targets.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ def define_arm_tests():
1212
test_files.remove("passes/test_ioquantization_pass.py")
1313

1414
# Operators
15-
test_files += ["ops/test_linear.py"]
16-
test_files += ["ops/test_slice.py"]
15+
test_files += [
16+
"ops/test_linear.py",
17+
"ops/test_slice.py",
18+
"ops/test_sigmoid.py",
19+
]
1720

1821
TESTS = {}
1922

backends/vulkan/runtime/api/containers/Tensor.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,26 @@ vkapi::VulkanImage allocate_image(
260260
return vkapi::VulkanImage();
261261
}
262262

263+
// TODO(ssjia): change to always check that the image extents do not exceed
264+
// physical limits. Adding the check now based on `maxImageDimension3D` will
265+
// cause some existing models to break. Anecdotally, on Adreno and
266+
// SwiftShader devices, using 3D textures that exceed `maxImageDimension3D`
267+
// appears to be ok. So we need to figure out if is it undefined behaviour
268+
// or if there's a better way to figure out what the limit is. For now, only
269+
// check during debug build so that we can detect when exceeding physical
270+
// limits could be a potential cause for model outputs to be wrong. In the
271+
// meantime, the threshold for using texture storage can be configured at
272+
// export time.
273+
#ifdef VULKAN_DEBUG
274+
uint32_t max_extent = storage_type == utils::kTexture3D
275+
? adapter_ptr->max_texture3d_dim()
276+
: adapter_ptr->max_texture2d_dim();
277+
278+
VK_CHECK_COND(
279+
image_extents[0] <= max_extent && image_extents[1] <= max_extent &&
280+
image_extents[2] <= max_extent);
281+
#endif
282+
263283
VkSampler sampler = adapter_ptr->sampler_cache().retrieve(sampler_props);
264284

265285
return adapter_ptr->vma().create_image(
@@ -291,6 +311,8 @@ vkapi::VulkanBuffer allocate_buffer(
291311
return vkapi::VulkanBuffer();
292312
}
293313

314+
VK_CHECK_COND(numel <= context_ptr->adapter_ptr()->max_buffer_numel());
315+
294316
return adapter_ptr->vma().create_storage_buffer(
295317
element_size(dtype) * numel, allocate_memory);
296318
}

backends/vulkan/runtime/gen_vulkan_spv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ def buffer_gvec_type(dtype: str, n: int) -> str:
125125

126126
if dtype == "float":
127127
return f"vec{n}"
128+
if dtype == "uint":
129+
return f"uvec{n}"
128130
elif dtype == "half":
129131
return f"f16vec{n}"
130132
elif dtype == "int":

0 commit comments

Comments
 (0)