Skip to content

Update schema to include infinity for double values #5203

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

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

lucylq
Copy link
Contributor

@lucylq lucylq commented Sep 9, 2024

Summary: Replace previous solution of parsing the json and replacing instances of "Infinity" with "inf"

Differential Revision: D62393242

Copy link

pytorch-bot bot commented Sep 9, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/5203

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit ac31049 with merge base 7650667 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 9, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62393242

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62393242

lucylq added a commit to lucylq/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5203

Replace previous solution of parsing the json and replacing instances of "Infinity" with "inf"

Differential Revision: D62393242
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62393242

lucylq added a commit to lucylq/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5203

Replace previous solution of parsing the json and replacing instances of "Infinity" with "inf"

Differential Revision: D62393242
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62393242

lucylq added a commit to lucylq/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5203

Replace previous solution of parsing the json and replacing instances of "Infinity" with "inf"

Deserialization process:
1. Convert flatbuffer to json, using program.fbs. Program.fbs doesn't have the Union double type (only schema.py); use regex to replace instances of `-inf` to `"-inf"`.
2. Convert json to dataclasses. Add support for Union double type here.

Differential Revision: D62393242
@lucylq lucylq force-pushed the export-D62393242 branch 2 times, most recently from ed081c0 to fd48e5e Compare September 10, 2024 01:00
lucylq added a commit to lucylq/executorch-1 that referenced this pull request Sep 10, 2024
Summary:
Pull Request resolved: pytorch#5203

Replace previous solution of parsing the json and replacing instances of "Infinity" with "inf"

Serialization:
1. Program is created using schema.py dataclasses in emitter. Add default constructors (`__init__`), so that all constructions of Double are either float, or string for infinity values.

Deserialization process:
1. Convert flatbuffer to json, using program.fbs. Program.fbs doesn't have the Union double type (only schema.py); use regex to replace instances of `-inf` to `"-inf"`.
2. Convert json to dataclasses. Add support for Union double type here.

Differential Revision: D62393242
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62393242

Summary:
Pull Request resolved: pytorch#5203

Replace previous solution of parsing the json and replacing instances of "Infinity" with "inf"

Serialization:
1. Python dataclasses --> JSON --> flatbuffer.
2. Convert Double inside schema.py to a union value of float and string, so that there is valid JSON when we convert dataclasses --> JSON.
2. Program is created using schema.py dataclasses in emitter. Add default constructors (`__init__`), so that all constructions of Double are either float, or string for infinity values.
3. Note: `program.fbs` remains unchanged.

Deserialization process:
1. Flatbuffer  --> JSON --> python dataclasses.
2. Flatbuffer is converted to JSON using `program.fbs`, which does not have the Union double definition. Use regex to replace instances of `-inf` to `"-inf"` so that there is valid JSON.
3. Add support for Union double type for the conversion from JSON to python dataclasses

Differential Revision: D62393242
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62393242

@facebook-github-bot facebook-github-bot merged commit c5a385e into pytorch:main Sep 10, 2024
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants