Skip to content

refactor test targets #7673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2025
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
25 changes: 2 additions & 23 deletions examples/cadence/operators/TARGETS
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
# 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.

load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
load("targets.bzl", "define_common_targets")

oncall("odai_jarvis")


python_unittest(
name = "test_add_op",
srcs = [
"test_add_op.py",
],
typing = True,
supports_static_listing = False,
deps = [
"fbsource//third-party/pypi/parameterized:parameterized",
"//caffe2:torch",
"//executorch/backends/cadence/aot:ops_registrations",
"//executorch/backends/cadence/aot:export_example",
"//executorch/backends/cadence/aot:compiler",
],
)
define_common_targets()
36 changes: 36 additions & 0 deletions examples/cadence/operators/targets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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.

load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")

TESTS_LIST = [
"add_op",
"quantized_conv1d_op",
"quantized_linear_op",
]

def define_common_targets():
for op in TESTS_LIST:
_define_test_target(op)


def _define_test_target(test_name):
file_name = "test_{}".format(test_name)
python_unittest(
name = file_name,
srcs = [
"{}.py".format(file_name),
],
typing = True,
supports_static_listing = False,
deps = [
"fbsource//third-party/pypi/parameterized:parameterized",
"fbcode//caffe2:torch",
"fbcode//executorch/backends/cadence/aot:ops_registrations",
"fbcode//executorch/backends/cadence/aot:export_example",
"fbcode//executorch/backends/cadence/aot:compiler",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import logging

from typing import cast, Sequence

import torch

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

example_inputs = (torch.randn(shape),)
example_inputs = (torch.randn(cast(Sequence[int], shape)),)

export_model(model, example_inputs)