Remove some more old stray files.

pull/322/head
Sean Silva 2021-09-22 23:06:25 +00:00
parent a0ccfcf581
commit 3dc9b4ee2f
10 changed files with 0 additions and 368 deletions

View File

@ -1,33 +0,0 @@
#!/bin/bash
set -e
if [ -z "$PYTHON" ]; then
PYTHON="$(which python)"
fi
version="$("$PYTHON" --version)"
echo "Using python: $PYTHON (version $version)"
repo_root="$(cd $(dirname $0)/.. && pwd)"
wheelhouse="$repo_root/wheelhouse"
mkdir -p $wheelhouse
cd $wheelhouse
echo "---- BUILDING npcomp-core ----"
CMAKE_GENERATOR=Ninja CMAKE_C_COMPILER_LAUNCHER=ccache CMAKE_CXX_COMPILER_LAUNCHER=ccache \
$PYTHON -m pip wheel "${repo_root}" \
--use-feature=in-tree-build \
-w "$wheelhouse" -v
echo "---- INSTALLING npcomp-core ----"
$PYTHON -m pip install -f "$wheelhouse" --force-reinstall npcomp-core
echo "---- BUILDING npcomp-torch ----"
$PYTHON -m pip wheel "${repo_root}/frontends/pytorch" \
--use-feature=in-tree-build \
-w "$wheelhouse" -v
echo "---- INSTALLING npcomp-torch ----"
$PYTHON -m pip install -f "$wheelhouse" --force-reinstall npcomp-torch
echo "---- QUICK SMOKE TEST ----"
$PYTHON $repo_root/frontends/pytorch/test/torchscript_e2e_test/basic.py

View File

@ -1,63 +0,0 @@
# No shebang, please `source` this file!
# For example, add this to your `.bashrc`:
# ```
# source $WHERE_YOU_CHECKED_OUT_NPCOMP/build_tools/docker_shell_funcs.sh
# ```
__npcomp_dir="$(realpath $(dirname "${BASH_SOURCE[0]}")/..)"
# Build the docker images for npcomp:
# npcomp:build-pytorch-nightly
# me/npcomp:build-pytorch-nightly (additional dev packages and current user)
function npcomp_docker_build() {
if ! [ -f "docker/pytorch-nightly/Dockerfile" ]; then
echo "Please run out of mlir-npcomp/ source directory..."
return 1
fi
echo "Building out of $(pwd)..."
docker build docker/pytorch-nightly --tag npcomp:build-pytorch-nightly
npcomp_docker_build_for_me npcomp:build-pytorch-nightly
}
# Start a container named "npcomp" in the background with the current-user
# dev image built above.
function npcomp_docker_start() {
local host_src_dir="${1-$__npcomp_dir}"
if ! [ -d "$host_src_dir" ]; then
echo "mlir-npcomp source directory not found:"
echo "Pass path to host source directory as argument (default=$host_src_dir)."
return 1
fi
docker volume create npcomp-build
docker run -d --rm --name "npcomp" \
--mount source=npcomp-build,target=/build \
--mount type=bind,source=$host_src_dir,target=/src/mlir-npcomp \
me/npcomp:build-pytorch-nightly tail -f /dev/null
}
# Stop the container named "npcomp".
function npcomp_docker_stop() {
docker stop npcomp
}
# Get an interactive bash shell to the "npcomp" container.
function npcomp_docker_login() {
docker exec --user $USER -it npcomp /bin/bash
}
### Implementation helpers below.
# From a root image, build an image just for me, hard-coded with a user
# matching the host user and a home directory that mirrors that on the host.
function npcomp_docker_build_for_me() {
local root_image="$1"
echo "
FROM $root_image
USER root
RUN apt install -y sudo byobu git procps lsb-release
RUN addgroup --gid $(id -g $USER) $USER
RUN mkdir -p $(dirname $HOME) && useradd -m -d $HOME --gid $(id -g $USER) --uid $(id -u $USER) $USER
RUN echo '$USER ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
USER $USER
" | docker build --tag me/${root_image} -
}

View File

