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

Optimize Split Transparency output for subsequent operations #2391

Merged
merged 1 commit into from Dec 9, 2023

Conversation

RunDevelopment
Copy link
Member

While optimizing resize, I learned that creating an RGB image by returning the first 3 channels of an RGBA image can cause very significant slow downs in subsequent operations. This is because iterating over array slices is a lot slower than iterating over contiguous memory. Slices also might require a copy to make them contiguous (some image operations are implemented in such a way that they require contiguous memory).

I also want to say that we generally don't need to worry about slices being bad for performance. They are only bad if they can be trivially avoided, like in Split Transparency. For RGB images, this node was creating a new RGBA image and then returned 2 slices to that RGBA image. So I added some code to return the RGB image and new image instead. This not only improves performance for subsequent operations, it also allocates less memory.

@joeyballentine joeyballentine merged commit 81ef184 into chaiNNer-org:main Dec 9, 2023
14 checks passed
@RunDevelopment RunDevelopment deleted the opt-split-trans branch December 9, 2023 12:54
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.

None yet

2 participants