Skip to content

[serialization] Add serialization support to generator interface #7792

Merged
steven-johnson merged 10 commits intomainfrom
dg/add_gengen_serialization
Aug 28, 2023
Merged

[serialization] Add serialization support to generator interface #7792
steven-johnson merged 10 commits intomainfrom
dg/add_gengen_serialization

Conversation

@derek-gerstmann
Copy link
Copy Markdown
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.

Comment thread src/Generator.cpp Outdated
Copy link
Copy Markdown
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?

Comment thread src/AbstractGenerator.h Outdated
Comment thread src/AbstractGenerator.h Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.h Outdated
Comment thread src/Module.cpp Outdated
Comment thread src/Module.h Outdated
may be target dependent).
Apply auto-scheduler before serialization so that schedules can be
serialized.
@derek-gerstmann
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.cpp Outdated
Comment thread src/Generator.h Outdated
Remove redundant cpp_stub check.
Fix comments.
@steven-johnson
Copy link
Copy Markdown
Contributor

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

@abadams
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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