Skip to content
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

Splitting python bindings and cpp in ttnn library #17957

Merged
merged 8 commits into from
Mar 1, 2025
31 changes: 21 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ endif()
# For top level install: cmake --build build --target install or make/ninja install -C build
############################################################################################################################
# Install for build artifacts that will upload build/lib

install(
TARGETS
tt_metal
Expand All @@ -280,17 +279,18 @@ install(
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT tar
)
install(
TARGETS
ttnn
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT tar
)
if(WITH_PYTHON_BINDINGS)
# Install .so into src files for pybinds implementation
install(
TARGETS
ttnn
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not familiar with COMPONENT part. what does it mean?

Copy link
Contributor Author

@dgomezTT dgomezTT Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik, is being used for the installation process, like a tag or a category. With that being said, you caught a problem that I already fixed!

)

install(
TARGETS
ttnn
Expand All @@ -299,6 +299,17 @@ if(WITH_PYTHON_BINDINGS)
COMPONENT
tt_pybinds
)
else()
#when we don't build python bindings, we generate a dynamic library ttnncpp
install(
TARGETS
ttnncpp
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT tar
)
endif()

# FIXME(17578): figure out what bits we actually need to ship and omit the rest
Expand Down
18 changes: 18 additions & 0 deletions build_metal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ show_help() {
echo " --toolchain-path Set path to CMake toolchain file."
echo " --configure-only Only configure the project, do not build."
echo " --enable-coverage Instrument the binaries for code coverage."
echo " --without-python-bindings Disable Python bindings (ttnncpp will be available as standalone library, otherwise ttnn will include the cpp backend and the python bindings), Enabled by default"
}

clean() {
Expand Down Expand Up @@ -75,6 +76,7 @@ ttnn_shared_sub_libs="OFF"
toolchain_path="cmake/x86_64-linux-clang-17-libcpp-toolchain.cmake"
configure_only="OFF"
enable_coverage="OFF"
with_python_bindings="ON"

declare -a cmake_args

Expand Down Expand Up @@ -114,6 +116,7 @@ ttnn-shared-sub-libs
toolchain-path:
configure-only
enable-coverage
without-python-bindings
"

# Flatten LONGOPTIONS into a comma-separated string for getopt
Expand Down Expand Up @@ -177,6 +180,8 @@ while true; do
ttnn_shared_sub_libs="ON";;
--configure-only)
configure_only="ON";;
--without-python-bindings)
with_python_bindings="OFF";;
--disable-unity-builds)
unity_builds="OFF";;
--disable-light-metal-trace)
Expand Down Expand Up @@ -256,6 +261,7 @@ echo "INFO: Build tests: $build_tests"
echo "INFO: Enable Unity builds: $unity_builds"
echo "INFO: TTNN Shared sub libs : $ttnn_shared_sub_libs"
echo "INFO: Enable Light Metal Trace: $light_metal_trace"
echo "INFO: With python bindings: $with_python_bindings"

# Prepare cmake arguments
cmake_args+=("-B" "$build_dir")
Expand Down Expand Up @@ -373,6 +379,18 @@ if [ "$build_all" = "ON" ]; then
cmake_args+=("-DBUILD_TT_TRAIN=ON")
fi

if [ "$light_metal_trace" = "ON" ]; then
cmake_args+=("-DTT_ENABLE_LIGHT_METAL_TRACE=ON")
else
cmake_args+=("-DTT_ENABLE_LIGHT_METAL_TRACE=OFF")
fi

if [ "$with_python_bindings" = "ON" ]; then
cmake_args+=("-DWITH_PYTHON_BINDINGS=ON")
else
cmake_args+=("-DWITH_PYTHON_BINDINGS=OFF")
fi

# toolchain and cxx_compiler settings would conflict with eachother
# only use toolchain if not setting cxx compiler directly
if [ "$cxx_compiler_path" == "" ]; then
Expand Down
Loading
Loading