From 011a7173019aad0e171373dacdc19b5f9c520a37 Mon Sep 17 00:00:00 2001 From: Jorge Pineda Date: Fri, 5 Apr 2024 15:45:16 -0700 Subject: [PATCH] [ET-VK] Add CUNET model test CUNET uses 3 operators: ``` aten.convolution.default aten.max_pool2d_with_indices.default aten.relu.default ``` which correspond to these signatures: ``` - func: convolution(Tensor input, Tensor weight, Tensor? bias, int[] stride, SymInt[] padding, int[] dilation, bool transposed, SymInt[] output_padding, int groups) -> Tensor - func: max_pool2d_with_indices(Tensor self, int[2] kernel_size, int[2] stride=[], int[2] padding=0, int[2] dilation=1, bool ceil_mode=False) -> (Tensor, Tensor) - func: relu(Tensor self) -> Tensor ``` Differential Revision: [D54700658](https://our.internmc.facebook.com/intern/diff/D54700658/) [ghstack-poisoned] --- backends/vulkan/test/TARGETS | 1 + backends/vulkan/test/test_vulkan_delegate.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/backends/vulkan/test/TARGETS b/backends/vulkan/test/TARGETS index 608b3137c36..3287fe79095 100644 --- a/backends/vulkan/test/TARGETS +++ b/backends/vulkan/test/TARGETS @@ -20,6 +20,7 @@ python_unittest( "//executorch/extension/pybindings:portable_lib", # @manual "//executorch/extension/pytree:pylib", "//executorch/kernels/portable:custom_ops_generated_lib", + "//wearables/camera/ml/model_experimentation/person_segmentation/cunet:cunet_lib", ], ) diff --git a/backends/vulkan/test/test_vulkan_delegate.py b/backends/vulkan/test/test_vulkan_delegate.py index dd2142eee47..a4421f0f7c7 100644 --- a/backends/vulkan/test/test_vulkan_delegate.py +++ b/backends/vulkan/test/test_vulkan_delegate.py @@ -17,6 +17,9 @@ from executorch.exir import EdgeProgramManager, to_edge from torch.export import Dim, export, ExportedProgram +from wearables.camera.ml.model_experimentation.person_segmentation.cunet.cunet import ( + C_UNet, +) ctypes.CDLL("libvulkan.so.1") @@ -628,3 +631,13 @@ def forward(self, x): sample_inputs, memory_layouts=[vk_graph_schema.VkMemoryLayout.TENSOR_CHANNELS_PACKED], ) + + def test_vulkan_backend_cunet(self): + module = C_UNet() + sample_inputs = (torch.rand((1, 3, 96, 72), dtype=torch.float32),) + + self.lower_module_and_test_output( + module, + sample_inputs, + memory_layouts=[vk_graph_schema.VkMemoryLayout.TENSOR_CHANNELS_PACKED], + )