Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions backends/cadence/aot/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions backends/cadence/aot/functions_hifi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions backends/cadence/hifi/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions backends/cadence/reference/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 30 additions & 0 deletions examples/cadence/models/mobilenet_v2.py
Original file line number Diff line number Diff line change
@@ -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)
30 changes: 30 additions & 0 deletions examples/cadence/models/resnet50.py
Original file line number Diff line number Diff line change
@@ -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)
Loading