add indice key to basicblock sparse encoder#3145
Open
GregorioFornetti wants to merge 1 commit into
Open
Conversation
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.
Motivation
I found that when setting
block_type="basicblock", the encoder was not passing theindice_keyinto theSparseBasicBlockgeneration loop.This creates a significant computational overhead when using the
spconvlibrary. Because the keys default toNone, the backend is forced to completely regenerate the spatial index mapping for every singleSubMConv3dlayer during each forward pass, instead of reusing the maps already created by previous layers in the same stage.With this modification, I obtained a small performance gain in CenterPoint-Voxel for nuScenes. The FPS in a P100 GPU went from 12.27 to 13.05.
Modification
To fix this problem, I made the following changes:
indice_key=f'subm_{i + 1}'argument to theSparseBasicBlockconstructor inside the encoder layer loop so that each downsampling stage receives its own unique identifier.SparseBasicBlockconstruction logic to create a shallow copy (conv_cfg.copy()) of the received configuration dictionary before updating it. This breaks Python's mutable dictionary reference chain, ensuring that key assignments from earlier stages do not overwrite or pollute subsequent, downsampled stages.