Skip to content

Commit 70aaf24

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Run quantized example models
Summary: Run quantized example models in `test_quantize.sh`, for both cmake and buck2. Differential Revision: D48634756 fbshipit-source-id: e418440a168f3a4718c8cd6c60b7fe3b0922ee6f
1 parent 8683882 commit 70aaf24

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ endif()
280280
# Generate lib to register quantized ops
281281
if(REGISTER_QUANTIZED_OPS)
282282
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/quantized)
283+
list(APPEND _libs quantized_ops_lib)
283284
endif()
284285

285286
# ios can only build library but not binary

examples/quantization/test_quantize.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ test_buck2_quantization() {
3030

3131
echo "Run example.py"
3232
${PYTHON_EXECUTABLE} -m "examples.quantization.example" --so_library="$SO_LIB" --model_name="$1"
33+
34+
echo 'Running executor_runner'
35+
buck2 run //examples/executor_runner:executor_runner \
36+
--config=executorch.register_quantized_ops=1 -- --model_path="./$1.pte"
37+
# should give correct result
38+
39+
echo "Removing $1.pte"
40+
rm "./$1.pte"
3341
}
3442

3543
test_cmake_quantization() {
@@ -52,6 +60,13 @@ test_cmake_quantization() {
5260

5361
echo "Run example.py, shared library $SO_LIB"
5462
${PYTHON_EXECUTABLE} -m "examples.quantization.example" --so_library="$SO_LIB" --model_name="$1"
63+
64+
echo 'Running executor_runner'
65+
cmake-out/executor_runner --model_path="./$1.pte"
66+
# should give correct result
67+
68+
echo "Removing $1.pte"
69+
rm "./$1.pte"
5570
}
5671

5772
if [[ -z $PYTHON_EXECUTABLE ]];

kernels/quantized/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ gen_custom_ops_aot_lib("quantized_ops_aot_lib" "${_quantized_sources}")
5252

5353
# Build a library for _quantized_kernels_srcs
5454
#
55-
# quantized_kernels: Pure-C++ kernel library for quantized ops
56-
gen_operators_lib("quantized_kernels" "${_quantized_kernels__srcs}")
55+
# quantized_ops_lib: Register quantized ops kernels into Executorch runtime
56+
gen_operators_lib("quantized_ops_lib" "${_quantized_kernels__srcs}")

0 commit comments

Comments
 (0)