Skip to content

Commit 77a69e1

Browse files
mcremon-metafacebook-github-bot
authored andcommitted
Add mobilenet_v2 and resnet50 to the examples (#6940)
Summary: As titled. Both from TorchVision. Reviewed By: tarun292 Differential Revision: D66132529
1 parent dcacde0 commit 77a69e1

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

backends/cadence/hifi/operators/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ set(_aten_ops__srcs
3333
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp"
3434
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_embedding.cpp"
3535
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_full.cpp"
36+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_hardtanh.cpp"
37+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_max_pool2d_with_indices.cpp"
3638
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_permute_copy.cpp"
3739
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_slice_copy.cpp"
3840
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_softmax.cpp"

backends/cadence/reference/operators/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ set(_aten_ops__srcs
3939
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_cat.cpp"
4040
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp"
4141
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_div.cpp"
42+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_hardtanh.cpp"
43+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_max_pool2d_with_indices.cpp"
4244
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_mean.cpp"
4345
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_mul.cpp"
4446
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_permute_copy.cpp"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Example script for exporting simple models to flatbuffer
8+
9+
import logging
10+
11+
import torch
12+
13+
from executorch.backends.cadence.aot.ops_registrations import * # noqa
14+
15+
16+
from executorch.backends.cadence.aot.export_example import export_model
17+
from torchvision.models import mobilenet_v2, MobileNet_V2_Weights
18+
19+
20+
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
21+
logging.basicConfig(level=logging.INFO, format=FORMAT)
22+
23+
24+
if __name__ == "__main__":
25+
26+
model = mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT)
27+
model.eval()
28+
example_inputs = (torch.randn(1, 3, 64, 64),)
29+
30+
export_model(model, example_inputs)

examples/cadence/models/resnet50.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Example script for exporting simple models to flatbuffer
8+
9+
import logging
10+
11+
import torch
12+
13+
from executorch.backends.cadence.aot.ops_registrations import * # noqa
14+
15+
16+
from executorch.backends.cadence.aot.export_example import export_model
17+
from torchvision.models import resnet50, ResNet50_Weights
18+
19+
20+
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
21+
logging.basicConfig(level=logging.INFO, format=FORMAT)
22+
23+
24+
if __name__ == "__main__":
25+
26+
model = resnet50(weights=ResNet50_Weights.DEFAULT)
27+
model.eval()
28+
example_inputs = (torch.randn(1, 3, 64, 64),)
29+
30+
export_model(model, example_inputs)

0 commit comments

Comments
 (0)