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

Fix handling of OrderedDict with optree and related documentation. #20481

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 11, 2024

  1. Fix handling of OrderedDict with optree and related documentation.

    The tree API had specific but contradicting documentation calling out the handling of `OrderedDict`s. However, the behavior of the `optree` implementation did not honor this documentation (using the key order, not the sequence order) for `flatten`, although it did for `pack_sequence_as`. The result was that not only did `flatten` not behave the same with `optree` and `dm-tree`, but also `pack_sequence_as(flatten(...))` was not idempotent. The `optree` implementation did have all the machinery needed to handle `OrderedDict`s per spec, which was used for `pack_sequence_as`, but not `flatten`. This also fixes the discrepancy in the behavior for `namedtuple`s.
    
    - Fixed contradicting documentation in `flatten` and `pack_sequence_as` related to the handling of `OrderedDict`s.
    - Fixed references to `unflatten_as`, which doesn't exist.
    - Removed most `if optree` tests in `tree_test.py`, which should not exist for consistency between `optree` and `dm-tree`.
    - Fixed unit tests which were incorrectly flattening the result of `flatten_with_path`.
    - Fixed unintented use of `tree` instead of `keras.tree` in unit test.
    - Ran unit tests for all backends with `dm-tree` uninstalled.
    hertschuh committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    def69ec View commit details
    Browse the repository at this point in the history