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

[serialization] Add serialization support to generator interface #7792

Merged
merged 10 commits into from
Aug 28, 2023

Conversation

derek-gerstmann
Copy link
Contributor

Added new 'hlpipe' output type.
Added new emit_hlpipe(...) method to generator class interface.
Added new pre_serialization()/post_serializtion() methods to set a flag to bypass target validation during build_pipeline()

Note that generators that currently use natural_vector_size(...) must have a target specified, otherwise they will emit a user_error during serialization. Since almost all our generators seem to rely upon natural_vector_size(...) it seems like we might need to allow some way to inject a placeholder into the serialization format to allow the target to be unspecified, and the vector size to be resolved when the pipeline is realized.

src/Generator.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

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

Since schedules depend pretty critically on the Target, we definitely want to require a target to be set.

That said, perhaps we could/should add an option to the string-to-target conversion that will produce the equivalent of Target() -- i.e., shorthand for arch_unknown-os_unknown-0, which is a "Target" that can't be used usefully for codegen, but perhaps could be useful for some serialization purposes?

src/AbstractGenerator.h Outdated Show resolved Hide resolved
src/AbstractGenerator.h Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.h Outdated Show resolved Hide resolved
src/Module.cpp Outdated Show resolved Hide resolved
src/Module.h Outdated Show resolved Hide resolved
may be target dependent).
Apply auto-scheduler before serialization so that schedules can be
serialized.
@derek-gerstmann
Copy link
Contributor Author

Since schedules depend pretty critically on the Target, we definitely want to require a target to be set.

That said, perhaps we could/should add an option to the string-to-target conversion that will produce the equivalent of Target() -- i.e., shorthand for arch_unknown-os_unknown-0, which is a "Target" that can't be used usefully for codegen, but perhaps could be useful for some serialization purposes?

Doing a quick pass through our generator tests, only a few can actually be serialized without specifying a target, so I'm not sure how useful it would be.

Derek Gerstmann added 2 commits August 22, 2023 11:43
Fix hlpipe comments.
Add missing hlpipe enum to pyenums.
@derek-gerstmann
Copy link
Contributor Author

Thanks for the comments and feedback! I've made the target a requirement and handle this within a target specific generator context which will also apply any attached autoscheduler prior to serialization (so that auto-generated schedules can be serialized). I've removed the pre_serialization and post_serialization passes from the Generator class, and other cruft that is not necessary anymore.

src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.cpp Outdated Show resolved Hide resolved
src/Generator.h Outdated Show resolved Hide resolved
Remove redundant cpp_stub check.
Fix comments.
@steven-johnson
Copy link
Contributor

Looks like the Make builds are failing to link...? Maybe #7762?

@abadams
Copy link
Member

abadams commented Aug 22, 2023

Some stuff probably needs to be guarded with #ifdef WITH_SERIALIZATION

@steven-johnson steven-johnson self-requested a review August 24, 2023 22:19
Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

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

LGTM -- bot failures are unrelated, ready to land unless @abadams objects

@abadams
Copy link
Member

abadams commented Aug 28, 2023

No objection here. I will defer to you, Steven.

@steven-johnson steven-johnson merged commit fe9f0b7 into main Aug 28, 2023
17 of 19 checks passed
@steven-johnson steven-johnson deleted the dg/add_gengen_serialization branch August 28, 2023 18:13
ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
…ide#7792)

* Add serialization support to Generator interface

* Clang format pass

* Make target required when emitting a serialized pipeline (since schedule
may be target dependent).
Apply auto-scheduler before serialization so that schedules can be
serialized.

* Fix enum ordering for hlpipe.
Fix hlpipe comments.
Add missing hlpipe enum to pyenums.

* Remove unused Serialization build_mode

* Fix formatting

* Remove unused serializable flag.
Remove redundant cpp_stub check.
Fix comments.

* Safeguard emit_hlpipe calls with #ifdef WITH_SERIALIZATION

---------

Co-authored-by: Derek Gerstmann <dgerstmann@adobe.com>
Co-authored-by: Steven Johnson <srj@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants