diff --git a/backends/qnnpack/QNNPackBackend.cpp b/backends/qnnpack/QNNPackBackend.cpp index eb33c7fd94d..6206ab80006 100644 --- a/backends/qnnpack/QNNPackBackend.cpp +++ b/backends/qnnpack/QNNPackBackend.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/backends/qnnpack/targets.bzl b/backends/qnnpack/targets.bzl index f0fc478ae8c..c4e63d106d7 100644 --- a/backends/qnnpack/targets.bzl +++ b/backends/qnnpack/targets.bzl @@ -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 = [ @@ -84,6 +65,7 @@ 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 = ( @@ -91,7 +73,6 @@ def define_common_targets(): ), ), ":qnnpack_schema", - ":qnnpack_utils", ], platforms = [ ANDROID, diff --git a/backends/xnnpack/runtime/XNNExecutor.cpp b/backends/xnnpack/runtime/XNNExecutor.cpp index f862021799b..5e39c86c1ba 100644 --- a/backends/xnnpack/runtime/XNNExecutor.cpp +++ b/backends/xnnpack/runtime/XNNExecutor.cpp @@ -6,8 +6,8 @@ * LICENSE file in the root directory of this source tree. */ -#include #include +#include namespace torch { namespace executor { diff --git a/backends/qnnpack/utils/utils.cpp b/backends/xnnpack/runtime/utils/utils.cpp similarity index 99% rename from backends/qnnpack/utils/utils.cpp rename to backends/xnnpack/runtime/utils/utils.cpp index 0c4b30fa11f..2331f4df52e 100644 --- a/backends/qnnpack/utils/utils.cpp +++ b/backends/xnnpack/runtime/utils/utils.cpp @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include #include namespace torch { diff --git a/backends/qnnpack/utils/utils.h b/backends/xnnpack/runtime/utils/utils.h similarity index 100% rename from backends/qnnpack/utils/utils.h rename to backends/xnnpack/runtime/utils/utils.h diff --git a/backends/xnnpack/targets.bzl b/backends/xnnpack/targets.bzl index 571cf4681f0..c4aa62e7f8e 100644 --- a/backends/xnnpack/targets.bzl +++ b/backends/xnnpack/targets.bzl @@ -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 = [ @@ -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", diff --git a/backends/xnnpack/test/TARGETS b/backends/xnnpack/test/TARGETS index 3c9647ef5ff..940aa5a9800 100644 --- a/backends/xnnpack/test/TARGETS +++ b/backends/xnnpack/test/TARGETS @@ -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", diff --git a/backends/qnnpack/test/test_utils.cpp b/backends/xnnpack/test/runtime/test_runtime_utils.cpp similarity index 98% rename from backends/qnnpack/test/test_utils.cpp rename to backends/xnnpack/test/runtime/test_runtime_utils.cpp index 24818036713..c057b32ecea 100644 --- a/backends/qnnpack/test/test_utils.cpp +++ b/backends/xnnpack/test/runtime/test_runtime_utils.cpp @@ -13,7 +13,7 @@ #include #include #include -#include "executorch/backends/qnnpack/utils/utils.h" +#include "executorch/backends/xnnpack/runtime/utils/utils.h" using namespace ::testing; diff --git a/backends/qnnpack/test/targets.bzl b/backends/xnnpack/test/targets.bzl similarity index 64% rename from backends/qnnpack/test/targets.bzl rename to backends/xnnpack/test/targets.bzl index 720658e038e..b2d94fef631 100644 --- a/backends/qnnpack/test/targets.bzl +++ b/backends/xnnpack/test/targets.bzl @@ -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", ], ) diff --git a/backends/xnnpack/threadpool/targets.bzl b/backends/xnnpack/threadpool/targets.bzl index 0c9e26d020d..a0e41422e01 100644 --- a/backends/xnnpack/threadpool/targets.bzl +++ b/backends/xnnpack/threadpool/targets.bzl @@ -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", ], diff --git a/shim/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl b/shim/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl index 401264bdc4d..75501ef5b2b 100644 --- a/shim/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl +++ b/shim/xplat/executorch/backends/xnnpack/third-party/third_party_libs.bzl @@ -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"], }