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

Experimental serializer #7594

Merged
merged 138 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 136 commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
7bafefc
init
TH3CHARLie Mar 22, 2023
10fce24
sync
TH3CHARLie Mar 30, 2023
acd6223
single func pipeline round-trip test
TH3CHARLie Apr 25, 2023
937cb48
Merge branch 'main' into xuanda/serialization
TH3CHARLie May 29, 2023
256c36d
roundtrip test framework completed, single output function tested, no…
TH3CHARLie May 29, 2023
7804953
serialize Stmt, partially done (cuz no support of Expr yet), not fully
TH3CHARLie May 29, 2023
dd6d9fc
deviceAPI MemoryType ForType
TH3CHARLie May 29, 2023
e3a55c5
Expr, with a grain of salt
TH3CHARLie May 30, 2023
4c19481
fix exprs in stmts
TH3CHARLie May 30, 2023
dfff1a9
format everything
TH3CHARLie May 30, 2023
6838258
Range
TH3CHARLie May 30, 2023
d6b0b00
fix undefined exprs and stmts
TH3CHARLie Jun 5, 2023
609705d
address some review comments:
TH3CHARLie Jun 5, 2023
4b86347
address more review comments
TH3CHARLie Jun 6, 2023
35296ff
deserialize_expr_vector
TH3CHARLie Jun 6, 2023
fe79618
support bound, storageDim, loopLevel and funcSchedule
TH3CHARLie Jun 6, 2023
478970e
Specialization, Definition
TH3CHARLie Jun 7, 2023
4140ae1
sync commit
TH3CHARLie Jun 19, 2023
df3620b
temporarily comment out func mapping stuff to remove blockers
TH3CHARLie Jun 20, 2023
b416d26
helper funcs
TH3CHARLie Jun 20, 2023
db47e2c
call_type and reduction_domain
TH3CHARLie Jun 20, 2023
63ac57a
ModulusRemainder and VectorReduceOp, some minor refactoring
TH3CHARLie Jun 20, 2023
ca4ac94
prefetch directive
TH3CHARLie Jun 20, 2023
097ec2e
name mangling and closing on function's odds and ends
TH3CHARLie Jun 20, 2023
88f4a5d
split
TH3CHARLie Jun 20, 2023
491b596
dim
TH3CHARLie Jun 20, 2023
b7292b7
stage schedule
TH3CHARLie Jun 21, 2023
271f4c8
tidy
TH3CHARLie Jun 21, 2023
9632e5b
parameter
TH3CHARLie Jun 21, 2023
49644e9
more parameter
TH3CHARLie Jun 21, 2023
c574e46
check nullptr and some minor fix
TH3CHARLie Jun 21, 2023
f86b390
fix crashing
TH3CHARLie Jun 21, 2023
5b49664
func index replacing func ptr during serialization
TH3CHARLie Jun 22, 2023
c6686cc
extern func arg, some minor cleanup
TH3CHARLie Jun 22, 2023
60aa622
replace cerr with halide assert
TH3CHARLie Jun 22, 2023
599859c
buffer??
TH3CHARLie Jun 22, 2023
882b38d
remove printer
TH3CHARLie Jun 22, 2023
958432e
fix
TH3CHARLie Jun 22, 2023
46a40f5
wrappers in func_schedule
TH3CHARLie Jun 23, 2023
2d2564d
clear func mapping to use serializer for more than 1 pipelines, use u…
TH3CHARLie Jun 23, 2023
21a7c3d
attempt to move serialization into core, get cmake working for now
TH3CHARLie Jun 27, 2023
3c284df
fix
TH3CHARLie Jun 27, 2023
62bb5df
we maybe don't need submodule
TH3CHARLie Jun 27, 2023
1e4e0c5
fix cmake
TH3CHARLie Jun 27, 2023
770a30e
make headers work again, with some hacks ofc
TH3CHARLie Jun 27, 2023
ad6eb06
serialization now lives in libHalide
TH3CHARLie Jun 27, 2023
ad54aeb
testing 101
TH3CHARLie Jun 27, 2023
42af1ad
don't include flatbuffers header in Halide.h
TH3CHARLie Jun 27, 2023
6c24ce6
fix
TH3CHARLie Jun 27, 2023
87d3be4
namespace adjust
TH3CHARLie Jun 27, 2023
303e7bb
user_assert
TH3CHARLie Jun 28, 2023
e1a79aa
fix a missing field
TH3CHARLie Jun 28, 2023
b47317c
fix missing type info in some exprs
TH3CHARLie Jun 28, 2023
efa5be4
fix bug in function mapping
TH3CHARLie Jun 29, 2023
df87b3f
fix function DAG broken issue
TH3CHARLie Jun 29, 2023
027de4f
format
TH3CHARLie Jun 29, 2023
19217ac
rm cout in cpp files and change test group name
TH3CHARLie Jul 10, 2023
fac998c
fix the case func ptr is not defined
TH3CHARLie Jul 10, 2023
c2f152a
add a missing call type deserialization
TH3CHARLie Jul 10, 2023
d9834b4
serialize unique parameters
TH3CHARLie Jul 11, 2023
46467ac
serialize unique buffers
TH3CHARLie Jul 11, 2023
5a5da05
fix missing type in parameter
TH3CHARLie Jul 11, 2023
66db495
fix a missing tail stra
TH3CHARLie Jul 11, 2023
dff37e0
change find_transive_call to build_enviroment to include wrappers in …
TH3CHARLie Jul 12, 2023
74f4b39
upstream current test strategy, intercept JIT compilation for each pi…
TH3CHARLie Jul 13, 2023
4bbc072
make sure buffer memory layout are the same
TH3CHARLie Jul 13, 2023
0e3f8a0
don't use ir comparator to compare pipelines, we will use jit tests f…
TH3CHARLie Jul 13, 2023
f175c84
don't serialize Parameter's buffer, compute external buffers from Cal…
TH3CHARLie Jul 13, 2023
ede205a
fix, 35 tests remaining
TH3CHARLie Jul 16, 2023
fcdd799
fix output function orders
TH3CHARLie Jul 17, 2023
f72598b
reuse jit_externs since we cannot really serialize it, 29 tests to go
TH3CHARLie Jul 17, 2023
fd31ae6
fix that buffer_constraints, host_alignment and memory_type are incor…
TH3CHARLie Jul 17, 2023
e2dccc1
only use outputs and requirements from deserialized pipeline during t…
TH3CHARLie Jul 17, 2023
7d16695
nits
TH3CHARLie Jul 17, 2023
86fd169
add missing requirements during deserialization
TH3CHARLie Jul 18, 2023
e34c02f
restore original pipeline's contents after lowering
TH3CHARLie Jul 18, 2023
8733128
address some review comments
TH3CHARLie Jul 18, 2023
118a391
Install flatbuffers for clang-tidy
steven-johnson Jul 18, 2023
3f586c9
Merge branch 'main' into xuanda/serialization
steven-johnson Jul 18, 2023
5b0ab8d
use std::map to make results the same on different compiler
TH3CHARLie Jul 18, 2023
7d4b7ce
Merge branch 'xuanda/serialization' of https://github.com/TH3CHARLie/…
TH3CHARLie Jul 18, 2023
9a64e12
proper way to handle cropped buffers
TH3CHARLie Jul 18, 2023
c6e8f5b
fix cmake build using alex's branch
TH3CHARLie Jul 18, 2023
017c0bb
try set flatbuffers_DIR explicitly
TH3CHARLie Jul 18, 2023
bb181d1
case sensitive?
TH3CHARLie Jul 18, 2023
a634150
rename serialization test env var
TH3CHARLie Jul 18, 2023
2b73e94
cleanup Serialization.cpp
TH3CHARLie Jul 18, 2023
f2cee65
format
TH3CHARLie Jul 18, 2023
991c3c8
have halide version embedded in the file identifier
TH3CHARLie Jul 19, 2023
1cc413a
nits and comments
TH3CHARLie Jul 19, 2023
f66f430
format
TH3CHARLie Jul 19, 2023
898d074
try make clang-tidy happy and const a lot of things
TH3CHARLie Jul 19, 2023
7ab29b6
const more things
TH3CHARLie Jul 19, 2023
fc9d1b3
support istream input
TH3CHARLie Jul 24, 2023
a7c67e3
nit
TH3CHARLie Jul 24, 2023
e384b93
add template function deserialize_vector
TH3CHARLie Jul 24, 2023
1981584
nit
TH3CHARLie Jul 24, 2023
28dbeb8
attempt to integrate serialization test
TH3CHARLie Jul 24, 2023
9d2aea1
line breaks
TH3CHARLie Jul 24, 2023
43efbba
remove hack in compile_jit, at least for now
TH3CHARLie Jul 24, 2023
3eb37b4
fix
TH3CHARLie Jul 24, 2023
c5fa85a
Merge branch 'main' into xuanda/serialization
TH3CHARLie Jul 27, 2023
1396434
add #ifdef guards
TH3CHARLie Jul 27, 2023
17dfcd1
format
TH3CHARLie Jul 27, 2023
cc81e1f
try nolint
TH3CHARLie Jul 28, 2023
654c8eb
special case two files so clang-tidy will be happy
TH3CHARLie Jul 28, 2023
625ad4e
Make Flatbuffers-missing error more useful
steven-johnson Aug 3, 2023
363a5b6
Merge branch 'xuanda/serialization' of https://github.com/TH3CHARLie/…
steven-johnson Aug 3, 2023
23c4907
Merge branch 'main' into pr/7594
steven-johnson Aug 3, 2023
15ba956
Make a few final changes
steven-johnson Aug 3, 2023
639ee8f
Oops addition
steven-johnson Aug 3, 2023
2eb4f9a
clang-format
steven-johnson Aug 3, 2023
ebc900b
Add temporary debug hackery
steven-johnson Aug 3, 2023
418dfb0
more hackery
steven-johnson Aug 3, 2023
d9cf85d
grr
steven-johnson Aug 3, 2023
85311ed
sdfsdf
steven-johnson Aug 3, 2023
e0399e2
sigh, capitalization
steven-johnson Aug 3, 2023
7b07c39
One more try
steven-johnson Aug 3, 2023
1ad585d
Update presubmit.yml
steven-johnson Aug 3, 2023
3caf020
No more mr nice guy
steven-johnson Aug 3, 2023
84a36d1
Update CMakeLists.txt
steven-johnson Aug 3, 2023
83c7a25
Revise build rules & script to allow clang-tidy for the new files
steven-johnson Aug 3, 2023
ae2cfd8
Update CMakeLists.txt
steven-johnson Aug 3, 2023
5d912c6
Apply clang-tidy fixes
steven-johnson Aug 3, 2023
7ddc210
Fix target for generated header
steven-johnson Aug 4, 2023
066d6f7
Prefer to use FetchContent for flatbuffers
steven-johnson Aug 4, 2023
7936657
Fixes
steven-johnson Aug 4, 2023
a02f6d5
set PIC on
steven-johnson Aug 4, 2023
b2673f5
more pic
steven-johnson Aug 4, 2023
934e3f9
fix attempt
steven-johnson Aug 4, 2023
4f2c6e4
fix attempt
steven-johnson Aug 4, 2023
568a740
try macos
steven-johnson Aug 4, 2023
8bf2d67
coreutils
steven-johnson Aug 4, 2023
df0addd
Update run-clang-tidy.sh
steven-johnson Aug 4, 2023
e9fd2aa
noquiet
steven-johnson Aug 4, 2023
1f9cf57
final again?
steven-johnson Aug 4, 2023
3ff9fd3
Merge branch 'main' into pr/7594
steven-johnson Aug 4, 2023
cc1eec5
Merge branch 'xuanda/serialization' of https://github.com/TH3CHARLie/…
steven-johnson Aug 4, 2023
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 .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ jobs:
source: '.'
extensions: 'h,c,cpp'
clangFormatVersion: 16
# As of Aug 2023, the macOS runners have more RAM (14GB vs 7GB) and CPU (3 cores vs 2)
# than the Linux and Windows runners, so let's use those instead, since clang-tidy is
# a bit of a sluggard
check_clang_tidy:
name: Check clang-tidy
runs-on: ubuntu-20.04
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Install clang-tidy
run: |
# from apt.llvm.org
# wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
sudo apt-add-repository "deb https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-16 main"
sudo apt-get update
sudo apt-get install llvm-16 clang-16 liblld-16-dev libclang-16-dev clang-tidy-16 ninja-build
brew update
brew install llvm@16 ninja coreutils
- name: Run clang-tidy
run: |
export CC=clang-16
export CXX=clang++-16
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-16
export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/local/opt/llvm
export CMAKE_GENERATOR=Ninja
./run-clang-tidy.sh
check_cmake_file_lists:
name: Check CMake file lists
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ issue.

