diff --git a/backends/cadence/aot/functions.yaml b/backends/cadence/aot/functions.yaml index 1ca6735b803..e7c16d00314 100644 --- a/backends/cadence/aot/functions.yaml +++ b/backends/cadence/aot/functions.yaml @@ -77,6 +77,16 @@ - arg_meta: null kernel_name: torch::executor::gelu_out +- op: hardtanh.out + kernels: + - arg_meta: null + kernel_name: torch::executor::hardtanh_out + +- op: max_pool2d_with_indices.out + kernels: + - arg_meta: null + kernel_name: torch::executor::max_pool2d_with_indices_out + - op: mean.out kernels: - arg_meta: null diff --git a/backends/cadence/aot/functions_hifi.yaml b/backends/cadence/aot/functions_hifi.yaml index 52390e19187..cf234c22c01 100644 --- a/backends/cadence/aot/functions_hifi.yaml +++ b/backends/cadence/aot/functions_hifi.yaml @@ -62,11 +62,26 @@ - arg_meta: null kernel_name: torch::executor::full_out +- op: gelu.out + kernels: + - arg_meta: null + kernel_name: torch::executor::gelu_out + +- op: hardtanh.out + kernels: + - arg_meta: null + kernel_name: torch::executor::hardtanh_out + +- op: max_pool2d_with_indices.out + kernels: + - arg_meta: null + kernel_name: torch::executor::max_pool2d_with_indices_out + - op: mean.out kernels: - arg_meta: null - kernel_name: cadence::impl::HiFi::mean_dim_out - + kernel_name: cadence::impl::HiFi::mean_dim_out + - op: mul.out kernels: - arg_meta: null diff --git a/backends/cadence/hifi/operators/CMakeLists.txt b/backends/cadence/hifi/operators/CMakeLists.txt index dbe5867550d..fc00345465b 100644 --- a/backends/cadence/hifi/operators/CMakeLists.txt +++ b/backends/cadence/hifi/operators/CMakeLists.txt @@ -33,6 +33,9 @@ set(_aten_ops__srcs "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_embedding.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_full.cpp" + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_gelu.cpp" + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_hardtanh.cpp" + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_max_pool2d_with_indices.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_permute_copy.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_slice_copy.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_softmax.cpp" diff --git a/backends/cadence/reference/operators/CMakeLists.txt b/backends/cadence/reference/operators/CMakeLists.txt index 6cd4c870b6c..c40d3ff66be 100644 --- a/backends/cadence/reference/operators/CMakeLists.txt +++ b/backends/cadence/reference/operators/CMakeLists.txt @@ -39,6 +39,8 @@ set(_aten_ops__srcs "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_cat.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_div.cpp" + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_hardtanh.cpp" + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_max_pool2d_with_indices.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_mean.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_mul.cpp" "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_permute_copy.cpp" diff --git a/examples/cadence/models/mobilenet_v2.py b/examples/cadence/models/mobilenet_v2.py new file mode 100644 index 00000000000..3c31af88de9 --- /dev/null +++ b/examples/cadence/models/mobilenet_v2.py @@ -0,0 +1,30 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Example script for exporting simple models to flatbuffer + +import logging + +import torch + +from executorch.backends.cadence.aot.ops_registrations import * # noqa + + +from executorch.backends.cadence.aot.export_example import export_model +from torchvision.models import mobilenet_v2, MobileNet_V2_Weights + + +FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s" +logging.basicConfig(level=logging.INFO, format=FORMAT) + + +if __name__ == "__main__": + + model = mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT) + model.eval() + example_inputs = (torch.randn(1, 3, 64, 64),) + + export_model(model, example_inputs) diff --git a/examples/cadence/models/resnet50.py b/examples/cadence/models/resnet50.py new file mode 100644 index 00000000000..cac73433d1d --- /dev/null +++ b/examples/cadence/models/resnet50.py @@ -0,0 +1,30 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Example script for exporting simple models to flatbuffer + +import logging + +import torch + +from executorch.backends.cadence.aot.ops_registrations import * # noqa + + +from executorch.backends.cadence.aot.export_example import export_model +from torchvision.models import resnet50, ResNet50_Weights + + +FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s" +logging.basicConfig(level=logging.INFO, format=FORMAT) + + +if __name__ == "__main__": + + model = resnet50(weights=ResNet50_Weights.DEFAULT) + model.eval() + example_inputs = (torch.randn(1, 3, 64, 64),) + + export_model(model, example_inputs)