Skip to content

Fix CI job #73

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 1 commit 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
4 changes: 2 additions & 2 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
bash .ci/scripts/test.sh

# Test custom ops
bash examples/custom_ops/test_custom_ops.sh buck2
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh buck2
popd

cmake-build-test-linux:
Expand Down Expand Up @@ -90,5 +90,5 @@ jobs:
bash .ci/scripts/setup-macos.sh

# Build and test custom ops
bash examples/custom_ops/test_custom_ops.sh cmake
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh cmake
popd
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ endif()
if(NOT BUCK2)
set(BUCK2 buck2)
endif()
if(NOT PYTHON_EXECUTABLE)
set(PYTHON_EXECUTABLE python3)
endif()

# TODO(dbort): Fix these warnings and remove this flag.
set(_common_compile_options -Wno-deprecated-declarations)
Expand All @@ -87,7 +90,7 @@ if(NOT EXECUTORCH_SRCS_FILE)
message(STATUS "executorch: Generating source lists")
set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/executorch_srcs.cmake")
execute_process(
COMMAND python3 build/extract_sources.py --buck2=${BUCK2}
COMMAND ${PYTHON_EXECUTABLE} build/extract_sources.py --buck2=${BUCK2}
--config=build/cmake_deps.toml --out=${EXECUTORCH_SRCS_FILE}
OUTPUT_VARIABLE gen_srcs_output
ERROR_VARIABLE gen_srcs_error
Expand Down
21 changes: 14 additions & 7 deletions examples/custom_ops/test_custom_ops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set -e
test_buck2_custom_op_1() {
local model_name='custom_ops_1'
echo "Exporting ${model_name}.pte"
python -m "examples.custom_ops.${model_name}"
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}"
# should save file custom_ops_1.pte

echo 'Running executor_runner'
Expand All @@ -29,12 +29,14 @@ test_buck2_custom_op_1() {
test_cmake_custom_op_1() {
local model_name='custom_ops_1'
echo "Exporting ${model_name}.pte"
python -m "examples.custom_ops.${model_name}"
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}"
# should save file custom_ops_1.pte
(rm -rf cmake-out \
&& mkdir cmake-out \
&& cd cmake-out \
&& cmake -DBUCK2=buck2 -DREGISTER_EXAMPLE_CUSTOM_OP_1=ON ..)
&& cmake -DBUCK2=buck2 \
-DREGISTER_EXAMPLE_CUSTOM_OP_1=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)

echo 'Building executor_runner'
cmake --build cmake-out -j9
Expand All @@ -50,7 +52,7 @@ test_buck2_custom_op_2() {
SO_LIB=$(buck2 build //examples/custom_ops:custom_ops_aot_lib_2 --show-output | grep "buck-out" | cut -d" " -f2)

echo "Exporting ${model_name}.pte"
python -m "examples.custom_ops.${model_name}" --so_library="$SO_LIB"
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}" --so_library="$SO_LIB"
# should save file custom_ops_2.pte

buck2 run //examples/executor_runner:executor_runner \
Expand All @@ -77,28 +79,33 @@ get_shared_lib_ext() {

test_cmake_custom_op_2() {
local model_name='custom_ops_2'
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"

(rm -rf cmake-out \
&& mkdir cmake-out \
&& cd cmake-out \
&& cmake -DBUCK2=buck2 \
-DREGISTER_EXAMPLE_CUSTOM_OP_2=ON \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" ..)
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)

echo 'Building executor_runner'
cmake --build cmake-out -j4

EXT=$(get_shared_lib_ext)
echo "Exporting ${model_name}.pte"
python -m "examples.custom_ops.${model_name}" --so_library="cmake-out/examples/custom_ops/libcustom_ops_aot_lib$EXT"
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}" --so_library="cmake-out/examples/custom_ops/libcustom_ops_aot_lib$EXT"
# should save file custom_ops_2.pte

echo 'Running executor_runner'
cmake-out/executor_runner "--model_path=./${model_name}.pte"
}

if [[ -z $PYTHON_EXECUTABLE ]];
then
PYTHON_EXECUTABLE=python3
fi
if [[ $1 == "cmake" ]];
then
test_cmake_custom_op_1
Expand Down
2 changes: 1 addition & 1 deletion third-party/link_torch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ while getopts ":o:f:" opt; do
esac
done

LIB=$(python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
LIB=$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')

# delimiter ,
export IFS=","
Expand Down