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

New Boost.Python interface #821

Merged
merged 141 commits into from Aug 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
b9e8a0f
Starting new python bindings for Halide. Var and Expr are in place.
rodrigob Jun 7, 2015
de5d10c
Adding missing files. Updated gitignore
rodrigob Jun 7, 2015
eab58b4
First version of Func::realize in place
rodrigob Jun 7, 2015
3031e20
Adding more methods to Func
rodrigob Jun 7, 2015
18d2e2d
Added Func vectorize, parallel; and base Int, UInt, Float types.
rodrigob Jun 7, 2015
b1f01cc
Adding small motivation readme. To be extended with compilation instr…
rodrigob Jun 7, 2015
720ed79
Added ImageParam class
rodrigob Jun 7, 2015
2360ffe
Added round/floor and trigonometric operators
rodrigob Jun 8, 2015
2f4f553
Including Param.cpp into python module to solve ImageParam linking is…
rodrigob Jun 8, 2015
a518ea6
Extending support for Func
rodrigob Jun 8, 2015
b614675
Extending support for Func (bis)
rodrigob Jun 8, 2015
5a13965
Exploded the python support into files mirroring the halide/src folder
rodrigob Jun 8, 2015
925b474
Implemented Func compile_* functions (at least the ones already avail…
rodrigob Jun 8, 2015
2c1393d
Added Argument class
rodrigob Jun 8, 2015
83cb33f
Fixed run-time error related to Func
rodrigob Jun 8, 2015
aa1b16c
Expr and Var now can be operated with ints and floats
rodrigob Jun 8, 2015
32df386
Minor edits
rodrigob Jun 8, 2015
4a428f0
Trying multiple work arounds for ArgumentsVector
rodrigob Jun 8, 2015
8424d89
ArgumentsVector cleanup
rodrigob Jun 8, 2015
64fc4cc
Starting new areas of API
rodrigob Jun 8, 2015
0940eca
Starting work on RDom
rodrigob Jun 9, 2015
0451da2
Implemented struct buffer_t
rodrigob Jun 10, 2015
f7b97cb
Implemented Buffer
rodrigob Jun 10, 2015
7dec325
Improved support for Type class members
rodrigob Jun 10, 2015
574a7e5
Working on support for Image class. __call__ methods still not workin…
rodrigob Jun 10, 2015
ca60e16
Working on Image call operators
rodrigob Jun 10, 2015
32421d6
Image class implemented.
rodrigob Jun 10, 2015
dbe4995
Basics are 80% implemented. Now trying to get things running. Impleme…
rodrigob Jun 10, 2015
cd3ba68
Working test_basics.py. Solved Type problem of Var('x') + 1. Now miss…
rodrigob Jun 10, 2015
473e111
Working test_basics.py. Currently stuck at "cannot update blur_x beca…
rodrigob Jun 10, 2015
13e64c1
Got test_basics.py running. First compile_jit ran from python. Time t…
rodrigob Jun 11, 2015
97f694b
Exploded Func.cpp into multiple files to keep things organized
rodrigob Jun 11, 2015
554f735
Improved python help message by adding 'self' argument
rodrigob Jun 11, 2015
ca0168f
Improved python help message by adding 'self' argument (bis)
rodrigob Jun 11, 2015
b29d646
test_basics.py passes. Func cpu methods coverage is quite extensive n…
rodrigob Jun 11, 2015
62fef29
Adding requirements.txt file
rodrigob Jun 11, 2015
d327fe9
working on ndarray_to_image
rodrigob Jun 11, 2015
6a611ee
ndarray_to_image seems to be alive. time to attempt a first image pro…
rodrigob Jun 11, 2015
dc41e08
Implemented BoundaryConditions
rodrigob Jun 11, 2015
43dc650
Multiple minor edits
rodrigob Jun 11, 2015
5275601
blur.py runs as desired hip-hip hurra \!
rodrigob Jun 11, 2015
078b9d4
blur.py clean-up
rodrigob Jun 11, 2015
6050c61
Added Halide::Target support
rodrigob Jun 11, 2015
2239d73
blur.py passed again
rodrigob Jun 11, 2015
5aa8247
erode.py runs as desired
rodrigob Jun 11, 2015
9e8cde5
Added placeholder file for Tuple API
rodrigob Jun 11, 2015
a67b20d
Implemented RDom and RVar
rodrigob Jun 13, 2015
1486dc1
Improved support of debugging API
rodrigob Jun 13, 2015
1dec98c
Working on C++ and Boost.Python magic to get Param(...) working as de…
rodrigob Jun 14, 2015
d353a53
Extended support for Halide::Param<T>
rodrigob Jun 14, 2015
3825b71
Added exception message for '//' operator
rodrigob Jun 14, 2015
89a7118
Fooling around test_basics
rodrigob Jun 14, 2015
0d0dec7
Added missing operators (log, exp, and select)
rodrigob Jun 14, 2015
0ccb125
Extended support for FuncRefExpr
rodrigob Jun 14, 2015
a8d8f9d
'//' implemented as Halide's '/'
rodrigob Jun 14, 2015
504e186
Improved support for FuncRefVar API
rodrigob Jun 15, 2015
d49b48d
Minor edits to Func.cpp
rodrigob Jun 15, 2015
8f622cd
Exposed Tuple, Realization to be done.
rodrigob Jun 15, 2015
823a5b8
Exposed Realization.
rodrigob Jun 15, 2015
fab4e06
Minor edit to Param.cpp
rodrigob Jun 15, 2015
cc761e4
Implemented Image(...) factory methods. tutorial/lesson_01_basics.py …
rodrigob Jun 15, 2015
129c609
Implemented image_to_ndarray. lesson_02_input_image.py implemented, b…
rodrigob Jun 16, 2015
c3f5cb6
lesson_12_using_the_gpu.py implemented, but does not passes (yet).
rodrigob Jun 16, 2015
5324235
lesson_05_scheduling_1.py implemented, but does not passes (yet).
rodrigob Jun 16, 2015
f1d8316
lesson_06_realizing_over_shifted_domains.py implemented, but does not…
rodrigob Jun 16, 2015
84f0dd1
lesson_03_debugging_1.py implemented, but does not passes (yet).
rodrigob Jun 16, 2015
a08efc1
lesson_04_debugging_2.py implemented, and passes.
rodrigob Jun 16, 2015
5ea21d4
lesson_10_aot_compilation_generate.py and lesson_03_debugging_1.py bo…
rodrigob Jun 16, 2015
74dbd33
Ported lesson_11_cross_compilation.py, but does not passes yet.
rodrigob Jun 17, 2015
e3bff0e
Ported lesson_09_update_definitions.py, to be tested
rodrigob Jun 18, 2015
26712c3
Ported lesson_08_scheduling_2.py, to be tested
rodrigob Jun 18, 2015
252cb25
Ported lesson_07_multi_stage_pipelines.py, to be tested
rodrigob Jun 19, 2015
5c825e8
lesson_10_aot_compilation_run.py works as desired
rodrigob Jun 19, 2015
0e610e8
Working on making python apps and tutorials pass. Work in progress.
rodrigob Jun 19, 2015
ba58bc0
lesson_02_input_image.py now works as desired
rodrigob Jun 20, 2015
c4cc45a
lesson_06_realizing_over_shifted_domains.py now works as desired
rodrigob Jun 20, 2015
b07f9ff
lesson_08_scheduling_2.py runs but does not pass the result values test
rodrigob Jun 20, 2015
90aa3c0
lesson_11_cross_compilation.py works as desired
rodrigob Jun 21, 2015
03817c7
lesson_05_scheduling_1.py works as desired
rodrigob Jun 21, 2015
5660f6f
lesson_07_multi_stage_pipelines.py works as desired. But there is an …
rodrigob Jun 21, 2015
4ae8a4b
bug hunting. lesson_09 and apps/bilateral_grid.py both fail with the …
rodrigob Jun 21, 2015
e3249a2
Working on lesson_12 test. Improved Buffer constructor.
rodrigob Jun 21, 2015
d04859b
Added GPU methods to Halide::Func.
rodrigob Jun 21, 2015
bf9c7fe
Extended API support for Halide::Var
rodrigob Jun 21, 2015
567504f
lesson_12_using_the_gpu.py works as desired (albeit OpenCL version is…
rodrigob Jun 21, 2015
e52ba4e
Minor edits to lesson_12
rodrigob Jun 21, 2015
175cec1
Fixed support for 42 + FuncRefVar. Now it works as desired (updated l…
rodrigob Jun 21, 2015
67761a5
Adding missing IROperator functions
rodrigob Jun 21, 2015
551432e
Added CPU scheduling API support for Halide::Stage (gpu to be done)
rodrigob Jun 21, 2015
a453b95
Removed unnecessary `using p::self`
rodrigob Jun 21, 2015
675aa2a
Exposed Stage GPU scheduling methods
rodrigob Jun 21, 2015
0e55729
Fixed bug regarding strides handling in ndarray_to_image (working on …
rodrigob Jun 21, 2015
13ed03f
bilateral_grid.py `generate = True` works as desired. JIT version run…
rodrigob Jun 21, 2015
c75b0a1
bilateral_grid.py works as desired (JIt/compile_to_file and CPU/GPU v…
rodrigob Jun 21, 2015
0781819
Implemented InlineReductions.cpp, now lesson_09 works as desired.
rodrigob Jun 21, 2015
fd03340
Fixed bugs in lesson_08_scheduling_2.py now lesson_08 works as desired.
rodrigob Jun 21, 2015
45e23bd
Fixed issue with ndarray_to_image reference counting. Updated lesson_…
rodrigob Jun 22, 2015
6e59925
Making sure the tutorial read images properly independent of the laun…
rodrigob Jun 22, 2015
fd82173
Removing unused code in Image.cpp
rodrigob Jun 22, 2015
d7e334c
Fixed gcc-4.8 compilation issue. Code also compiles with clang-3.5
rodrigob Jun 22, 2015
f750ef7
Removed old swig python bindings. Renamed boost_python_bindings as py…
rodrigob Jun 22, 2015
432119c
Added initial doc
rodrigob Jun 23, 2015
3dccb2a
Minor edit to doc/index.rst
rodrigob Jun 23, 2015
23679dc
Ported interpolate.py, but does not yet work as intended (missing exp…
rodrigob Jun 24, 2015
0132e8e
Added local_laplacian.py but does not yet work as intended
rodrigob Jun 24, 2015
841b508
Improving repr for some of the classes
rodrigob Jun 24, 2015
88470b1
Trying to fix the operators type convertions. Simplified Func_Ref.cpp…
rodrigob Jun 24, 2015
3c7f87a
End of work session. tests/test_basics.py still not passing. More wor…
rodrigob Jun 24, 2015
2d77e9b
Fixed regression. Lessons pass again. interpolate.py and local_laplac…
rodrigob Jun 24, 2015
15b4911
local_laplacian.py application nows runs as desired
rodrigob Jun 24, 2015
d212a8a
Drafting updated python_bindings/readme.text
rodrigob Jun 24, 2015
5431748
Exposed Lambda.cpp, improved Func.reorder_storage.
rodrigob Jun 24, 2015
dc8975c
interpolate.py runs as desired.
rodrigob Jun 24, 2015
872d086
Found bug in image_to_ndarray, added check to test_basics.py
rodrigob Jun 24, 2015
423d81b
Fixed bug in image_to_ndarray, updated interpolate.py to use the alte…
rodrigob Jun 24, 2015
d99f78b
Updated readme and minor edits to the python docs (added link to host…
rodrigob Jun 24, 2015
72bfd95
Minor edit
rodrigob Jun 24, 2015
1f38f33
.text -> .md
rodrigob Jun 25, 2015
33a737d
Trying to fix markdown
rodrigob Jun 25, 2015
67e92f4
Minor edit
rodrigob Jun 25, 2015
a2d685c
Minor edit (bis)
rodrigob Jun 25, 2015
22b0b43
Starting work on importing the minimal boost.numpy into the python_bi…
rodrigob Jun 25, 2015
9758625
`USE_BOOST_NUMPY ON` works as desired. `USE_BOOST_NUMPY OFF` does not…
rodrigob Jun 25, 2015
0503cc7
`USE_BOOST_NUMPY OFF` generates a SIGILL; cannot figure out why yet.
rodrigob Jun 25, 2015
746ce69
Removing invoke_matching.hpp (since not needed)
rodrigob Jun 25, 2015
603adc8
After a clean compilation `USE_BOOST_NUMPY OFF` works as intended.
rodrigob Jun 25, 2015
c07808b
Ported lesson 13 (tuples), does not yet pass
rodrigob Jul 28, 2015
3774a66
Lesson 13 passes
rodrigob Jul 28, 2015
440f69b
Lesson 14 ported, but does not passes (yet)
rodrigob Jul 28, 2015
3a13529
Lesson 14 now passes
rodrigob Jul 29, 2015
c2d5dbb
Added test_param_bug (currently fails)
rodrigob Jul 29, 2015
fbf72e6
Now test_param_bug passes, but it seems the updates on tuples broke s…
rodrigob Jul 29, 2015
6275e36
Making compilation more robust across boost versions
rodrigob Jul 29, 2015
241a3a9
run_*.sh stops when one tutorial/app fails
rodrigob Jul 29, 2015
fa2ed9a
Mentioning PYTHONPATH in readme.md
rodrigob Jul 29, 2015
8cd28d2
Fixed ImageParam bug
rodrigob Jul 29, 2015
b992284
All tutorials and apps run as intended
rodrigob Jul 30, 2015
ff1bcf9
Added python path to run_*.sh
rodrigob Jul 30, 2015
348ba32
Exposing Func::define_extern and related methods
rodrigob Aug 2, 2015
d6a45ab
Doing some experiments to use define_extern from python
rodrigob Aug 3, 2015
fd6f819
commented out load_library_into_llvm helper
rodrigob Aug 3, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -122,6 +122,7 @@ bin/*
build-ios/*
build-osx/*
cmake_build/*
*/build/*
tmp/*
doc/*
include/*
Expand All @@ -134,6 +135,7 @@ msvc/*/x64/*
*~
*.o
*.a
*.so
*.dot
.DS_Store
*.log
Expand Down Expand Up @@ -161,6 +163,9 @@ src/test_*.s
.*.swp
Doxyfile

*.txt.user*
.idea

# jrk editor settings
.tm_properties
*.sublime-project
Expand Down Expand Up @@ -212,6 +217,9 @@ apps/HelloAndroidGL/jni/halide_gl_filter.h
apps/HelloAndroid*/local.properties
apps/HelloAndroid*/proguard-project.txt

# tutorial intermediates
tutorial/lesson_10_halide.h

# test intermediates
log.txt
err.txt
Expand Down
5 changes: 0 additions & 5 deletions python_bindings/.gitignore

This file was deleted.

93 changes: 93 additions & 0 deletions python_bindings/CMakeLists.txt
@@ -0,0 +1,93 @@

project(PyHalide)
cmake_minimum_required(VERSION 3.0) # for up-to-date FindPythonLibs.cmake
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR} )

# Find Python and boost python
if(USE_PYTHON EQUAL 2)
find_package(PythonInterp 2.7 REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
find_package(NumPy REQUIRED)
if (NOT USE_EXTERNAL_BOOST)
find_package(Boost COMPONENTS python REQUIRED)
endif()
else()
find_package(PythonInterp 3.4 REQUIRED)
find_package(PythonLibs 3.4 REQUIRED)
find_package(NumPy REQUIRED)
if (NOT USE_EXTERNAL_BOOST)
find_package(Boost COMPONENTS python-py34)
if(NOT Boost_FOUND)
find_package(Boost COMPONENTS python-py33)
endif()
if(NOT Boost_FOUND)
find_package(Boost COMPONENTS python3 REQUIRED)
endif()
endif()
endif()

option(USE_BOOST_NUMPY "Use Boost.Numpy dependency instead of Halide.Numpy" OFF)


if(USE_BOOST_NUMPY)
add_definitions( -DUSE_BOOST_NUMPY )
set(BoostNumpy_INCLUDE_DIRS "")
set(BoostNumpy_LIBRARY_DIR "")
set(BoostNumpy_LIBRARIES boost_numpy)
else()
#(NOT USE_BOOST_NUMPY) is true

file(GLOB MicroNumpyCpp
numpy/*.cpp
numpy/*.hpp
)

add_library(halide_numpy STATIC ${MicroNumpyCpp})
target_link_libraries(halide_numpy ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${NumPy_LIBRARIES})
set_property(TARGET halide_numpy PROPERTY POSITION_INDEPENDENT_CODE TRUE)

set(BoostNumpy_INCLUDE_DIRS ./numpy)
set(BoostNumpy_LIBRARY_DIR ./numpy)
set(BoostNumpy_LIBRARIES halide_numpy)
endif()

add_definitions("-std=c++11")

include_directories(
../build/include
${Boost_INCLUDE_DIRS}
${BoostNumpy_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
)

link_directories(
../build/lib
${Boost_LIBRARY_DIR}
${BoostNumpy_LIBRARY_DIR}
${Numpy_LIBRARY_DIR}
)


if(FALSE AND UNIX )
# Disable the pointer-to-function and pointer-to-object warnings
add_definitions( -Wno-unused-local-typedefs )
set_property(SOURCE util.cpp PROPERTY COMPILE_FLAGS -w )
endif()

file(GLOB SrcCpp
python/*.cpp
../src/Param.cpp)

add_library(halide SHARED ${SrcCpp})
target_link_libraries(halide
Halide InitialModules
${Boost_LIBRARIES}
${BoostNumpy_LIBRARIES}
${PYTHON_LIBRARIES}
)

set_target_properties( halide PROPERTIES PREFIX "")
if(APPLE)
set_target_properties( halide PROPERTIES SUFFIX ".so" )
endif()
90 changes: 90 additions & 0 deletions python_bindings/FindNumPy.cmake
@@ -0,0 +1,90 @@
# - Find the NumPy libraries
# This module finds if NumPy is installed, and sets the following variables
# indicating where it is.
#
# TODO: Update to provide the libraries and paths for linking npymath lib.
#
# NUMPY_FOUND - was NumPy found
# NUMPY_VERSION - the version of NumPy found as a string
# NUMPY_VERSION_MAJOR - the major version number of NumPy
# NUMPY_VERSION_MINOR - the minor version number of NumPy
# NUMPY_VERSION_PATCH - the patch version number of NumPy
# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601
# NUMPY_INCLUDE_DIRS - path to the NumPy include files

#============================================================================
# Copyright 2012 Continuum Analytics, Inc.
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
#============================================================================

# Finding NumPy involves calling the Python interpreter
if(NumPy_FIND_REQUIRED)
find_package(PythonInterp REQUIRED)
else()
find_package(PythonInterp)
endif()

if(NOT PYTHONINTERP_FOUND)
set(NUMPY_FOUND FALSE)
endif()

execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import numpy as n; print(n.__version__); print(n.get_include());"
RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS
OUTPUT_VARIABLE _NUMPY_VALUES
ERROR_VARIABLE _NUMPY_ERROR_VALUE
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0)
if(NumPy_FIND_REQUIRED)
message(FATAL_ERROR
"NumPy import failure:\n${_NUMPY_ERROR_VALUE}")
endif()
set(NUMPY_FOUND FALSE)
endif()

# Convert the process output into a list
string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES})
string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES})
list(GET _NUMPY_VALUES 0 NUMPY_VERSION)
list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS)

# Make sure all directory separators are '/'
string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS})

# Get the major and minor version numbers
string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION})
list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR)
list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR)
list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH)
string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH})
math(EXPR NUMPY_VERSION_DECIMAL
"(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}")

find_package_message(NUMPY
"Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}"
"${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}")

set(NUMPY_FOUND TRUE)

39 changes: 0 additions & 39 deletions python_bindings/Makefile

This file was deleted.

55 changes: 0 additions & 55 deletions python_bindings/README.md

This file was deleted.

Empty file removed python_bindings/apps/__init__.py
Empty file.