Skip to content

Commit

Permalink
refactor test targets
Browse files Browse the repository at this point in the history
Differential Revision: D68194772
  • Loading branch information
Zonglin Peng authored and facebook-github-bot committed Jan 16, 2025
1 parent 1b7b10e commit 44f1d61
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
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)

0 comments on commit 44f1d61

Please sign in to comment.