Skip to content

Conversation

@Leguark
Copy link
Member

@Leguark Leguark commented Oct 26, 2025

TL;DR

Fix tensor concatenation to handle mixed numpy arrays

What changed?

Modified the _concatenate function in backend_tensor.py to properly handle cases where some tensors in the input list are numpy arrays. The previous implementation only checked the type of the first tensor, which could lead to errors when concatenating mixed tensor types. Also added an explicit error for unsupported tensor types.

How to test?

Test concatenating a list of tensors where some elements are numpy arrays and others are not. Verify that the function correctly identifies and handles numpy arrays regardless of their position in the list.

Why make this change?

The previous implementation had a bug where it only checked the type of the first tensor in the list, which would fail if the first tensor was not a numpy array but other tensors in the list were. This change makes the function more robust by checking if any tensor in the list is a numpy array, ensuring proper handling of mixed tensor types.

Copy link
Member Author

Leguark commented Oct 26, 2025

@Leguark Leguark changed the title Add TypeError handling to _concatenate for unsupported tensor types [FIX] Fix tensor concatenation to handle mixed numpy/torch arrays Oct 26, 2025
@Leguark Leguark marked this pull request as ready for review October 26, 2025 13:23
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.

1 participant