Skip to content

Commit

Permalink
[HACK] debug of aot_lib - moving to cmake version
Browse files Browse the repository at this point in the history
this requires some modifications to the cmake deps and variants which
are being registered.

Signed-off-by: Rob Elliott <robert.elliott@arm.com>
  • Loading branch information
robell committed Apr 25, 2024
1 parent b387ef2 commit 5996cbf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
28 changes: 27 additions & 1 deletion examples/arm/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,38 @@ function generate_pte_file() {
pte_file=$(realpath ${model_filename})
rm -f "${pte_file}"

SO_LIB=$(buck2 build //kernels/quantized:aot_lib --show-output | grep "buck-out" | cut -d" " -f2)
# This works, but blows up in ci because TMPDIR is long (as a choice of buck2 implementation)
# and sccache fails to open a unix domain socket under this directory .
# SO_LIB=$(buck2 build //kernels/quantized:aot_lib --show-output | grep "buck-out" | cut -d" " -f2)
# We are using the aot_lib from build_quantization_aot_lib below
SO_LIB=$(find -name libquantized_ops_aot_lib.so)

python3 -m examples.arm.aot_arm_compiler --model_name="${model}" ${delegate} --so_library="$SO_LIB" 1>&2
[[ -f ${pte_file} ]] || { echo "Failed to generate a pte file - ${pte_file}"; exit 1; }
echo "${pte_file}"
}

function build_quantization_aot_lib()
{
SITE_PACKAGES="$(python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"

cd $et_root_dir
mkdir -p cmake-out-aot-lib
cmake -DBUCK2=${buck2} \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_BUILD_QUANTIZED=ON \
-DEXECUTORCH_BUILD_QUANTIZED_OPS_AOT=ON \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DPYTHON_EXECUTABLE=python3 \
-Bcmake-out-aot-lib \
"${et_root_dir}"

n=$(nproc)
cmake --build cmake-out-aot-lib -j"$((n - 5))" -- quantized_ops_aot_lib
}

# build ExecuTorch Libraries
function build_executorch() {
set -x
Expand Down Expand Up @@ -173,6 +198,7 @@ type ${buck2} 2>&1 > /dev/null \

# build executorch libraries
build_executorch
build_quantization_aot_lib

# the test models run, and whether to delegate
test_model=( "softmax" "add" "add3" "mv2" )
Expand Down
1 change: 1 addition & 0 deletions kernels/quantized/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if(NOT EXECUTORCH_BUILD_ARM_BAREMETAL)
# Build a AOT library to register quantized ops into PyTorch. This is a hack.
set(_quantized_sources
${_quantized_kernels__srcs}
${EXECUTORCH_ROOT}/kernels/portable/cpu/util/reduce_util.cpp
${EXECUTORCH_ROOT}/runtime/core/exec_aten/util/tensor_util_aten.cpp)
gen_custom_ops_aot_lib("quantized_ops_aot_lib" "${_quantized_sources}")
endif()
Expand Down
24 changes: 0 additions & 24 deletions kernels/quantized/quantized.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,6 @@
- arg_meta: null
kernel_name: torch::executor::dequantize_per_channel_out

- func: quantized_decomposed::embedding_byte.out(Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, int weight_quant_min, int weight_quant_max, Tensor indices, *, Tensor(a!) out) -> Tensor(a!)
variants: function
kernels:
- arg_meta: null
kernel_name: torch::executor::quantized_embedding_byte_out

- func: quantized_decomposed::embedding_byte.dtype_out(Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, int weight_quant_min, int weight_quant_max, Tensor indices, *, ScalarType? dtype=None, Tensor(a!) out) -> Tensor(a!)
variants: function
kernels:
- arg_meta: null
kernel_name: torch::executor::quantized_embedding_byte_dtype_out

- func: quantized_decomposed::embedding_4bit.out(Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, int weight_quant_min, int weight_quant_max, Tensor indices, *, Tensor(a!) out) -> Tensor(a!)
variants: function
kernels:
- arg_meta: null
kernel_name: torch::executor::quantized_embedding_4bit_out

- func: quantized_decomposed::embedding_4bit.dtype_out(Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, int weight_quant_min, int weight_quant_max, Tensor indices, ScalarType? dtype=None, *, Tensor(a!) out) -> Tensor(a!)
variants: function
kernels:
- arg_meta: null
kernel_name: torch::executor::quantized_embedding_4bit_dtype_out

- func: quantized_decomposed::mixed_mm.out(Tensor input, Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, *, Tensor(a!) out) -> Tensor(a!)
variants: function
kernels:
Expand Down

0 comments on commit 5996cbf

Please sign in to comment.