From 685dc4007817b61ddb920eda9ad18c1e6dbe41c9 Mon Sep 17 00:00:00 2001 From: Siddartha Pothapragada Date: Mon, 22 Dec 2025 15:02:47 -0800 Subject: [PATCH] Fix xplat/fbcode sync for cortex_m quantizer Summary: This diff adds missing Buck build targets and module exports for the cortex_m quantizer package in both xplat and fbcode. ## Rationale The recent diff-train commit D89549367 added softmax support to the cortex_m backend, which introduced new quantizer files (operator_configs.py, quantization_configs.py, quantizer.py). However, the following were missing: 1. **TARGETS files**: No Buck build targets existed for the quantizer package, making it impossible to depend on these modules from other targets 2. **__init__.py files**: No module exports existed, preventing proper Python package imports 3. **Dependency in ops/TARGETS**: The ops target was missing the quantization_configs dependency needed for the operators module ## Changes - Add `quantizer` and `quantization_configs` Buck targets to both xplat and fbcode - Add `__init__.py` with proper exports for quantizer classes and config constants - Add missing `quantization_configs` dependency to `ops/TARGETS` - Use appropriate build macros: `runtime.python_library` for xplat, `python_library` for fbcode Reviewed By: rascani, digantdesai Differential Revision: D89688088 --- backends/cortex_m/ops/TARGETS | 1 + backends/cortex_m/quantizer/TARGETS | 36 +++++++++++++++++++++++++ backends/cortex_m/quantizer/__init__.py | 19 +++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 backends/cortex_m/quantizer/TARGETS create mode 100644 backends/cortex_m/quantizer/__init__.py diff --git a/backends/cortex_m/ops/TARGETS b/backends/cortex_m/ops/TARGETS index 12044266ca1..18b387c8ad2 100644 --- a/backends/cortex_m/ops/TARGETS +++ b/backends/cortex_m/ops/TARGETS @@ -17,6 +17,7 @@ runtime.python_library( deps = [ "fbcode//caffe2:torch", "//executorch/backends/cortex_m/passes:passes_utils", + "//executorch/backends/cortex_m/quantizer:quantization_configs", ], ) diff --git a/backends/cortex_m/quantizer/TARGETS b/backends/cortex_m/quantizer/TARGETS new file mode 100644 index 00000000000..0af105efef0 --- /dev/null +++ b/backends/cortex_m/quantizer/TARGETS @@ -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_library.bzl", "python_library") + +oncall("executorch") + +python_library( + name = "quantizer", + srcs = [ + "__init__.py", + "operator_configs.py", + "quantization_configs.py", + "quantizer.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/arm/quantizer:quantization_config", + "//pytorch/ao:torchao", + ], +) + +python_library( + name = "quantization_configs", + srcs = [ + "quantization_configs.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/arm/quantizer:quantization_config", + "//pytorch/ao:torchao", + ], +) diff --git a/backends/cortex_m/quantizer/__init__.py b/backends/cortex_m/quantizer/__init__.py new file mode 100644 index 00000000000..39a3de431ff --- /dev/null +++ b/backends/cortex_m/quantizer/__init__.py @@ -0,0 +1,19 @@ +# 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. + +from .quantization_configs import ( # noqa + CMSIS_SOFTMAX_SCALE, + CMSIS_SOFTMAX_ZERO_POINT, + INT8_ACTIVATION_PER_CHANNEL_QSPEC, + INT8_ACTIVATION_PER_TENSOR_QSPEC, + INT8_PER_CHANNEL_CONFIG, + INT8_PER_TENSOR_CONFIG, + INT8_WEIGHT_PER_CHANNEL_QSPEC, + INT8_WEIGHT_PER_TENSOR_QSPEC, + SOFTMAX_OUTPUT_FIXED_QSPEC, + SOFTMAX_PER_TENSOR_CONFIG, +) +from .quantizer import CortexMQuantizer, SharedQspecQuantizer # noqa