feat: flatten last n layers.#2182
Open
lingdie wants to merge 1 commit intogoogle:mainfrom
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new feature to the
flattencommand, allowing users to flatten only the last N layers of an image instead of all layers. This adds flexibility for advanced image management and optimization. The implementation includes a new flag, updates to function signatures, and a new helper function for partial flattening.Feature Addition: Partial Layer Flattening
--last-n-layers(-n) flag to theflattencommand, enabling users to specify that only the last N layers of an image should be flattened. Includes validation to ensure the flag is non-negative. [1] [2]Codebase Updates for Flag Support
flatten,flattenIndex,flattenChild,flattenImage) to accept thelastNparameter and propagate it through the flattening logic. [1] [2] [3] [4] [5]Core Logic Implementation
partialFlattenImagefunction, which merges only the last N layers into a single layer while preserving the earlier layers and original image history. This function handles layer extraction, merging, and history propagation, and ensures annotations are retained.Input Validation
partialFlattenImagefunction to ensurelastNis within a sensible range (1 to total layers). [1] [2]Let me know if you want a walkthrough of how the partial flattening works or have questions about the changes!