huggingface / huggingface/accelerate
Title: Support for non-tensor based datasets in Accelerate
- Dominant language
- Python
- Stars
- 9.9k
- Forks
- 1.5k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
### System Info
```Shell
accelerate==0.21.0
python==3.9
```
### Information
- [X] The official example scripts
- [ ] My own modified scripts
### Tasks
- [ ] One of the scripts in the examples/ folder of Accelerate or an officially supported `no_trainer` script in the `examples` folder of the `transformers` repo (such as `run_no_trainer_glue.py`)
- [X] My own task or dataset (give details below)
### Reproduction
I encountered an issue while using the Accelerate library, as it does not support non-tensor based datasets. For instance, consider the following situation:
```python
return {
"image": tensor,
"text_input": str
}
```
In this case, an error occurs: `Can only concatenate tensors but got `. The problem lies in the following code:
[raise TypeError(f"Can only concatenate tensors but got {type(data[0])}")](https://github.com/huggingface/accelerate/blob/69e4c3c54da3201eda288b500d138761e7a5221c/src/accelerate/utils/operations.py#L365C1-L365C1)
The concat function here can only handle tensor type data, otherwise, it raises an error.
### Expected behavior
However, in many practical applications, we often need to work with non-tensor datasets in IO operations. I would like to request support for non-tensor type datasets in Accelerate.
Contributor guide
Assessment
This issue has not been assessed yet.