SIGN IN SIGN UP

Improve serialization of union types. (#1502)

Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/1502

X-link: https://github.com/pytorch/pytorch/pull/116511

Making union types harder to use wrong:
1. Initialize unset fields still with None, but we don't assert on the uniqueness of not None field, since it's possible to set a real field to None.
2. Raise error on unset fields in union, reducing the error surface and enforcing type safety.
3. Serialize union type with only tag and omit all the unset fields, this makes the serialized model more readable and debuggable.

Reviewed By: angelayi

Differential Revision: D52446586

fbshipit-source-id: 5edb0c9e990c1f9b0b7da3691735833011499841
Z
Zhengxu Chen committed
a33e6a6189a8964ced3a9246d53a1ad0d3afef51
Parent: 504366f
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 1/3/2024, 4:51:50 AM