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

Rename all pybuda to ttforge in all build files #10

Merged
merged 1 commit into from
Jul 31, 2024
Merged
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
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(pybuda LANGUAGES CXX)
project(ttforge LANGUAGES CXX)

find_program(CLANG_17 clang++-17)
find_program(CLANG clang)
Expand All @@ -8,7 +8,7 @@ if(CLANG_17 AND CLANG)
set(CMAKE_CXX_COMPILER "${CLANG_17}")
set(CMAKE_C_COMPILER "${CLANG}")
else()
message(WARNING "Clang++-17 or clang not found!!!")
message(FATAL_ERROR "Clang++-17 or clang not found!!!")
endif()

set(CMAKE_CXX_STANDARD 17)
Expand All @@ -19,13 +19,13 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(Utils)

check_required_env_var(PYBUDA_PYTHON_VERSION)
check_required_env_var(PYBUDA_TOOLCHAIN_DIR)
check_required_env_var(PYBUDA_VENV_DIR)
check_required_env_var(TTFORGE_PYTHON_VERSION)
check_required_env_var(TTFORGE_TOOLCHAIN_DIR)
check_required_env_var(TTFORGE_VENV_DIR)

set(PYBUDA_PYTHON_VERSION $ENV{PYBUDA_PYTHON_VERSION})
set(PYBUDA_TOOLCHAIN_DIR $ENV{PYBUDA_TOOLCHAIN_DIR})
set(PYBUDA_VENV_DIR $ENV{PYBUDA_VENV_DIR})
set(TTFORGE_PYTHON_VERSION $ENV{TTFORGE_PYTHON_VERSION})
set(TTFORGE_TOOLCHAIN_DIR $ENV{TTFORGE_TOOLCHAIN_DIR})
set(TTFORGE_VENV_DIR $ENV{TTFORGE_VENV_DIR})

set(TTMLIR_TOOLCHAIN_DIR $ENV{TTMLIR_TOOLCHAIN_DIR})
set(TTMLIR_VENV_DIR $ENV{TTMLIR_VENV_DIR})
Expand All @@ -36,9 +36,9 @@ endif()

add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter)

set(PYBUDA_CSRC_WARNINGS -Wall -Wextra -Wno-pragmas -Wno-unused-parameter)
set(TTFORGE_CSRC_WARNINGS -Wall -Wextra -Wno-pragmas -Wno-unused-parameter)
set(CFLAGS_NO_WARN -DFMT_HEADER_ONLY)
set(PYBUDA_CSRC_CFLAGS ${CFLAGS_NO_WARN} ${PYBUDA_CSRC_WARNINGS} -DUTILS_LOGGER_PYTHON_OSTREAM_REDIRECT=1)
set(TTFORGE_CSRC_CFLAGS ${CFLAGS_NO_WARN} ${TTFORGE_CSRC_WARNINGS} -DUTILS_LOGGER_PYTHON_OSTREAM_REDIRECT=1)

set(CONFIG_LDFLAGS "")

Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
### Building dependencies
* `cmake`
* `clang`
* `Ninja` - sudo apt-get install ninja-build
Building dependencies
-----
* `cmake3.20`
* `clang` and `clang++-17`
* `Ninja`
* `Python3.10`

### Building environment
This is one off step. It will pull all dependencies needed for tt-forge.
Building environment
-----
This is one off step to build the toolchain and create virtual environment for tt-forge.
Generally you need to run this step only once, unless you want to update the toolchain.

* `git submodule update --init --recursive -f`
* `source env/activate`
* `cmake -B env/build env`
* `cmake --build env/build`

### Build tt-forge
Build tt-forge
-----
* `source env/activate`
* `cmake -G Ninja -B build .`
* `cmake --build build`

### Cleanup
Cleanup
-----
* `rm -rf build` - to cleanup tt-forge build artifacts.
* `./clean_all.sh` - to cleanup all build artifacts (tt-forge/tvm/tt-mlir/tt-metal). This will not remove toolchain dependencies.

### Environment variables:
Environment variables:
-----
* `TTMLIR_TOOLCHAIN_DIR` - points to toolchain dir where dependencies of TTLMIR will be installed. If not defined it defaults to /opt/ttmlir-toolchain
* `TTMLIR_VENV_DIR` - points to virtual environment directory of TTMLIR.If not defined it defaults to /opt/ttmlir-toolchain/venv
* `PYBUDA_TOOLCHAIN_DIR` - points to toolchain dir where dependencies of PyBuda will be installed. If not defined it defaults to /opt/pybuda-toolchain
* `PYBUDA_VENV_DIR` - points to virtual environment directory of tt-forge. If not defined it defaults to /opt/pybuda-toolchain/venv
* `PYBUDA_PYTHON_VERSION` - set to override python version. If not defined it defaults to python3.10
* `TTFORGE_TOOLCHAIN_DIR` - points to toolchain dir where dependencies of tt-forge will be installed. If not defined it defaults to /opt/ttforge-toolchain
* `TTFORGE_VENV_DIR` - points to virtual environment directory of tt-forge. If not defined it defaults to /opt/ttforge-toolchain/venv
* `TTFORGE_PYTHON_VERSION` - set to override python version. If not defined it defaults to python3.10
2 changes: 1 addition & 1 deletion cmake/Utils.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Utility functions for pybuda ###
### Utility functions for tt-forge ###