@ -1,20 +0,0 @@
#!/bin/bash
# Formats all source files.
set +e
td="$(dirname $0)/.."
function find_cc_sources() {
local dir="$1"
find "$dir" -name "*.h"
find "$dir" -name "*.cpp"
}
# C/C++ sources.
set -o xtrace
clang-format -i \
$(find_cc_sources include) \
$(find_cc_sources lib) \
$(find_cc_sources frontends/pytorch/csrc)
# Python sources.
yapf --recursive -i "$td/python" "$td/pytest"

View File

@ -1,23 +0,0 @@
#!/usr/bin/python3
# Simple script to run and verify python path and ability to find
# modules. Run/debug this from your terminal or IDE to make sure things
# are setup correctly.
import sys
print("PYTHONPATH =", sys.path)
print("SYS VERSION =", sys.version)
print("PYTHON EXE =", sys.executable)
try:
import npcomp
print("Loaded npcomp module")
except ImportError:
print("ERROR: Could not load the npcomp module.",
"Ensure that build/python is on your PYTHONPATH")
try:
import _npcomp
print("Loaded (native) _npcomp module")
except ImportError:
print("ERROR: Could not load the _npcomp native module.",
"Ensure that build/python_native is on your PYTHONPATH")

View File

@ -1,18 +0,0 @@
#!/bin/bash
# Script for invoking all test tests. It also prints out a banner in case
# of success.
# TODO: I think we can just remove this.
set -euo pipefail
td="$(realpath $(dirname $0)/..)"
cd $td/build
ninja
ninja check-npcomp-all
echo
echo "========"
echo "ALL PASS"
echo "========"

View File

@ -1,12 +0,0 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"cmake>=3.12",
# MLIR build depends.
"numpy",
# Version 2.7.0 excluded: https://github.com/pybind/pybind11/issues/3136
"pybind11>=2.6.0,!=2.7.0",
"PyYAML",
]
build-backend = "setuptools.build_meta"

113
setup.py
View File

@ -1,113 +0,0 @@
# Build/install the npcomp-core python package.
# Note that this includes a relatively large build of LLVM (~2400 C++ files)
# and can take a considerable amount of time, especially with defaults.
# To install:
# pip install . --use-feature=in-tree-build
# To build a wheel:
# pip wheel . --use-feature=in-tree-build
#
# It is recommended to build with Ninja and ccache. To do so, set environment
# variables by prefixing to above invocations:
# CMAKE_GENERATOR=Ninja CMAKE_C_COMPILER_LAUNCHER=ccache CMAKE_CXX_COMPILER_LAUNCHER=ccache
#
# On CIs, it is often advantageous to re-use/control the CMake build directory.
# This can be set with the NPCOMP_CMAKE_BUILD_DIR env var.
import os
import shutil
import subprocess
import sys
from distutils.command.build import build as _build
from setuptools import find_namespace_packages, setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.build_py import build_py
# Build phase discovery is unreliable. Just tell it what phases to run.
class CustomBuild(_build):
def run(self):
self.run_command("build_py")
self.run_command("build_ext")
self.run_command("build_scripts")
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_py):
def run(self):
target_dir = self.build_lib
cmake_build_dir = os.getenv("NPCOMP_CMAKE_BUILD_DIR")
if not cmake_build_dir:
cmake_build_dir = os.path.join(target_dir, "..", "cmake_build")
cmake_install_dir = os.path.join(target_dir, "..", "cmake_install")
src_dir = os.path.abspath(os.path.dirname(__file__))
cfg = "Release"
cmake_args = [
"-DCMAKE_INSTALL_PREFIX={}".format(os.path.abspath(cmake_install_dir)),
"-DPython3_EXECUTABLE={}".format(sys.executable),
"-DNPCOMP_VERSION_INFO={}".format(self.distribution.get_version()),
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
"-DLLVM_TARGETS_TO_BUILD=host",
]
build_args = []
os.makedirs(cmake_build_dir, exist_ok=True)
if os.path.exists(cmake_install_dir):
shutil.rmtree(cmake_install_dir)
cmake_cache_file = os.path.join(cmake_build_dir, "CMakeCache.txt")
if os.path.exists(cmake_cache_file):
os.remove(cmake_cache_file)
subprocess.check_call(["cmake", src_dir] + cmake_args, cwd=cmake_build_dir)
subprocess.check_call(["cmake", "--build", ".", "--target", "install"] +
build_args,
cwd=cmake_build_dir)
shutil.copytree(os.path.join(cmake_install_dir, "python_packages",
"npcomp_core"),
target_dir,
symlinks=False,
dirs_exist_ok=True)
class NoopBuildExtension(build_ext):
def build_extension(self, ext):
pass
setup(
name="npcomp-core",
version="0.0.1",
author="Stella Laurenzo",
author_email="stellaraccident@gmail.com",
description="NPComp Core",
long_description="",
include_package_data=True,
ext_modules=[
CMakeExtension("npcomp._mlir_libs._mlir"),
CMakeExtension("npcomp._mlir_libs._npcomp"),
# TODO: We don't really want these but they are along for the ride.
CMakeExtension("npcomp._mlir_libs._mlirAsyncPasses"),
CMakeExtension("npcomp._mlir_libs._mlirConversions"),
CMakeExtension("npcomp._mlir_libs._mlirTransforms"),
CMakeExtension("npcomp._mlir_libs._mlirSparseTensorPasses"),
CMakeExtension("npcomp._mlir_libs._mlirAllPassesRegisration"),
CMakeExtension("npcomp._mlir_libs._mlirLinalgPasses"),
CMakeExtension("npcomp._mlir_libs._mlirGPUPasses"),
],
cmdclass={
"build": CustomBuild,
"built_ext": NoopBuildExtension,
"build_py": CMakeBuild,
},
zip_safe=False,
packages=find_namespace_packages(include=[
"npcomp",
"npcomp.*",
]),
)

