Skip to content

move qnnpack utils under xnnpack #65

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion backends/qnnpack/QNNPackBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <executorch/backends/qnnpack/executor/QNNExecutor.h>
#include <executorch/backends/qnnpack/qnnpack_schema_generated.h>
#include <executorch/backends/qnnpack/utils/utils.h>
#include <executorch/backends/xnnpack/runtime/utils/utils.h>
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/runtime/backend/backend_registry.h>
#include <executorch/runtime/core/error.h>
Expand Down
21 changes: 1 addition & 20 deletions backends/qnnpack/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,6 @@ def define_common_targets():
],
)

for aten_mode in (True, False):
aten_suffix = "_aten" if aten_mode else ""
runtime.cxx_library(
name = "qnnpack_utils" + aten_suffix,
srcs = [
"utils/utils.cpp",
],
exported_headers = ["utils/utils.h"],
deps = [
"//executorch/runtime/core/exec_aten:lib" + aten_suffix,
"//executorch/runtime/backend:backend_registry",
],
visibility = [
"//executorch/backends/qnnpack/test/...",
"//executorch/backends/xnnpack/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.cxx_library(
name = "qnnpack_backend",
srcs = [
Expand All @@ -84,14 +65,14 @@ def define_common_targets():
"//executorch/runtime/core/exec_aten/util:tensor_util",
"//executorch/runtime/backend:backend_registry",
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/backends/xnnpack:dynamic_quant_utils",
"//executorch/util:memory_utils",
"//{prefix}caffe2/aten/src/ATen/native/quantized/cpu/qnnpack:pytorch_qnnpack".format(
prefix = (
"xplat/" if is_xplat() else ""
),
),
":qnnpack_schema",
":qnnpack_utils",
],
platforms = [
ANDROID,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/runtime/XNNExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/

#include <executorch/backends/qnnpack/utils/utils.h>
#include <executorch/backends/xnnpack/runtime/XNNExecutor.h>
#include <executorch/backends/xnnpack/runtime/utils/utils.h>

namespace torch {
namespace executor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include <executorch/backends/qnnpack/utils/utils.h>
#include <executorch/backends/xnnpack/runtime/utils/utils.h>
#include <executorch/runtime/platform/assert.h>

namespace torch {
Expand Down
18 changes: 17 additions & 1 deletion backends/xnnpack/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def define_common_targets():
runtime.cxx_library(
name = "dynamic_quant_utils",
srcs = [
"runtime/utils/utils.cpp",
],
exported_headers = ["runtime/utils/utils.h"],
deps = [
"//executorch/runtime/core/exec_aten:lib",
"//executorch/runtime/backend:backend_registry",
],
visibility = [
"//executorch/backends/xnnpack/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.genrule(
name = "gen_xnnpack_schema",
srcs = [
Expand Down Expand Up @@ -52,8 +68,8 @@ def define_common_targets():
deps = [
third_party_dep("XNNPACK"),
":xnnpack_schema",
":dynamic_quant_utils", # TODO Use (1) portable for choose_qparams(), (2) xnnpack for quantize_per_tensor(),
"//executorch/runtime/backend:backend_registry",
"//executorch/backends/qnnpack:qnnpack_utils", # TODO Use (1) portable for choose_qparams(), (2) xnnpack for quantize_per_tensor()
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/util:memory_utils",
"//executorch/runtime/core/exec_aten/util:tensor_util",
Expand Down
3 changes: 3 additions & 0 deletions backends/xnnpack/test/TARGETS
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
load(":targets.bzl", "define_common_targets")

define_common_targets()

python_unittest(
name = "test_xnnpack",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
#include <executorch/runtime/platform/runtime.h>
#include "executorch/backends/qnnpack/utils/utils.h"
#include "executorch/backends/xnnpack/runtime/utils/utils.h"

using namespace ::testing;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
load(
"@fbsource//tools/build_defs:default_platform_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def define_common_targets():
runtime.cxx_test(
name = "qnnpack_utils_test",
srcs = ["test_utils.cpp"],
name = "dynamic_quant_utils_test",
srcs = ["runtime/test_runtime_utils.cpp"],
fbcode_deps = [
"//caffe2:ATen-cpu",
],
xplat_deps = [
"//caffe2:aten_cpu",
],
platforms = [ANDROID, APPLE, CXX],
deps = [
"//executorch/runtime/core/exec_aten/testing_util:tensor_util",
"//executorch/runtime/core/exec_aten/util:scalar_type_util",
"//executorch/extension/aten_util:aten_bridge",
"//executorch/backends/qnnpack:qnnpack_utils",
"//executorch/backends/xnnpack:dynamic_quant_utils",
],
)
2 changes: 1 addition & 1 deletion backends/xnnpack/threadpool/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def define_common_targets():
exported_headers = _THREADPOOL_HEADERS,
exported_deps = [
third_party_dep("pthreadpool"),
third_party_dep("cpuinfo"),
],
external_deps = ["cpuinfo"],
exported_preprocessor_flags = [
"-DET_USE_THREADPOOL",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _THIRD_PARTY_LIBS = {
"FXdiv": ["//xplat/third-party/FXdiv:FXdiv", "//backends/xnnpack/third-party:FXdiv"],
"XNNPACK": ["//xplat/third-party/XNNPACK:XNNPACK", "//backends/xnnpack/third-party:XNNPACK"],
"clog": ["//xplat/third-party/clog:clog", "//backends/xnnpack/third-party:clog"],
"cpuinfo": ["//third-party/cpuinfo:cpuinfo", "//backends/xnnpack/third-party:cpuinfo"],
"cpuinfo": ["fbsource//third-party/cpuinfo:cpuinfo", "//backends/xnnpack/third-party:cpuinfo"],
"pthreadpool": ["//xplat/third-party/pthreadpool:pthreadpool", "//backends/xnnpack/third-party:pthreadpool"],
"pthreadpool_header": ["//xplat/third-party/pthreadpool:pthreadpool_header", "//backends/xnnpack/third-party:pthreadpool_header"],
}
Expand Down