Skip to content

Commit f5abda2

Browse files
Yujie Huifacebook-github-bot
authored andcommitted
update Vulkan nn.module test to support not decomposition (#4054)
Summary: Pull Request resolved: #4054 In order to test the operators that are disabled to decompose, we need different APIs from excutorch to compile the model. We need to use `_to_edge_transform_and_lower()` by passing the Vulkan partitioner. If we use this API, we don't use the combination of `to_edge()` and `to_backend()`. https://www.internalfb.com/code/fbsource/[1176a06a4b48]/xplat/executorch/exir/program/_program.py?lines=862 Add a test option in `lower_module_and_test_output`. By default, it will call normal APIs, with `not_decompose` enabled, it will call `_to_edge_transform_and_lower()` instead. Differential Revision: D58907317
1 parent eba236c commit f5abda2

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

backends/vulkan/test/test_vulkan_delegate.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ctypes.CDLL("libvulkan.so.1")
2727

2828

29+
from executorch.exir.program._program import _to_edge_transform_and_lower
2930
from executorch.extension.pybindings.portable_lib import ( # @manual
3031
_load_for_executorch_from_buffer,
3132
)
@@ -100,6 +101,7 @@ def lower_module_and_test_output(
100101
test_inputs=None,
101102
memory_layouts=None,
102103
first_output_only=False,
104+
not_decompose=False,
103105
):
104106
"""
105107
Helper testing function that takes a torch.nn.Module and lowers it to Vulkan with
@@ -119,16 +121,25 @@ def run_test(memory_layout):
119121
program: ExportedProgram = export(
120122
model, sample_inputs, dynamic_shapes=dynamic_shapes
121123
)
122-
edge_program: EdgeProgramManager = to_edge(
123-
program, compile_config=self._edge_compile_config
124-
)
125-
126-
edge_program = edge_program.transform(
127-
[I64toI32(self._edge_compile_config._skip_dim_order), MeanToSumDiv()]
128-
)
124+
if not_decompose is False:
125+
edge_program: EdgeProgramManager = to_edge(
126+
program, compile_config=self._edge_compile_config
127+
)
129128

130-
edge_program = edge_program.to_backend(VulkanPartitioner(compile_options))
129+
edge_program = edge_program.transform(
130+
[
131+
I64toI32(self._edge_compile_config._skip_dim_order),
132+
MeanToSumDiv(),
133+
]
134+
)
131135

136+
edge_program = edge_program.to_backend(
137+
VulkanPartitioner(compile_options)
138+
)
139+
else:
140+
edge_program = _to_edge_transform_and_lower(
141+
program, partitioner=[VulkanPartitioner(compile_options)]
142+
)
132143
executorch_program = edge_program.to_executorch()
133144

134145
self.assertEqual(

0 commit comments

Comments
 (0)