### TL;DR

Have llvm-15.0 (or greater) installed and run `make` in the root directory of
Have llvm-16.0 (or greater) installed and run `make` in the root directory of
the repository (where this README is).

### Acquiring LLVM
Expand Down
2 changes: 1 addition & 1 deletion packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (TARGET Halide_Adams2019)
endif ()

# Halide_LLVM
foreach (dep IN ITEMS Halide_LLVM Halide_wabt)
foreach (dep IN ITEMS Halide_LLVM Halide_wabt Halide_flatbuffers)
if (TARGET ${dep})
install(TARGETS ${dep} EXPORT Halide_Targets)
endif ()
Expand Down
38 changes: 33 additions & 5 deletions run-clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@ set -e

ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

[[ "$1" != "" && "$1" != "-fix" ]] && echo "The only supported argument is -fix" && exit

FIX=$1
usage() { echo "Usage: $0 [-j MAX_PROCESS_COUNT] [-f]" 1>&2; exit 1; }

J=$(nproc)
FIX=

while getopts ":j:f" o; do
case "${o}" in
j)
J="${OPTARG}"
[[ "${J}" =~ ^[0-9]+$ ]] || ( echo "-j requires an integer argument"; usage )
;;
f)
FIX="-fix"
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))

echo "Using ${J} processes."
if [ -n "${FIX}" ]; then
echo "Operating in -fix mode!"
fi

