diff --git a/Makefile b/Makefile index 8fa5856e5812..d2a1fcb0544a 100644 --- a/Makefile +++ b/Makefile @@ -67,8 +67,6 @@ LLVM_CXX_FLAGS = -std=c++17 $(filter-out -O% -g -fomit-frame-pointer -pedantic OPTIMIZE ?= -O3 OPTIMIZE_FOR_BUILD_TIME ?= -O0 -PYTHON ?= python3 - CLANG ?= $(LLVM_BINDIR)/clang CLANG_VERSION = $(shell $(CLANG) --version) @@ -1946,8 +1944,7 @@ test_adams2019: distrib test_li2018: distrib build_python_bindings $(MAKE) -f $(SRC_DIR)/autoschedulers/li2018/Makefile test \ - HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings + HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) time_compilation_test_%: $(BIN_DIR)/test_% $(TIME_COMPILATION) compile_times_correctness.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_test_%=test_%) @@ -1982,20 +1979,18 @@ TEST_APPS=\ TEST_APPS_DEPS=$(TEST_APPS:%=%_test_app) BUILD_APPS_DEPS=$(TEST_APPS:%=%_build_app) -$(BUILD_APPS_DEPS): distrib build_python_bindings +$(BUILD_APPS_DEPS): distrib @echo Building app $(@:%_build_app=%) for ${HL_TARGET}... @$(MAKE) -C $(ROOT_DIR)/apps/$(@:%_build_app=%) build \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings \ BIN_DIR=$(CURDIR)/$(BIN_DIR)/apps/$(@:%_build_app=%)/bin \ HL_TARGET=$(HL_TARGET) \ || exit 1 ; \ -$(TEST_APPS_DEPS): distrib build_python_bindings +$(TEST_APPS_DEPS): distrib @echo Testing app $(@:%_test_app=%) for ${HL_TARGET}... @$(MAKE) -C $(ROOT_DIR)/apps/$(@:%_test_app=%) test \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings \ BIN_DIR=$(CURDIR)/$(BIN_DIR)/apps/$(@:%_test_app=%)/bin \ HL_TARGET=$(HL_TARGET) \ || exit 1 ; \ @@ -2010,7 +2005,6 @@ build_hannk: distrib @echo Building apps/hannk for ${HL_TARGET}... @$(MAKE) -C $(ROOT_DIR)/apps/hannk build \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings \ BIN_DIR=$(CURDIR)/$(BIN_DIR)/apps/hannk/bin \ HL_TARGET=$(HL_TARGET) \ || exit 1 ; \ @@ -2019,7 +2013,6 @@ test_hannk: build_hannk @echo Testing apps/hannk for ${HL_TARGET}... @$(MAKE) -C $(ROOT_DIR)/apps/hannk test \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings \ BIN_DIR=$(CURDIR)/$(BIN_DIR)/apps/hannk/bin \ HL_TARGET=$(HL_TARGET) \ || exit 1 ; \ @@ -2032,12 +2025,11 @@ BENCHMARK_APPS=\ nl_means \ stencil_chain -$(BENCHMARK_APPS): distrib build_python_bindings +$(BENCHMARK_APPS): distrib @echo Building $@ for ${HL_TARGET}... @$(MAKE) -C $(ROOT_DIR)/apps/$@ \ $(CURDIR)/$(BIN_DIR)/apps/$@/bin/$(HL_TARGET)/$@.rungen \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings \ BIN_DIR=$(CURDIR)/$(BIN_DIR)/apps/$@/bin \ HL_TARGET=$(HL_TARGET) \ > /dev/null \ @@ -2051,33 +2043,15 @@ benchmark_apps: $(BENCHMARK_APPS) make -C $(ROOT_DIR)/apps/$${APP} \ $${APP}.benchmark \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings \ BIN_DIR=$(CURDIR)/$(BIN_DIR)/apps/$${APP}/bin \ HL_TARGET=$(HL_TARGET) \ || exit 1 ; \ done -# TODO(srj): the python bindings need to be put into the distrib folders; -# this is a hopefully-temporary workaround (https://github.com/halide/Halide/issues/4368) -.PHONY: build_python_bindings -build_python_bindings: distrib $(BIN_DIR)/host/runtime.a - $(MAKE) -C $(ROOT_DIR)/python_bindings \ - -f $(ROOT_DIR)/python_bindings/Makefile \ - build_python_bindings \ - HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - BIN=$(CURDIR)/$(BIN_DIR)/python3_bindings \ - PYTHON=$(PYTHON) \ - OPTIMIZE="$(OPTIMIZE)" - +# TODO: remove this target after landing PR #6821 .PHONY: test_python -test_python: distrib $(BIN_DIR)/host/runtime.a build_python_bindings - $(MAKE) -C $(ROOT_DIR)/python_bindings \ - -f $(ROOT_DIR)/python_bindings/Makefile \ - test \ - HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - BIN=$(CURDIR)/$(BIN_DIR)/python3_bindings \ - PYTHON=$(PYTHON) \ - OPTIMIZE="$(OPTIMIZE)" +test_python: + @echo "TODO: remove this target after landing PR #6821" # It's just for compiling the runtime, so earlier clangs *might* work, # but best to peg it to the minimum llvm version. diff --git a/apps/support/Makefile.inc b/apps/support/Makefile.inc index fc782a36b08f..09798c434ef3 100644 --- a/apps/support/Makefile.inc +++ b/apps/support/Makefile.inc @@ -13,11 +13,6 @@ IMAGES ?= ../images UNAME ?= $(shell uname) SHELL = bash PYTHON ?= python3 - -# TODO(srj): the python bindings need to be put into the distrib folders; -# this is a hopefully-temporary workaround (https://github.com/halide/Halide/issues/4368) -HALIDE_PYTHON_BINDINGS_PATH ?= $(realpath ../../bin/python3_bindings) - BIN_DIR ?= bin # Most build outputs go into $(BIN)/$(HL_TARGET)/$(HL_TARGET)/, so that you can vary the test diff --git a/python_bindings/Makefile b/python_bindings/Makefile deleted file mode 100644 index 4b59feaa7ca1..000000000000 --- a/python_bindings/Makefile +++ /dev/null @@ -1,258 +0,0 @@ -UNAME = $(shell uname) -THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) -ROOT_DIR = $(strip $(shell dirname $(THIS_MAKEFILE))) - -# These are set by Halide's Makefile when built via that path. -HALIDE_PATH ?= $(ROOT_DIR)/.. -HALIDE_DISTRIB_PATH ?= $(HALIDE_PATH)/distrib -BIN ?= $(ROOT_DIR)/bin -PYTHON ?= python3 -TEST_TMP ?= $(BIN)/tmp - -FPIC=-fPIC -ifeq ($(UNAME), Darwin) - SHARED_EXT=dylib -else - SHARED_EXT=so -endif - -ifeq ($(UNAME), Linux) -USE_EXPORT_DYNAMIC=-rdynamic -else -ifeq ($(UNAME), Darwin) -USE_EXPORT_DYNAMIC=-undefined dynamic_lookup -else -USE_EXPORT_DYNAMIC= -endif -endif - -LIBHALIDE ?= $(HALIDE_DISTRIB_PATH)/lib/libHalide.$(SHARED_EXT) - -SUFFIX = $(shell $(PYTHON)-config --extension-suffix) - -# Discover PyBind path from `python3 -m pybind11 --includes` -PYBIND11_CFLAGS = $(shell $(PYTHON) -m pybind11 --includes) - -OPTIMIZE ?= -O3 - -# defining DEBUG + undefining NDEBUG gives extra debug info in PyBind11 -# OPTIMIZE ?= -g -DDEBUG=1 -UNDEBUG - -# Compiling with -fvisibility=hidden saves ~80k on optimized x64 builds. -# It's critical to include -fno-omit-frame-pointer, otherwise introspection can -# break in amusing ways. -CCFLAGS=$(shell $(PYTHON)-config --cflags) $(PYBIND11_CFLAGS) -I $(HALIDE_DISTRIB_PATH)/include -I $(ROOT_DIR) -std=c++17 $(FPIC) -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer $(OPTIMIZE) $(CXXFLAGS) -# Filter out a pointless warning present in some Python installs -CCFLAGS := $(filter-out -Wstrict-prototypes,$(CCFLAGS)) - -# DON'T link libpython* - leave those symbols to lazily resolve at load time -# Cf. https://github.com/pybind/pybind11/blob/master/docs/compiling.rst#building-manually -LDFLAGS += -lz $(USE_EXPORT_DYNAMIC) -LDFLAGS += -Wl,-rpath,$(dir $(LIBHALIDE)) - -PY_SRCS=$(shell ls $(ROOT_DIR)/src/*.cpp) -PY_OBJS=$(PY_SRCS:$(ROOT_DIR)/src/%.cpp=$(BIN)/src/%.o) - -MODULE=$(BIN)/halide$(SUFFIX) - -$(MODULE): $(PY_OBJS) $(LIBHALIDE) - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $^ $(LDFLAGS) -shared -o $@ - -# We don't want any of this auto-deleted -.SECONDARY: - -$(BIN)/src/%.o: $(ROOT_DIR)/src/%.cpp - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(CCFLAGS) -c $< -o $@ - -$(BIN)/%_generator.o: $(ROOT_DIR)/correctness/generators/%_generator.cpp $(HALIDE_DISTRIB_PATH)/include/Halide.h - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(CCFLAGS) -c $< -o $@ - -# There are two sorts of Python Extensions that we can produce for a Halide Generator -# written in C++: -# -# - One that is essentially the 'native code' output of a Generator, wrapped with enough CPython -# glue code to make it callable from Python. This is analogous to the usual Generator output -# when building a C++ codebase, and is the usual mode used for distribution of final product; -# these correspond to 'ahead-of-time' (AOT) code generation. The resulting code has no dependency -# on libHalide. We'll refer to this sort of extension as an "AOT extension". -# -# - One that essentially *the Generator itself*, wrapped in CPython glue code to make it callable -# from Python at Halide compilation time. This is analogous to the (rarely used) GeneratorStub -# code that can be used to compose multiple Generators together. The resulting extension *does* -# depend on libHalide, and can be used in either JIT or AOT mode for compilation. -# We'll refer to this sort of extension as a "Stub extension". -# -# For testing purposes here, we don't bother using distutils/setuptools to produce a properly-packaged -# Python extension; rather, we simply produce a .so file with the correct name exported, and ensure -# it's in the PYTHONPATH when testing. -# -# In our build files here, we build both kinds of extension for every Generator in the generators/ -# directory (even though not all are used). As a simplistic way to distinguish between the two -# sorts of extensions, we use the unadorned Generator name for AOT extensions, and the Generator name -# suffixed with "_pystub" for Stub extensions. (TODO: this is unsatisfyingly hackish; better suggestions -# would be welcome.) - -$(BIN)/PyStubImpl.o: $(ROOT_DIR)/stub/PyStubImpl.cpp $(HALIDE_DISTRIB_PATH)/include/Halide.h - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(CCFLAGS) -c $< -o $@ - -# Compile the generators: -$(BIN)/%.generator: $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp $(BIN)/%_generator.o $(LIBHALIDE) - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(CCFLAGS) $(LDFLAGS) $^ -o $@ - -# Special generator for generating a runtime: -$(BIN)/runtime.generator: $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp $(LIBHALIDE) - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(CCFLAGS) $(LDFLAGS) $^ -o $@ - -# Generate a runtime: -$(BIN)/runtime.a: $(BIN)/runtime.generator - @echo Building $@... - @mkdir -p $(@D) - @$< -r runtime -o $(BIN) target=host - -# Construct linker script that will export *just* the PyInit entry -# point we want. (If we don't do this we can have interesting failures -# when loading multiple of these Python extensions in the same space.) -ifeq ($(UNAME), Darwin) -$(BIN)/%.ldscript: $(ROOT_DIR)/stub/ext.ldscript.apple.in - @echo Building $@... - @mkdir -p $(@D) - @cat $< | sed 's/$${SYMBOL}/$*/' > $@ -PYEXT_LDSCRIPT_FLAG = -Wl,-exported_symbols_list %LDSCRIPT% -else -# Assume Desktop Linux -$(BIN)/%.ldscript: $(ROOT_DIR)/stub/ext.ldscript.linux.in - @echo Building $@... - @mkdir -p $(@D) - @cat $< | sed 's/$${SYMBOL}/$*/' > $@ -PYEXT_LDSCRIPT_FLAG = -Wl,--version-script=%LDSCRIPT% -endif - -# Some Generators require extra Halide Target Features to be set. -FEATURES_user_context=-user_context - -# Some Generators have undefined types, sizes, etc that are useful for Stubs extensions, -# but unacceptable for AOT Extensions; ensure that all of those are explicitly -# specified for AOT. (We currently don't use or test these in AOT form, so the settings -# are somewhat arbitrary.) -GENPARAMS_complex=\ - array_input.size=2 \ - array_input.type=uint8 \ - int_arg.size=2 \ - simple_input.type=uint8 \ - untyped_buffer_input.type=uint8 \ - untyped_buffer_output.type=uint8 - -GENPARAMS_simple=\ - func_input.type=uint8 - -# Run the Generator to produce a static library of AOT code, -# plus the 'python_extension' code necessary to produce a useful -# AOT Extention for Python: -$(BIN)/%.py.cpp $(BIN)/%.a $(BIN)/%.h: $(BIN)/%.generator - @echo Building $@... - @LD_LIBRARY_PATH=$(HALIDE_DISTRIB_PATH)/bin $< \ - -e static_library,c_header,python_extension \ - -g $(notdir $(basename $<)) \ - -o $(BIN) \ - target=host-no_runtime$(FEATURES_$(notdir $(basename $<))) \ - $(GENPARAMS_$(notdir $(basename $<))) - -# Compile the generated Python extension(s): -$(BIN)/%.py.o: $(BIN)/%.py.cpp - @echo Building $@... - @$(CXX) -c $(FPIC) $(CCFLAGS) $^ -o $@ - -# We take the native-code output of the Generator, add the Python-Extension -# code (to make it callable from Python), and put the resulting Python AOT Extension -# into the 'aot' folder. -$(BIN)/aot/%.so: $(BIN)/%.py.o $(BIN)/%.a $(BIN)/runtime.a $(BIN)/%.ldscript - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(LDFLAGS) $(filter-out %.ldscript,$^) -shared $(subst %LDSCRIPT%,$(BIN)/$*.ldscript,$(PYEXT_LDSCRIPT_FLAG)) -o $@ - -# OK, now we want to produce a Stub Extension for the same Generator: -# Compiling PyStub.cpp, then linking with the generator's .o file, PyStubImpl.o, plus the same libHalide -# being used by halide.so. -# -# Note that we set HALIDE_PYSTUB_MODULE_NAME to $*_pystub (e.g. foo_pystub) but -# set HALIDE_PYSTUB_GENERATOR_NAME to the unadorned name of the Generator. -$(BIN)/%_PyStub.o: $(ROOT_DIR)/stub/PyStub.cpp - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(CCFLAGS) -DHALIDE_PYSTUB_MODULE_NAME=$*_pystub -DHALIDE_PYSTUB_GENERATOR_NAME=$* -c $< -o $@ - -$(BIN)/stub/%_pystub.so: $(BIN)/%_PyStub.o $(BIN)/PyStubImpl.o $(BIN)/%_generator.o $(BIN)/%_pystub.ldscript $(LIBHALIDE) - @echo Building $@... - @mkdir -p $(@D) - @$(CXX) $(LDFLAGS) $(filter-out %.ldscript,$^) -shared $(subst %LDSCRIPT%,$(BIN)/$*_pystub.ldscript,$(PYEXT_LDSCRIPT_FLAG)) -o $@ - -GENERATOR_SRCS=$(shell ls $(ROOT_DIR)/correctness/generators/*_generator.cpp) -GENERATOR_AOT_EXTENSIONS=$(GENERATOR_SRCS:$(ROOT_DIR)/correctness/generators/%_generator.cpp=$(BIN)/aot/%.so) -GENERATOR_STUB_EXTENSIONS=$(GENERATOR_SRCS:$(ROOT_DIR)/correctness/generators/%_generator.cpp=$(BIN)/stub/%_pystub.so) - -APPS = $(shell ls $(ROOT_DIR)/apps/*.py) -CORRECTNESS = $(shell ls $(ROOT_DIR)/correctness/*.py) -TUTORIAL = $(shell ls $(ROOT_DIR)/tutorial/*.py) - -.PHONY: test_apps -test_apps: $(APPS:$(ROOT_DIR)/apps/%.py=test_apps_%) - -test_apps_%: $(ROOT_DIR)/apps/%.py $(MODULE) - @echo Testing $*... - @mkdir -p $(TEST_TMP) - @# Send stdout (but not stderr) from these to /dev/null to reduce noise - @cd $(TEST_TMP); PYTHONPATH="$(BIN):$$PYTHONPATH" $(PYTHON) $< >/dev/null - -.PHONY: test_correctness -test_correctness: $(CORRECTNESS:$(ROOT_DIR)/correctness/%.py=test_correctness_%) - -# For simplicity of the build system, we just have every correctness test depend -# on every Generator and AOT extension. Normally this would not be a good idea, -# but it's fine for us here. -test_correctness_%: $(ROOT_DIR)/correctness/%.py $(MODULE) $(GENERATOR_AOT_EXTENSIONS) $(GENERATOR_STUB_EXTENSIONS) - @echo Testing $*... - @mkdir -p $(TEST_TMP) - @cd $(TEST_TMP); PYTHONPATH="$(BIN)/aot:$(BIN)/stub:$(BIN):$$PYTHONPATH" $(PYTHON) $< - -.PHONY: test_tutorial -test_tutorial: $(TUTORIAL:$(ROOT_DIR)/tutorial/%.py=test_tutorial_%) - -test_tutorial_%: $(ROOT_DIR)/tutorial/%.py $(MODULE) - @echo Testing $*... - @mkdir -p $(TEST_TMP) - @# Send stdout (but not stderr) from these to /dev/null to reduce noise - @# We need "." in the PYTHONPATH for lesson_10_halide.so. - @cd $(TEST_TMP); PYTHONPATH=".:$(BIN):$$PYTHONPATH" $(PYTHON) $< >/dev/null - -test_tutorial_lesson_10_aot_compilation_run: $(TEST_TMP)/lesson_10_halide.so - -$(TEST_TMP)/lesson_10_halide.so: test_tutorial_lesson_10_aot_compilation_generate - @echo Building $@... - @$(CXX) $(CCFLAGS) $(LDFLAGS) $(FPIC) -shared \ - $(TEST_TMP)/lesson_10_halide.py.cpp \ - $(TEST_TMP)/lesson_10_halide.o \ - -I $(TEST_TMP) -o $@ - -.PHONY: clean -clean: - rm -rf $(BIN) - -.PHONY: test -test: test_correctness test_apps test_tutorial - -# TODO(srj): the python bindings need to be put into the distrib folders; -# this is a hopefully-temporary workaround (https://github.com/halide/Halide/issues/4368) -.PHONY: build_python_bindings -build_python_bindings: $(MODULE) diff --git a/python_bindings/readme.md b/python_bindings/readme.md index e285a1716cab..3192f12834a2 100644 --- a/python_bindings/readme.md +++ b/python_bindings/readme.md @@ -13,12 +13,12 @@ with some differences where the C++ idiom is either inappropriate or impossible: as `[]` is not syntactically acceptable in Python. - Some classes in the Halide API aren't provided because they are 'wrapped' with standard Python idioms: - - `Halide::Tuple` doesn't exist in the Python bindings; an ordinary Python - tuple of `Halide::Expr` is used instead. - - `Halide::Realization` doesn't exist in the Python bindings; an ordinary - Python tuple of `Halide::Buffer` is used instead. - - `Halide::Error` and friends don't exist; standard Python error handling is - used instead. + - `Halide::Tuple` doesn't exist in the Python bindings; an ordinary Python + tuple of `Halide::Expr` is used instead. + - `Halide::Realization` doesn't exist in the Python bindings; an ordinary + Python tuple of `Halide::Buffer` is used instead. + - `Halide::Error` and friends don't exist; standard Python error handling is + used instead. - static and instance method overloads with the same name in the same class aren't allowed, so some convenience methods are missing from `Halide::Var` - Templated types (notably `Halide::Buffer<>` and `Halide::Param<>`) aren't @@ -35,7 +35,9 @@ with some differences where the C++ idiom is either inappropriate or impossible: entirely for now. - `Func::in` becomes `Func.in_` because `in` is a Python keyword. - `Func::async` becomes `Func.async_` because `async` is a Python keyword. -- The `not` keyword cannot be used to negate boolean Halide expressions. Instead, the `logical_not` function can be used and is equivalent to using `operator!` in C++. +- The `not` keyword cannot be used to negate boolean Halide expressions. + Instead, the `logical_not` function can be used and is equivalent to + using `operator!` in C++. ## Enhancements to the C++ API @@ -47,8 +49,7 @@ with some differences where the C++ idiom is either inappropriate or impossible: ## Prerequisites The bindings (and demonstration applications) should work well for Python 3.4 -(or higher), on Linux and OSX platforms. Windows support is experimental, and -available through the CMake build. +(or higher), on Linux and OSX platforms. Windows support is experimental. #### Python requirements: @@ -57,18 +58,15 @@ The best way to get set up is to use a virtual environment: ```console $ python3 -m venv venv $ . venv/bin/activate -$ pip install -r requirements.txt +$ python3 -m pip install -U setuptools wheel +$ python3 -m pip install -r requirements.txt ``` -#### C++ requirements: - -- Halide compiled to a distribution (e.g. `make distrib` or similar), with the - `HALIDE_DISTRIB_PATH` env var pointing to it -- If using CMake, simply set `-DWITH_PYTHON_BINDINGS=ON` from the main build. - ## Compilation instructions -Build using: `make` +Build as part of the CMake build with `-DWITH_PYTHON_BINDINGS=ON`. Note that +this requires both Halide and LLVM to be built with RTTI and exceptions +**enabled**, which is not the default for LLVM. ## Documentation and Examples @@ -78,11 +76,14 @@ The Python API reflects directly the Check out the code for the example applications in the `apps/` and `tutorial/` subdirectory. -You can run them as a batch via `make test_apps` or `make test_tutorial`. +The tests run as part of the standard CTest infrastructure and are labeled with +the `python` label. You can run the Python tests specifically by running: + +``` +$ ctest -L python +``` -To run these examples, make sure the `PYTHONPATH` environment variable points to -your build directory (e.g. -`export PYTHONPATH=halide_source/python_bindings/bin:$PYTHONPATH`). +From the Halide build directory. ## License diff --git a/python_bindings/tutorial/CMakeLists.txt b/python_bindings/tutorial/CMakeLists.txt index e605282e5f0a..98967af578a1 100644 --- a/python_bindings/tutorial/CMakeLists.txt +++ b/python_bindings/tutorial/CMakeLists.txt @@ -32,6 +32,11 @@ endforeach () ## of doing this might be to treat lesson 10 like an app and give it its own CMakeLists.txt, but since this is a one-off ## it is probably less maintenance work to do it like this. +# Note that the following tests that are mentioned below were created in the above foreach loop: +# 1. python_tutorial_lesson_10_aot_compilation_generate +# 2. python_tutorial_lesson_10_aot_compilation_run +# The test `python_tutorial_lesson_10_compile` below is responsible for running (1) in service of (2). + # This dummy command "generates" the files that the TEST python_tutorial_lesson_10_aot_compilation_generate will # actually generate as part of the fixture below. add_custom_command(OUTPUT lesson_10_halide.py.cpp lesson_10_halide.o diff --git a/src/autoschedulers/li2018/Makefile b/src/autoschedulers/li2018/Makefile index db11cd90768e..2dc6a1aed289 100644 --- a/src/autoschedulers/li2018/Makefile +++ b/src/autoschedulers/li2018/Makefile @@ -41,7 +41,7 @@ $(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -I$(BIN)/$* $^ -o $@ $(HALIDE_SYSTEM_LIBS) $(IMAGE_IO_FLAGS) -.PHONY: build test clean run_test_cpp run_test_py test_generator +.PHONY: build test clean run_test_cpp test_generator # demonstrates single-shot use of the autoscheduler test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(SHARED_EXT) @@ -50,14 +50,9 @@ test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$( run_test_cpp: $(BIN)/test LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_li2018.$(SHARED_EXT) -run_test_py: $(SRC)/test.py $(BIN)/libautoschedule_li2018.$(SHARED_EXT) - PYTHONPATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin:$$PYTHONPATH \ - LD_LIBRARY_PATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin \ - $(PYTHON) $(SRC)/test.py - \build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(SHARED_EXT) -test: run_test_cpp run_test_py test_generator +test: run_test_cpp test_generator clean: rm -rf $(BIN)