Fix bug in LayerInfo.get_kernel_size when kernel sizes are torch.Tensor with single item #365
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.
As reported in issue #355,
LayerInfo.get_kernel_size
raises aTypeError: iteration over a 0-d tensor
when the kernel_size of a module is a tensor with only one item. This happens for some model implementations from the transformers library (e.g., EncodecConv1d, MimiConv1d)This fixes the issue by modifying
get_kernel_size
to turn thekernel_size
of a module into a list, only if it is not a 0-d tensor.