Skip to content

Commit 2dab102

Browse files
committed
Update on "[ET-VK] Replace Uniform buffers with push constants for view op"
This diff replaces uniform buffers with push constants for view op in the Vulkan backend of Executorch. The changes include updating the GLSL code to use push constants instead of uniform buffers and updating the C++ code to pass the sizes as push constants to the shader. Differential Revision: [D66733658](https://our.internmc.facebook.com/intern/diff/D66733658/) [ghstack-poisoned]
2 parents 7e35fe6 + 776b861 commit 2dab102

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

devtools/bundled_program/core.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import Dict, List, Optional, Sequence, Type, Union
1010

1111
import executorch.devtools.bundled_program.schema as bp_schema
12-
from pyre_extensions import none_throws
1312

1413
import executorch.exir.schema as core_schema
1514

@@ -44,10 +43,12 @@ class BundledProgram:
4443

4544
def __init__(
4645
self,
47-
executorch_program: Optional[Union[
48-
ExecutorchProgram,
49-
ExecutorchProgramManager,
50-
]],
46+
executorch_program: Optional[
47+
Union[
48+
ExecutorchProgram,
49+
ExecutorchProgramManager,
50+
]
51+
],
5152
method_test_suites: Sequence[MethodTestSuite],
5253
pte_file_path: Optional[str] = None,
5354
):
@@ -59,18 +60,24 @@ def __init__(
5960
pte_file_path: The path to pte file to deserialize program if executorch_program is not provided.
6061
"""
6162
if not executorch_program and not pte_file_path:
62-
raise RuntimeError("Either executorch_program or pte_file_path must be provided")
63+
raise RuntimeError(
64+
"Either executorch_program or pte_file_path must be provided"
65+
)
6366

6467
if executorch_program and pte_file_path:
65-
raise RuntimeError("Only one of executorch_program or pte_file_path can be used")
68+
raise RuntimeError(
69+
"Only one of executorch_program or pte_file_path can be used"
70+
)
6671

6772
method_test_suites = sorted(method_test_suites, key=lambda x: x.method_name)
6873
if executorch_program:
6974
self._assert_valid_bundle(executorch_program, method_test_suites)
70-
self.executorch_program: Optional[Union[
71-
ExecutorchProgram,
72-
ExecutorchProgramManager,
73-
]] = executorch_program
75+
self.executorch_program: Optional[
76+
Union[
77+
ExecutorchProgram,
78+
ExecutorchProgramManager,
79+
]
80+
] = executorch_program
7481
self._pte_file_path: Optional[str] = pte_file_path
7582

7683
self.method_test_suites = method_test_suites
@@ -88,7 +95,8 @@ def serialize_to_schema(self) -> bp_schema.BundledProgram:
8895
if self.executorch_program:
8996
program = self._extract_program(self.executorch_program)
9097
else:
91-
with open(none_throws(self._pte_file_path), "rb") as f:
98+
assert self._pte_file_path is not None
99+
with open(self._pte_file_path, "rb") as f:
92100
p_bytes = f.read()
93101
program = _deserialize_pte_binary(p_bytes)
94102

devtools/bundled_program/test/test_bundle_data.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
# pyre-strict
88

9+
import tempfile
910
import unittest
1011
from typing import List
11-
import tempfile
12+
1213
import executorch.devtools.bundled_program.schema as bp_schema
1314

1415
import torch
@@ -73,7 +74,7 @@ def test_bundled_program(self) -> None:
7374
bundled_program.serialize_to_schema().program,
7475
bytes(_serialize_pte_binary(executorch_program.executorch_program)),
7576
)
76-
77+
7778
def test_bundled_program_from_pte(self) -> None:
7879
executorch_program, method_test_suites = get_common_executorch_program()
7980

@@ -82,11 +83,17 @@ def test_bundled_program_from_pte(self) -> None:
8283
with open(executorch_model_path, "wb") as f:
8384
f.write(executorch_program.buffer)
8485

85-
bundled_program = BundledProgram(executorch_program=None, method_test_suites=method_test_suites, pte_file_path=executorch_model_path)
86+
bundled_program = BundledProgram(
87+
executorch_program=None,
88+
method_test_suites=method_test_suites,
89+
pte_file_path=executorch_model_path,
90+
)
8691

8792
method_test_suites = sorted(method_test_suites, key=lambda t: t.method_name)
8893

89-
for plan_id in range(len(executorch_program.executorch_program.execution_plan)):
94+
for plan_id in range(
95+
len(executorch_program.executorch_program.execution_plan)
96+
):
9097
bundled_plan_test = (
9198
bundled_program.serialize_to_schema().method_test_suites[plan_id]
9299
)

0 commit comments

Comments
 (0)