### Check if an environment variable exists ###
function(check_env_variable_internal VARIABLE_NAME ret)
Expand Down
24 changes: 12 additions & 12 deletions env/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(pybuda-toolchain LANGUAGES CXX)
project(ttforge-toolchain LANGUAGES CXX)

# Get parent directory of current source directory
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
Expand All @@ -9,19 +9,19 @@ list(APPEND CMAKE_MODULE_PATH ${PARENT_DIR}/cmake)
include(Utils)

# Check if the environment variable is set, if not error out
check_required_env_var(PYBUDA_PYTHON_VERSION)
check_required_env_var(PYBUDA_TOOLCHAIN_DIR)
check_required_env_var(PYBUDA_VENV_DIR)
check_required_env_var(TTFORGE_PYTHON_VERSION)
check_required_env_var(TTFORGE_TOOLCHAIN_DIR)
check_required_env_var(TTFORGE_VENV_DIR)

set(PYBUDA_PYTHON_VERSION $ENV{PYBUDA_PYTHON_VERSION})
set(PYBUDA_TOOLCHAIN_DIR $ENV{PYBUDA_TOOLCHAIN_DIR})
set(PYBUDA_VENV_DIR $ENV{PYBUDA_VENV_DIR})
set(TTFORGE_PYTHON_VERSION $ENV{TTFORGE_PYTHON_VERSION})
set(TTFORGE_TOOLCHAIN_DIR $ENV{TTFORGE_TOOLCHAIN_DIR})
set(TTFORGE_VENV_DIR $ENV{TTFORGE_VENV_DIR})

set(TTMLIR_TOOLCHAIN_DIR $ENV{TTMLIR_TOOLCHAIN_DIR})
set(TTMLIR_VENV_DIR $ENV{TTMLIR_VENV_DIR})

if (NOT EXISTS "${PYBUDA_TOOLCHAIN_DIR}")
message( FATAL_ERROR "The directory ${PYBUDA_TOOLCHAIN_DIR} does not exist. Please create it before running this script.\n sudo mkdir -p ${PYBUDA_TOOLCHAIN_DIR}\n sudo chown -R $ENV{USER} ${PYBUDA_TOOLCHAIN_DIR}")
if (NOT EXISTS "${TTFORGE_TOOLCHAIN_DIR}")
message( FATAL_ERROR "The directory ${TTFORGE_TOOLCHAIN_DIR} does not exist. Please create it before running this script.\n sudo mkdir -p ${TTFORGE_TOOLCHAIN_DIR}\n sudo chown -R $ENV{USER} ${TTFORGE_TOOLCHAIN_DIR}")
endif()

if (NOT EXISTS "${TTMLIR_TOOLCHAIN_DIR}")
Expand All @@ -31,8 +31,8 @@ endif()
# Install all python dependencies
add_custom_target(python-venv
ALL COMMAND
PYBUDA_PYTHON_VERSION=${PYBUDA_PYTHON_VERSION}
PYBUDA_TOOLCHAIN_DIR=${PYBUDA_TOOLCHAIN_DIR}
TTFORGE_PYTHON_VERSION=${TTFORGE_PYTHON_VERSION}
TTFORGE_TOOLCHAIN_DIR=${TTFORGE_TOOLCHAIN_DIR}
CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
PYBUDA_VENV_DIR=${PYBUDA_VENV_DIR}
TTFORGE_VENV_DIR=${TTFORGE_VENV_DIR}
bash ${CMAKE_CURRENT_SOURCE_DIR}/create_venv.sh)
22 changes: 15 additions & 7 deletions env/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
This directory contains all environment dependencies for the project.
All dependencies are installed to /opt/pybuda-toolchain.

load_env_variables.sh - Script to load the environment variables for the project.
- Its used when downloading dependencies for the project.
- Its also used when activating env for project. This is important since it contains path to different lib/inc paths.
Overview
-----
This directory contains all environment dependencies for tt-forge. By default all dependencies will be installed
to the /opt/ttforge-toolchain directory. To override this behavior, set the `TTFORGE_TOOLCHAIN_DIR` environment variable.
Note that you need to build toolchain only once, unless you want to update it.