View File

@ -1,38 +0,0 @@
# No shebang, please `source` this file!
# For example, add this to your `.bashrc`:
# ```
# source $WHERE_YOU_CHECKED_OUT_NPCOMP/tools/bash_helpers.sh
# ```
td="$(realpath $(dirname "${BASH_SOURCE[0]}")/..)"
build_dir="$td/build"
npcomp-opt() {
# Helper for building and invoking npcomp-opt.
# Usage:
# $ npcomp-opt <regular npcomp-opt options>
ninja -C "$build_dir" npcomp-opt 1>&2 || return 1
# Also produce a reproducer by default.
"${build_dir}/bin/npcomp-opt" \
"-pass-pipeline-crash-reproducer=/tmp/reproducer.mlir" \
"$@"
}
# Go to the root of your npcomp checkout.
alias npd="cd $td"
# Handy so that `npctest -v` runs lit with -v and thus prints out errors,
# which `check-npcomp` does not.
npctest() {
(npd && tools/run_lit.sh test "$@")
}
npctall() {
(npd && build_tools/test_all.sh "$@")
}
# Don't autocomplete `install-mlir` which conflicts with `include` in our
# typical build setup.
#
# See here for more info about the incantation:
# https://stackoverflow.com/a/34272881
# https://superuser.com/q/253068
export FIGNORE=$FIGNORE:nstall-mlir

View File

@ -1,36 +0,0 @@
#!/bin/bash
# Runs lit-based tests by properly translating paths to the build directory.
# Example:
# ./tools/run_lit.sh test/Dialect -v
set -e
td="$(realpath $(dirname $0)/..)"
build_dir="$td/build"
build_mlir="$build_dir/llvm"
lit_exe="$build_mlir/bin/llvm-lit"
if ! [ -f "$lit_exe" ]; then
echo "Could not find lit: $lit_exe"
exit 1
fi
declare -a lit_args
for i in "$@"; do
if [[ ${i:0:1} = "-" ]] || [[ ${i:0:1} = "/" ]]; then
lit_args+=("$i")
else
if ! [ -e "$i" ]; then
echo "Specified lit input does not exist: $i"
exit 1
fi
test_local_path="$(realpath $i)"
# Replace the src prefix with the build dir.
test_build_path="$build_dir/${test_local_path##$td/}"
lit_args+=("$test_build_path")
fi
done
set -x
cd $build_dir
ninja
cd test && python3 "$lit_exe" ${lit_args[@]}

View File

@ -1,12 +0,0 @@
#!/bin/bash
set -euo pipefail
src_dir="$(realpath $(dirname $0)/..)"
cd "$src_dir"
# Ensure PYTHONPATH is set for export to child processes, even if empty.
export PYTHONPATH=${PYTHONPATH-}
source .env
python -m e2e_testing.torchscript.main "$@"