Skip to content

Commit

Permalink
Create noop IPEX using temp folder (#1985)
Browse files Browse the repository at this point in the history
Closes #1984

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Aug 23, 2024
1 parent d5c1db8 commit 0455e4a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 35 deletions.
53 changes: 18 additions & 35 deletions scripts/compile-pytorch-ipex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,46 +244,29 @@ build_pytorch() {
# Configure and build the ipex project.

build_ipex() {
if [ ! -d "$IPEX_PROJ" ]; then
cd $BASE
if [ "$NO_OP_IPEX" = true ]; then
echo "**** Setup no-op $IPEX_PROJ ****"
mkdir intel-extension-for-pytorch
cd intel-extension-for-pytorch
cat > setup.py <<EOF
from setuptools import setup
name = "intel_extension_for_pytorch"
version = "2.4.0+noop"
setup(
name=name,
version=version,
description="No-op Intel Extension for PyTorch"
)
EOF

mkdir intel_extension_for_pytorch
echo '__version__ = "2.4.0+noop"' > intel_extension_for_pytorch/__init__.py
touch requirements.txt
else
if [ "$NO_OP_IPEX" = true ]; then
echo "**** Setup no-op IPEX ****"
python $SCRIPTS_DIR/create-noop-ipex.py
else
if [ ! -d "$IPEX_PROJ" ]; then
cd $BASE
echo "**** Cloning $IPEX_PROJ ****"
git clone --single-branch -b dev/triton-test-3.0 --recurse-submodules --jobs 8 https://github.com/intel/intel-extension-for-pytorch.git
fi
fi
echo "****** Building $IPEX_PROJ ******"
cd $IPEX_PROJ
if [ ! -d "$IPEX_PROJ/dist" ]; then
if [ "$BUILD_PINNED" = true ]; then
git fetch origin $IPEX_PINNED_COMMIT
git checkout $IPEX_PINNED_COMMIT
git submodule sync
git submodule update --init --recursive
echo "****** Building $IPEX_PROJ ******"
cd $IPEX_PROJ
if [ ! -d "$IPEX_PROJ/dist" ]; then
if [ "$BUILD_PINNED" = true ]; then
git fetch origin $IPEX_PINNED_COMMIT
git checkout $IPEX_PINNED_COMMIT
git submodule sync
git submodule update --init --recursive
fi
pip install -r requirements.txt
python setup.py bdist_wheel
fi
pip install -r requirements.txt
python setup.py bdist_wheel
pip install dist/*.whl
fi
pip install dist/*.whl
cd $BASE
python -c "import intel_extension_for_pytorch as ipex;print(ipex.__version__)"
}
Expand Down
29 changes: 29 additions & 0 deletions scripts/create-noop-ipex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from os import chdir, makedirs
from tempfile import TemporaryDirectory
from subprocess import run

with TemporaryDirectory() as tmpdir:
pkg = "intel_extension_for_pytorch"
version = "2.4.0+noop"

chdir(tmpdir)
makedirs(pkg, exist_ok=True)

files = {
f"{pkg}/__init__.py":
f"__version__ = \"{version}\"", "setup.py":
("from setuptools import setup, find_packages\n"
f"setup(name='{pkg}', version='{version}', packages=find_packages())\n"), "project.toml":
("[build-system]\n"
"requires = [\"setuptools\", \"wheel\"]\n"
"build-backend = \"setuptools.build_meta\"\n")
}
for file, content in files.items():
with open(file, "w") as f:
f.write(content)
cmds = [
f"pip uninstall -y {pkg}", "pip install build", "python -m build .",
f"pip install dist/{pkg}-{version}-py3-none-any.whl"
]
for cmd in cmds:
run(cmd.split(), check=True)

0 comments on commit 0455e4a

Please sign in to comment.