Dependencies:
(Python.3.10)[https://www.python.org/downloads/release/python-3100/] - Version of python which is compatible with the project.
-----
* [Python.3.10](https://www.python.org/downloads/release/python-3100/) - Version of python which is compatible with the project.
* [cmake3.20](https://cmake.org/download/) - Version of cmake which is compatible with the project.

Building the toolchain
-----
To build toolchain you need to run the following commands from the root directory of the project:
* `source env/activate` - This command will set all environment variables needed for the project.
* `cmake -B env/build env` - This command will generate the build files for the project.
* `cmake --build env/build` - This command will build the project.
16 changes: 8 additions & 8 deletions env/activate
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

# NOTE
# These env variables are stored in this file because they are needed by both
# toolchain project and the pybuda project. This file is sourced by both projects.
# toolchain project and the tt-forge project. This file is sourced by both projects.
# For tt-mlir we have similar env variables but since we build toolchain and binaries of tt-mlir
# using install.sh from tt-mlir project, we only define them in pybuda project top level cmake file.
# using install.sh from tt-mlir project, we only define them in tt-forge project top level cmake file.

# Set PYBUDA_TOOLCHAIN_DIR to a default value if not already set
export PYBUDA_TOOLCHAIN_DIR="${PYBUDA_TOOLCHAIN_DIR:-/opt/pybuda-toolchain}"
# Set TTFORGE_TOOLCHAIN_DIR to a default value if not already set
export TTFORGE_TOOLCHAIN_DIR="${TTFORGE_TOOLCHAIN_DIR:-/opt/ttforge-toolchain}"

# Set PYTHON_VERSION
export PYBUDA_PYTHON_VERSION="${PYBUDA_PYTHON_VERSION:-python3.10}"
export TTFORGE_PYTHON_VERSION="${TTFORGE_PYTHON_VERSION:-python3.10}"

# Set PYBUDA_VENV_DIR to a default value if not already set
export PYBUDA_VENV_DIR="${PYBUDA_VENV_DIR:-${PYBUDA_TOOLCHAIN_DIR}/venv}"
# Set TTFORGE_VENV_DIR to a default value if not already set
export TTFORGE_VENV_DIR="${TTFORGE_VENV_DIR:-${TTFORGE_TOOLCHAIN_DIR}/venv}"

[ -f $PYBUDA_VENV_DIR/bin/activate ] && source $PYBUDA_VENV_DIR/bin/activate
[ -f $TTFORGE_VENV_DIR/bin/activate ] && source $TTFORGE_VENV_DIR/bin/activate

if [ -n "$PROJECT_ROOT" ]; then
export TT_METAL_HOME="$PROJECT_ROOT/third_party/tt-mlir/third_party/tt-metal/src/tt-metal"
Expand Down
16 changes: 8 additions & 8 deletions env/create_venv.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
if [[ -z "$PYBUDA_PYTHON_VERSION" ]]; then
echo "PYBUDA_PYTHON_VERSION environment variable is not set"
if [[ -z "$TTFORGE_PYTHON_VERSION" ]]; then
echo "TTFORGE_PYTHON_VERSION environment variable is not set"
exit 1
fi

if [[ -z "$PYBUDA_TOOLCHAIN_DIR" ]]; then
echo "PYBUDA_TOOLCHAIN_DIR environment variable is not set"
if [[ -z "$TTFORGE_TOOLCHAIN_DIR" ]]; then
echo "TTFORGE_TOOLCHAIN_DIR environment variable is not set"
exit 1
fi

if [[ -z "$PYBUDA_VENV_DIR" ]]; then
echo "PYBUDA_VENV_DIR environment variable is not set"
if [[ -z "$TTFORGE_VENV_DIR" ]]; then
echo "TTFORGE_VENV_DIR environment variable is not set"
exit 1
fi

Expand All @@ -27,9 +27,9 @@ else
REQUIREMENTS_FILE="$CURRENT_SOURCE_DIR/linux_requirements.txt"
fi

$PYBUDA_PYTHON_VERSION -m venv $PYBUDA_VENV_DIR
$TTFORGE_PYTHON_VERSION -m venv $TTFORGE_VENV_DIR
unset LD_PRELOAD
source $PYBUDA_VENV_DIR/bin/activate
source $TTFORGE_VENV_DIR/bin/activate
python -m pip install --upgrade pip
pip3 install wheel==0.37.1
pip3 install -r $REQUIREMENTS_FILE -f https://download.pytorch.org/whl/cpu/torch_stable.html
44 changes: 0 additions & 44 deletions pybuda/README.md

This file was deleted.

Loading
Loading