Skip to content

Commit e7ebb5e

Browse files
Yujie Huifacebook-github-bot
authored andcommitted
add support not decompose into vulkan_partition (#4056)
Summary: Pull Request resolved: #4056 Operator `aten.upsample_nearest2d.vec` will be decomposed into several operators when lowering to Vulkan delegation. While we already have the implementation of this op in Vulkan. Add support to disable decomposition in Vulkan Partitioner. Follow usage in this [example](https://www.internalfb.com/code/fbsource/[697a6da34c78]/fbcode/executorch/exir/backend/test/op_partitioner_demo.py?lines=158). Reviewed By: jorgep31415 Differential Revision: D58900868 fbshipit-source-id: e251b6f0c96ed80731766d3451af1cd8c20fce96
1 parent 34fd767 commit e7ebb5e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

backends/vulkan/partitioner/vulkan_partitioner.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# pyre-strict
88

99
import logging
10-
from typing import Any, Dict, final, List, Mapping, Optional
10+
from typing import Any, Callable, Dict, final, List, Mapping, Optional, Tuple
1111

1212
import executorch.backends.vulkan.serialization.vulkan_graph_schema as vk_graph_schema
1313

@@ -33,6 +33,11 @@
3333

3434
from torch.fx.passes.operator_support import OperatorSupportBase
3535

36+
# pyre-ignore
37+
ops_not_to_decompose = [
38+
torch.ops.aten.upsample_nearest2d.vec,
39+
]
40+
3641

3742
class VulkanSupportedOperators(OperatorSupportBase):
3843
_ops: OpList = enumerate_supported_ops()
@@ -150,6 +155,11 @@ def __init__(self, compile_options: Optional[Dict[str, Any]] = None) -> None:
150155
compile_spec = parse_compile_options(self.options)
151156
self.delegation_spec = DelegationSpec(VulkanBackend.__name__, compile_spec)
152157

158+
def ops_to_not_decompose(
159+
self, ep: ExportedProgram
160+
) -> Tuple[List[torch._ops.OpOverload], Optional[Callable[[torch.fx.Node], bool]]]:
161+
return (ops_not_to_decompose, None)
162+
153163
def partition(self, exported_program: ExportedProgram) -> PartitionResult:
154164
# Run the CapabilityBasedPartitioner to return the largest possible
155165
# subgraphs containing the nodes with the tags

0 commit comments

Comments
 (0)