# We are currently standardized on using LLVM/Clang16 for this script.
# Note that this is totally independent of the version of LLVM that you
Expand Down Expand Up @@ -47,7 +69,11 @@ cmake -DCMAKE_BUILD_TYPE=Debug \
[ -a ${CLANG_TIDY_BUILD_DIR}/compile_commands.json ]

# We must populate the includes directory to check things outside of src/
cmake --build ${CLANG_TIDY_BUILD_DIR} --target HalideIncludes
echo Building HalideIncludes...
cmake --build ${CLANG_TIDY_BUILD_DIR} -j $(nproc) --target HalideIncludes

echo Building flatbuffer stuff...
cmake --build ${CLANG_TIDY_BUILD_DIR} -j $(nproc) --target generate_fb_header

RUN_CLANG_TIDY=${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/run-clang-tidy

Expand All @@ -57,6 +83,7 @@ RUN_CLANG_TIDY=${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/run-clang-tidy
# Skip DefaultCostModel.cpp as it relies on cost_model.h.
# Skip GenGen.cpp and RunGenMain.cpp as they bring clang-tidy to its knees,
# for reasons that aren't entirely clear yet.
echo Finding targets...
CLANG_TIDY_TARGETS=$(find \
"${ROOT_DIR}/src" \
"${ROOT_DIR}/python_bindings" \
Expand All @@ -71,9 +98,10 @@ CLANG_TIDY_TARGETS=$(find \
# so we will instead build an include filter
CLANG_TIDY_HEADER_FILTER=".*/src/.*|.*/python_bindings/.*|.*/tools/.*|.*/util/.*"

echo Running clang-tidy...
${RUN_CLANG_TIDY} \
${FIX} \
-j $(nproc) \
-j ${J} \
-header-filter="${CLANG_TIDY_HEADER_FILTER}" \
-quiet \
-p ${CLANG_TIDY_BUILD_DIR} \
Expand Down
90 changes: 90 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(HEADER_FILES
Deinterleave.h
Derivative.h
DerivativeUtils.h
Deserialization.h
DeviceAPI.h
DeviceArgument.h
DeviceInterface.h
Expand Down Expand Up @@ -140,6 +141,7 @@ set(HEADER_FILES
ScheduleFunctions.h
Scope.h
SelectGPUAPI.h
Serialization.h
Simplify.h
SimplifyCorrelatedDifferences.h
SimplifySpecializations.h
Expand Down Expand Up @@ -221,6 +223,7 @@ set(SOURCE_FILES
Deinterleave.cpp
Derivative.cpp
DerivativeUtils.cpp
Deserialization.cpp
DeviceArgument.cpp
DeviceInterface.cpp
Dimension.cpp
Expand Down Expand Up @@ -299,6 +302,7 @@ set(SOURCE_FILES
Schedule.cpp
ScheduleFunctions.cpp
SelectGPUAPI.cpp
Serialization.cpp
Simplify.cpp
Simplify_Add.cpp
Simplify_And.cpp
Expand Down Expand Up @@ -394,6 +398,7 @@ foreach (f IN LISTS HTML_TEMPLATE_FILES)
target_sources(Halide_c_templates PRIVATE ${DST})
endforeach ()


##
# Build the Halide mono-header.
##
Expand All @@ -418,6 +423,91 @@ add_library(Halide
# Including these as sources works around the need to "install" Halide_initmod
$<TARGET_OBJECTS:Halide_initmod>
$<TARGET_OBJECTS:Halide_c_templates>)

##
# Flatbuffers and Serialization dependencies.
##

# Build serialization, enabled by default
option(WITH_SERIALIZATION "Include experimental Serialization/Deserialization code" ON)

# flatbuffers is small and compiles quickly, but if you want/need to use
# a local version (via find_package), configure with FLATBUFFERS_USE_FETCHCONTENT=OFF
option(FLATBUFFERS_USE_FETCHCONTENT "Enable to download the Flatbuffers library via FetchContent" ON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole FetchContent thing makes me sad. We'll (I'll) be able to do much better with CMake 3.24+ and its tighter integration between the two methods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, an upgrade would give us so much leverage that I think we should poll our users to see if they can tolerate an early upgrade to 3.24.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

set(FLATBUFFERS_VER 23.5.26 CACHE STRING "The Flatbuffers version to use (or download)")

if (WITH_SERIALIZATION)
if (FLATBUFFERS_USE_FETCHCONTENT)
include(FetchContent)
message(STATUS "Fetching flatbuffers ${FLATBUFFERS_VER}...")
FetchContent_Declare(
flatbuffers
GIT_REPOSITORY https://github.com/google/flatbuffers.git
GIT_TAG v${FLATBUFFERS_VER}
GIT_SHALLOW TRUE
)
# configuration for flatbuffers
set(FLATBUFFERS_BUILD_TESTS OFF)
set(FLATBUFFERS_INSTALL OFF)
FetchContent_MakeAvailable(flatbuffers)
set_target_properties(flatbuffers PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(Halide_flatbuffers INTERFACE)
target_sources(Halide_flatbuffers INTERFACE $<BUILD_INTERFACE:$<TARGET_OBJECTS:flatbuffers>>)
target_include_directories(Halide_flatbuffers
SYSTEM # Use -isystem instead of -I; this is a trick so that clang-tidy won't analyze these includes
INTERFACE
$<BUILD_INTERFACE:${flatbuffers_SOURCE_DIR}>/include
$<BUILD_INTERFACE:${flatbuffers_BINARY_DIR}>/include)
set_target_properties(Halide_flatbuffers PROPERTIES EXPORT_NAME flatbuffers)

add_executable(flatbuffers::flatc ALIAS flatc)
message(STATUS "Using fetched-and-built flatbuffers, version ${FLATBUFFERS_VER}")
else ()
# Sadly, there seem to be at least three variations of the Flatbuffer package
# in terms of the case of the relevant CMake files; if we guess wrong, we
# fail on case-sensitive file systems. We'll try this as a hack workaround:
# just try all three. (Note that the internal CMake library name appears to be
# `flatbuffers` in all cases.)
set(FB_NAME "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using the NAMES argument to find_package? That would simplify this considerably

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...because I didn't know about it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, sometimes I forget the abyss stared back into me

foreach (N IN ITEMS flatbuffers Flatbuffers FlatBuffers)
# TODO: should we check the version here?
find_package(${N} QUIET)
if (${N}_FOUND)
set(FB_NAME ${N})
message(STATUS "Using installed flatbuffers, version ${${N}_VERSION}")
break()
endif ()
endforeach ()

if (NOT FB_NAME)
message(FATAL_ERROR "WITH_SERIALIZATION is ON and FLATBUFFERS_USE_FETCHCONTENT is OFF, "
"but could not find flatbuffers installed locally. "
"Either install flatbuffers or build with WITH_SERIALIZATION=OFF.")
endif ()

add_library(Halide_flatbuffers ALIAS flatbuffers::flatbuffers)
endif ()

set(fb_dir "${Halide_BINARY_DIR}/flatc/include")

set(fb_def "${CMAKE_CURRENT_SOURCE_DIR}/halide_ir.fbs")
set(fb_header "${fb_dir}/halide_ir_generated.h")
add_custom_command(
OUTPUT "${fb_header}"
COMMAND flatbuffers::flatc --cpp -o "${fb_dir}" "${fb_def}"
DEPENDS "${fb_def}"
VERBATIM
)
add_custom_target(generate_fb_header DEPENDS "${fb_header}")
set_source_files_properties("${fb_header}" PROPERTIES GENERATED TRUE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Add custom command sets it automatically

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that.


add_dependencies(Halide generate_fb_header)
target_include_directories(Halide PRIVATE "$<BUILD_INTERFACE:${fb_dir}>")
target_link_libraries(Halide PRIVATE Halide_flatbuffers)
target_compile_definitions(Halide PRIVATE WITH_SERIALIZATION)
endif ()

add_library(Halide::Halide ALIAS Halide)

target_link_libraries(Halide PRIVATE Halide::LLVM)
Expand Down
12 changes: 12 additions & 0 deletions src/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ Definition::Definition(const std::vector<Expr> &args, const std::vector<Expr> &v
}
}

Definition::Definition(bool is_init, const Expr &predicate, const std::vector<Expr> &args, const std::vector<Expr> &values,
steven-johnson marked this conversation as resolved.
Show resolved Hide resolved
const StageSchedule &schedule, const std::vector<Specialization> &specializations, const std::string &source_location)
: contents(new DefinitionContents) {
contents->is_init = is_init;
contents->values = values;
contents->args = args;
contents->predicate = predicate;
contents->stage_schedule = schedule;
contents->specializations = specializations;
contents->source_location = source_location;
}

Definition Definition::get_copy() const {
internal_assert(contents.defined()) << "Cannot copy undefined Definition\n";

Expand Down
4 changes: 4 additions & 0 deletions src/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class Definition {
Definition(const std::vector<Expr> &args, const std::vector<Expr> &values,
const ReductionDomain &rdom, bool is_init);

/** Construct a Definition with deserialized data. */
Definition(bool is_init, const Expr &predicate, const std::vector<Expr> &args, const std::vector<Expr> &values,
const StageSchedule &schedule, const std::vector<Specialization> &specializations, const std::string &source_location);

/** Construct an undefined Definition object. */
Definition();

Expand Down
Loading