Skip to content

Commit 1a6b7a6

Browse files
authored
refactor test targets
Differential Revision: D68194772 Pull Request resolved: #7673
1 parent fbb0395 commit 1a6b7a6

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
lines changed

examples/cadence/operators/TARGETS

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
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-
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
1+
load("targets.bzl", "define_common_targets")
82

93
oncall("odai_jarvis")
104

11-
12-
python_unittest(
13-
name = "test_add_op",
14-
srcs = [
15-
"test_add_op.py",
16-
],
17-
typing = True,
18-
supports_static_listing = False,
19-
deps = [
20-
"fbsource//third-party/pypi/parameterized:parameterized",
21-
"//caffe2:torch",
22-
"//executorch/backends/cadence/aot:ops_registrations",
23-
"//executorch/backends/cadence/aot:export_example",
24-
"//executorch/backends/cadence/aot:compiler",
25-
],
26-
)
5+
define_common_targets()
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
8+
9+
TESTS_LIST = [
10+
"add_op",
11+
"quantized_conv1d_op",
12+
"quantized_linear_op",
13+
]
14+
15+
def define_common_targets():
16+
for op in TESTS_LIST:
17+
_define_test_target(op)
18+
19+
20+
def _define_test_target(test_name):
21+
file_name = "test_{}".format(test_name)
22+
python_unittest(
23+
name = file_name,
24+
srcs = [
25+
"{}.py".format(file_name),
26+
],
27+
typing = True,
28+
supports_static_listing = False,
29+
deps = [
30+
"fbsource//third-party/pypi/parameterized:parameterized",
31+
"fbcode//caffe2:torch",
32+
"fbcode//executorch/backends/cadence/aot:ops_registrations",
33+
"fbcode//executorch/backends/cadence/aot:export_example",
34+
"fbcode//executorch/backends/cadence/aot:compiler",
35+
],
36+
)

examples/cadence/operators/quantized_conv1d_op.py renamed to examples/cadence/operators/test_quantized_conv1d_op.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import logging
1010

11+
from typing import cast, Sequence
12+
1113
import torch
1214

1315
from executorch.backends.cadence.aot.ops_registrations import * # noqa
@@ -53,6 +55,6 @@ def forward(self, x: torch.Tensor):
5355
model = QuantizedConv()
5456
model.eval()
5557

56-
example_inputs = (torch.randn(shape),)
58+
example_inputs = (torch.randn(cast(Sequence[int], shape)),)
5759

5860
export_model(model, example_inputs)

0 commit comments

Comments
 (0)