Skip to content

Commit ab5219c

Browse files
mcr229facebook-github-bot
authored andcommitted
move qnnpack utils under xnnpack
Differential Revision: D48367520 fbshipit-source-id: a69558d0bf48cc81a0347c58d52aaf71dd7f2086
1 parent b015e54 commit ab5219c

File tree

10 files changed

+28
-38
lines changed

10 files changed

+28
-38
lines changed

backends/qnnpack/QNNPackBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <executorch/backends/qnnpack/executor/QNNExecutor.h>
1010
#include <executorch/backends/qnnpack/qnnpack_schema_generated.h>
11-
#include <executorch/backends/qnnpack/utils/utils.h>
11+
#include <executorch/backends/xnnpack/runtime/utils/utils.h>
1212
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
1313
#include <executorch/runtime/backend/backend_registry.h>
1414
#include <executorch/runtime/core/error.h>

backends/qnnpack/targets.bzl

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,6 @@ def define_common_targets():
4242
],
4343
)
4444

45-
for aten_mode in (True, False):
46-
aten_suffix = "_aten" if aten_mode else ""
47-
runtime.cxx_library(
48-
name = "qnnpack_utils" + aten_suffix,
49-
srcs = [
50-
"utils/utils.cpp",
51-
],
52-
exported_headers = ["utils/utils.h"],
53-
deps = [
54-
"//executorch/runtime/core/exec_aten:lib" + aten_suffix,
55-
"//executorch/runtime/backend:backend_registry",
56-
],
57-
visibility = [
58-
"//executorch/backends/qnnpack/test/...",
59-
"//executorch/backends/xnnpack/...",
60-
"@EXECUTORCH_CLIENTS",
61-
],
62-
)
63-
6445
runtime.cxx_library(
6546
name = "qnnpack_backend",
6647
srcs = [
@@ -84,14 +65,14 @@ def define_common_targets():
8465
"//executorch/runtime/core/exec_aten/util:tensor_util",
8566
"//executorch/runtime/backend:backend_registry",
8667
"//executorch/backends/xnnpack/threadpool:threadpool",
68+
"//executorch/backends/xnnpack:dynamic_quant_utils",
8769
"//executorch/util:memory_utils",
8870
"//{prefix}caffe2/aten/src/ATen/native/quantized/cpu/qnnpack:pytorch_qnnpack".format(
8971
prefix = (
9072
"xplat/" if is_xplat() else ""
9173
),
9274
),
9375
":qnnpack_schema",
94-
":qnnpack_utils",
9576
],
9677
platforms = [
9778
ANDROID,

backends/qnnpack/test/TARGETS

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
2-
load(":targets.bzl", "define_common_targets")
3-
4-
define_common_targets()
52

63
python_unittest(
74
name = "test_qnnpack",

backends/xnnpack/runtime/XNNExecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
#include <executorch/backends/qnnpack/utils/utils.h>
109
#include <executorch/backends/xnnpack/runtime/XNNExecutor.h>
10+
#include <executorch/backends/xnnpack/runtime/utils/utils.h>
1111

1212
namespace torch {
1313
namespace executor {

backends/qnnpack/utils/utils.cpp renamed to backends/xnnpack/runtime/utils/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
#include <executorch/backends/qnnpack/utils/utils.h>
9+
#include <executorch/backends/xnnpack/runtime/utils/utils.h>
1010
#include <executorch/runtime/platform/assert.h>
1111

1212
namespace torch {

backends/xnnpack/targets.bzl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.
22
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
33

44
def define_common_targets():
5+
runtime.cxx_library(
6+
name = "dynamic_quant_utils",
7+
srcs = [
8+
"runtime/utils/utils.cpp",
9+
],
10+
exported_headers = ["runtime/utils/utils.h"],
11+
deps = [
12+
"//executorch/runtime/core/exec_aten:lib",
13+
"//executorch/runtime/backend:backend_registry",
14+
],
15+
visibility = [
16+
"//executorch/backends/xnnpack/...",
17+
"@EXECUTORCH_CLIENTS",
18+
],
19+
)
20+
521
runtime.genrule(
622
name = "gen_xnnpack_schema",
723
srcs = [
@@ -52,8 +68,8 @@ def define_common_targets():
5268
deps = [
5369
third_party_dep("XNNPACK"),
5470
":xnnpack_schema",
71+
":dynamic_quant_utils", # TODO Use (1) portable for choose_qparams(), (2) xnnpack for quantize_per_tensor(),
5572
"//executorch/runtime/backend:backend_registry",
56-
"//executorch/backends/qnnpack:qnnpack_utils", # TODO Use (1) portable for choose_qparams(), (2) xnnpack for quantize_per_tensor()
5773
"//executorch/backends/xnnpack/threadpool:threadpool",
5874
"//executorch/util:memory_utils",
5975
"//executorch/runtime/core/exec_aten/util:tensor_util",

backends/xnnpack/test/TARGETS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
2+
load(":targets.bzl", "define_common_targets")
3+
4+
define_common_targets()
25

36
python_unittest(
47
name = "test_xnnpack",

backends/qnnpack/test/test_utils.cpp renamed to backends/xnnpack/test/runtime/test_runtime_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1414
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
1515
#include <executorch/runtime/platform/runtime.h>
16-
#include "executorch/backends/qnnpack/utils/utils.h"
16+
#include "executorch/backends/xnnpack/runtime/utils/utils.h"
1717

1818
using namespace ::testing;
1919

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
load(
2-
"@fbsource//tools/build_defs:default_platform_defs.bzl",
3-
"ANDROID",
4-
"APPLE",
5-
"CXX",
6-
)
71
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
82

93
def define_common_targets():
104
runtime.cxx_test(
11-
name = "qnnpack_utils_test",
12-
srcs = ["test_utils.cpp"],
5+
name = "dynamic_quant_utils_test",
6+
srcs = ["runtime/test_runtime_utils.cpp"],
137
fbcode_deps = [
148
"//caffe2:ATen-cpu",
159
],
1610
xplat_deps = [
1711
"//caffe2:aten_cpu",
1812
],
19-
platforms = [ANDROID, APPLE, CXX],
2013
deps = [
2114
"//executorch/runtime/core/exec_aten/testing_util:tensor_util",
2215
"//executorch/runtime/core/exec_aten/util:scalar_type_util",
2316
"//executorch/extension/aten_util:aten_bridge",
24-
"//executorch/backends/qnnpack:qnnpack_utils",
17+
"//executorch/backends/xnnpack:dynamic_quant_utils",
2518
],
2619
)

0 commit comments

Comments
 (0)